deleted more code following line-buffer refactoring
This commit is contained in:
parent
7e152851cc
commit
9a41b3a4fb
17
gcode.c
17
gcode.c
@ -76,7 +76,6 @@
|
|||||||
#define SPINDLE_DIRECTION_CCW 1
|
#define SPINDLE_DIRECTION_CCW 1
|
||||||
|
|
||||||
struct ParserState {
|
struct ParserState {
|
||||||
uint32_t line_number;
|
|
||||||
uint8_t status_code;
|
uint8_t status_code;
|
||||||
|
|
||||||
uint8_t motion_mode; /* {G0, G1, G2, G3, G38.2, G80, G81, G82, G83, G84, G85, G86, G87, G88, G89} */
|
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(target);
|
||||||
clear_vector(offset);
|
clear_vector(offset);
|
||||||
|
|
||||||
gc.line_number++;
|
|
||||||
gc.status_code = GCSTATUS_OK;
|
gc.status_code = GCSTATUS_OK;
|
||||||
|
|
||||||
/* First: parse all statements */
|
/* First: parse all statements */
|
||||||
@ -387,21 +385,6 @@ uint8_t gc_execute_line(char *line) {
|
|||||||
return(gc.status_code);
|
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
|
// 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
|
// 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).
|
// or there was an error (check state.status_code).
|
||||||
|
55
geometry.c
55
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)<labs(y)){
|
|
||||||
if (y>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);
|
|
||||||
}
|
|
||||||
|
27
geometry.h
27
geometry.h
@ -25,31 +25,4 @@
|
|||||||
// Find the angle from the positive y axis to the given point with respect to origo.
|
// Find the angle from the positive y axis to the given point with respect to origo.
|
||||||
double theta(double x, double y);
|
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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user