More concise tmc_util output, fix a ternary type

This commit is contained in:
Scott Lahteine 2018-03-14 04:10:24 -05:00
parent bba2a3b906
commit 07b1ac06a9

View File

@ -227,11 +227,11 @@ void _tmc_say_axis(const TMC_AxisEnum axis) {
void _tmc_say_current(const TMC_AxisEnum axis, const uint16_t curr) { void _tmc_say_current(const TMC_AxisEnum axis, const uint16_t curr) {
_tmc_say_axis(axis); _tmc_say_axis(axis);
SERIAL_ECHOLNPAIR(" axis driver current: ", curr); SERIAL_ECHOLNPAIR(" driver current: ", curr);
} }
void _tmc_say_otpw(const TMC_AxisEnum axis, const bool otpw) { void _tmc_say_otpw(const TMC_AxisEnum axis, const bool otpw) {
_tmc_say_axis(axis); _tmc_say_axis(axis);
SERIAL_ECHOPGM(" axis temperature prewarn triggered: "); SERIAL_ECHOPGM(" temperature prewarn triggered: ");
serialprintPGM(otpw ? PSTR("true") : PSTR("false")); serialprintPGM(otpw ? PSTR("true") : PSTR("false"));
SERIAL_EOL(); SERIAL_EOL();
} }
@ -241,11 +241,11 @@ void _tmc_say_otpw_cleared(const TMC_AxisEnum axis) {
} }
void _tmc_say_pwmthrs(const TMC_AxisEnum axis, const uint32_t thrs) { void _tmc_say_pwmthrs(const TMC_AxisEnum axis, const uint32_t thrs) {
_tmc_say_axis(axis); _tmc_say_axis(axis);
SERIAL_ECHOLNPAIR(" stealthChop max speed set to ", thrs); SERIAL_ECHOLNPAIR(" stealthChop max speed: ", thrs);
} }
void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
_tmc_say_axis(axis); _tmc_say_axis(axis);
SERIAL_ECHOPGM(" driver homing sensitivity set to "); SERIAL_ECHOPGM(" homing sensitivity: ");
SERIAL_PRINTLN(sgt, DEC); SERIAL_PRINTLN(sgt, DEC);
} }
@ -312,7 +312,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
#if ENABLED(HAVE_TMC2130) #if ENABLED(HAVE_TMC2130)
static void tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) { static void tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) {
switch(i) { switch (i) {
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break; case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break;
case TMC_TSTEP: SERIAL_ECHO(st.TSTEP()); break; case TMC_TSTEP: SERIAL_ECHO(st.TSTEP()); break;
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break; case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
@ -321,7 +321,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
} }
} }
static void tmc_parse_drv_status(TMC2130Stepper &st, const TMC_drv_status_enum i) { static void tmc_parse_drv_status(TMC2130Stepper &st, const TMC_drv_status_enum i) {
switch(i) { switch (i) {
case TMC_STALLGUARD: if (st.stallguard()) SERIAL_CHAR('X'); break; case TMC_STALLGUARD: if (st.stallguard()) SERIAL_CHAR('X'); break;
case TMC_SG_RESULT: SERIAL_PRINT(st.sg_result(), DEC); break; case TMC_SG_RESULT: SERIAL_PRINT(st.sg_result(), DEC); break;
case TMC_FSACTIVE: if (st.fsactive()) SERIAL_CHAR('X'); break; case TMC_FSACTIVE: if (st.fsactive()) SERIAL_CHAR('X'); break;
@ -331,7 +331,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
#endif #endif
#if ENABLED(HAVE_TMC2208) #if ENABLED(HAVE_TMC2208)
static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) { static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
switch(i) { switch (i) {
case TMC_TSTEP: { uint32_t data = 0; st.TSTEP(&data); SERIAL_PROTOCOL(data); break; } case TMC_TSTEP: { uint32_t data = 0; st.TSTEP(&data); SERIAL_PROTOCOL(data); break; }
case TMC_PWM_SCALE: SERIAL_PRINT(st.pwm_scale_sum(), DEC); break; case TMC_PWM_SCALE: SERIAL_PRINT(st.pwm_scale_sum(), DEC); break;
case TMC_STEALTHCHOP: serialprintPGM(st.stealth() ? PSTR("true") : PSTR("false")); break; case TMC_STEALTHCHOP: serialprintPGM(st.stealth() ? PSTR("true") : PSTR("false")); break;
@ -341,7 +341,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
} }
} }
static void tmc_parse_drv_status(TMC2208Stepper &st, const TMC_drv_status_enum i) { static void tmc_parse_drv_status(TMC2208Stepper &st, const TMC_drv_status_enum i) {
switch(i) { switch (i) {
case TMC_T157: if (st.t157()) SERIAL_CHAR('X'); break; case TMC_T157: if (st.t157()) SERIAL_CHAR('X'); break;
case TMC_T150: if (st.t150()) SERIAL_CHAR('X'); break; case TMC_T150: if (st.t150()) SERIAL_CHAR('X'); break;
case TMC_T143: if (st.t143()) SERIAL_CHAR('X'); break; case TMC_T143: if (st.t143()) SERIAL_CHAR('X'); break;
@ -354,7 +354,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
template <typename TMC> template <typename TMC>
static void tmc_status(TMC &st, const TMC_AxisEnum axis, const TMC_debug_enum i, const float spmm) { static void tmc_status(TMC &st, const TMC_AxisEnum axis, const TMC_debug_enum i, const float spmm) {
SERIAL_ECHO('\t'); SERIAL_ECHO('\t');
switch(i) { switch (i) {
case TMC_CODES: _tmc_say_axis(axis); break; case TMC_CODES: _tmc_say_axis(axis); break;
case TMC_ENABLED: serialprintPGM(st.isEnabled() ? PSTR("true") : PSTR("false")); break; case TMC_ENABLED: serialprintPGM(st.isEnabled() ? PSTR("true") : PSTR("false")); break;
case TMC_CURRENT: SERIAL_ECHO(st.getCurrent()); break; case TMC_CURRENT: SERIAL_ECHO(st.getCurrent()); break;
@ -383,7 +383,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
break; break;
case TMC_TPWMTHRS_MMS: { case TMC_TPWMTHRS_MMS: {
uint32_t tpwmthrs_val = st.TPWMTHRS(); uint32_t tpwmthrs_val = st.TPWMTHRS();
tpwmthrs_val ? SERIAL_ECHO(12650000UL * st.microsteps() / (256 * tpwmthrs_val * spmm)) : SERIAL_CHAR('-'); tpwmthrs_val ? SERIAL_ECHO(12650000UL * st.microsteps() / (256 * tpwmthrs_val * spmm)) : (void)SERIAL_CHAR('-');
} }
break; break;
case TMC_OTPW: serialprintPGM(st.otpw() ? PSTR("true") : PSTR("false")); break; case TMC_OTPW: serialprintPGM(st.otpw() ? PSTR("true") : PSTR("false")); break;
@ -399,7 +399,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
template <typename TMC> template <typename TMC>
static void tmc_parse_drv_status(TMC &st, const TMC_AxisEnum axis, const TMC_drv_status_enum i) { static void tmc_parse_drv_status(TMC &st, const TMC_AxisEnum axis, const TMC_drv_status_enum i) {
SERIAL_CHAR('\t'); SERIAL_CHAR('\t');
switch(i) { switch (i) {
case TMC_DRV_CODES: _tmc_say_axis(axis); break; case TMC_DRV_CODES: _tmc_say_axis(axis); break;
case TMC_STST: if (st.stst()) SERIAL_CHAR('X'); break; case TMC_STST: if (st.stst()) SERIAL_CHAR('X'); break;
case TMC_OLB: if (st.olb()) SERIAL_CHAR('X'); break; case TMC_OLB: if (st.olb()) SERIAL_CHAR('X'); break;