From 76361a60b3365ab515c419111b819f095d4ab3a3 Mon Sep 17 00:00:00 2001 From: Alden Hart Date: Mon, 20 Mar 2017 17:09:18 -0400 Subject: [PATCH] Removed overloading on get_int; shared some code on set_ints; removed set_flu() --- g2core/canonical_machine.cpp | 64 ++++++++++++++-------------- g2core/config.h | 7 +-- g2core/config_app.cpp | 82 ++++++++++-------------------------- g2core/coolant.cpp | 18 ++++---- g2core/gpio.cpp | 16 +++---- g2core/json_parser.cpp | 8 ++-- g2core/report.cpp | 10 ++--- g2core/spindle.cpp | 22 +++++----- g2core/stepper.cpp | 14 +++--- g2core/text_parser.cpp | 4 +- 10 files changed, 103 insertions(+), 142 deletions(-) diff --git a/g2core/canonical_machine.cpp b/g2core/canonical_machine.cpp index c940f8ae..f045b6f0 100644 --- a/g2core/canonical_machine.cpp +++ b/g2core/canonical_machine.cpp @@ -1958,9 +1958,9 @@ stat_t cm_get_dist(nvObj_t *nv) { return(_get_msg_helper(nv, msg_dist, cm_get_di stat_t cm_get_admo(nvObj_t *nv) { return(_get_msg_helper(nv, msg_admo, cm_get_arc_distance_mode(ACTIVE_MODEL)));} stat_t cm_get_frmo(nvObj_t *nv) { return(_get_msg_helper(nv, msg_frmo, cm_get_feed_rate_mode(ACTIVE_MODEL)));} -stat_t cm_get_toolv(nvObj_t *nv) { return(get_int(nv, cm_get_tool(ACTIVE_MODEL))); } -stat_t cm_get_mline(nvObj_t *nv) { return(get_int32(nv, cm_get_linenum(MODEL))); } -stat_t cm_get_line(nvObj_t *nv) { return(get_int32(nv, cm_get_linenum(ACTIVE_MODEL))); } +stat_t cm_get_toolv(nvObj_t *nv) { return(get_integer(nv, cm_get_tool(ACTIVE_MODEL))); } +stat_t cm_get_mline(nvObj_t *nv) { return(get_integer(nv, cm_get_linenum(MODEL))); } +stat_t cm_get_line(nvObj_t *nv) { return(get_integer(nv, cm_get_linenum(ACTIVE_MODEL))); } stat_t cm_get_vel(nvObj_t *nv) { @@ -1983,8 +1983,8 @@ stat_t cm_get_mpo(nvObj_t *nv) { return (get_float(nv, cm_get_absolute_position stat_t cm_get_ofs(nvObj_t *nv) { return (get_float(nv, cm_get_display_offset(ACTIVE_MODEL, _axis(nv)))); } stat_t cm_get_home(nvObj_t *nv) { return(_get_msg_helper(nv, msg_home, cm_get_homing_state())); } -stat_t cm_set_home(nvObj_t *nv) { return (set_int(nv, ((uint8_t &)(cm->homing_state)), false, true)); } -stat_t cm_get_hom(nvObj_t *nv) { return (get_int(nv, cm->homed[_axis(nv)])); } +stat_t cm_set_home(nvObj_t *nv) { return (set_integer(nv, ((uint8_t &)(cm->homing_state)), false, true)); } +stat_t cm_get_hom(nvObj_t *nv) { return (get_integer(nv, cm->homed[_axis(nv)])); } stat_t cm_get_prob(nvObj_t *nv) { return(_get_msg_helper(nv, msg_probe, cm_get_probe_state())); } stat_t cm_get_prb(nvObj_t *nv) { return (get_float(nv, cm->probe_results[0][_axis(nv)])); } @@ -1992,7 +1992,7 @@ stat_t cm_get_prb(nvObj_t *nv) { return (get_float(nv, cm->probe_results[0][_ax stat_t cm_get_coord(nvObj_t *nv) { return (get_float(nv, cm->coord_offset[_coord(nv)][_axis(nv)])); } stat_t cm_set_coord(nvObj_t *nv) { return (set_float(nv, cm->coord_offset[_coord(nv)][_axis(nv)])); } -stat_t cm_get_g92e(nvObj_t *nv) { return (get_int(nv, cm->gmx.origin_offset_enable)); } +stat_t cm_get_g92e(nvObj_t *nv) { return (get_integer(nv, cm->gmx.origin_offset_enable)); } stat_t cm_get_g92(nvObj_t *nv) { return (get_float(nv, cm->gmx.origin_offset[_axis(nv)])); } stat_t cm_get_g28(nvObj_t *nv) { return (get_float(nv, cm->gmx.g28_position[_axis(nv)])); } stat_t cm_get_g30(nvObj_t *nv) { return (get_float(nv, cm->gmx.g30_position[_axis(nv)])); } @@ -2179,10 +2179,10 @@ stat_t cm_set_jh(nvObj_t *nv) * cm_set_zb() - set homing zero backoff */ -stat_t cm_get_hi(nvObj_t *nv) { return (get_int(nv, cm->a[_axis(nv)].homing_input)); } -stat_t cm_set_hi(nvObj_t *nv) { return (set_int(nv, cm->a[_axis(nv)].homing_input, 0, D_IN_CHANNELS)); } -stat_t cm_get_hd(nvObj_t *nv) { return (get_int(nv, cm->a[_axis(nv)].homing_dir)); } -stat_t cm_set_hd(nvObj_t *nv) { return (set_int(nv, cm->a[_axis(nv)].homing_dir, 0, 1)); } +stat_t cm_get_hi(nvObj_t *nv) { return (get_integer(nv, cm->a[_axis(nv)].homing_input)); } +stat_t cm_set_hi(nvObj_t *nv) { return (set_integer(nv, cm->a[_axis(nv)].homing_input, 0, D_IN_CHANNELS)); } +stat_t cm_get_hd(nvObj_t *nv) { return (get_integer(nv, cm->a[_axis(nv)].homing_dir)); } +stat_t cm_set_hd(nvObj_t *nv) { return (set_integer(nv, cm->a[_axis(nv)].homing_dir, 0, 1)); } stat_t cm_get_sv(nvObj_t *nv) { return (get_float(nv, cm->a[_axis(nv)].search_velocity)); } stat_t cm_set_sv(nvObj_t *nv) { return (set_float_range(nv, cm->a[_axis(nv)].search_velocity, 0, MAX_LONG)); } stat_t cm_get_lv(nvObj_t *nv) { return (get_float(nv, cm->a[_axis(nv)].latch_velocity)); } @@ -2225,42 +2225,42 @@ stat_t cm_set_ct(nvObj_t *nv) { return(set_float_range(nv, cm->chordal_tolerance stat_t cm_get_zl(nvObj_t *nv) { return(get_float(nv, cm->feedhold_z_lift)); } stat_t cm_set_zl(nvObj_t *nv) { return(set_float(nv, cm->feedhold_z_lift)); } -stat_t cm_get_sl(nvObj_t *nv) { return(get_int(nv, cm->soft_limit_enable)); } -stat_t cm_set_sl(nvObj_t *nv) { return(set_int(nv, (uint8_t &)cm->soft_limit_enable, 0, 1)); } +stat_t cm_get_sl(nvObj_t *nv) { return(get_integer(nv, cm->soft_limit_enable)); } +stat_t cm_set_sl(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)cm->soft_limit_enable, 0, 1)); } -stat_t cm_get_lim(nvObj_t *nv) { return(get_int(nv, cm->limit_enable)); } -stat_t cm_set_lim(nvObj_t *nv) { return(set_int(nv, (uint8_t &)cm->limit_enable, 0, 1)); } +stat_t cm_get_lim(nvObj_t *nv) { return(get_integer(nv, cm->limit_enable)); } +stat_t cm_set_lim(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)cm->limit_enable, 0, 1)); } -stat_t cm_get_saf(nvObj_t *nv) { return(get_int(nv, cm->safety_interlock_enable)); } -stat_t cm_set_saf(nvObj_t *nv) { return(set_int(nv, (uint8_t &)cm->safety_interlock_enable, 0, 1)); } +stat_t cm_get_saf(nvObj_t *nv) { return(get_integer(nv, cm->safety_interlock_enable)); } +stat_t cm_set_saf(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)cm->safety_interlock_enable, 0, 1)); } -stat_t cm_get_m48(nvObj_t *nv) { return(get_int(nv, cm->gmx.m48_enable)); } -stat_t cm_set_m48(nvObj_t *nv) { return(set_int(nv, (uint8_t &)cm->gmx.m48_enable, 0, 1)); } +stat_t cm_get_m48(nvObj_t *nv) { return(get_integer(nv, cm->gmx.m48_enable)); } +stat_t cm_set_m48(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)cm->gmx.m48_enable, 0, 1)); } -stat_t cm_get_froe(nvObj_t *nv) { return(get_int(nv, cm->gmx.mfo_enable)); } -stat_t cm_set_froe(nvObj_t *nv) { return(set_int(nv, (uint8_t &)cm->gmx.mfo_enable, 0, 1)); } +stat_t cm_get_froe(nvObj_t *nv) { return(get_integer(nv, cm->gmx.mfo_enable)); } +stat_t cm_set_froe(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)cm->gmx.mfo_enable, 0, 1)); } stat_t cm_get_fro(nvObj_t *nv) { return(get_float(nv, cm->gmx.mfo_factor)); } stat_t cm_set_fro(nvObj_t *nv) { return(set_float_range(nv, cm->gmx.mfo_factor, FEED_OVERRIDE_MIN, FEED_OVERRIDE_MAX)); } -stat_t cm_get_troe(nvObj_t *nv) { return(get_int(nv, cm->gmx.mto_enable)); } -stat_t cm_set_troe(nvObj_t *nv) { return(set_int(nv, (uint8_t &)cm->gmx.mto_enable, 0, 1)); } +stat_t cm_get_troe(nvObj_t *nv) { return(get_integer(nv, cm->gmx.mto_enable)); } +stat_t cm_set_troe(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)cm->gmx.mto_enable, 0, 1)); } stat_t cm_get_tro(nvObj_t *nv) { return(get_float(nv, cm->gmx.mto_factor)); } stat_t cm_set_tro(nvObj_t *nv) { return(set_float_range(nv, cm->gmx.mto_factor, TRAVERSE_OVERRIDE_MIN, TRAVERSE_OVERRIDE_MAX)); } -stat_t cm_get_gpl(nvObj_t *nv) { return(get_int(nv, cm->default_select_plane)); } -stat_t cm_set_gpl(nvObj_t *nv) { return(set_int(nv, (uint8_t &)cm->default_select_plane, CANON_PLANE_XY, CANON_PLANE_YZ)); } +stat_t cm_get_gpl(nvObj_t *nv) { return(get_integer(nv, cm->default_select_plane)); } +stat_t cm_set_gpl(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)cm->default_select_plane, CANON_PLANE_XY, CANON_PLANE_YZ)); } -stat_t cm_get_gun(nvObj_t *nv) { return(get_int(nv, cm->default_units_mode)); } -stat_t cm_set_gun(nvObj_t *nv) { return(set_int(nv, (uint8_t &)cm->default_units_mode, INCHES, MILLIMETERS)); } +stat_t cm_get_gun(nvObj_t *nv) { return(get_integer(nv, cm->default_units_mode)); } +stat_t cm_set_gun(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)cm->default_units_mode, INCHES, MILLIMETERS)); } -stat_t cm_get_gco(nvObj_t *nv) { return(get_int(nv, cm->default_coord_system)); } -stat_t cm_set_gco(nvObj_t *nv) { return(set_int(nv, (uint8_t &)cm->default_coord_system, G54, G59)); } +stat_t cm_get_gco(nvObj_t *nv) { return(get_integer(nv, cm->default_coord_system)); } +stat_t cm_set_gco(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)cm->default_coord_system, G54, G59)); } -stat_t cm_get_gpa(nvObj_t *nv) { return(get_int(nv, cm->default_path_control)); } -stat_t cm_set_gpa(nvObj_t *nv) { return(set_int(nv, (uint8_t &)cm->default_path_control, PATH_EXACT_PATH, PATH_CONTINUOUS)); } +stat_t cm_get_gpa(nvObj_t *nv) { return(get_integer(nv, cm->default_path_control)); } +stat_t cm_set_gpa(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)cm->default_path_control, PATH_EXACT_PATH, PATH_CONTINUOUS)); } -stat_t cm_get_gdi(nvObj_t *nv) { return(get_int(nv, cm->default_distance_mode)); } -stat_t cm_set_gdi(nvObj_t *nv) { return(set_int(nv, (uint8_t &)cm->default_distance_mode, ABSOLUTE_DISTANCE_MODE, INCREMENTAL_DISTANCE_MODE)); } +stat_t cm_get_gdi(nvObj_t *nv) { return(get_integer(nv, cm->default_distance_mode)); } +stat_t cm_set_gdi(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)cm->default_distance_mode, ABSOLUTE_DISTANCE_MODE, INCREMENTAL_DISTANCE_MODE)); } /*********************************************************************************** * Debugging Commands diff --git a/g2core/config.h b/g2core/config.h index 30c34e54..5be86054 100644 --- a/g2core/config.h +++ b/g2core/config.h @@ -392,8 +392,6 @@ void nv_print_list(stat_t status, uint8_t text_flags, uint8_t json_flags); // application specific helpers and functions (config_app.c) -stat_t set_flu(nvObj_t *nv); // set floating point number with G20/G21 units conversion - void convert_incoming_float(nvObj_t *nv); // pre-process outgoing float values for units and illegal values void convert_outgoing_float(nvObj_t *nv); // pre-process incoming float values for canonical units @@ -401,9 +399,8 @@ stat_t get_float(nvObj_t *nv, const float value); // boilerplate for retrievin stat_t set_float(nvObj_t *nv, float &value); // boilerplate for setting a floating point value w/conversion stat_t set_float_range(nvObj_t *nv, float &value, float low, float high); -stat_t get_int(nvObj_t *nv, const uint8_t value); // boilerplate for retrieving 8 bit integer value -stat_t set_int(nvObj_t *nv, uint8_t &value, uint8_t low, uint8_t high); -stat_t get_int32(nvObj_t *nv, const int32_t value); // boilerplate for retrieving 32 bit integer value +stat_t get_integer(nvObj_t *nv, const int32_t value); // boilerplate for retrieving 8 bit integer value +stat_t set_integer(nvObj_t *nv, uint8_t &value, uint8_t low, uint8_t high); stat_t set_int32(nvObj_t *nv, int32_t &value, int32_t low, int32_t high); stat_t get_string(nvObj_t *nv, const char *str); diff --git a/g2core/config_app.cpp b/g2core/config_app.cpp index 2d143ab8..333d887c 100644 --- a/g2core/config_app.cpp +++ b/g2core/config_app.cpp @@ -1245,29 +1245,6 @@ bool nv_index_is_group(index_t index) { return (((index >= NV_INDEX_START_GROUPS bool nv_index_lt_groups(index_t index) { return ((index <= NV_INDEX_START_GROUPS) ? true : false);} /***** APPLICATION SPECIFIC CONFIGS AND EXTENSIONS TO GENERIC FUNCTIONS *****/ - -/* - * set_flu() - set floating point number with G20/G21 units conversion - * - * The number 'setted' will have been delivered in external units (inches or mm). - * It is written to the target memory location in internal canonical units (mm). - * The original nv->value is also changed so persistence works correctly. - * Displays should convert back from internal canonical form to external form. - * - * !!!! WARNING !!!! set_flu() doesn't care about axes, so make sure you aren't passing it ABC axes - */ - -stat_t set_flu(nvObj_t *nv) -{ - if (cm_get_units_mode(MODEL) == INCHES) { // if in inches... - nv->value_flt *= MM_PER_INCH; // convert to canonical millimeter units - } - *((float *)GET_TABLE_WORD(target)) = nv->value_flt; // write value as millimeters or degrees - nv->precision = GET_TABLE_WORD(precision); - nv->valuetype = TYPE_FLOAT; - return(STAT_OK); -} - /* * convert_incoming_float() - pre-process an incoming floating point number for canonical units * convert_outgoing_float() - pre-process an outgoing floating point number for units display @@ -1362,61 +1339,48 @@ stat_t set_float_range(nvObj_t *nv, float &value, float low, float high) { } /* - * get_int() - boilerplate for retrieving 8 bit integer value - * set_int() - boilerplate for setting 8 bit integer value with range checking - * get_int32() - boilerplate for retrieving 32 bit integer value - * set_int32() - boilerplate for setting 32 bit integer value with range checking + * get_integer() - boilerplate for retrieving 8 and 32 bit integer values + * set_integer() - boilerplate for setting 8 bit integer value with range checking + * set_int32() - boilerplate for setting 32 bit integer value with range checking */ -stat_t get_int(nvObj_t *nv, const uint8_t value) { - nv->value_int = value; - nv->valuetype = TYPE_INTEGER; - return STAT_OK; -} - -stat_t set_int(nvObj_t *nv, uint8_t &value, uint8_t low, uint8_t high) { - +static stat_t _set_int_tests(nvObj_t *nv, int32_t low, int32_t high) +{ char msg[64]; if (nv->value_int < low) { - sprintf(msg, "Input is less than minimum value %d", low); + sprintf(msg, "Input less than minimum value %d", (int)low); nv_add_conditional_message(msg); nv->valuetype = TYPE_NULL; return (STAT_INPUT_LESS_THAN_MIN_VALUE); } if (nv->value_int > high) { - sprintf(msg, "Input is more than maximum value %d", high); + sprintf(msg, "Input more than maximum value %d", (int)high); nv_add_conditional_message(msg); nv->valuetype = TYPE_NULL; return (STAT_INPUT_EXCEEDS_MAX_VALUE); } + return (STAT_OK); +} + +stat_t get_integer(nvObj_t *nv, const int32_t value) +{ + nv->value_int = value; + nv->valuetype = TYPE_INTEGER; + return STAT_OK; +} + +stat_t set_integer(nvObj_t *nv, uint8_t &value, uint8_t low, uint8_t high) +{ + ritorno(_set_int_tests(nv, low, high)) value = nv->value_int; nv->valuetype = TYPE_INTEGER; return (STAT_OK); } -stat_t get_int32(nvObj_t *nv, const int32_t value) { - nv->value_int = value; - nv->valuetype = TYPE_INTEGER; - return STAT_OK; -} - -stat_t set_int32(nvObj_t *nv, int32_t &value, int32_t low, int32_t high) { - - char msg[64]; - - if (nv->value_int < low) { - sprintf(msg, "Input is less than minimum value %lu", low); - nv_add_conditional_message(msg); - nv->valuetype = TYPE_NULL; - return (STAT_INPUT_LESS_THAN_MIN_VALUE); - } - if (nv->value_int > high) { - sprintf(msg, "Input is more than maximum value %lu", high); - nv_add_conditional_message(msg); - nv->valuetype = TYPE_NULL; - return (STAT_INPUT_EXCEEDS_MAX_VALUE); - } +stat_t set_int32(nvObj_t *nv, int32_t &value, int32_t low, int32_t high) +{ + ritorno(_set_int_tests(nv, low, high)) value = nv->value_int; // note: valuetype = TYPE_INT already set nv->valuetype = TYPE_INTEGER; return (STAT_OK); diff --git a/g2core/coolant.cpp b/g2core/coolant.cpp index f0db9b52..fc813202 100644 --- a/g2core/coolant.cpp +++ b/g2core/coolant.cpp @@ -153,21 +153,21 @@ static void _exec_coolant_control(float* value, bool* flag) { **** Coolant Settings ************************************************************* ***********************************************************************************/ -stat_t co_get_com(nvObj_t *nv) { return(get_int(nv, coolant.mist.state)); } +stat_t co_get_com(nvObj_t *nv) { return(get_integer(nv, coolant.mist.state)); } stat_t co_set_com(nvObj_t *nv) { return(coolant_control_immediate((coControl)nv->value_int, COOLANT_MIST)); } -stat_t co_get_cof(nvObj_t *nv) { return(get_int(nv, coolant.flood.state)); } +stat_t co_get_cof(nvObj_t *nv) { return(get_integer(nv, coolant.flood.state)); } stat_t co_set_cof(nvObj_t *nv) { return(coolant_control_immediate((coControl)nv->value_int, COOLANT_FLOOD)); } -stat_t co_get_coph(nvObj_t *nv) { return(get_int(nv, coolant.mist.pause_enable)); } +stat_t co_get_coph(nvObj_t *nv) { return(get_integer(nv, coolant.mist.pause_enable)); } stat_t co_set_coph(nvObj_t *nv) { - ritorno(set_int(nv, (uint8_t &)coolant.mist.pause_enable, 0, 1)); - return (set_int(nv, (uint8_t &)coolant.flood.pause_enable, 0, 1)); + ritorno(set_integer(nv, (uint8_t &)coolant.mist.pause_enable, 0, 1)); + return (set_integer(nv, (uint8_t &)coolant.flood.pause_enable, 0, 1)); } -stat_t co_get_comp(nvObj_t *nv) { return(get_int(nv, coolant.mist.polarity)); } -stat_t co_set_comp(nvObj_t *nv) { return(set_int(nv, (uint8_t &)coolant.mist.polarity, 0, 1)); } -stat_t co_get_cofp(nvObj_t *nv) { return(get_int(nv, coolant.flood.polarity)); } -stat_t co_set_cofp(nvObj_t *nv) { return(set_int(nv, (uint8_t &)coolant.flood.polarity, 0, 1)); } +stat_t co_get_comp(nvObj_t *nv) { return(get_integer(nv, coolant.mist.polarity)); } +stat_t co_set_comp(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)coolant.mist.polarity, 0, 1)); } +stat_t co_get_cofp(nvObj_t *nv) { return(get_integer(nv, coolant.flood.polarity)); } +stat_t co_set_cofp(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)coolant.flood.polarity, 0, 1)); } /*********************************************************************************** * TEXT MODE SUPPORT diff --git a/g2core/gpio.cpp b/g2core/gpio.cpp index 8ec12408..fdd857c5 100644 --- a/g2core/gpio.cpp +++ b/g2core/gpio.cpp @@ -504,30 +504,30 @@ static uint8_t _io(const index_t index) * io_get_fn() - get input function * io_set_fn() - set input function */ -stat_t io_get_mo(nvObj_t *nv) { return(get_int(nv, d_in[_io(nv->index)].mode)); } +stat_t io_get_mo(nvObj_t *nv) { return(get_integer(nv, d_in[_io(nv->index)].mode)); } stat_t io_set_mo(nvObj_t *nv) { - ritorno(set_int(nv, (uint8_t &)d_in[_io(nv->index)].mode, 0, IO_MODE_MAX)); + ritorno(set_integer(nv, (uint8_t &)d_in[_io(nv->index)].mode, 0, IO_MODE_MAX)); if (cm_get_machine_state() != MACHINE_INITIALIZING) { inputs_reset(); } return (STAT_OK); } -stat_t io_get_ac(nvObj_t *nv) { return(get_int(nv, d_in[_io(nv->index)].action)); } +stat_t io_get_ac(nvObj_t *nv) { return(get_integer(nv, d_in[_io(nv->index)].action)); } stat_t io_set_ac(nvObj_t *nv) { - ritorno(set_int(nv, (uint8_t &)d_in[_io(nv->index)].action, 0, INPUT_ACTION_MAX)); + ritorno(set_integer(nv, (uint8_t &)d_in[_io(nv->index)].action, 0, INPUT_ACTION_MAX)); if (cm_get_machine_state() != MACHINE_INITIALIZING) { inputs_reset(); } return (STAT_OK); } -stat_t io_get_fn(nvObj_t *nv) { return(get_int(nv, d_in[_io(nv->index)].function)); } +stat_t io_get_fn(nvObj_t *nv) { return(get_integer(nv, d_in[_io(nv->index)].function)); } stat_t io_set_fn(nvObj_t *nv) { - ritorno(set_int(nv, (uint8_t &)d_in[_io(nv->index)].function, 0, INPUT_FUNCTION_MAX)); + ritorno(set_integer(nv, (uint8_t &)d_in[_io(nv->index)].function, 0, INPUT_FUNCTION_MAX)); if (cm_get_machine_state() != MACHINE_INITIALIZING) { inputs_reset(); } @@ -548,7 +548,7 @@ stat_t io_get_input(nvObj_t *nv) * io_get_domode() - get digital output mode * io_set_domode() - set digital output mode */ -stat_t io_get_domode(nvObj_t *nv) { return(get_int(nv, d_out[_io(nv->index)].mode)); } +stat_t io_get_domode(nvObj_t *nv) { return(get_integer(nv, d_out[_io(nv->index)].mode)); } stat_t io_set_domode(nvObj_t *nv) // output function { uint8_t output_num = _io(nv->index); // returns 1 based output number (arrays) @@ -571,7 +571,7 @@ stat_t io_set_domode(nvObj_t *nv) // output function default: {} } - ritorno(set_int(nv, (uint8_t &)d_out[output_num].mode, 0, IO_MODE_MAX)); + ritorno(set_integer(nv, (uint8_t &)d_out[output_num].mode, 0, IO_MODE_MAX)); if (cm_get_machine_state() != MACHINE_INITIALIZING) { outputs_reset(); } diff --git a/g2core/json_parser.cpp b/g2core/json_parser.cpp index 65ebd177..b3d53a3d 100644 --- a/g2core/json_parser.cpp +++ b/g2core/json_parser.cpp @@ -628,10 +628,10 @@ void json_print_response(uint8_t status, const bool only_to_muted /*= false*/) * If comm_mode is set to AUTO_MORE (0) then json_mode should not be changed */ -stat_t js_get_ej(nvObj_t *nv) { return(get_int(nv, cs.comm_mode)); } +stat_t js_get_ej(nvObj_t *nv) { return(get_integer(nv, cs.comm_mode)); } stat_t js_set_ej(nvObj_t *nv) { - ritorno (set_int(nv, (uint8_t &)cs.comm_mode, TEXT_MODE, AUTO_MODE)); + ritorno (set_integer(nv, (uint8_t &)cs.comm_mode, TEXT_MODE, AUTO_MODE)); if (commMode(nv->value_int) < AUTO_MODE) { // set json_mode to 0 or 1, but don't change it if comm_mode == 2 js.json_mode = commMode(nv->value_int); } @@ -643,10 +643,10 @@ stat_t js_set_ej(nvObj_t *nv) * js_set_jv() - set JSON verbosity and related flags */ -stat_t js_get_jv(nvObj_t *nv) { return(get_int(nv, js.json_verbosity)); } +stat_t js_get_jv(nvObj_t *nv) { return(get_integer(nv, js.json_verbosity)); } stat_t js_set_jv(nvObj_t *nv) { - ritorno (set_int(nv, (uint8_t &)js.json_verbosity, JV_SILENT, JV_MAX_VALUE)); + ritorno (set_integer(nv, (uint8_t &)js.json_verbosity, JV_SILENT, JV_MAX_VALUE)); js.echo_json_footer = false; js.echo_json_messages = false; diff --git a/g2core/report.cpp b/g2core/report.cpp index 55c17f1d..d9131733 100644 --- a/g2core/report.cpp +++ b/g2core/report.cpp @@ -430,9 +430,9 @@ static uint8_t _populate_filtered_status_report() stat_t sr_get(nvObj_t *nv) { return (_populate_unfiltered_status_report()); } stat_t sr_set(nvObj_t *nv) { return (sr_set_status_report(nv)); } -stat_t sr_get_sv(nvObj_t *nv) { return(get_int(nv, (uint8_t &)sr.status_report_verbosity)); } -stat_t sr_set_sv(nvObj_t *nv) { return(set_int(nv, (uint8_t &)sr.status_report_verbosity, SR_OFF, SR_VERBOSE)); } -stat_t sr_get_si(nvObj_t *nv) { return(get_int32(nv, sr.status_report_interval)); } +stat_t sr_get_sv(nvObj_t *nv) { return(get_integer(nv, (uint8_t &)sr.status_report_verbosity)); } +stat_t sr_set_sv(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)sr.status_report_verbosity, SR_OFF, SR_VERBOSE)); } +stat_t sr_get_si(nvObj_t *nv) { return(get_integer(nv, sr.status_report_interval)); } stat_t sr_set_si(nvObj_t *nv) { return(set_int32(nv, sr.status_report_interval, STATUS_REPORT_MIN_MS, STATUS_REPORT_MAX_MS)); } /********************* @@ -595,8 +595,8 @@ stat_t qo_get(nvObj_t *nv) return (STAT_OK); } -stat_t qr_get_qv(nvObj_t *nv) { return(get_int(nv, (uint8_t &)qr.queue_report_verbosity)); } -stat_t qr_set_qv(nvObj_t *nv) { return(set_int(nv, (uint8_t &)qr.queue_report_verbosity, QR_OFF, QR_TRIPLE)); } +stat_t qr_get_qv(nvObj_t *nv) { return(get_integer(nv, (uint8_t &)qr.queue_report_verbosity)); } +stat_t qr_set_qv(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)qr.queue_report_verbosity, QR_OFF, QR_TRIPLE)); } /***************************************************************************** * JOB ID REPORTS diff --git a/g2core/spindle.cpp b/g2core/spindle.cpp index dba5eae5..c5f42a26 100644 --- a/g2core/spindle.cpp +++ b/g2core/spindle.cpp @@ -380,25 +380,25 @@ void spindle_end_override(const float ramp_time) **** Spindle Settings ************************************************************* ***********************************************************************************/ -stat_t sp_get_spmo(nvObj_t *nv) { return(get_int(nv, spindle.mode)); } -stat_t sp_set_spmo(nvObj_t *nv) { return(set_int(nv, (uint8_t &)spindle.mode, SPINDLE_DISABLED, SPINDLE_MODE_MAX)); } +stat_t sp_get_spmo(nvObj_t *nv) { return(get_integer(nv, spindle.mode)); } +stat_t sp_set_spmo(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)spindle.mode, SPINDLE_DISABLED, SPINDLE_MODE_MAX)); } -stat_t sp_get_spep(nvObj_t *nv) { return(get_int(nv, spindle.enable_polarity)); } +stat_t sp_get_spep(nvObj_t *nv) { return(get_integer(nv, spindle.enable_polarity)); } stat_t sp_set_spep(nvObj_t *nv) { - stat_t status = set_int(nv, (uint8_t &)spindle.enable_polarity, 0, 1); + stat_t status = set_integer(nv, (uint8_t &)spindle.enable_polarity, 0, 1); spindle_control_immediate(SPINDLE_OFF); // stop spindle and apply new settings return (status); } -stat_t sp_get_spdp(nvObj_t *nv) { return(get_int(nv, spindle.dir_polarity)); } +stat_t sp_get_spdp(nvObj_t *nv) { return(get_integer(nv, spindle.dir_polarity)); } stat_t sp_set_spdp(nvObj_t *nv) { - stat_t status = set_int(nv, (uint8_t &)spindle.dir_polarity, 0, 1); + stat_t status = set_integer(nv, (uint8_t &)spindle.dir_polarity, 0, 1); spindle_control_immediate(SPINDLE_OFF); // stop spindle and apply new settings return (status); } -stat_t sp_get_spph(nvObj_t *nv) { return(get_int(nv, spindle.pause_enable)); } -stat_t sp_set_spph(nvObj_t *nv) { return(set_int(nv, (uint8_t &)spindle.pause_enable, 0, 1)); } +stat_t sp_get_spph(nvObj_t *nv) { return(get_integer(nv, spindle.pause_enable)); } +stat_t sp_set_spph(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)spindle.pause_enable, 0, 1)); } stat_t sp_get_spde(nvObj_t *nv) { return(get_float(nv, spindle.spinup_delay)); } stat_t sp_set_spde(nvObj_t *nv) { return(set_float_range(nv, spindle.spinup_delay, 0, SPINDLE_DWELL_MAX)); } @@ -407,13 +407,13 @@ stat_t sp_set_spsn(nvObj_t *nv) { return(set_float_range(nv, spindle.speed_min, stat_t sp_get_spsm(nvObj_t *nv) { return(get_float(nv, spindle.speed_max)); } stat_t sp_set_spsm(nvObj_t *nv) { return(set_float_range(nv, spindle.speed_max, SPINDLE_SPEED_MIN, SPINDLE_SPEED_MAX)); } -stat_t sp_get_spoe(nvObj_t *nv) { return(get_int(nv, spindle.override_enable)); } -stat_t sp_set_spoe(nvObj_t *nv) { return(set_int(nv, (uint8_t &)spindle.override_enable, 0, 1)); } +stat_t sp_get_spoe(nvObj_t *nv) { return(get_integer(nv, spindle.override_enable)); } +stat_t sp_set_spoe(nvObj_t *nv) { return(set_integer(nv, (uint8_t &)spindle.override_enable, 0, 1)); } stat_t sp_get_spo(nvObj_t *nv) { return(get_float(nv, spindle.override_factor)); } stat_t sp_set_spo(nvObj_t *nv) { return(set_float_range(nv, spindle.override_factor, SPINDLE_OVERRIDE_MIN, SPINDLE_OVERRIDE_MAX)); } // These are provided as a way to view and control spindles without using M commands -stat_t sp_get_spc(nvObj_t *nv) { return(get_int(nv, spindle.state)); } +stat_t sp_get_spc(nvObj_t *nv) { return(get_integer(nv, spindle.state)); } stat_t sp_set_spc(nvObj_t *nv) { return(spindle_control_immediate((spControl)nv->value_int)); } stat_t sp_get_sps(nvObj_t *nv) { return(get_float(nv, spindle.speed)); } stat_t sp_set_sps(nvObj_t *nv) { return(spindle_speed_immediate(nv->value_flt)); } diff --git a/g2core/stepper.cpp b/g2core/stepper.cpp index b01868ac..81f570cc 100644 --- a/g2core/stepper.cpp +++ b/g2core/stepper.cpp @@ -816,8 +816,8 @@ static float _set_motor_steps_per_unit(nvObj_t *nv) */ // motor axis mapping -stat_t st_get_ma(nvObj_t *nv) { return(get_int(nv, st_cfg.mot[_motor(nv->index)].motor_map)); } -stat_t st_set_ma(nvObj_t *nv) { return(set_int(nv, st_cfg.mot[_motor(nv->index)].motor_map, 0, AXES)); } +stat_t st_get_ma(nvObj_t *nv) { return(get_integer(nv, st_cfg.mot[_motor(nv->index)].motor_map)); } +stat_t st_set_ma(nvObj_t *nv) { return(set_integer(nv, st_cfg.mot[_motor(nv->index)].motor_map, 0, AXES)); } // step angle stat_t st_get_sa(nvObj_t *nv) { return(get_float(nv, st_cfg.mot[_motor(nv->index)].step_angle)); } @@ -838,7 +838,7 @@ stat_t st_set_tr(nvObj_t *nv) } // microsteps -stat_t st_get_mi(nvObj_t *nv) { return(get_int(nv, st_cfg.mot[_motor(nv->index)].microsteps)); } +stat_t st_get_mi(nvObj_t *nv) { return(get_integer(nv, st_cfg.mot[_motor(nv->index)].microsteps)); } stat_t st_set_mi(nvObj_t *nv) { if (nv->value_int <= 0) { @@ -851,7 +851,7 @@ stat_t st_set_mi(nvObj_t *nv) nv_add_conditional_message((const char *)"*** WARNING *** Setting non-standard microstep value"); } // set it anyway, even if it's unsupported - ritorno(set_int(nv, st_cfg.mot[_motor(nv->index)].microsteps, 1, 255)); + ritorno(set_integer(nv, st_cfg.mot[_motor(nv->index)].microsteps, 1, 255)); _set_motor_steps_per_unit(nv); _set_hw_microsteps(_motor(nv->index), nv->value_int); return (STAT_OK); @@ -890,8 +890,8 @@ stat_t st_set_su(nvObj_t *nv) } // polarity -stat_t st_get_po(nvObj_t *nv) { return(get_int(nv, st_cfg.mot[_motor(nv->index)].polarity)); } -stat_t st_set_po(nvObj_t *nv) { return(set_int(nv, st_cfg.mot[_motor(nv->index)].polarity, 0, 1)); } +stat_t st_get_po(nvObj_t *nv) { return(get_integer(nv, st_cfg.mot[_motor(nv->index)].polarity)); } +stat_t st_set_po(nvObj_t *nv) { return(set_integer(nv, st_cfg.mot[_motor(nv->index)].polarity, 0, 1)); } // power management mode stat_t st_get_pm(nvObj_t *nv) @@ -905,7 +905,7 @@ stat_t st_set_pm(nvObj_t *nv) { // Test the value without setting it, then setPowerMode() now // to both set and take effect immediately. - ritorno(set_int(nv, (uint8_t &)cs.null, 0, MOTOR_POWER_MODE_MAX_VALUE )); + ritorno(set_integer(nv, (uint8_t &)cs.null, 0, MOTOR_POWER_MODE_MAX_VALUE )); Motors[_motor(nv->index)]->setPowerMode((stPowerMode)nv->value_int); return (STAT_OK); } diff --git a/g2core/text_parser.cpp b/g2core/text_parser.cpp index 8720109a..56723673 100644 --- a/g2core/text_parser.cpp +++ b/g2core/text_parser.cpp @@ -296,7 +296,7 @@ void tx_print_tv(nvObj_t *nv) { text_print(nv, fmt_tv);} // TYPE_INT * txt_set_tv() - set text verbosity */ -stat_t txt_get_tv(nvObj_t *nv) { return (get_int(nv, txt.text_verbosity)); } -stat_t txt_set_tv(nvObj_t *nv) { return (set_int(nv, txt.text_verbosity, TV_SILENT, TV_VERBOSE)); } +stat_t txt_get_tv(nvObj_t *nv) { return (get_integer(nv, txt.text_verbosity)); } +stat_t txt_set_tv(nvObj_t *nv) { return (set_integer(nv, txt.text_verbosity, TV_SILENT, TV_VERBOSE)); } #endif // __TEXT_MODE