From 59e4d07c54619d6de39bc010e16375b9e8c77228 Mon Sep 17 00:00:00 2001 From: Rob Giseburt Date: Sun, 6 Nov 2016 15:59:59 -0600 Subject: [PATCH] Made motion_mode an enum type. Removed unused recip_jerk. --- g2core/canonical_machine.cpp | 4 ++-- g2core/canonical_machine.h | 12 ++++++------ g2core/gcode_parser.cpp | 1 + g2core/plan_arc.cpp | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/g2core/canonical_machine.cpp b/g2core/canonical_machine.cpp index ec7a3cb8..9892da8a 100755 --- a/g2core/canonical_machine.cpp +++ b/g2core/canonical_machine.cpp @@ -225,7 +225,7 @@ cmCombinedState cm_get_combined_state() * ACTIVE_MODEL cm.am // active model pointer is maintained by state management */ uint32_t cm_get_linenum(const GCodeState_t *gcode_state) { return gcode_state->linenum;} -uint8_t cm_get_motion_mode(const GCodeState_t *gcode_state) { return gcode_state->motion_mode;} +cmMotionMode cm_get_motion_mode(const GCodeState_t *gcode_state) { return gcode_state->motion_mode;} uint8_t cm_get_coord_system(const GCodeState_t *gcode_state) { return gcode_state->coord_system;} uint8_t cm_get_units_mode(const GCodeState_t *gcode_state) { return gcode_state->units_mode;} uint8_t cm_get_select_plane(const GCodeState_t *gcode_state) { return gcode_state->select_plane;} @@ -2311,7 +2311,7 @@ void _cm_recalc_max_junction_accel(const uint8_t axis) { void cm_set_axis_jerk(const uint8_t axis, const float jerk) { cm.a[axis].jerk_max = jerk; - cm.a[axis].recip_jerk = 1/(jerk * JERK_MULTIPLIER); + //cm.a[axis].recip_jerk = 1/(jerk * JERK_MULTIPLIER); // Must recalculate the max_junction_accel now that the jerk has changed. _cm_recalc_max_junction_accel(axis); diff --git a/g2core/canonical_machine.h b/g2core/canonical_machine.h index 61c2b8f5..509df9d4 100755 --- a/g2core/canonical_machine.h +++ b/g2core/canonical_machine.h @@ -320,7 +320,7 @@ typedef enum { // axis modes (ordered: see _cm_get_feed_time()) */ typedef struct GCodeState { // Gcode model state - used by model, planning and runtime uint32_t linenum; // Gcode block line number - uint8_t motion_mode; // Group1: G0, G1, G2, G3, G38.2, G80, G81, + cmMotionMode motion_mode; // Group1: G0, G1, G2, G3, G38.2, G80, G81, // G82, G83 G84, G85, G86, G87, G88, G89 float target[AXES]; // XYZABC where the move should go @@ -343,7 +343,7 @@ typedef struct GCodeState { // Gcode model state - used by model, pl void reset() { linenum = 0; - motion_mode = 0; + motion_mode = MOTION_MODE_STRAIGHT_TRAVERSE; for (uint8_t i = 0; i< AXES; i++) { target[i] = 0.0; @@ -397,7 +397,7 @@ typedef struct GCodeStateExtended { // Gcode dynamic state extensions - used typedef struct GCodeInput { // Gcode model inputs - meaning depends on context uint8_t next_action; // handles G modal group 1 moves & non-modals - uint8_t motion_mode; // Group1: G0, G1, G2, G3, G38.2, G80, G81, G82 + cmMotionMode motion_mode; // Group1: G0, G1, G2, G3, G38.2, G80, G81, G82 // G83, G84, G85, G86, G87, G88, G89 uint8_t program_flow; // used only by the gcode_parser @@ -497,7 +497,7 @@ typedef struct cmAxis { float travel_min; // min work envelope for soft limits float jerk_max; // max jerk (Jm) in mm/min^3 divided by 1 million float jerk_high; // high speed deceleration jerk (Jh) in mm/min^3 divided by 1 million - float recip_jerk; // stored reciprocal of current jerk value - has the million in it + //float recip_jerk; // stored reciprocal of current jerk value - has the million in it float max_junction_accel; // high speed deceleration jerk (Jh) in mm/min^3 divided by 1 million float junction_dev; // aka cornering delta -- DEPRICATED! float radius; // radius in mm for rotary axis modes @@ -606,7 +606,7 @@ float cm_get_axis_jerk(const uint8_t axis); void cm_set_axis_jerk(const uint8_t axis, const float jerk); uint32_t cm_get_linenum(const GCodeState_t *gcode_state); -uint8_t cm_get_motion_mode(const GCodeState_t *gcode_state); +cmMotionMode cm_get_motion_mode(const GCodeState_t *gcode_state); uint8_t cm_get_coord_system(const GCodeState_t *gcode_state); uint8_t cm_get_units_mode(const GCodeState_t *gcode_state); uint8_t cm_get_select_plane(const GCodeState_t *gcode_state); @@ -701,7 +701,7 @@ stat_t cm_arc_feed(const float target[], const bool target_f[], // G const float radius, const bool radius_f, // radius if radius mode const float P_word, const bool P_word_f, // parameter const bool modal_g1_f, // modal group flag for motion group - const uint8_t motion_mode); // defined motion mode + const cmMotionMode motion_mode); // defined motion mode // Spindle Functions (4.3.7) // see spindle.h for spindle functions - which would go right here diff --git a/g2core/gcode_parser.cpp b/g2core/gcode_parser.cpp index c8095d18..cd591cda 100755 --- a/g2core/gcode_parser.cpp +++ b/g2core/gcode_parser.cpp @@ -697,6 +697,7 @@ static stat_t _execute_gcode_block(char *active_comment) cm.gn.motion_mode); break; } + default: break; } cm_set_absolute_override(MODEL, ABSOLUTE_OVERRIDE_OFF); // un-set absolute override once the move is planned } diff --git a/g2core/plan_arc.cpp b/g2core/plan_arc.cpp index f7c3296f..09977d6a 100755 --- a/g2core/plan_arc.cpp +++ b/g2core/plan_arc.cpp @@ -108,7 +108,7 @@ stat_t cm_arc_feed(const float target[], const bool target_f[], // target en const float radius, const bool radius_f, // radius if radius mode const float P_word, const bool P_word_f, // parameter const bool modal_g1_f, // modal group flag for motion group - const uint8_t motion_mode) // defined motion mode + const cmMotionMode motion_mode) // defined motion mode { // Start setting up the arc and trapping arc specification errors