From 8e7e62cb9aec5b312c2d0eda3a682691825753b3 Mon Sep 17 00:00:00 2001 From: Alden Hart Date: Sun, 15 Apr 2018 06:07:30 -0400 Subject: [PATCH] Replaced explicit axes array initializations with conditional one from util.h; Fixed range error in cm_get_axis_char() --- g2core/canonical_machine.cpp | 15 +++++++-------- g2core/cycle_jogging.cpp | 4 ++-- g2core/util.h | 6 ++---- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/g2core/canonical_machine.cpp b/g2core/canonical_machine.cpp index 5b7cea1f..f462af5f 100644 --- a/g2core/canonical_machine.cpp +++ b/g2core/canonical_machine.cpp @@ -1061,8 +1061,7 @@ stat_t cm_set_absolute_origin(const float origin[], bool flag[]) for (uint8_t axis = AXIS_X; axis < AXES; axis++) { if (flag[axis]) { -// REMOVED value[axis] = cm->offset[cm->gm.coord_system][axis] + _to_millimeters(origin[axis]); // G2 Issue #26 - value[axis] = _to_millimeters(origin[axis]); // replaced the above + value[axis] = _to_millimeters(origin[axis]); cm->gmx.position[axis] = value[axis]; // set model position cm->gm.target[axis] = value[axis]; // reset model target mp_set_planner_position(axis, value[axis]); // set mm position @@ -1197,7 +1196,7 @@ stat_t _goto_stored_position(const float stored_position[], // always in mm cm_set_absolute_override(MODEL, ABSOLUTE_OVERRIDE_ON_DISPLAY_WITH_OFFSETS); // Position stored in abs coords cm_set_distance_mode(ABSOLUTE_DISTANCE_MODE); // Must run in absolute distance mode - bool flags2[] = { 1,1,1,1,1,1 }; + bool flags2[] = INIT_AXES_TRUE; stat_t status = cm_straight_traverse(target, flags2, PROFILE_NORMAL); // Go to stored position cm_set_absolute_override(MODEL, ABSOLUTE_OVERRIDE_OFF); cm_set_distance_mode(saved_distance_mode); // Restore distance mode @@ -1697,8 +1696,8 @@ stat_t cm_json_wait(char *json_string) stat_t cm_run_home(nvObj_t *nv) { if (nv->value_int) { // if true - float axes[] = { 1,1,1,1,1,1 }; - bool flags[] = { 1,1,1,1,1,1 }; + float axes[] = INIT_AXES_ONES; + bool flags[] = INIT_AXES_TRUE; cm_homing_cycle_start(axes, flags); } return (STAT_OK); @@ -1738,7 +1737,7 @@ stat_t cm_run_jog(nvObj_t *nv) * _coord() - return coordinate system number (53=0...59=6) or -1 if error * _axis() - return axis # or -1 if not an axis (works for mapped motors as well) * cm_get_axis_type() - return linear axis (0), rotary axis (1) or error (-1) - * cm_get_axis_char() - return ASCII char for axis number provided + * cm_get_axis_char() - return ASCII char for internal axis number provided */ static int8_t _coord(nvObj_t *nv) // extract coordinate system from 3rd character @@ -1803,9 +1802,9 @@ cmAxisType cm_get_axis_type(const nvObj_t *nv) return (AXIS_TYPE_LINEAR); } -char cm_get_axis_char(const int8_t axis) +char cm_get_axis_char(const int8_t axis) // Uses internal axis numbering { - char axis_char[] = "XYZABC"; + char axis_char[] = "XYZUVWABC"; if ((axis < 0) || (axis > AXES)) return (' '); return (axis_char[axis]); } diff --git a/g2core/cycle_jogging.cpp b/g2core/cycle_jogging.cpp index e9571576..caba8451 100644 --- a/g2core/cycle_jogging.cpp +++ b/g2core/cycle_jogging.cpp @@ -177,8 +177,8 @@ static stat_t _jogging_axis_ramp_jog(int8_t axis) // run the jog ramp } static stat_t _jogging_axis_move(int8_t axis, float target, float velocity) { - float vect[] = { 0,0,0,0,0,0 }; - bool flags[] = { false,false,false,false,false,false }; + float vect[] = INIT_AXES_ZEROES; + bool flags[] = INIT_AXES_FALSE; vect[axis] = target; flags[axis] = true; diff --git a/g2core/util.h b/g2core/util.h index ef29a515..ac2cb9a5 100644 --- a/g2core/util.h +++ b/g2core/util.h @@ -32,13 +32,10 @@ * - support for debugging routines */ -#include "hardware.h" // for AXES - #ifndef UTIL_H_ONCE #define UTIL_H_ONCE #include -//#include "sam.h" #include "MotateTimers.h" using Motate::delay; using Motate::SysTickTimer; @@ -78,8 +75,9 @@ float *set_vector_by_axis(float value, uint8_t axis); #if (AXES == 9) #define INIT_AXES_ZEROES {0,0,0,0,0,0,0,0,0} -#define INIT_AXES_TRUE {1,1,1,1,1,1,1,1,1} +#define INIT_AXES_ONES {1,1,1,1,1,1,1,1,1} #define INIT_AXES_FALSE INIT_AXES_ZEROES +#define INIT_AXES_TRUE INIT_AXES_ONES #else #warning UNSUPPORTED AXES SETTING! #endif