Browse Source

Serial refactor followup (#20932)

X-Ryl669 4 years ago
parent
commit
27366197f3
No account linked to committer's email address

+ 1
- 1
Marlin/src/HAL/STM32/MarlinSerial.cpp View File

@@ -81,7 +81,7 @@ void MarlinSerial::_rx_complete_irq(serial_t *obj) {
81 81
     }
82 82
 
83 83
     #if ENABLED(EMERGENCY_PARSER)
84
-      emergency_parser.update(emergency_state, c);
84
+      emergency_parser.update(static_cast<MSerialT*>(this)->emergency_state, c);
85 85
     #endif
86 86
   }
87 87
 }

+ 2
- 2
Marlin/src/MarlinCore.cpp View File

@@ -614,8 +614,8 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
614 614
  */
615 615
 void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
616 616
   #if ENABLED(MARLIN_DEV_MODE)
617
-    static uint8_t idle_depth = 0;
618
-    if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", int(idle_depth));
617
+    static uint16_t idle_depth = 0;
618
+    if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", idle_depth);
619 619
   #endif
620 620
 
621 621
   // Core Marlin activities

+ 20
- 7
Marlin/src/core/serial_base.h View File

@@ -78,13 +78,22 @@ struct SerialBase {
78 78
   FORCE_INLINE void write(const char* str)                    { while (*str) write(*str++); }
79 79
   FORCE_INLINE void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); }
80 80
   FORCE_INLINE void print(const char* str)                    { write(str); }
81
-  NO_INLINE void print(char c, int base = 0)               { print((long)c, base); }
82
-  NO_INLINE void print(unsigned char c, int base = 0)      { print((unsigned long)c, base); }
83
-  NO_INLINE void print(int c, int base = DEC)              { print((long)c, base); }
84
-  NO_INLINE void print(unsigned int c, int base = DEC)     { print((unsigned long)c, base); }
85
-  void print(long c, int base = DEC)            { if (!base) write(c); write((const uint8_t*)"-", c < 0); printNumber(c < 0 ? -c : c, base); }
86
-  void print(unsigned long c, int base = DEC)   { printNumber(c, base); }
87
-  void print(double c, int digits = 2)          { printFloat(c, digits); }
81
+  NO_INLINE void print(char c, int base = 0)              { print((long)c, base); }
82
+  NO_INLINE void print(unsigned char c, int base = 0)     { print((unsigned long)c, base); }
83
+  NO_INLINE void print(int c, int base = DEC)             { print((long)c, base); }
84
+  NO_INLINE void print(unsigned int c, int base = DEC)    { print((unsigned long)c, base); }
85
+  void print(unsigned long c, int base = DEC)             { printNumber(c, base); }
86
+  void print(double c, int digits = 2)                    { printFloat(c, digits); }
87
+  void print(long c, int base = DEC)                      {
88
+    if (!base) {
89
+      write(c);
90
+      return;
91
+    }
92
+    if (base == DEC && c < 0) {
93
+      write((uint8_t)'-'); c = -c;
94
+    }
95
+    printNumber(c, base);
96
+  }
88 97
 
89 98
   NO_INLINE void println(const char s[])                  { print(s); println(); }
90 99
   NO_INLINE void println(char c, int base = 0)            { print(c, base); println(); }
@@ -98,6 +107,10 @@ struct SerialBase {
98 107
 
99 108
   // Print a number with the given base
100 109
   void printNumber(unsigned long n, const uint8_t base) {
110
+    if (!base) {
111
+      write((uint8_t)n);
112
+      return;
113
+    }
101 114
     if (n) {
102 115
       unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
103 116
       int8_t i = 0;

+ 1
- 1
Marlin/src/feature/bedlevel/ubl/ubl.cpp View File

@@ -150,7 +150,7 @@
150 150
     SERIAL_ECHO_SP(7);
151 151
     LOOP_L_N(i, GRID_MAX_POINTS_X) {
152 152
       if (i < 10) SERIAL_CHAR(' ');
153
-      SERIAL_ECHO(i);
153
+      SERIAL_ECHO((int)i);
154 154
       SERIAL_ECHO_SP(sp);
155 155
     }
156 156
     serial_delay(10);

+ 2
- 2
Marlin/src/gcode/calibrate/M48.cpp View File

@@ -240,8 +240,8 @@ void GcodeSuite::M48() {
240 240
       sigma = SQRT(dev_sum / (n + 1));
241 241
 
242 242
       if (verbose_level > 1) {
243
-        SERIAL_ECHO(n + 1);
244
-        SERIAL_ECHOPAIR(" of ", int(n_samples));
243
+        SERIAL_ECHO((int)(n + 1));
244
+        SERIAL_ECHOPAIR(" of ", (int)n_samples);
245 245
         SERIAL_ECHOPAIR_F(": z: ", pz, 3);
246 246
         SERIAL_CHAR(' ');
247 247
         dev_report(verbose_level > 2, mean, sigma, min, max);

+ 2
- 2
Marlin/src/gcode/host/M115.cpp View File

@@ -35,8 +35,8 @@
35 35
   static void cap_line(PGM_P const name, bool ena=false) {
36 36
     SERIAL_ECHOPGM("Cap:");
37 37
     serialprintPGM(name);
38
-    SERIAL_CHAR(':');
39
-    SERIAL_ECHOLN(int(ena ? 1 : 0));
38
+    SERIAL_CHAR(':', ena ? '1' : '0');
39
+    SERIAL_EOL();
40 40
   }
41 41
 #endif
42 42
 

+ 1
- 1
Marlin/src/module/temperature.cpp View File

@@ -2062,7 +2062,7 @@ void Temperature::init() {
2062 2062
       switch (heater_id) {
2063 2063
         case H_BED:     SERIAL_ECHOPGM("bed"); break;
2064 2064
         case H_CHAMBER: SERIAL_ECHOPGM("chamber"); break;
2065
-        default:        SERIAL_ECHO(heater_id);
2065
+        default:        SERIAL_ECHO((int)heater_id);
2066 2066
       }
2067 2067
       SERIAL_ECHOLNPAIR(
2068 2068
         " ; sizeof(running_temp):", sizeof(running_temp),

+ 1
- 1
Marlin/src/module/tool_change.cpp View File

@@ -709,7 +709,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
709 709
 #if EXTRUDERS
710 710
   inline void invalid_extruder_error(const uint8_t e) {
711 711
     SERIAL_ECHO_START();
712
-    SERIAL_CHAR('T'); SERIAL_ECHO(int(e));
712
+    SERIAL_CHAR('T'); SERIAL_ECHO((int)e);
713 713
     SERIAL_CHAR(' '); SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER);
714 714
   }
715 715
 #endif

+ 1
- 1
Marlin/src/sd/SdBaseFile.cpp View File

@@ -926,7 +926,7 @@ int SdBaseFile::peek() {
926 926
 // print uint8_t with width 2
927 927
 static void print2u(const uint8_t v) {
928 928
   if (v < 10) SERIAL_CHAR('0');
929
-  SERIAL_ECHO(int(v));
929
+  SERIAL_ECHO((int)v);
930 930
 }
931 931
 
932 932
 /**

Loading…
Cancel
Save