diff --git a/Marlin/src/HAL/STM32/MarlinSerial.cpp b/Marlin/src/HAL/STM32/MarlinSerial.cpp index c420ce40cf..cfb13f5bb5 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.cpp +++ b/Marlin/src/HAL/STM32/MarlinSerial.cpp @@ -81,7 +81,7 @@ void MarlinSerial::_rx_complete_irq(serial_t *obj) { } #if ENABLED(EMERGENCY_PARSER) - emergency_parser.update(emergency_state, c); + emergency_parser.update(static_cast(this)->emergency_state, c); #endif } } diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 8692e9219e..16111936da 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -614,8 +614,8 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { */ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { #if ENABLED(MARLIN_DEV_MODE) - static uint8_t idle_depth = 0; - if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", int(idle_depth)); + static uint16_t idle_depth = 0; + if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", idle_depth); #endif // Core Marlin activities diff --git a/Marlin/src/core/serial_base.h b/Marlin/src/core/serial_base.h index 220ccae831..f52fa11202 100644 --- a/Marlin/src/core/serial_base.h +++ b/Marlin/src/core/serial_base.h @@ -78,13 +78,22 @@ struct SerialBase { FORCE_INLINE void write(const char* str) { while (*str) write(*str++); } FORCE_INLINE void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); } FORCE_INLINE void print(const char* str) { write(str); } - NO_INLINE void print(char c, int base = 0) { print((long)c, base); } - NO_INLINE void print(unsigned char c, int base = 0) { print((unsigned long)c, base); } - NO_INLINE void print(int c, int base = DEC) { print((long)c, base); } - NO_INLINE void print(unsigned int c, int base = DEC) { print((unsigned long)c, base); } - void print(long c, int base = DEC) { if (!base) write(c); write((const uint8_t*)"-", c < 0); printNumber(c < 0 ? -c : c, base); } - void print(unsigned long c, int base = DEC) { printNumber(c, base); } - void print(double c, int digits = 2) { printFloat(c, digits); } + NO_INLINE void print(char c, int base = 0) { print((long)c, base); } + NO_INLINE void print(unsigned char c, int base = 0) { print((unsigned long)c, base); } + NO_INLINE void print(int c, int base = DEC) { print((long)c, base); } + NO_INLINE void print(unsigned int c, int base = DEC) { print((unsigned long)c, base); } + void print(unsigned long c, int base = DEC) { printNumber(c, base); } + void print(double c, int digits = 2) { printFloat(c, digits); } + void print(long c, int base = DEC) { + if (!base) { + write(c); + return; + } + if (base == DEC && c < 0) { + write((uint8_t)'-'); c = -c; + } + printNumber(c, base); + } NO_INLINE void println(const char s[]) { print(s); println(); } NO_INLINE void println(char c, int base = 0) { print(c, base); println(); } @@ -98,6 +107,10 @@ struct SerialBase { // Print a number with the given base void printNumber(unsigned long n, const uint8_t base) { + if (!base) { + write((uint8_t)n); + return; + } if (n) { unsigned char buf[8 * sizeof(long)]; // Enough space for base 2 int8_t i = 0; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index fba065fed9..b0640e5fa2 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -150,7 +150,7 @@ SERIAL_ECHO_SP(7); LOOP_L_N(i, GRID_MAX_POINTS_X) { if (i < 10) SERIAL_CHAR(' '); - SERIAL_ECHO(i); + SERIAL_ECHO((int)i); SERIAL_ECHO_SP(sp); } serial_delay(10); diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 529d5c75d9..97aea59221 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -240,8 +240,8 @@ void GcodeSuite::M48() { sigma = SQRT(dev_sum / (n + 1)); if (verbose_level > 1) { - SERIAL_ECHO(n + 1); - SERIAL_ECHOPAIR(" of ", int(n_samples)); + SERIAL_ECHO((int)(n + 1)); + SERIAL_ECHOPAIR(" of ", (int)n_samples); SERIAL_ECHOPAIR_F(": z: ", pz, 3); SERIAL_CHAR(' '); dev_report(verbose_level > 2, mean, sigma, min, max); diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 1b088e7d34..0501f3f60b 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -35,8 +35,8 @@ static void cap_line(PGM_P const name, bool ena=false) { SERIAL_ECHOPGM("Cap:"); serialprintPGM(name); - SERIAL_CHAR(':'); - SERIAL_ECHOLN(int(ena ? 1 : 0)); + SERIAL_CHAR(':', ena ? '1' : '0'); + SERIAL_EOL(); } #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index e1fd00dcd6..c6ed3d3a48 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2062,7 +2062,7 @@ void Temperature::init() { switch (heater_id) { case H_BED: SERIAL_ECHOPGM("bed"); break; case H_CHAMBER: SERIAL_ECHOPGM("chamber"); break; - default: SERIAL_ECHO(heater_id); + default: SERIAL_ECHO((int)heater_id); } SERIAL_ECHOLNPAIR( " ; sizeof(running_temp):", sizeof(running_temp), diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 867ae5d927..4278e6be26 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -709,7 +709,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a #if EXTRUDERS inline void invalid_extruder_error(const uint8_t e) { SERIAL_ECHO_START(); - SERIAL_CHAR('T'); SERIAL_ECHO(int(e)); + SERIAL_CHAR('T'); SERIAL_ECHO((int)e); SERIAL_CHAR(' '); SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER); } #endif diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index 270053be3e..7693c52330 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -926,7 +926,7 @@ int SdBaseFile::peek() { // print uint8_t with width 2 static void print2u(const uint8_t v) { if (v < 10) SERIAL_CHAR('0'); - SERIAL_ECHO(int(v)); + SERIAL_ECHO((int)v); } /**