Refactored CT command; renamed a few things

This commit is contained in:
Alden Hart
2016-12-11 08:25:57 -05:00
parent c5224b34a1
commit 07896b8886
6 changed files with 58 additions and 51 deletions
+9 -3
View File
@@ -2396,11 +2396,12 @@ stat_t cm_set_zb(nvObj_t *nv) { return (set_float(nv, cm->a[_axis(nv->index)].ze
/*** Canonical Machine Global Settings ***/
/*
* cm_get_jt() - get junction integration time
* cm_set_jt() - get junction integration time
* cm_set_jt() - set junction integration time
* cm_get_ct() - get chordal tolerance
* cm_set_ct() - set chordal tolerance
*/
stat_t cm_get_jt(nvObj_t *nv) {
return(get_float(nv, cm->junction_integration_time)); }
stat_t cm_get_jt(nvObj_t *nv) { return(get_float(nv, cm->junction_integration_time)); }
stat_t cm_set_jt(nvObj_t *nv)
{
@@ -2416,6 +2417,11 @@ stat_t cm_set_jt(nvObj_t *nv)
return(STAT_OK);
}
stat_t cm_get_ct(nvObj_t *nv) { return(get_float(nv, cm->chordal_tolerance)); }
stat_t cm_set_ct(nvObj_t *nv) { return(set_float_range(nv, cm->chordal_tolerance,
CHORDAL_TOLERANCE_MIN,
10000000)); }
/*
* cm_set_mfo() - set manual feedrate override factor
* cm_set_mto() - set manual traverse override factor
+3
View File
@@ -47,6 +47,7 @@
#define JOGGING_START_VELOCITY ((float)10.0)
#define DISABLE_SOFT_LIMIT (999999)
#define CHORDAL_TOLERANCE_MIN (0.001)
#define PROBES_STORED 3 // we store three probes for coordinate rotation computation
/*****************************************************************************
@@ -503,6 +504,8 @@ stat_t cm_set_zb(nvObj_t *nv); // set homing zero backoff
stat_t cm_get_jt(nvObj_t *nv); // get junction integration time constant
stat_t cm_set_jt(nvObj_t *nv); // set junction integration time constant
stat_t cm_get_ct(nvObj_t *nv); // get chordal tolerance
stat_t cm_set_ct(nvObj_t *nv); // set chordal tolerance
stat_t cm_set_mfo(nvObj_t *nv); // set manual feedrate override factor
stat_t cm_set_mto(nvObj_t *nv); // set manual traverse override factor
+3 -4
View File
@@ -354,16 +354,15 @@ 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 process_incoming_float(nvObj_t *nv); // pre-process outgoing float values for units and illegal values
void process_outgoing_float(nvObj_t *nv); // pre-process incoming float values for canonical units
stat_t get_float(nvObj_t *nv, const float value); // boilerplate for retrieving raw floating point value
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 an integer value
stat_t get_int(nvObj_t *nv, const uint8_t value); // boilerplate for retrieving an integer value
stat_t set_int(nvObj_t *nv, uint8_t &value, uint8_t low, uint8_t high);
void preprocess_incoming_float(nvObj_t *nv); // pre-process outgoing float values for units and illegal values
void preprocess_outgoing_float(nvObj_t *nv); // pre-process incoming float values for canonical units
// diagnostics
void nv_dump_nv(nvObj_t *nv);
+41 -42
View File
@@ -603,8 +603,8 @@ const cfgItem_t cfgArray[] = {
{ "jid","jidd",_f0, 0, tx_print_nul, get_data, set_data, (float *)&cfg.job_id[3], 0},
// General system parameters
{ "sys","jt", _fipn, 2, cm_print_jt, cm_get_jt, cm_set_jt, (float *)&cm->junction_integration_time,JUNCTION_INTEGRATION_TIME },
{ "sys","ct", _fipnc,4, cm_print_ct, get_flt, set_flu, (float *)&cm->chordal_tolerance, CHORDAL_TOLERANCE },
{ "sys","jt", _fipn, 2, cm_print_jt, cm_get_jt, cm_set_jt, (float *)&cs.null, JUNCTION_INTEGRATION_TIME },
{ "sys","ct", _fipnc,4, cm_print_ct, cm_get_ct, cm_set_ct, (float *)&cs.null, CHORDAL_TOLERANCE },
{ "sys","sl", _fipn, 0, cm_print_sl, get_ui8, set_01, (float *)&cm->soft_limit_enable, SOFT_LIMIT_ENABLE },
{ "sys","lim", _fipn,0, cm_print_lim, get_ui8, set_01, (float *)&cm->limit_enable, HARD_LIMIT_ENABLE },
{ "sys","saf", _fipn,0, cm_print_saf, get_ui8, set_01, (float *)&cm->safety_interlock_enable, SAFETY_INTERLOCK_ENABLE },
@@ -995,9 +995,11 @@ stat_t set_flu(nvObj_t *nv)
}
/*
* get_float() - boilerplate for retrieving raw floating point value
* set_float() - boilerplate for setting a floating point value with unit conversion
* set_float_range() - set a floating point value with inclusive range check
* process_incoming_float() - pre-process an incoming floating point number for canonical units
* process_outgoing_float() - pre-process an outgoing floating point number for units display
* get_float() - boilerplate for retrieving raw floating point value
* set_float() - boilerplate for setting a floating point value with unit conversion
* set_float_range() - set a floating point value with inclusive range check
*
* get_float() returns a raw float value in internal canonical units (e.g. mm, degrees)
* without units conversion. If conversion is required call preprocess_outgoing_float()
@@ -1008,6 +1010,37 @@ stat_t set_flu(nvObj_t *nv)
* set_float_range() perfoems an inclusive range test on the CONVERTED value
*/
void process_incoming_float(nvObj_t *nv)
{
uint8_t f;
f = GET_TABLE_BYTE(flags);
// if (f & (F_CONVERT | F_ICONVERT)) { // unit conversion required?
if (f & F_CONVERT) { // unit conversion required?
if (cm_get_units_mode(MODEL) == INCHES) { // If inn inches mode
if (cm_get_axis_type(nv->index) == AXIS_TYPE_LINEAR) { // ...and a linear axis...
nv->value *= MM_PER_INCH; // convert to canonical millimeter units
}
}
}
}
void process_outgoing_float(nvObj_t *nv)
{
uint8_t f;
if (isnan((double)nv->value) || isinf((double)nv->value)) return; // illegal float values
f = GET_TABLE_BYTE(flags);
if (f & (F_CONVERT | F_ICONVERT)) { // unit conversion required?
if (cm_get_units_mode(MODEL) == INCHES) {
if(f & F_ICONVERT) {
nv->value *= MM_PER_INCH;
} else {
nv->value *= INCHES_PER_MM;
}
}
}
nv->precision = GET_TABLE_WORD(precision);
nv->valuetype = TYPE_FLOAT;
}
stat_t get_float(nvObj_t *nv, const float value) {
nv->value = value;
nv->valuetype = TYPE_FLOAT;
@@ -1016,14 +1049,15 @@ stat_t get_float(nvObj_t *nv, const float value) {
}
stat_t set_float(nvObj_t *nv, float &value) {
preprocess_incoming_float(nv);
process_incoming_float(nv);
value = nv->value;
return (STAT_OK);
}
stat_t set_float_range(nvObj_t *nv, float &value, float low, float high) {
preprocess_incoming_float(nv);
process_incoming_float(nv); // conditional unit conversion
if ((nv->value < low) || (nv->value > high)) {
nv->valuetype = TYPE_NULL;
return (STAT_INPUT_VALUE_RANGE_ERROR);
}
value = nv->value;
@@ -1050,42 +1084,7 @@ stat_t set_int(nvObj_t *nv, uint8_t &value, uint8_t low, uint8_t high) {
return (STAT_OK);
}
/*
* preprocess_incoming_float() - pre-process an incoming floating point number for canonical units
* preprocess_outgoing_float() - pre-process an outgoing floating point number for units display
*/
void preprocess_incoming_float(nvObj_t *nv)
{
uint8_t f;
f = GET_TABLE_BYTE(flags);
// if (f & (F_CONVERT | F_ICONVERT)) { // unit conversion required?
if (f & F_CONVERT) { // unit conversion required?
if (cm_get_units_mode(MODEL) == INCHES) { // If inn inches mode
if (cm_get_axis_type(nv->index) == AXIS_TYPE_LINEAR) { // ...and a linear axis...
nv->value *= MM_PER_INCH; // convert to canonical millimeter units
}
}
}
}
void preprocess_outgoing_float(nvObj_t *nv)
{
uint8_t f;
if (isnan((double)nv->value) || isinf((double)nv->value)) return; // illegal float values
f = GET_TABLE_BYTE(flags);
if (f & (F_CONVERT | F_ICONVERT)) { // unit conversion required?
if (cm_get_units_mode(MODEL) == INCHES) {
if(f & F_ICONVERT) {
nv->value *= MM_PER_INCH;
} else {
nv->value *= INCHES_PER_MM;
}
}
}
nv->precision = GET_TABLE_WORD(precision);
nv->valuetype = TYPE_FLOAT;
}
/*
* nv_group_is_prefixed() - hack
+1 -1
View File
@@ -421,7 +421,7 @@ uint16_t json_serialize(nvObj_t *nv, char *out_buf, uint16_t size)
need_a_comma = false;
break;
}
case (TYPE_FLOAT): { preprocess_outgoing_float(nv);
case (TYPE_FLOAT): { process_outgoing_float(nv);
str += floattoa(str, nv->value, nv->precision);
break;
}
+1 -1
View File
@@ -196,7 +196,7 @@ void text_print_multiline_formatted(nvObj_t *nv)
{
for (uint8_t i=0; i<NV_BODY_LEN-1; i++) {
if (nv->valuetype != TYPE_PARENT) {
preprocess_outgoing_float(nv);
process_outgoing_float(nv);
nv_print(nv);
}
if ((nv = nv->nx) == NULL) return;