From 6e5f41fe6b996e074b042c6ac521475b8e8aab91 Mon Sep 17 00:00:00 2001 From: Scott Lahteine <thinkyhead@users.noreply.github.com> Date: Mon, 15 May 2023 19:48:30 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Serial=20te?= =?UTF-8?q?rnary=20args,=20etc.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/serial.h | 4 ++-- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 2 +- Marlin/src/feature/encoder_i2c.cpp | 2 +- Marlin/src/gcode/config/M43.cpp | 2 +- Marlin/src/gcode/feature/trinamic/M906.cpp | 1 - Marlin/src/gcode/host/M114.cpp | 8 ++------ Marlin/src/lcd/e3v2/proui/dwin_defines.h | 1 - Marlin/src/module/planner.cpp | 1 + Marlin/src/module/temperature.cpp | 2 +- 9 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 475761216c6..62e1294e046 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -292,7 +292,7 @@ inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, di #define SERIAL_ECHO_SP(C) serial_spaces(C) -#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, F(PRE), F(ON), F(OFF), F(POST)) +#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(F(PRE), TF, F(ON), F(OFF), F(POST)) #if SERIAL_FLOAT_PRECISION #define SERIAL_DECIMAL(V) SERIAL_PRINT(V, SERIAL_FLOAT_PRECISION) @@ -327,7 +327,7 @@ inline void serial_echolnpair(FSTR_P const fstr, T v) { serial_echolnpair_P(FTOP void serial_echo_start(); void serial_error_start(); -inline void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr) { +inline void serial_ternary(FSTR_P const pre, const bool onoff, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr) { if (pre) serial_print(pre); if (onoff && on) serial_print(on); if (!onoff && off) serial_print(off); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index b7ee6aeef8a..ca519f86b49 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -59,7 +59,7 @@ void unified_bed_leveling::report_current_mesh() { void unified_bed_leveling::report_state() { echo_name(); - serial_ternary(planner.leveling_active, F(" System v" UBL_VERSION " "), nullptr, F("in"), F("active\n")); + serial_ternary(F(" System v" UBL_VERSION " "), planner.leveling_active, nullptr, F("in"), F("active\n")); serial_delay(50); } diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index 092ce0f8b85..b1ff21cf92c 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -232,7 +232,7 @@ bool I2CPositionEncoder::passes_test(const bool report) { if (report) { if (H != I2CPE_MAG_SIG_GOOD) SERIAL_ECHOPGM("Warning. "); SERIAL_CHAR(AXIS_CHAR(encoderAxis)); - serial_ternary(H == I2CPE_MAG_SIG_BAD, F(" axis "), F("magnetic strip "), F("encoder ")); + serial_ternary(F(" axis "), H == I2CPE_MAG_SIG_BAD, F("magnetic strip "), F("encoder ")); switch (H) { case I2CPE_MAG_SIG_GOOD: case I2CPE_MAG_SIG_MID: diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index 91db87a1d24..3b95ccd3bb1 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -149,7 +149,7 @@ inline void servo_probe_test() { #endif SERIAL_ECHOLNPGM(". Probe " _PROBE_PREF "_PIN: ", PROBE_TEST_PIN); - serial_ternary(probe_hit_state, F(". " _PROBE_PREF "_ENDSTOP_HIT_STATE: "), F("HIGH"), F("LOW")); + serial_ternary(F(". " _PROBE_PREF "_ENDSTOP_HIT_STATE: "), probe_hit_state, F("HIGH"), F("LOW")); SERIAL_EOL(); SET_INPUT_PULLUP(PROBE_TEST_PIN); diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index b2cab135531..b949200ad77 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -328,7 +328,6 @@ void GcodeSuite::M906_report(const bool forReplay/*=true*/) { say_M906(forReplay); SERIAL_ECHOLNPGM(" T7 E", stepperE7.getMilliamps()); #endif - SERIAL_EOL(); } #endif // HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/gcode/host/M114.cpp b/Marlin/src/gcode/host/M114.cpp index e6e83ba6e59..3a75e687b84 100644 --- a/Marlin/src/gcode/host/M114.cpp +++ b/Marlin/src/gcode/host/M114.cpp @@ -128,9 +128,7 @@ void GcodeSuite::M114() { #if ENABLED(M114_DETAIL) if (parser.seen_test('D')) { - #if DISABLED(M114_LEGACY) - planner.synchronize(); - #endif + IF_DISABLED(M114_LEGACY, planner.synchronize()); report_current_position(); report_current_position_detail(); return; @@ -143,9 +141,7 @@ void GcodeSuite::M114() { #endif #endif - #if ENABLED(M114_REALTIME) - if (parser.seen_test('R')) { report_real_position(); return; } - #endif + TERN_(M114_REALTIME, if (parser.seen_test('R')) return report_real_position()); TERN_(M114_LEGACY, planner.synchronize()); report_current_position_projected(); diff --git a/Marlin/src/lcd/e3v2/proui/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h index e87aedf3117..164fd00fe6d 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_defines.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -29,7 +29,6 @@ */ //#define DEBUG_DWIN 1 -//#define NEED_HEX_PRINT 1 #if defined(__STM32F1__) || defined(STM32F1) #define DASH_REDRAW 1 diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index a9da48df018..a2d7e6843be 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1929,6 +1929,7 @@ bool Planner::_populate_block( #endif #if HAS_W_AXIS " " STR_W ":", target.w, " (", dw, " steps)" + #endif #if HAS_EXTRUDERS " E:", target.e, " (", de, " steps)" #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 685f5dab2f5..f785a683eb4 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3145,7 +3145,7 @@ void Temperature::init() { if (TERN0(REPORT_ADAPTIVE_FAN_SLOWING, DEBUGGING(INFO))) { const uint8_t fss7 = fan_speed_scaler[fan_index] & 0x80; if (fss7 ^ (scale & 0x80)) - serial_ternary(fss7, F("Adaptive Fan Slowing "), nullptr, F("de"), F("activated.\n")); + serial_ternary(F("Adaptive Fan Slowing "), fss7, nullptr, F("de"), F("activated.\n")); } fan_speed_scaler[fan_index] = scale;