From 2f0ee56ecbffad52f47ad239005ff48c209fa481 Mon Sep 17 00:00:00 2001 From: Alden Hart Date: Fri, 9 Dec 2016 07:51:57 -0500 Subject: [PATCH] Messing with axis types a bit --- g2core/canonical_machine.cpp | 23 ++++++++++++----------- g2core/canonical_machine.h | 10 ++++++++-- g2core/config_app.cpp | 3 ++- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/g2core/canonical_machine.cpp b/g2core/canonical_machine.cpp index 434102d1..f99bb641 100644 --- a/g2core/canonical_machine.cpp +++ b/g2core/canonical_machine.cpp @@ -128,7 +128,7 @@ static void _exec_absolute_origin(float *value, bool *flag); static void _exec_program_finalize(float *value, bool *flag); static int8_t _get_axis(const index_t index); -static int8_t _get_axis_type(const index_t index); +static cmAxisType _get_axis_type(const index_t index); /*********************************************************************************** **** CODE ************************************************************************* @@ -2107,12 +2107,12 @@ static int8_t _get_axis(const index_t index) return (ptr - axes); } -static int8_t _get_axis_type(const index_t index) +static cmAxisType _get_axis_type(const index_t index) { int8_t axis = _get_axis(index); - if (axis >= AXIS_A) return (1); - if (axis == -1) return (-1); - return (0); + if (axis >= AXIS_A) return (AXIS_TYPE_ROTARY); + if (axis == -1) return (AXIS_TYPE_UNDEFINED); + return (AXIS_TYPE_LINEAR); } /**** Functions called directly from cfgArray table - mostly wrappers **** @@ -2262,10 +2262,12 @@ stat_t cm_get_am(nvObj_t *nv) stat_t cm_set_am(nvObj_t *nv) // axis mode { - if (_get_axis_type(nv->index) == 0) { // linear - if (nv->value > AXIS_MODE_MAX_LINEAR) { return (STAT_INPUT_VALUE_RANGE_ERROR);} + + nv->valuetype = TYPE_INT; + if (_get_axis_type(nv->index) == AXIS_TYPE_LINEAR) { + if (nv->value > AXIS_MODE_LINEAR_MAX) { return (STAT_INPUT_VALUE_RANGE_ERROR);} } else { - if (nv->value > AXIS_MODE_MAX_ROTARY) { return (STAT_INPUT_VALUE_RANGE_ERROR);} + if (nv->value > AXIS_MODE_ROTARY_MAX) { return (STAT_INPUT_VALUE_RANGE_ERROR);} } cmAxisMode *am = (cmAxisMode *)cfgArray[nv->index].target; void *p = (cfgArray[nv->index].target); @@ -2274,11 +2276,10 @@ stat_t cm_set_am(nvObj_t *nv) // axis mode // cmAxisMode a = (cmAxisMode)nv->value; // *am = (cmAxisMode)nv->value; *am = a; - nv->valuetype = TYPE_INT; return(STAT_OK); - set_ui8(nv); - return(STAT_OK); +// set_ui8(nv); +// return(STAT_OK); } #pragma GCC reset_options diff --git a/g2core/canonical_machine.h b/g2core/canonical_machine.h index c851a2c7..13b51ff9 100644 --- a/g2core/canonical_machine.h +++ b/g2core/canonical_machine.h @@ -276,14 +276,20 @@ typedef enum { // used for spindle and arc dir DIRECTION_CCW } cmDirection; +typedef enum { // axis types + AXIS_TYPE_UNDEFINED=-1, // invalid type + AXIS_TYPE_LINEAR, // linear axis + AXIS_TYPE_ROTARY // rotary axis +} cmAxisType; + typedef enum { // axis modes (ordered: see _cm_get_feed_time()) AXIS_DISABLED = 0, // kill axis AXIS_STANDARD, // axis in coordinated motion w/standard behaviors AXIS_INHIBITED, // axis is computed but not activated AXIS_RADIUS // rotary axis calibrated to circumference } cmAxisMode; -#define AXIS_MODE_MAX_LINEAR AXIS_INHIBITED -#define AXIS_MODE_MAX_ROTARY AXIS_RADIUS +#define AXIS_MODE_LINEAR_MAX AXIS_INHIBITED +#define AXIS_MODE_ROTARY_MAX AXIS_RADIUS /***************************************************************************** * GCODE MODEL - The following GCodeModel/GCodeInput structs are used: diff --git a/g2core/config_app.cpp b/g2core/config_app.cpp index 267dbfc6..2eaa9636 100644 --- a/g2core/config_app.cpp +++ b/g2core/config_app.cpp @@ -267,7 +267,8 @@ const cfgItem_t cfgArray[] = { // { "6","6mt",_fip, 2, st_print_mt, get_flt, st_set_mt, (float *)&st_cfg.mot[MOTOR_6].motor_timeout, M6_MOTOR_TIMEOUT }, #endif // Axis parameters - { "x","xam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cm->a[AXIS_X].axis_mode, X_AXIS_MODE }, + { "x","xam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cs.null, X_AXIS_MODE }, +// { "x","xam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cm->a[AXIS_X].axis_mode, X_AXIS_MODE }, { "x","xvm",_fipc, 0, cm_print_vm, get_flt, cm_set_vm, (float *)&cm->a[AXIS_X].velocity_max, X_VELOCITY_MAX }, { "x","xfr",_fipc, 0, cm_print_fr, get_flt, cm_set_fr, (float *)&cm->a[AXIS_X].feedrate_max, X_FEEDRATE_MAX }, { "x","xtn",_fipc, 3, cm_print_tn, get_flt, set_flu, (float *)&cm->a[AXIS_X].travel_min, X_TRAVEL_MIN },