From ef20be9f4c819a3e8893abcc92b1fdf3af286e05 Mon Sep 17 00:00:00 2001 From: Simen Svale Skogsrud Date: Mon, 21 Feb 2011 22:32:42 +0100 Subject: [PATCH] result of G92 also affects planner --- gcode.c | 6 +++++- motion_control.h | 8 +++++--- planner.c | 8 ++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gcode.c b/gcode.c index ce762e9..4e0278d 100644 --- a/gcode.c +++ b/gcode.c @@ -97,6 +97,7 @@ static float to_millimeters(double value) { return(gc.inches_mode ? (value * MM_PER_INCH) : value); } +#ifdef __AVR_ATmega328P__ // Find the angle in radians of deviance from the positive y axis. negative angles to the left of y-axis, // positive to the right. static double theta(double x, double y) @@ -113,6 +114,7 @@ static double theta(double x, double y) } } } +#endif // Executes one line of 0-terminated G-Code. The line is assumed to contain only uppercase // characters and signed floating point values (no whitespace). @@ -236,7 +238,9 @@ uint8_t gc_execute_line(char *line) { switch (next_action) { case NEXT_ACTION_GO_HOME: mc_go_home(); clear_vector(gc.position); break; case NEXT_ACTION_DWELL: mc_dwell(trunc(p*1000)); break; - case NEXT_ACTION_SET_COORDINATE_OFFSET: break; // no action needed + case NEXT_ACTION_SET_COORDINATE_OFFSET: + mc_set_current_position(target[X_AXIS], target[Y_AXIS], target[Z_AXIS]); + break; case NEXT_ACTION_DEFAULT: switch (gc.motion_mode) { case MOTION_MODE_CANCEL: break; diff --git a/motion_control.h b/motion_control.h index 89020ad..a66123e 100644 --- a/motion_control.h +++ b/motion_control.h @@ -24,14 +24,16 @@ #include #include "planner.h" +// NOTE: Although the following functions structurally belongs in this module, there is nothing to do but +// to forward the request to the planner. + // Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second // unless invert_feed_rate is true. Then the feed_rate means that the motion should be completed in // (1 minute)/feed_rate time. -// NOTE: Although this function structurally belongs in this module, there is nothing to do but -// to forward the request to the planner. For efficiency the function is implemented with a macro. - #define mc_line(x, y, z, feed_rate, invert_feed_rate) plan_buffer_line(x, y, z, feed_rate, invert_feed_rate) +#define mc_set_current_position(x, y, z) plan_set_current_position(x, y, z) + #ifdef __AVR_ATmega328P__ // Execute an arc. theta == start angle, angular_travel == number of radians to go along the arc, // positive angular_travel means clockwise, negative means counterclockwise. Radius == the radius of the diff --git a/planner.c b/planner.c index af75a06..2859881 100644 --- a/planner.c +++ b/planner.c @@ -391,9 +391,9 @@ void plan_buffer_line(double x, double y, double z, double feed_rate, int invert st_wake_up(); } -// Reset the position vector +// Reset the planner position vector void plan_set_current_position(double x, double y, double z) { - position[X_AXIS] = x; - position[Y_AXIS] = y; - position[Z_AXIS] = z; + position[X_AXIS] = lround(x*settings.steps_per_mm[X_AXIS]); + position[Y_AXIS] = lround(y*settings.steps_per_mm[Y_AXIS]); + position[Z_AXIS] = lround(z*settings.steps_per_mm[Z_AXIS]); }