<commit_before>#include <string.h>
#include "gcodeinter.h"
#include "cnc-controller.h"
#define MAX_F 100.0
#define MAX_A 1
#define X_STEP_LENGTH_MM 1.0
#define Y_STEP_LENGTH_MM 1.0
#define Z_STEP_LENGTH_MM 1.0
#define X_STEP_LENGTH_INCH 1.0
#define Y_STEP_LENGTH_INCH 1.0
#define Z_STEP_LENGTH_INCH 1.0 //TODO: Calibrate this

float X_STEP_LENGTH = X_STEP_LENGTH_MM;
float Y_STEP_LENGTH = Y_STEP_LENGTH_MM;
float Z_STEP_LENGTH = Z_STEP_LENGTH_MM;

int32_t abs_mode = 1;
float curr_x = 0;
float curr_y = 0;
float curr_z = 0;
float offset_x = 0;
float offset_y = 0;
float offset_z = 0;

float curr_v = 0;
float atof(const char* s){
    float rez = 0, fact = 1;
    if (*s == '-'){
        s++;
        fact = -1;
    };
    for (int point_seen = 0; *s; s++){
        if (*s == '.'){
            point_seen = 1; 
            continue;
        };
    int d = *s - '0';
    if (d >= 0 && d <= 9){
        if (point_seen) fact /= 10.0f;
        rez = rez * 10.0f + (float)d;
        };
    };
    return rez * fact;
};
void line_move(uint32_t gnum, char gcode[], struct Exist *exist){
    struct Vector v;
    struct Vector sv;
    int t = strlen(gcode);
    char tmp;

    for (int i=strlen(gcode)-1; i>=1; i--){
        if ((gcode[i]<48 || gcode[i]>57) && gcode[i]!='.' && gcode[i]!='-'){
            tmp = gcode[t];
            gcode[t] = '\0';
            if(gcode[i] == 'F')v.f = atof(gcode+i+1);
            else if(gcode[i] == 'Z')v.z = atof(gcode+i+1);
            else if(gcode[i] == 'Y')v.y = atof(gcode+i+1);
            else if(gcode[i] == 'X')v.x = atof(gcode+i+1);
            
            gcode[t] = tmp;
            t = i;
        }<commit_msg>Calibrate Step per inch and mm<commit_after>#include <string.h>
#include "gcodeinter.h"
#include "cnc-controller.h"
#define MAX_F 100.0
#define MAX_A 1
#define X_STEP_LENGTH_MM 0.00625
#define Y_STEP_LENGTH_MM 0.00625
#define Z_STEP_LENGTH_MM 0.004
#define X_STEP_LENGTH_INCH 0.00024606299
#define Y_STEP_LENGTH_INCH 0.00024606299
#define Z_STEP_LENGTH_INCH 0.00015748031

float X_STEP_LENGTH = X_STEP_LENGTH_MM;
float Y_STEP_LENGTH = Y_STEP_LENGTH_MM;
float Z_STEP_LENGTH = Z_STEP_LENGTH_MM;

int32_t abs_mode = 1;
float curr_x = 0;
float curr_y = 0;
float curr_z = 0;
float offset_x = 0;
float offset_y = 0;
float offset_z = 0;

float curr_v = 0;
float atof(const char* s){
    float rez = 0, fact = 1;
    if (*s == '-'){
        s++;
        fact = -1;
    };
    for (int point_seen = 0; *s; s++){
        if (*s == '.'){
            point_seen = 1; 
            continue;
        };
    int d = *s - '0';
    if (d >= 0 && d <= 9){
        if (point_seen) fact /= 10.0f;
        rez = rez * 10.0f + (float)d;
        };
    };
    return rez * fact;
};

void line_move(uint32_t gnum, char gcode[], struct Exist *exist){
    struct Vector v;
    struct Vector sv;
    int t = strlen(gcode);
    char tmp;

    for (int i=strlen(gcode)-1; i>=1; i--){
        if ((gcode[i]<48 || gcode[i]>57) && gcode[i]!='.' && gcode[i]!='-'){
            tmp = gcode[t];
            gcode[t] = '\0';
            if(gcode[i] == 'F')v.f = atof(gcode+i+1);
            else if(gcode[i] == 'Z')v.z = atof(gcode+i+1);
            else if(gcode[i] == 'Y')v.y = atof(gcode+i+1);
            else if(gcode[i] == 'X')v.x = atof(gcode+i+1);
            
            gcode[t] = tmp;
            t = i;
        }
{'fraction_non_alphanumeric': 0.16482201615315584, 'fraction_numerical': 0.04427161232425965, 'mean_word_length': 2.2978303747534516, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2528415', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1400, 'n_words': 328}