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
     }
81
     }
82
 
82
 
83
     #if ENABLED(EMERGENCY_PARSER)
83
     #if ENABLED(EMERGENCY_PARSER)
84
-      emergency_parser.update(emergency_state, c);
84
+      emergency_parser.update(static_cast<MSerialT*>(this)->emergency_state, c);
85
     #endif
85
     #endif
86
   }
86
   }
87
 }
87
 }

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

614
  */
614
  */
615
 void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
615
 void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
616
   #if ENABLED(MARLIN_DEV_MODE)
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
   #endif
619
   #endif
620
 
620
 
621
   // Core Marlin activities
621
   // Core Marlin activities

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

78
   FORCE_INLINE void write(const char* str)                    { while (*str) write(*str++); }
78
   FORCE_INLINE void write(const char* str)                    { while (*str) write(*str++); }
79
   FORCE_INLINE void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); }
79
   FORCE_INLINE void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); }
80
   FORCE_INLINE void print(const char* str)                    { write(str); }
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
   NO_INLINE void println(const char s[])                  { print(s); println(); }
98
   NO_INLINE void println(const char s[])                  { print(s); println(); }
90
   NO_INLINE void println(char c, int base = 0)            { print(c, base); println(); }
99
   NO_INLINE void println(char c, int base = 0)            { print(c, base); println(); }
98
 
107
 
99
   // Print a number with the given base
108
   // Print a number with the given base
100
   void printNumber(unsigned long n, const uint8_t base) {
109
   void printNumber(unsigned long n, const uint8_t base) {
110
+    if (!base) {
111
+      write((uint8_t)n);
112
+      return;
113
+    }
101
     if (n) {
114
     if (n) {
102
       unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
115
       unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
103
       int8_t i = 0;
116
       int8_t i = 0;

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

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

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

240
       sigma = SQRT(dev_sum / (n + 1));
240
       sigma = SQRT(dev_sum / (n + 1));
241
 
241
 
242
       if (verbose_level > 1) {
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
         SERIAL_ECHOPAIR_F(": z: ", pz, 3);
245
         SERIAL_ECHOPAIR_F(": z: ", pz, 3);
246
         SERIAL_CHAR(' ');
246
         SERIAL_CHAR(' ');
247
         dev_report(verbose_level > 2, mean, sigma, min, max);
247
         dev_report(verbose_level > 2, mean, sigma, min, max);

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

35
   static void cap_line(PGM_P const name, bool ena=false) {
35
   static void cap_line(PGM_P const name, bool ena=false) {
36
     SERIAL_ECHOPGM("Cap:");
36
     SERIAL_ECHOPGM("Cap:");
37
     serialprintPGM(name);
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
 #endif
41
 #endif
42
 
42
 

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

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

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

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

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

926
 // print uint8_t with width 2
926
 // print uint8_t with width 2
927
 static void print2u(const uint8_t v) {
927
 static void print2u(const uint8_t v) {
928
   if (v < 10) SERIAL_CHAR('0');
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