Browse Source

Save PROGMEM on serial prefixes (#12033)

With default config and `EEPROM_SETTINGS`, saves over 200 bytes of PROGMEM.
Scott Lahteine 6 years ago
parent
commit
cb7844c8d4
No account linked to committer's email address
3 changed files with 138 additions and 127 deletions
  1. 2
    2
      Marlin/src/HAL/HAL_LPC1768/HAL.cpp
  2. 8
    1
      Marlin/src/core/serial.cpp
  3. 128
    124
      Marlin/src/core/serial.h

+ 2
- 2
Marlin/src/HAL/HAL_LPC1768/HAL.cpp View File

@@ -75,13 +75,13 @@ void HAL_adc_init(void) {
75 75
 #include "../../core/language.h"
76 76
 
77 77
 extern void kill(PGM_P);
78
-extern const char errormagic[];
79 78
 
80 79
 void HAL_adc_enable_channel(int ch) {
81 80
   pin_t pin = analogInputToDigitalPin(ch);
82 81
 
83 82
   if (pin == -1) {
84
-    SERIAL_PRINTF("%sINVALID ANALOG PORT:%d\n", errormagic, ch);
83
+    serial_error_start();
84
+    SERIAL_PRINTF("INVALID ANALOG PORT:%d\n", ch);
85 85
     kill(MSG_KILLED);
86 86
   }
87 87
 

+ 8
- 1
Marlin/src/core/serial.cpp View File

@@ -25,7 +25,7 @@
25 25
 uint8_t marlin_debug_flags = DEBUG_NONE;
26 26
 
27 27
 const char errormagic[] PROGMEM = "Error:";
28
-const char echomagic[] PROGMEM = "echo:";
28
+const char echomagic[]  PROGMEM = "echo:";
29 29
 
30 30
 #if NUM_SERIAL > 1
31 31
   void serialprintPGM_P(const int8_t p, const char * str) {
@@ -42,6 +42,10 @@ const char echomagic[] PROGMEM = "echo:";
42 42
   void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, unsigned long v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); }
43 43
 
44 44
   void serial_spaces_P(const int8_t p, uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR_P(p, ' '); }
45
+
46
+  void serial_echo_start_P(const int8_t p)  { serialprintPGM_P(p, echomagic); }
47
+  void serial_error_start_P(const int8_t p) { serialprintPGM_P(p, errormagic); }
48
+
45 49
 #endif
46 50
 
47 51
 void serialprintPGM(PGM_P str) {
@@ -59,6 +63,9 @@ void serial_echopair_PGM(PGM_P s_P, unsigned long v) { serialprintPGM(s_P); SERI
59 63
 
60 64
 void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); }
61 65
 
66
+void serial_echo_start()  { serialprintPGM(echomagic); }
67
+void serial_error_start() { serialprintPGM(errormagic); }
68
+
62 69
 #if ENABLED(DEBUG_LEVELING_FEATURE)
63 70
 
64 71
   #include "enum.h"

+ 128
- 124
Marlin/src/core/serial.h View File

@@ -44,60 +44,57 @@ enum DebugFlags : unsigned char {
44 44
 extern uint8_t marlin_debug_flags;
45 45
 #define DEBUGGING(F) (marlin_debug_flags & (DEBUG_## F))
46 46
 
47
-extern const char echomagic[] PROGMEM;
48
-extern const char errormagic[] PROGMEM;
49
-
50 47
 #if TX_BUFFER_SIZE < 1
51 48
   #define SERIAL_FLUSHTX_P(p)
52 49
   #define SERIAL_FLUSHTX()
53 50
 #endif
54 51
 
55 52
 #if NUM_SERIAL > 1
56
-  #define SERIAL_CHAR_P(p,x)          (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.write(x) : MYSERIAL1.write(x)) : SERIAL_CHAR(x))
57
-  #define SERIAL_PROTOCOL_P(p,x)      (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.print(x) : MYSERIAL1.print(x)) : SERIAL_PROTOCOL(x))
58
-  #define SERIAL_PROTOCOL_F_P(p,x,y)  (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.print(x,y) : MYSERIAL1.print(x,y)) : SERIAL_PROTOCOL_F(x,y))
59
-  #define SERIAL_PROTOCOLLN_P(p,x)    (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.println(x) : MYSERIAL1.println(x)) : SERIAL_PROTOCOLLN(x))
60
-  #define SERIAL_PRINT_P(p,x,b)       (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.print(x,b) : MYSERIAL1.print(x,b)) : SERIAL_PRINT(x,b))
61
-  #define SERIAL_PRINTLN_P(p,x,b)     (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.println(x,b) : MYSERIAL1.println(x,b)) : SERIAL_PRINTLN(x,b))
62
-  #define SERIAL_PRINTF_P(p,args...)  (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.printf(args) : MYSERIAL1.printf(args)) : SERIAL_PRINTF(args))
63
-
64
-  #define SERIAL_CHAR(x)              (MYSERIAL0.write(x), MYSERIAL1.write(x))
65
-  #define SERIAL_PROTOCOL(x)          (MYSERIAL0.print(x), MYSERIAL1.print(x))
66
-  #define SERIAL_PROTOCOL_F(x,y)      (MYSERIAL0.print(x,y), MYSERIAL1.print(x,y))
67
-  #define SERIAL_PROTOCOLLN(x)        (MYSERIAL0.println(x), MYSERIAL1.println(x))
68
-  #define SERIAL_PRINT(x,b)           (MYSERIAL0.print(x,b), MYSERIAL1.print(x,b))
69
-  #define SERIAL_PRINTLN(x,b)         (MYSERIAL0.println(x,b), MYSERIAL1.println(x,b))
70
-  #define SERIAL_PRINTF(args...)      (MYSERIAL0.printf(args), MYSERIAL1.printf(args))
71
-
72
-  #define SERIAL_FLUSH_P(p)           (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.flush() : MYSERIAL1.flush()) : SERIAL_FLUSH())
73
-  #define SERIAL_FLUSH()              (MYSERIAL0.flush(), MYSERIAL1.flush())
53
+  #define SERIAL_CHAR_P(p,x)                        (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.write(x) : MYSERIAL1.write(x)) : SERIAL_CHAR(x))
54
+  #define SERIAL_PROTOCOL_P(p,x)                    (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.print(x) : MYSERIAL1.print(x)) : SERIAL_PROTOCOL(x))
55
+  #define SERIAL_PROTOCOL_F_P(p,x,y)                (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.print(x,y) : MYSERIAL1.print(x,y)) : SERIAL_PROTOCOL_F(x,y))
56
+  #define SERIAL_PROTOCOLLN_P(p,x)                  (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.println(x) : MYSERIAL1.println(x)) : SERIAL_PROTOCOLLN(x))
57
+  #define SERIAL_PRINT_P(p,x,b)                     (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.print(x,b) : MYSERIAL1.print(x,b)) : SERIAL_PRINT(x,b))
58
+  #define SERIAL_PRINTLN_P(p,x,b)                   (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.println(x,b) : MYSERIAL1.println(x,b)) : SERIAL_PRINTLN(x,b))
59
+  #define SERIAL_PRINTF_P(p,args...)                (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.printf(args) : MYSERIAL1.printf(args)) : SERIAL_PRINTF(args))
60
+
61
+  #define SERIAL_CHAR(x)                            (MYSERIAL0.write(x), MYSERIAL1.write(x))
62
+  #define SERIAL_PROTOCOL(x)                        (MYSERIAL0.print(x), MYSERIAL1.print(x))
63
+  #define SERIAL_PROTOCOL_F(x,y)                    (MYSERIAL0.print(x,y), MYSERIAL1.print(x,y))
64
+  #define SERIAL_PROTOCOLLN(x)                      (MYSERIAL0.println(x), MYSERIAL1.println(x))
65
+  #define SERIAL_PRINT(x,b)                         (MYSERIAL0.print(x,b), MYSERIAL1.print(x,b))
66
+  #define SERIAL_PRINTLN(x,b)                       (MYSERIAL0.println(x,b), MYSERIAL1.println(x,b))
67
+  #define SERIAL_PRINTF(args...)                    (MYSERIAL0.printf(args), MYSERIAL1.printf(args))
68
+
69
+  #define SERIAL_FLUSH_P(p)                         (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.flush() : MYSERIAL1.flush()) : SERIAL_FLUSH())
70
+  #define SERIAL_FLUSH()                            (MYSERIAL0.flush(), MYSERIAL1.flush())
74 71
   #if TX_BUFFER_SIZE > 0
75
-    #define SERIAL_FLUSHTX_P(p)       (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.flushTX() : MYSERIAL1.flushTX()) : SERIAL_FLUSHTX())
76
-    #define SERIAL_FLUSHTX()          (MYSERIAL0.flushTX(), MYSERIAL1.flushTX())
72
+    #define SERIAL_FLUSHTX_P(p)                     (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.flushTX() : MYSERIAL1.flushTX()) : SERIAL_FLUSHTX())
73
+    #define SERIAL_FLUSHTX()                        (MYSERIAL0.flushTX(), MYSERIAL1.flushTX())
77 74
   #endif
78 75
 
79 76
   #define SERIAL_EOL_P(p) SERIAL_CHAR_P(p,'\n')
80 77
 
81
-  #define SERIAL_PROTOCOLCHAR_P(p,x)              SERIAL_CHAR_P(p,x)
82
-  #define SERIAL_PROTOCOLPGM_P(p,x)               (serialprintPGM_P(p,PSTR(x)))
83
-  #define SERIAL_PROTOCOLLNPGM_P(p,x)             (serialprintPGM_P(p,PSTR(x "\n")))
84
-  #define SERIAL_PROTOCOLPAIR_P(p, pre, value)    (serial_echopair_PGM_P(p,PSTR(pre),(value)))
85
-  #define SERIAL_PROTOCOLLNPAIR_P(p, pre, value)  do { SERIAL_PROTOCOLPAIR_P(p, pre, value); SERIAL_EOL_P(p); } while(0)
86
-
87
-  #define SERIAL_ECHO_START_P(p)             (serialprintPGM_P(p,echomagic))
88
-  #define SERIAL_ECHO_P(p,x)                 SERIAL_PROTOCOL_P(p,x)
89
-  #define SERIAL_ECHOPGM_P(p,x)              SERIAL_PROTOCOLPGM_P(p,x)
90
-  #define SERIAL_ECHOLN_P(p,x)               SERIAL_PROTOCOLLN_P(p,x)
91
-  #define SERIAL_ECHOLNPGM_P(p,x)            SERIAL_PROTOCOLLNPGM_P(p,x)
92
-  #define SERIAL_ECHOPAIR_P(p,pre,value)     SERIAL_PROTOCOLPAIR_P(p, pre, value)
93
-  #define SERIAL_ECHOLNPAIR_P(p,pre, value)  SERIAL_PROTOCOLLNPAIR_P(p, pre, value)
94
-  #define SERIAL_ECHO_F_P(p,x,y)             SERIAL_PROTOCOL_F_P(p,x,y)
95
-
96
-  #define SERIAL_ERROR_START_P(p)            (serialprintPGM_P(p,errormagic))
97
-  #define SERIAL_ERROR_P(p,x)                SERIAL_PROTOCOL_P(p,x)
98
-  #define SERIAL_ERRORPGM_P(p,x)             SERIAL_PROTOCOLPGM_P(p,x)
99
-  #define SERIAL_ERRORLN_P(p,x)              SERIAL_PROTOCOLLN_P(p,x)
100
-  #define SERIAL_ERRORLNPGM_P(p,x)           SERIAL_PROTOCOLLNPGM_P(p,x)
78
+  #define SERIAL_PROTOCOLCHAR_P(p,x)                SERIAL_CHAR_P(p,x)
79
+  #define SERIAL_PROTOCOLPGM_P(p,x)                 (serialprintPGM_P(p,PSTR(x)))
80
+  #define SERIAL_PROTOCOLLNPGM_P(p,x)               (serialprintPGM_P(p,PSTR(x "\n")))
81
+  #define SERIAL_PROTOCOLPAIR_P(p, pre, value)      (serial_echopair_PGM_P(p,PSTR(pre),(value)))
82
+  #define SERIAL_PROTOCOLLNPAIR_P(p, pre, value)    do{ SERIAL_PROTOCOLPAIR_P(p, pre, value); SERIAL_EOL_P(p); }while(0)
83
+
84
+  #define SERIAL_ECHO_START_P(p)                    serial_echo_start_P(p)
85
+  #define SERIAL_ECHO_P(p,x)                        SERIAL_PROTOCOL_P(p,x)
86
+  #define SERIAL_ECHOPGM_P(p,x)                     SERIAL_PROTOCOLPGM_P(p,x)
87
+  #define SERIAL_ECHOLN_P(p,x)                      SERIAL_PROTOCOLLN_P(p,x)
88
+  #define SERIAL_ECHOLNPGM_P(p,x)                   SERIAL_PROTOCOLLNPGM_P(p,x)
89
+  #define SERIAL_ECHOPAIR_P(p,pre,value)            SERIAL_PROTOCOLPAIR_P(p, pre, value)
90
+  #define SERIAL_ECHOLNPAIR_P(p,pre, value)         SERIAL_PROTOCOLLNPAIR_P(p, pre, value)
91
+  #define SERIAL_ECHO_F_P(p,x,y)                    SERIAL_PROTOCOL_F_P(p,x,y)
92
+
93
+  #define SERIAL_ERROR_START_P(p)                   serial_error_start_P(p)
94
+  #define SERIAL_ERROR_P(p,x)                       SERIAL_PROTOCOL_P(p,x)
95
+  #define SERIAL_ERRORPGM_P(p,x)                    SERIAL_PROTOCOLPGM_P(p,x)
96
+  #define SERIAL_ERRORLN_P(p,x)                     SERIAL_PROTOCOLLN_P(p,x)
97
+  #define SERIAL_ERRORLNPGM_P(p,x)                  SERIAL_PROTOCOLLNPGM_P(p,x)
101 98
 
102 99
   // These macros compensate for float imprecision
103 100
   #define SERIAL_PROTOCOLPAIR_F_P(p, pre, value)    SERIAL_PROTOCOLPAIR_P(p, pre, FIXFLOAT(value))
@@ -114,61 +111,65 @@ extern const char errormagic[] PROGMEM;
114 111
   void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, unsigned int v);
115 112
   void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, unsigned long v);
116 113
   FORCE_INLINE void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, uint8_t v) { serial_echopair_PGM_P(p, s_P, (int)v); }
117
-  FORCE_INLINE void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, bool v) { serial_echopair_PGM_P(p, s_P, (int)v); }
118
-  FORCE_INLINE void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, void *v) { serial_echopair_PGM_P(p, s_P, (unsigned long)v); }
114
+  FORCE_INLINE void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, bool v)    { serial_echopair_PGM_P(p, s_P, (int)v); }
115
+  FORCE_INLINE void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, void *v)   { serial_echopair_PGM_P(p, s_P, (unsigned long)v); }
119 116
 
120 117
   void serial_spaces_P(const int8_t p, uint8_t count);
121
-  #define SERIAL_ECHO_SP_P(p,C)     serial_spaces_P(p,C)
122
-  #define SERIAL_ERROR_SP_P(p,C)    serial_spaces_P(p,C)
123
-  #define SERIAL_PROTOCOL_SP_P(p,C) serial_spaces_P(p,C)
118
+  #define SERIAL_ECHO_SP_P(p,C)                     serial_spaces_P(p,C)
119
+  #define SERIAL_ERROR_SP_P(p,C)                    serial_spaces_P(p,C)
120
+  #define SERIAL_PROTOCOL_SP_P(p,C)                 serial_spaces_P(p,C)
124 121
 
125 122
   void serialprintPGM_P(const int8_t p, PGM_P str);
126
-#else
127
-  #define SERIAL_CHAR_P(p,x)          SERIAL_CHAR(x)
128
-  #define SERIAL_PROTOCOL_P(p,x)      SERIAL_PROTOCOL(x)
129
-  #define SERIAL_PROTOCOL_F_P(p,x,y)  SERIAL_PROTOCOL_F(x,y)
130
-  #define SERIAL_PROTOCOLLN_P(p,x)    SERIAL_PROTOCOLLN(x)
131
-  #define SERIAL_PRINT_P(p,x,b)       SERIAL_PRINT(x,b)
132
-  #define SERIAL_PRINTLN_P(p,x,b)     SERIAL_PRINTLN(x,b)
133
-  #define SERIAL_PRINTF_P(p,args...)  SERIAL_PRINTF(args)
134
-
135
-  #define SERIAL_CHAR(x)              MYSERIAL0.write(x)
136
-  #define SERIAL_PROTOCOL(x)          MYSERIAL0.print(x)
137
-  #define SERIAL_PROTOCOL_F(x,y)      MYSERIAL0.print(x,y)
138
-  #define SERIAL_PROTOCOLLN(x)        MYSERIAL0.println(x)
139
-  #define SERIAL_PRINT(x,b)           MYSERIAL0.print(x,b)
140
-  #define SERIAL_PRINTLN(x,b)         MYSERIAL0.println(x,b)
141
-  #define SERIAL_PRINTF(args...)      MYSERIAL0.printf(args)
142
-
143
-  #define SERIAL_FLUSH_P(p)           SERIAL_FLUSH()
144
-  #define SERIAL_FLUSH()              MYSERIAL0.flush()
123
+  void serial_echo_start_P(const int8_t p);
124
+  void serial_error_start_P(const int8_t p);
125
+
126
+#else // NUM_SERIAL < 2
127
+
128
+  #define SERIAL_CHAR_P(p,x)                        SERIAL_CHAR(x)
129
+  #define SERIAL_PROTOCOL_P(p,x)                    SERIAL_PROTOCOL(x)
130
+  #define SERIAL_PROTOCOL_F_P(p,x,y)                SERIAL_PROTOCOL_F(x,y)
131
+  #define SERIAL_PROTOCOLLN_P(p,x)                  SERIAL_PROTOCOLLN(x)
132
+  #define SERIAL_PRINT_P(p,x,b)                     SERIAL_PRINT(x,b)
133
+  #define SERIAL_PRINTLN_P(p,x,b)                   SERIAL_PRINTLN(x,b)
134
+  #define SERIAL_PRINTF_P(p,args...)                SERIAL_PRINTF(args)
135
+
136
+  #define SERIAL_CHAR(x)                            MYSERIAL0.write(x)
137
+  #define SERIAL_PROTOCOL(x)                        MYSERIAL0.print(x)
138
+  #define SERIAL_PROTOCOL_F(x,y)                    MYSERIAL0.print(x,y)
139
+  #define SERIAL_PROTOCOLLN(x)                      MYSERIAL0.println(x)
140
+  #define SERIAL_PRINT(x,b)                         MYSERIAL0.print(x,b)
141
+  #define SERIAL_PRINTLN(x,b)                       MYSERIAL0.println(x,b)
142
+  #define SERIAL_PRINTF(args...)                    MYSERIAL0.printf(args)
143
+
144
+  #define SERIAL_FLUSH_P(p)                         SERIAL_FLUSH()
145
+  #define SERIAL_FLUSH()                            MYSERIAL0.flush()
145 146
   #if TX_BUFFER_SIZE > 0
146
-    #define SERIAL_FLUSHTX_P(p)       SERIAL_FLUSHTX()
147
-    #define SERIAL_FLUSHTX()          MYSERIAL0.flushTX()
147
+    #define SERIAL_FLUSHTX_P(p)                     SERIAL_FLUSHTX()
148
+    #define SERIAL_FLUSHTX()                        MYSERIAL0.flushTX()
148 149
   #endif
149 150
 
150 151
   #define SERIAL_EOL_P(p) SERIAL_EOL()
151 152
 
152
-  #define SERIAL_PROTOCOLCHAR_P(p,x)              SERIAL_PROTOCOLCHAR(x)
153
-  #define SERIAL_PROTOCOLPGM_P(p,x)               SERIAL_PROTOCOLPGM(x)
154
-  #define SERIAL_PROTOCOLLNPGM_P(p,x)             SERIAL_PROTOCOLLNPGM(x)
155
-  #define SERIAL_PROTOCOLPAIR_P(p, pre, value)    SERIAL_PROTOCOLPAIR(pre, value)
156
-  #define SERIAL_PROTOCOLLNPAIR_P(p, pre, value)  SERIAL_PROTOCOLLNPAIR(pre, value)
157
-
158
-  #define SERIAL_ECHO_START_P(p)             SERIAL_ECHO_START()
159
-  #define SERIAL_ECHO_P(p,x)                 SERIAL_ECHO(x)
160
-  #define SERIAL_ECHOPGM_P(p,x)              SERIAL_ECHOPGM(x)
161
-  #define SERIAL_ECHOLN_P(p,x)               SERIAL_ECHOLN(x)
162
-  #define SERIAL_ECHOLNPGM_P(p,x)            SERIAL_ECHOLNPGM(x)
163
-  #define SERIAL_ECHOPAIR_P(p,pre,value)     SERIAL_ECHOPAIR(pre, value)
164
-  #define SERIAL_ECHOLNPAIR_P(p,pre, value)  SERIAL_ECHOLNPAIR(pre, value)
165
-  #define SERIAL_ECHO_F_P(p,x,y)             SERIAL_ECHO_F(x,y)
166
-
167
-  #define SERIAL_ERROR_START_P(p)            SERIAL_ERROR_START()
168
-  #define SERIAL_ERROR_P(p,x)                SERIAL_ERROR(x)
169
-  #define SERIAL_ERRORPGM_P(p,x)             SERIAL_ERRORPGM(x)
170
-  #define SERIAL_ERRORLN_P(p,x)              SERIAL_ERRORLN(x)
171
-  #define SERIAL_ERRORLNPGM_P(p,x)           SERIAL_ERRORLNPGM(x)
153
+  #define SERIAL_PROTOCOLCHAR_P(p,x)                SERIAL_PROTOCOLCHAR(x)
154
+  #define SERIAL_PROTOCOLPGM_P(p,x)                 SERIAL_PROTOCOLPGM(x)
155
+  #define SERIAL_PROTOCOLLNPGM_P(p,x)               SERIAL_PROTOCOLLNPGM(x)
156
+  #define SERIAL_PROTOCOLPAIR_P(p, pre, value)      SERIAL_PROTOCOLPAIR(pre, value)
157
+  #define SERIAL_PROTOCOLLNPAIR_P(p, pre, value)    SERIAL_PROTOCOLLNPAIR(pre, value)
158
+
159
+  #define SERIAL_ECHO_START_P(p)                    SERIAL_ECHO_START()
160
+  #define SERIAL_ECHO_P(p,x)                        SERIAL_ECHO(x)
161
+  #define SERIAL_ECHOPGM_P(p,x)                     SERIAL_ECHOPGM(x)
162
+  #define SERIAL_ECHOLN_P(p,x)                      SERIAL_ECHOLN(x)
163
+  #define SERIAL_ECHOLNPGM_P(p,x)                   SERIAL_ECHOLNPGM(x)
164
+  #define SERIAL_ECHOPAIR_P(p,pre,value)            SERIAL_ECHOPAIR(pre, value)
165
+  #define SERIAL_ECHOLNPAIR_P(p,pre, value)         SERIAL_ECHOLNPAIR(pre, value)
166
+  #define SERIAL_ECHO_F_P(p,x,y)                    SERIAL_ECHO_F(x,y)
167
+        
168
+  #define SERIAL_ERROR_START_P(p)                   SERIAL_ERROR_START()
169
+  #define SERIAL_ERROR_P(p,x)                       SERIAL_ERROR(x)
170
+  #define SERIAL_ERRORPGM_P(p,x)                    SERIAL_ERRORPGM(x)
171
+  #define SERIAL_ERRORLN_P(p,x)                     SERIAL_ERRORLN(x)
172
+  #define SERIAL_ERRORLNPGM_P(p,x)                  SERIAL_ERRORLNPGM(x)
172 173
 
173 174
   // These macros compensate for float imprecision
174 175
   #define SERIAL_PROTOCOLPAIR_F_P(p, pre, value)    SERIAL_PROTOCOLPAIR_F(pre, value)
@@ -178,42 +179,43 @@ extern const char errormagic[] PROGMEM;
178 179
 
179 180
   #define serial_echopair_PGM_P(p,s_P,v)            serial_echopair_PGM(s_P, v)
180 181
 
181
-  #define serial_spaces_P(p,c)      serial_spaces(c)
182
-  #define SERIAL_ECHO_SP_P(p,C)     SERIAL_ECHO_SP(C)
183
-  #define SERIAL_ERROR_SP_P(p,C)    SERIAL_ERROR_SP(C)
184
-  #define SERIAL_PROTOCOL_SP_P(p,C) SERIAL_PROTOCOL_SP(C)
182
+  #define serial_spaces_P(p,c)                      serial_spaces(c)
183
+  #define SERIAL_ECHO_SP_P(p,C)                     SERIAL_ECHO_SP(C)
184
+  #define SERIAL_ERROR_SP_P(p,C)                    SERIAL_ERROR_SP(C)
185
+  #define SERIAL_PROTOCOL_SP_P(p,C)                 SERIAL_PROTOCOL_SP(C)
185 186
 
186
-  #define serialprintPGM_P(p,s)     serialprintPGM(s)
187
-#endif
187
+  #define serialprintPGM_P(p,s)                     serialprintPGM(s)
188
+
189
+#endif // NUM_SERIAL < 2
188 190
 
189 191
 #define SERIAL_EOL() SERIAL_CHAR('\n')
190 192
 
191
-#define SERIAL_PROTOCOLCHAR(x)              SERIAL_CHAR(x)
192
-#define SERIAL_PROTOCOLPGM(x)               (serialprintPGM(PSTR(x)))
193
-#define SERIAL_PROTOCOLLNPGM(x)             (serialprintPGM(PSTR(x "\n")))
194
-#define SERIAL_PROTOCOLPAIR(pre, value)     (serial_echopair_PGM(PSTR(pre), value))
195
-#define SERIAL_PROTOCOLLNPAIR(pre, value)   do { SERIAL_PROTOCOLPAIR(pre, value); SERIAL_EOL(); } while(0)
196
-
197
-#define SERIAL_ECHO_START()            (serialprintPGM(echomagic))
198
-#define SERIAL_ECHO(x)                 SERIAL_PROTOCOL(x)
199
-#define SERIAL_ECHOPGM(x)              SERIAL_PROTOCOLPGM(x)
200
-#define SERIAL_ECHOLN(x)               SERIAL_PROTOCOLLN(x)
201
-#define SERIAL_ECHOLNPGM(x)            SERIAL_PROTOCOLLNPGM(x)
202
-#define SERIAL_ECHOPAIR(pre,value)     SERIAL_PROTOCOLPAIR(pre, value)
203
-#define SERIAL_ECHOLNPAIR(pre, value)  SERIAL_PROTOCOLLNPAIR(pre, value)
204
-#define SERIAL_ECHO_F(x,y)             SERIAL_PROTOCOL_F(x, y)
205
-
206
-#define SERIAL_ERROR_START()           (serialprintPGM(errormagic))
207
-#define SERIAL_ERROR(x)                SERIAL_PROTOCOL(x)
208
-#define SERIAL_ERRORPGM(x)             SERIAL_PROTOCOLPGM(x)
209
-#define SERIAL_ERRORLN(x)              SERIAL_PROTOCOLLN(x)
210
-#define SERIAL_ERRORLNPGM(x)           SERIAL_PROTOCOLLNPGM(x)
193
+#define SERIAL_PROTOCOLCHAR(x)                      SERIAL_CHAR(x)
194
+#define SERIAL_PROTOCOLPGM(x)                       (serialprintPGM(PSTR(x)))
195
+#define SERIAL_PROTOCOLLNPGM(x)                     (serialprintPGM(PSTR(x "\n")))
196
+#define SERIAL_PROTOCOLPAIR(pre, value)             (serial_echopair_PGM(PSTR(pre), value))
197
+#define SERIAL_PROTOCOLLNPAIR(pre, value)           do { SERIAL_PROTOCOLPAIR(pre, value); SERIAL_EOL(); } while(0)
198
+
199
+#define SERIAL_ECHO_START()                         serial_echo_start()
200
+#define SERIAL_ECHO(x)                              SERIAL_PROTOCOL(x)
201
+#define SERIAL_ECHOPGM(x)                           SERIAL_PROTOCOLPGM(x)
202
+#define SERIAL_ECHOLN(x)                            SERIAL_PROTOCOLLN(x)
203
+#define SERIAL_ECHOLNPGM(x)                         SERIAL_PROTOCOLLNPGM(x)
204
+#define SERIAL_ECHOPAIR(pre,value)                  SERIAL_PROTOCOLPAIR(pre, value)
205
+#define SERIAL_ECHOLNPAIR(pre, value)               SERIAL_PROTOCOLLNPAIR(pre, value)
206
+#define SERIAL_ECHO_F(x,y)                          SERIAL_PROTOCOL_F(x, y)
207
+
208
+#define SERIAL_ERROR_START()                        serial_error_start()
209
+#define SERIAL_ERROR(x)                             SERIAL_PROTOCOL(x)
210
+#define SERIAL_ERRORPGM(x)                          SERIAL_PROTOCOLPGM(x)
211
+#define SERIAL_ERRORLN(x)                           SERIAL_PROTOCOLLN(x)
212
+#define SERIAL_ERRORLNPGM(x)                        SERIAL_PROTOCOLLNPGM(x)
211 213
 
212 214
 // These macros compensate for float imprecision
213
-#define SERIAL_PROTOCOLPAIR_F(pre, value)   SERIAL_PROTOCOLPAIR(pre, FIXFLOAT(value))
214
-#define SERIAL_PROTOCOLLNPAIR_F(pre, value) SERIAL_PROTOCOLLNPAIR(pre, FIXFLOAT(value))
215
-#define SERIAL_ECHOPAIR_F(pre,value)        SERIAL_ECHOPAIR(pre, FIXFLOAT(value))
216
-#define SERIAL_ECHOLNPAIR_F(pre, value)     SERIAL_ECHOLNPAIR(pre, FIXFLOAT(value))
215
+#define SERIAL_PROTOCOLPAIR_F(pre, value)           SERIAL_PROTOCOLPAIR(pre, FIXFLOAT(value))
216
+#define SERIAL_PROTOCOLLNPAIR_F(pre, value)         SERIAL_PROTOCOLLNPAIR(pre, FIXFLOAT(value))
217
+#define SERIAL_ECHOPAIR_F(pre,value)                SERIAL_ECHOPAIR(pre, FIXFLOAT(value))
218
+#define SERIAL_ECHOLNPAIR_F(pre, value)             SERIAL_ECHOLNPAIR(pre, FIXFLOAT(value))
217 219
 
218 220
 void serial_echopair_PGM(PGM_P s_P, const char *v);
219 221
 void serial_echopair_PGM(PGM_P s_P, char v);
@@ -224,18 +226,20 @@ void serial_echopair_PGM(PGM_P s_P, double v);
224 226
 void serial_echopair_PGM(PGM_P s_P, unsigned int v);
225 227
 void serial_echopair_PGM(PGM_P s_P, unsigned long v);
226 228
 FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, uint8_t v) { serial_echopair_PGM(s_P, (int)v); }
227
-FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, bool v) { serial_echopair_PGM(s_P, (int)v); }
228
-FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, void *v) { serial_echopair_PGM(s_P, (unsigned long)v); }
229
+FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, bool v)    { serial_echopair_PGM(s_P, (int)v); }
230
+FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, void *v)   { serial_echopair_PGM(s_P, (unsigned long)v); }
229 231
 
230 232
 void serial_spaces(uint8_t count);
231
-#define SERIAL_ECHO_SP(C)     serial_spaces(C)
232
-#define SERIAL_ERROR_SP(C)    serial_spaces(C)
233
-#define SERIAL_PROTOCOL_SP(C) serial_spaces(C)
233
+#define SERIAL_ECHO_SP(C)                           serial_spaces(C)
234
+#define SERIAL_ERROR_SP(C)                          serial_spaces(C)
235
+#define SERIAL_PROTOCOL_SP(C)                       serial_spaces(C)
234 236
 
235 237
 //
236 238
 // Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
237 239
 //
238 240
 void serialprintPGM(PGM_P str);
241
+void serial_echo_start();
242
+void serial_error_start();
239 243
 
240 244
 #if ENABLED(DEBUG_LEVELING_FEATURE)
241 245
   void print_xyz(PGM_P prefix, PGM_P suffix, const float x, const float y, const float z);

Loading…
Cancel
Save