🧑‍💻 Serial ON_OFF, TRUE_FALSE

This commit is contained in:
Scott Lahteine 2025-05-26 14:33:40 -05:00
parent af7b126edc
commit 0916d32589
15 changed files with 45 additions and 62 deletions

View file

@ -114,10 +114,6 @@ void serial_ternary(FSTR_P const pre, const bool onoff, FSTR_P const on, FSTR_P
if (post) SERIAL_ECHO(post);
}
void serialprint_onoff(const bool onoff) { SERIAL_ECHO(onoff ? F(STR_ON) : F(STR_OFF)); }
void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); }
void serialprint_truefalse(const bool tf) { SERIAL_ECHO(tf ? F("true") : F("false")); }
void print_bin(uint16_t val) {
for (uint8_t i = 16; i--;) {
SERIAL_CHAR('0' + TEST(val, i));

View file

@ -233,9 +233,9 @@ void serial_ternary(FSTR_P const pre, const bool onoff, FSTR_P const on, FSTR_P
// Print up to 255 spaces
void SERIAL_ECHO_SP(uint8_t count);
void serialprint_onoff(const bool onoff);
void serialprintln_onoff(const bool onoff);
void serialprint_truefalse(const bool tf);
inline FSTR_P const ON_OFF(const bool onoff) { return onoff ? F("ON") : F("OFF"); }
inline FSTR_P const TRUE_FALSE(const bool tf) { return tf ? F("true") : F("false"); }
void serial_offset(const_float_t v, const uint8_t sp=0); // For v==0 draw space (sp==1) or plus (sp==2)
void print_bin(const uint16_t val);

View file

@ -169,9 +169,11 @@ void MeatPack::handle_command(const MeatPack_Command c) {
void MeatPack::report_state() {
// NOTE: if any configuration vars are added below, the outgoing sync text for host plugin
// should not contain the "PV' substring, as this is used to indicate protocol version
SERIAL_ECHOPGM("[MP] " MeatPack_ProtocolVersion " ");
serialprint_onoff(TEST(state, MPConfig_Bit_Active));
SERIAL_ECHO(TEST(state, MPConfig_Bit_NoSpaces) ? F(" NSP\n") : F(" ESP\n"));
SERIAL_ECHO(
F("[MP] " MeatPack_ProtocolVersion " "),
ON_OFF(TEST(state, MPConfig_Bit_Active)),
TEST(state, MPConfig_Bit_NoSpaces) ? F(" NSP\n") : F(" ESP\n")
);
}
/**

View file

@ -595,13 +595,15 @@
void print_cs_actual(TMCMarlin<TMC2240Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &) { }
#endif
static void print_true_or_false(const bool tf) { SERIAL_ECHO(TRUE_FALSE(tf)); }
#if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC5130)
static void _tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_PWM_SCALE: SERIAL_ECHO(st.PWM_SCALE()); break;
case TMC_SGT: SERIAL_ECHO(st.sgt()); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break;
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
case TMC_STEALTHCHOP: print_true_or_false(st.en_pwm_mode()); break;
case TMC_INTERPOLATE: print_true_or_false(st.intpol()); break;
default: break;
}
}
@ -623,7 +625,7 @@
switch (i) {
case TMC_PWM_SCALE: SERIAL_ECHO(st.PWM_SCALE()); break;
case TMC_SGT: SERIAL_ECHO(st.sgt()); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break;
case TMC_STEALTHCHOP: print_true_or_false(st.en_pwm_mode()); break;
case TMC_GLOBAL_SCALER:
{
const uint16_t value = st.GLOBAL_SCALER();
@ -631,7 +633,7 @@
SERIAL_ECHOPGM("/256");
}
break;
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
case TMC_INTERPOLATE: print_true_or_false(st.intpol()); break;
default: break;
}
}
@ -645,8 +647,8 @@
case TMC_PWM_SCALE_AUTO: SERIAL_ECHO(st.pwm_scale_auto()); break;
case TMC_PWM_OFS_AUTO: SERIAL_ECHO(st.pwm_ofs_auto()); break;
case TMC_PWM_GRAD_AUTO: SERIAL_ECHO(st.pwm_grad_auto()); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.stealth()); break;
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
case TMC_STEALTHCHOP: print_true_or_false(st.stealth()); break;
case TMC_INTERPOLATE: print_true_or_false(st.intpol()); break;
default: break;
}
}
@ -697,8 +699,8 @@
case TMC_PWM_SCALE_AUTO: SERIAL_ECHO(st.pwm_scale_auto()); break;
case TMC_PWM_OFS_AUTO: SERIAL_ECHO(st.pwm_ofs_auto()); break;
case TMC_PWM_GRAD_AUTO: SERIAL_ECHO(st.pwm_grad_auto()); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.stealth()); break;
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
case TMC_STEALTHCHOP: print_true_or_false(st.stealth()); break;
case TMC_INTERPOLATE: print_true_or_false(st.intpol()); break;
default: break;
}
}
@ -708,7 +710,7 @@
static void _tmc_parse_drv_status(TMC2660Stepper, const TMC_drv_status_enum) { }
static void _tmc_status(TMC2660Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
case TMC_INTERPOLATE: print_true_or_false(st.intpol()); break;
default: break;
}
}
@ -734,7 +736,7 @@
SERIAL_CHAR('\t');
switch (i) {
case TMC_CODES: st.printLabel(); break;
case TMC_ENABLED: serialprint_truefalse(st.isEnabled()); break;
case TMC_ENABLED: print_true_or_false(st.isEnabled()); break;
case TMC_CURRENT: SERIAL_ECHO(st.getMilliamps()); break;
case TMC_RMS_CURRENT: SERIAL_ECHO(st.rms_current()); break;
case TMC_MAX_CURRENT: SERIAL_ECHO(p_float_t(st.rms_current() * 1.41, 0)); break;
@ -757,9 +759,9 @@
if (tpwmthrs_val) SERIAL_ECHO(tpwmthrs_val); else SERIAL_CHAR('-');
} break;
#endif
case TMC_OTPW: serialprint_truefalse(st.otpw()); break;
case TMC_OTPW: print_true_or_false(st.otpw()); break;
#if ENABLED(MONITOR_DRIVER_STATUS)
case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break;
case TMC_OTPW_TRIGGERED: print_true_or_false(st.getOTPW()); break;
#endif
case TMC_TOFF: SERIAL_ECHO(st.toff()); break;
case TMC_TBL: print_blank_time(st); break;
@ -776,7 +778,7 @@
SERIAL_CHAR('\t');
switch (i) {
case TMC_CODES: st.printLabel(); break;
case TMC_ENABLED: serialprint_truefalse(st.isEnabled()); break;
case TMC_ENABLED: print_true_or_false(st.isEnabled()); break;
case TMC_CURRENT: SERIAL_ECHO(st.getMilliamps()); break;
case TMC_RMS_CURRENT: SERIAL_ECHO(st.rms_current()); break;
case TMC_MAX_CURRENT: SERIAL_ECHO(p_float_t(st.rms_current() * 1.41, 0)); break;
@ -786,8 +788,8 @@
break;
case TMC_VSENSE: SERIAL_ECHO(st.vsense() ? F("1=.165") : F("0=.310")); break;
case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break;
//case TMC_OTPW: serialprint_truefalse(st.otpw()); break;
//case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break;
//case TMC_OTPW: print_true_or_false(st.otpw()); break;
//case TMC_OTPW_TRIGGERED: print_true_or_false(st.getOTPW()); break;
case TMC_SGT: SERIAL_ECHO(st.sgt()); break;
case TMC_TOFF: SERIAL_ECHO(st.toff()); break;
case TMC_TBL: print_blank_time(st); break;

View file

@ -228,9 +228,7 @@ void GcodeSuite::M420() {
if (to_enable && !planner.leveling_active)
SERIAL_ERROR_MSG(STR_ERR_M420_FAILED);
SERIAL_ECHO_START();
SERIAL_ECHOPGM("Bed Leveling ");
serialprintln_onoff(planner.leveling_active);
SERIAL_ECHO_MSG("Bed Leveling ", ON_OFF(planner.leveling_active));
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
SERIAL_ECHO_START();
@ -252,14 +250,13 @@ void GcodeSuite::M420_report(const bool forReplay/*=true*/) {
report_heading_etc(forReplay, F(
TERN(MESH_BED_LEVELING, "Mesh Bed Leveling", TERN(AUTO_BED_LEVELING_UBL, "Unified Bed Leveling", "Auto Bed Leveling"))
));
SERIAL_ECHO(
SERIAL_ECHOLN(
F(" M420 S"), planner.leveling_active
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
, FPSTR(SP_Z_STR), LINEAR_UNIT(planner.z_fade_height)
#endif
, F(" ; Leveling ")
, F(" ; Leveling "), ON_OFF(planner.leveling_active)
);
serialprintln_onoff(planner.leveling_active);
}
#endif // HAS_LEVELING

View file

@ -99,7 +99,7 @@ void GcodeSuite::G29() {
case MeshReport:
SERIAL_ECHOPGM("Mesh Bed Leveling ");
if (leveling_is_valid()) {
serialprintln_onoff(planner.leveling_active);
SERIAL_ECHOLN(ON_OFF(planner.leveling_active));
bedlevel.report_mesh();
}
else

View file

@ -43,8 +43,7 @@ void GcodeSuite::M211_report(const bool forReplay/*=true*/) {
TERN_(MARLIN_SMALL_BUILD, return);
report_heading_etc(forReplay, F(STR_SOFT_ENDSTOPS));
SERIAL_ECHOPGM(" M211 S", AS_DIGIT(soft_endstop._enabled), " ; ");
serialprintln_onoff(soft_endstop._enabled);
SERIAL_ECHOLNPGM(" M211 S", AS_DIGIT(soft_endstop._enabled), " ; ", ON_OFF(soft_endstop._enabled));
report_echo_start(forReplay);
const xyz_pos_t l_soft_min = soft_endstop.min.asLogical(),

View file

@ -173,8 +173,7 @@
set_duplication_enabled(ena && (duplication_e_mask >= 3));
}
SERIAL_ECHO_START();
SERIAL_ECHOPGM(STR_DUPLICATION_MODE);
serialprint_onoff(extruder_duplication_enabled);
SERIAL_ECHOPGM(STR_DUPLICATION_MODE, ON_OFF(extruder_duplication_enabled));
if (ena) {
SERIAL_ECHOPGM(" ( ");
HOTEND_LOOP() if (TEST(duplication_e_mask, e)) { SERIAL_ECHO(e); SERIAL_CHAR(' '); }

View file

@ -68,8 +68,7 @@ void GcodeSuite::M166() {
mixer.refresh_gradient();
SERIAL_ECHOPGM("Gradient Mix ");
serialprint_onoff(mixer.gradient.enabled);
SERIAL_ECHOPGM("Gradient Mix ", ON_OFF(mixer.gradient.enabled));
if (mixer.gradient.enabled) {
#if ENABLED(GRADIENT_VTOOL)

View file

@ -67,13 +67,12 @@ void GcodeSuite::M413_report(const bool forReplay/*=true*/) {
TERN_(MARLIN_SMALL_BUILD, return);
report_heading_etc(forReplay, F(STR_POWER_LOSS_RECOVERY));
SERIAL_ECHOPGM(" M413 S", AS_DIGIT(recovery.enabled)
SERIAL_ECHOLNPGM(" M413 S", AS_DIGIT(recovery.enabled)
#if HAS_PLR_BED_THRESHOLD
, " B", recovery.bed_temp_threshold
#endif
, " ; ", ON_OFF(recovery.enabled)
);
SERIAL_ECHO(" ; ");
serialprintln_onoff(recovery.enabled);
}
#endif // POWER_LOSS_RECOVERY

View file

@ -185,13 +185,12 @@ void GcodeSuite::M709() {
void GcodeSuite::MMU3_report(const bool forReplay/*=true*/) {
using namespace MMU3;
report_heading(forReplay, F("MMU3 Operational Stats"));
SERIAL_ECHOPGM(" MMU "); serialprintln_onoff(mmu3.mmu_hw_enabled);
SERIAL_ECHOPGM(" Stealth Mode "); serialprintln_onoff(mmu3.stealth_mode);
SERIAL_ECHOLNPGM(" MMU ", ON_OFF(mmu3.mmu_hw_enabled));
SERIAL_ECHOLNPGM(" Stealth Mode ", ON_OFF(mmu3.stealth_mode));
#if ENABLED(MMU3_HAS_CUTTER)
SERIAL_ECHOPGM(" Cutter ");
serialprintln_onoff(mmu3.cutter_mode != 0);
SERIAL_ECHOLNPGM(" Cutter ", ON_OFF(mmu3.cutter_mode != 0));
#endif
SERIAL_ECHOPGM(" SpoolJoin "); serialprintln_onoff(spooljoin.enabled);
SERIAL_ECHOLNPGM(" SpoolJoin ", ON_OFF(spooljoin.enabled));
SERIAL_ECHOLNPGM(" Tool Changes ", operation_statistics.tool_change_counter);
SERIAL_ECHOLNPGM(" Total Tool Changes ", operation_statistics.tool_change_total_counter);
SERIAL_ECHOLNPGM(" Fails ", operation_statistics.fail_num);

View file

@ -53,14 +53,12 @@ void GcodeSuite::M412() {
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOPGM("Filament runout ");
serialprint_onoff(runout.enabled);
SERIAL_ECHOPGM("Filament runout ", ON_OFF(runout.enabled));
#if HAS_FILAMENT_RUNOUT_DISTANCE
SERIAL_ECHOPGM(" ; Distance ", runout.runout_distance(), "mm");
#endif
#if ENABLED(HOST_ACTION_COMMANDS)
SERIAL_ECHOPGM(" ; Host handling ");
serialprint_onoff(runout.host_handling);
SERIAL_ECHOPGM(" ; Host handling ", ON_OFF(runout.host_handling));
#endif
SERIAL_EOL();
}
@ -70,14 +68,13 @@ void GcodeSuite::M412_report(const bool forReplay/*=true*/) {
TERN_(MARLIN_SMALL_BUILD, return);
report_heading_etc(forReplay, F(STR_FILAMENT_RUNOUT_SENSOR));
SERIAL_ECHOPGM(
SERIAL_ECHOLNPGM(
" M412 S", runout.enabled
#if HAS_FILAMENT_RUNOUT_DISTANCE
, " D", LINEAR_UNIT(runout.runout_distance())
#endif
, " ; Sensor "
, " ; Sensor ", ON_OFF(runout.enabled)
);
serialprintln_onoff(runout.enabled);
}
#endif // HAS_FILAMENT_SENSOR

View file

@ -76,9 +76,7 @@
template<typename TMC>
static void tmc_report_otpw(TMC &st) {
st.printLabel();
SERIAL_ECHOPGM(" temperature prewarn triggered: ");
serialprint_truefalse(st.getOTPW());
SERIAL_EOL();
SERIAL_ECHOLNPGM(" temperature prewarn triggered: ", TRUE_FALSE(st.getOTPW()));
}
template<typename TMC>

View file

@ -47,9 +47,7 @@ void GcodeSuite::M401() {
seenS = parser.seen('S');
if (seenH || seenS) {
if (seenS) bltouch.high_speed_mode = parser.value_bool();
SERIAL_ECHO_START();
SERIAL_ECHOPGM("BLTouch HS mode ");
serialprintln_onoff(bltouch.high_speed_mode);
SERIAL_ECHO_MSG("BLTouch HS mode ", ON_OFF(bltouch.high_speed_mode));
return;
}
#endif

View file

@ -50,9 +50,7 @@ void GcodeSuite::M303() {
#if HAS_PID_DEBUG
if (parser.seen_test('D')) {
FLIP(thermalManager.pid_debug_flag);
SERIAL_ECHO_START();
SERIAL_ECHOPGM("PID Debug ");
serialprintln_onoff(thermalManager.pid_debug_flag);
SERIAL_ECHO_MSG("PID Debug ", ON_OFF(thermalManager.pid_debug_flag));
return;
}
#endif