diff --git a/gcode.c b/gcode.c index d15ff20..90a1792 100644 --- a/gcode.c +++ b/gcode.c @@ -76,7 +76,6 @@ #define SPINDLE_DIRECTION_CCW 1 struct ParserState { - uint32_t line_number; uint8_t status_code; uint8_t motion_mode; /* {G0, G1, G2, G3, G38.2, G80, G81, G82, G83, G84, G85, G86, G87, G88, G89} */ @@ -143,7 +142,6 @@ uint8_t gc_execute_line(char *line) { clear_vector(target); clear_vector(offset); - gc.line_number++; gc.status_code = GCSTATUS_OK; /* First: parse all statements */ @@ -387,21 +385,6 @@ uint8_t gc_execute_line(char *line) { return(gc.status_code); } -void gc_get_status(double *position, uint8_t *status_code, int *inches_mode, uint32_t *line_number) -{ - int axis; - if (gc.inches_mode) { - for(axis = X_AXIS; axis <= Z_AXIS; axis++) { - position[axis] = gc.position[axis]*INCHES_PER_MM; - } - } else { - memcpy(position, gc.position, sizeof(gc.position)); - } - *status_code = gc.status_code; - *inches_mode = gc.inches_mode; - *line_number = gc.line_number; -} - // Parses the next statement and leaves the counter on the first character following // the statement. Returns 1 if there was a statements, 0 if end of string was reached // or there was an error (check state.status_code). diff --git a/geometry.c b/geometry.c index d828983..86aff47 100644 --- a/geometry.c +++ b/geometry.c @@ -40,58 +40,3 @@ double theta(double x, double y) } } -/* - Quadrants of the circle - - +---- 0 ----+ 0 - y is always positive and |x| < |y| - | | 1 - x is always positive and |x| > |y| - | | 2 - y is always negative and |x| < |y| - 3 + 1 3 - x is always negative and |x| > |y| - | | - | | - +---- 2 ----+ -*/ - -// Find the quadrant of the coordinate -int quadrant_of_the_circle(int32_t x, int32_t y) { - if (labs(x)0) { - return(0); - } else { - return(2); - } - } else { - if (x>0) { - return(1); - } else { - return(3); - } - } -} - -// Very specialized helper to calculate the amount of steps to travel in the given quadrant of a circle provided the -// axial direction of the quadrant, the angular_direction of travel (-1 or +1) and amount of steps in one half quadrant -// of the circle. -uint32_t steps_in_partial_quadrant(int32_t x, int32_t y, int quadrant, int angular_direction, - int32_t steps_in_half_quadrant) { - if (quadrant_horizontal(quadrant)) { // A horizontal quadrant - if ((angular_direction == 1) ^ (quadrant == 2)) { - return(steps_in_half_quadrant-x); - } else { - return(x+steps_in_half_quadrant); - } - } else { // A vertical quadrant - if ((angular_direction == 1) ^ (quadrant == 3)) { - return(steps_in_half_quadrant-y); - } else { - return(y+steps_in_half_quadrant); - } - } -} - -// Counts the amount of full quadrants between quadrant_start and quadrant_target along the angular_direction -int full_quadrants_between(int quadrant_start, int quadrant_target, int angular_direction) { - int diff = angular_direction*(quadrant_target-quadrant_start); - if (diff <= 0) { diff += 4; } - return (diff-1); -} diff --git a/geometry.h b/geometry.h index 10cf318..1f2ecb5 100644 --- a/geometry.h +++ b/geometry.h @@ -25,31 +25,4 @@ // Find the angle from the positive y axis to the given point with respect to origo. double theta(double x, double y); -// Find the quadrant of the coordinate -int quadrant_of_the_circle(int32_t x, int32_t y); - -/* - Quadrants of the circle - - +---- 0 ----+ 0 - y is always positive and |x| < |y| - | | 1 - x is always positive and |x| > |y| - | | 2 - y is always negative and |x| < |y| - 3 + 1 3 - x is always negative and |x| > |y| - | | - | | - +---- 2 ----+ -*/ - -// A macro to decide if a quadrant-number represent a horizontal quadrant -#define quadrant_horizontal(q) ((q % 2) == 0) - -// Very specialized helper to calculate the amount of steps to travel in the given quadrant of a circle provided the -// axial direction of the quadrant, the angular_direction of travel (-1 or +1) and amount of steps in one half quadrant -// of the circle. -uint32_t steps_in_partial_quadrant(int32_t x, int32_t y, int horizontal_quadrant, int angular_direction, - int32_t steps_in_half_quadrant); - -// Counts the amount of full quadrants between quadrant_start and quadrant_target along the angular_direction -int full_quadrants_between(int quadrant_start, int quadrant_target, int angular_direction); - #endif