Browse Source

Merge pull request #3427 from thinkyhead/rc_better_SERIAL_ECHOPAIR

No casting needed for SERIAL_ECHOPAIR
Scott Lahteine 8 years ago
parent
commit
5e18d650c4
5 changed files with 38 additions and 33 deletions
  1. 5
    5
      Marlin/M100_Free_Mem_Chk.cpp
  2. 3
    1
      Marlin/Marlin.h
  3. 12
    9
      Marlin/Marlin_main.cpp
  4. 14
    14
      Marlin/configuration_store.cpp
  5. 4
    4
      Marlin/stepper.cpp

+ 5
- 5
Marlin/M100_Free_Mem_Chk.cpp View File

180
     x = code_value();
180
     x = code_value();
181
     SERIAL_ECHOLNPGM("Corrupting free memory block.\n");
181
     SERIAL_ECHOLNPGM("Corrupting free memory block.\n");
182
     ptr = (unsigned char*) __brkval;
182
     ptr = (unsigned char*) __brkval;
183
-    SERIAL_ECHOPAIR("\n__brkval : ", (long) ptr);
183
+    SERIAL_ECHOPAIR("\n__brkval : ", ptr);
184
     ptr += 8;
184
     ptr += 8;
185
     sp = top_of_stack();
185
     sp = top_of_stack();
186
-    SERIAL_ECHOPAIR("\nStack Pointer : ", (long) sp);
186
+    SERIAL_ECHOPAIR("\nStack Pointer : ", sp);
187
     SERIAL_ECHOLNPGM("\n");
187
     SERIAL_ECHOLNPGM("\n");
188
     n = sp - ptr - 64;    // -64 just to keep us from finding interrupt activity that
188
     n = sp - ptr - 64;    // -64 just to keep us from finding interrupt activity that
189
     // has altered the stack.
189
     // has altered the stack.
204
   if (m100_not_initialized || code_seen('I')) {       // If no sub-command is specified, the first time
204
   if (m100_not_initialized || code_seen('I')) {       // If no sub-command is specified, the first time
205
     SERIAL_ECHOLNPGM("Initializing free memory block.\n");    // this happens, it will Initialize.
205
     SERIAL_ECHOLNPGM("Initializing free memory block.\n");    // this happens, it will Initialize.
206
     ptr = (unsigned char*) __brkval;        // Repeated M100 with no sub-command will not destroy the
206
     ptr = (unsigned char*) __brkval;        // Repeated M100 with no sub-command will not destroy the
207
-    SERIAL_ECHOPAIR("\n__brkval : ", (long) ptr);     // state of the initialized free memory pool.
207
+    SERIAL_ECHOPAIR("\n__brkval : ", ptr);     // state of the initialized free memory pool.
208
     ptr += 8;
208
     ptr += 8;
209
     sp = top_of_stack();
209
     sp = top_of_stack();
210
-    SERIAL_ECHOPAIR("\nStack Pointer : ", (long) sp);
210
+    SERIAL_ECHOPAIR("\nStack Pointer : ", sp);
211
     SERIAL_ECHOLNPGM("\n");
211
     SERIAL_ECHOLNPGM("\n");
212
     n = sp - ptr - 64;    // -64 just to keep us from finding interrupt activity that
212
     n = sp - ptr - 64;    // -64 just to keep us from finding interrupt activity that
213
     // has altered the stack.
213
     // has altered the stack.
217
       *(ptr + i) = (unsigned char) 0xe5;
217
       *(ptr + i) = (unsigned char) 0xe5;
218
     for (i = 0; i < n; i++) {
218
     for (i = 0; i < n; i++) {
219
       if (*(ptr + i) != (unsigned char) 0xe5) {
219
       if (*(ptr + i) != (unsigned char) 0xe5) {
220
-        SERIAL_ECHOPAIR("? address : ", (unsigned long) ptr + i);
220
+        SERIAL_ECHOPAIR("? address : ", ptr + i);
221
         SERIAL_ECHOPAIR("=", *(ptr + i));
221
         SERIAL_ECHOPAIR("=", *(ptr + i));
222
         SERIAL_ECHOLNPGM("\n");
222
         SERIAL_ECHOLNPGM("\n");
223
       }
223
       }

+ 3
- 1
Marlin/Marlin.h View File

103
 #define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
103
 #define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
104
 #define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
104
 #define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
105
 
105
 
106
-#define SERIAL_ECHOPAIR(name,value) do{ serial_echopair_P(PSTR(name),(value)); }while(0)
106
+#define SERIAL_ECHOPAIR(name,value) (serial_echopair_P(PSTR(name),(value)))
107
 
107
 
108
 void serial_echopair_P(const char* s_P, int v);
108
 void serial_echopair_P(const char* s_P, int v);
109
 void serial_echopair_P(const char* s_P, long v);
109
 void serial_echopair_P(const char* s_P, long v);
110
 void serial_echopair_P(const char* s_P, float v);
110
 void serial_echopair_P(const char* s_P, float v);
111
 void serial_echopair_P(const char* s_P, double v);
111
 void serial_echopair_P(const char* s_P, double v);
112
 void serial_echopair_P(const char* s_P, unsigned long v);
112
 void serial_echopair_P(const char* s_P, unsigned long v);
113
+FORCE_INLINE void serial_echopair_P(const char* s_P, bool v) { serial_echopair_P(s_P, (int)v); }
114
+FORCE_INLINE void serial_echopair_P(const char* s_P, void *v) { serial_echopair_P(s_P, (unsigned long)v); }
113
 
115
 
114
 // Things to write to serial from Program memory. Saves 400 to 2k of RAM.
116
 // Things to write to serial from Program memory. Saves 400 to 2k of RAM.
115
 FORCE_INLINE void serialprintPGM(const char* str) {
117
 FORCE_INLINE void serialprintPGM(const char* str) {

+ 12
- 9
Marlin/Marlin_main.cpp View File

1168
 static void set_axis_is_at_home(AxisEnum axis) {
1168
 static void set_axis_is_at_home(AxisEnum axis) {
1169
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1169
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1170
     if (DEBUGGING(LEVELING)) {
1170
     if (DEBUGGING(LEVELING)) {
1171
-      SERIAL_ECHOPAIR("set_axis_is_at_home(", (unsigned long)axis);
1171
+      SERIAL_ECHOPAIR("set_axis_is_at_home(", axis);
1172
       SERIAL_ECHOLNPGM(") >>>");
1172
       SERIAL_ECHOLNPGM(") >>>");
1173
     }
1173
     }
1174
   #endif
1174
   #endif
1256
   }
1256
   }
1257
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1257
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1258
     if (DEBUGGING(LEVELING)) {
1258
     if (DEBUGGING(LEVELING)) {
1259
-      SERIAL_ECHOPAIR("<<< set_axis_is_at_home(", (unsigned long)axis);
1259
+      SERIAL_ECHOPAIR("<<< set_axis_is_at_home(", axis);
1260
       SERIAL_ECHOLNPGM(")");
1260
       SERIAL_ECHOLNPGM(")");
1261
     }
1261
     }
1262
   #endif
1262
   #endif
1651
           if (doRaise) {
1651
           if (doRaise) {
1652
             #if ENABLED(DEBUG_LEVELING_FEATURE)
1652
             #if ENABLED(DEBUG_LEVELING_FEATURE)
1653
               if (DEBUGGING(LEVELING)) {
1653
               if (DEBUGGING(LEVELING)) {
1654
-                SERIAL_ECHOPAIR("Raise Z (after) by ", (float)Z_RAISE_AFTER_PROBING);
1654
+                SERIAL_ECHOPAIR("Raise Z (after) by ", Z_RAISE_AFTER_PROBING);
1655
                 SERIAL_EOL;
1655
                 SERIAL_EOL;
1656
                 SERIAL_ECHO("> SERVO_ENDSTOPS > raise_z_after_probing()");
1656
                 SERIAL_ECHO("> SERVO_ENDSTOPS > raise_z_after_probing()");
1657
                 SERIAL_EOL;
1657
                 SERIAL_EOL;
1747
     #if ENABLED(DEBUG_LEVELING_FEATURE)
1747
     #if ENABLED(DEBUG_LEVELING_FEATURE)
1748
       if (DEBUGGING(LEVELING)) {
1748
       if (DEBUGGING(LEVELING)) {
1749
         SERIAL_ECHOLNPGM("probe_pt >>>");
1749
         SERIAL_ECHOLNPGM("probe_pt >>>");
1750
-        SERIAL_ECHOPAIR("> ProbeAction:", (unsigned long)probe_action);
1750
+        SERIAL_ECHOPAIR("> ProbeAction:", probe_action);
1751
         SERIAL_EOL;
1751
         SERIAL_EOL;
1752
         DEBUG_POS("", current_position);
1752
         DEBUG_POS("", current_position);
1753
       }
1753
       }
1968
 static void homeaxis(AxisEnum axis) {
1968
 static void homeaxis(AxisEnum axis) {
1969
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1969
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1970
     if (DEBUGGING(LEVELING)) {
1970
     if (DEBUGGING(LEVELING)) {
1971
-      SERIAL_ECHOPAIR(">>> homeaxis(", (unsigned long)axis);
1971
+      SERIAL_ECHOPAIR(">>> homeaxis(", axis);
1972
       SERIAL_ECHOLNPGM(")");
1972
       SERIAL_ECHOLNPGM(")");
1973
     }
1973
     }
1974
   #endif
1974
   #endif
2156
 
2156
 
2157
   #if ENABLED(DEBUG_LEVELING_FEATURE)
2157
   #if ENABLED(DEBUG_LEVELING_FEATURE)
2158
     if (DEBUGGING(LEVELING)) {
2158
     if (DEBUGGING(LEVELING)) {
2159
-      SERIAL_ECHOPAIR("<<< homeaxis(", (unsigned long)axis);
2159
+      SERIAL_ECHOPAIR("<<< homeaxis(", axis);
2160
       SERIAL_ECHOLNPGM(")");
2160
       SERIAL_ECHOLNPGM(")");
2161
     }
2161
     }
2162
   #endif
2162
   #endif
2484
         feedrate = max_feedrate[Z_AXIS] * 60;  // feedrate (mm/m) = max_feedrate (mm/s)
2484
         feedrate = max_feedrate[Z_AXIS] * 60;  // feedrate (mm/m) = max_feedrate (mm/s)
2485
         #if ENABLED(DEBUG_LEVELING_FEATURE)
2485
         #if ENABLED(DEBUG_LEVELING_FEATURE)
2486
           if (DEBUGGING(LEVELING)) {
2486
           if (DEBUGGING(LEVELING)) {
2487
-            SERIAL_ECHOPAIR("Raise Z (before homing) to ", (float)(MIN_Z_HEIGHT_FOR_HOMING));
2487
+            SERIAL_ECHOPAIR("Raise Z (before homing) to ", (MIN_Z_HEIGHT_FOR_HOMING));
2488
             SERIAL_EOL;
2488
             SERIAL_EOL;
2489
             DEBUG_POS("> (home_all_axis || homeZ)", current_position);
2489
             DEBUG_POS("> (home_all_axis || homeZ)", current_position);
2490
             DEBUG_POS("> (home_all_axis || homeZ)", destination);
2490
             DEBUG_POS("> (home_all_axis || homeZ)", destination);
3115
           if (probePointCounter) {
3115
           if (probePointCounter) {
3116
             #if ENABLED(DEBUG_LEVELING_FEATURE)
3116
             #if ENABLED(DEBUG_LEVELING_FEATURE)
3117
               if (DEBUGGING(LEVELING)) {
3117
               if (DEBUGGING(LEVELING)) {
3118
-                SERIAL_ECHOPAIR("z_before = (between) ", (float)(Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS]));
3118
+                SERIAL_ECHOPAIR("z_before = (between) ", (Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS]));
3119
                 SERIAL_EOL;
3119
                 SERIAL_EOL;
3120
               }
3120
               }
3121
             #endif
3121
             #endif
3123
           else {
3123
           else {
3124
             #if ENABLED(DEBUG_LEVELING_FEATURE)
3124
             #if ENABLED(DEBUG_LEVELING_FEATURE)
3125
               if (DEBUGGING(LEVELING)) {
3125
               if (DEBUGGING(LEVELING)) {
3126
-                SERIAL_ECHOPAIR("z_before = (before) ", (float)Z_RAISE_BEFORE_PROBING);
3126
+                SERIAL_ECHOPAIR("z_before = (before) ", Z_RAISE_BEFORE_PROBING);
3127
                 SERIAL_EOL;
3127
                 SERIAL_EOL;
3128
               }
3128
               }
3129
             #endif
3129
             #endif
3481
   inline void gcode_M0_M1() {
3481
   inline void gcode_M0_M1() {
3482
     char* args = current_command_args;
3482
     char* args = current_command_args;
3483
 
3483
 
3484
+    uint8_t test_value = 12;
3485
+    SERIAL_ECHOPAIR("TEST", test_value);
3486
+
3484
     millis_t codenum = 0;
3487
     millis_t codenum = 0;
3485
     bool hasP = false, hasS = false;
3488
     bool hasP = false, hasS = false;
3486
     if (code_seen('P')) {
3489
     if (code_seen('P')) {

+ 14
- 14
Marlin/configuration_store.cpp View File

328
 
328
 
329
   // Report storage size
329
   // Report storage size
330
   SERIAL_ECHO_START;
330
   SERIAL_ECHO_START;
331
-  SERIAL_ECHOPAIR("Settings Stored (", (unsigned long)i);
331
+  SERIAL_ECHOPAIR("Settings Stored (", i);
332
   SERIAL_ECHOLNPGM(" bytes)");
332
   SERIAL_ECHOLNPGM(" bytes)");
333
 }
333
 }
334
 
334
 
507
     // Report settings retrieved and length
507
     // Report settings retrieved and length
508
     SERIAL_ECHO_START;
508
     SERIAL_ECHO_START;
509
     SERIAL_ECHO(ver);
509
     SERIAL_ECHO(ver);
510
-    SERIAL_ECHOPAIR(" stored settings retrieved (", (unsigned long)i);
510
+    SERIAL_ECHOPAIR(" stored settings retrieved (", i);
511
     SERIAL_ECHOLNPGM(" bytes)");
511
     SERIAL_ECHOLNPGM(" bytes)");
512
   }
512
   }
513
 
513
 
730
       SERIAL_ECHOLNPGM("Mesh bed leveling:");
730
       SERIAL_ECHOLNPGM("Mesh bed leveling:");
731
       CONFIG_ECHO_START;
731
       CONFIG_ECHO_START;
732
     }
732
     }
733
-    SERIAL_ECHOPAIR("  M420 S", (unsigned long)mbl.active);
734
-    SERIAL_ECHOPAIR(" X", (unsigned long)MESH_NUM_X_POINTS);
735
-    SERIAL_ECHOPAIR(" Y", (unsigned long)MESH_NUM_Y_POINTS);
733
+    SERIAL_ECHOPAIR("  M420 S", mbl.active);
734
+    SERIAL_ECHOPAIR(" X", MESH_NUM_X_POINTS);
735
+    SERIAL_ECHOPAIR(" Y", MESH_NUM_Y_POINTS);
736
     SERIAL_EOL;
736
     SERIAL_EOL;
737
     for (uint8_t y = 0; y < MESH_NUM_Y_POINTS; y++) {
737
     for (uint8_t y = 0; y < MESH_NUM_Y_POINTS; y++) {
738
       for (uint8_t x = 0; x < MESH_NUM_X_POINTS; x++) {
738
       for (uint8_t x = 0; x < MESH_NUM_X_POINTS; x++) {
783
       SERIAL_ECHOLNPGM("Material heatup parameters:");
783
       SERIAL_ECHOLNPGM("Material heatup parameters:");
784
       CONFIG_ECHO_START;
784
       CONFIG_ECHO_START;
785
     }
785
     }
786
-    SERIAL_ECHOPAIR("  M145 S0 H", (unsigned long)plaPreheatHotendTemp);
787
-    SERIAL_ECHOPAIR(" B", (unsigned long)plaPreheatHPBTemp);
788
-    SERIAL_ECHOPAIR(" F", (unsigned long)plaPreheatFanSpeed);
786
+    SERIAL_ECHOPAIR("  M145 S0 H", plaPreheatHotendTemp);
787
+    SERIAL_ECHOPAIR(" B", plaPreheatHPBTemp);
788
+    SERIAL_ECHOPAIR(" F", plaPreheatFanSpeed);
789
     SERIAL_EOL;
789
     SERIAL_EOL;
790
     CONFIG_ECHO_START;
790
     CONFIG_ECHO_START;
791
-    SERIAL_ECHOPAIR("  M145 S1 H", (unsigned long)absPreheatHotendTemp);
792
-    SERIAL_ECHOPAIR(" B", (unsigned long)absPreheatHPBTemp);
793
-    SERIAL_ECHOPAIR(" F", (unsigned long)absPreheatFanSpeed);
791
+    SERIAL_ECHOPAIR("  M145 S1 H", absPreheatHotendTemp);
792
+    SERIAL_ECHOPAIR(" B", absPreheatHPBTemp);
793
+    SERIAL_ECHOPAIR(" F", absPreheatFanSpeed);
794
     SERIAL_EOL;
794
     SERIAL_EOL;
795
   #endif // ULTIPANEL
795
   #endif // ULTIPANEL
796
 
796
 
805
         if (forReplay) {
805
         if (forReplay) {
806
           for (uint8_t i = 0; i < EXTRUDERS; i++) {
806
           for (uint8_t i = 0; i < EXTRUDERS; i++) {
807
             CONFIG_ECHO_START;
807
             CONFIG_ECHO_START;
808
-            SERIAL_ECHOPAIR("  M301 E", (unsigned long)i);
808
+            SERIAL_ECHOPAIR("  M301 E", i);
809
             SERIAL_ECHOPAIR(" P", PID_PARAM(Kp, i));
809
             SERIAL_ECHOPAIR(" P", PID_PARAM(Kp, i));
810
             SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, i)));
810
             SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, i)));
811
             SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, i)));
811
             SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, i)));
848
       SERIAL_ECHOLNPGM("LCD Contrast:");
848
       SERIAL_ECHOLNPGM("LCD Contrast:");
849
       CONFIG_ECHO_START;
849
       CONFIG_ECHO_START;
850
     }
850
     }
851
-    SERIAL_ECHOPAIR("  M250 C", (unsigned long)lcd_contrast);
851
+    SERIAL_ECHOPAIR("  M250 C", lcd_contrast);
852
     SERIAL_EOL;
852
     SERIAL_EOL;
853
   #endif
853
   #endif
854
 
854
 
882
       SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
882
       SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
883
       CONFIG_ECHO_START;
883
       CONFIG_ECHO_START;
884
     }
884
     }
885
-    SERIAL_ECHOPAIR("  M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
885
+    SERIAL_ECHOPAIR("  M209 S", (autoretract_enabled ? 1 : 0));
886
     SERIAL_EOL;
886
     SERIAL_EOL;
887
 
887
 
888
   #endif // FWRETRACT
888
   #endif // FWRETRACT

+ 4
- 4
Marlin/stepper.cpp View File

294
     SERIAL_ECHO_START;
294
     SERIAL_ECHO_START;
295
     SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT);
295
     SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT);
296
     if (TEST(endstop_hit_bits, X_MIN)) {
296
     if (TEST(endstop_hit_bits, X_MIN)) {
297
-      SERIAL_ECHOPAIR(" X:", (float)endstops_trigsteps[X_AXIS] / axis_steps_per_unit[X_AXIS]);
297
+      SERIAL_ECHOPAIR(" X:", endstops_trigsteps[X_AXIS] / axis_steps_per_unit[X_AXIS]);
298
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "X");
298
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "X");
299
     }
299
     }
300
     if (TEST(endstop_hit_bits, Y_MIN)) {
300
     if (TEST(endstop_hit_bits, Y_MIN)) {
301
-      SERIAL_ECHOPAIR(" Y:", (float)endstops_trigsteps[Y_AXIS] / axis_steps_per_unit[Y_AXIS]);
301
+      SERIAL_ECHOPAIR(" Y:", endstops_trigsteps[Y_AXIS] / axis_steps_per_unit[Y_AXIS]);
302
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Y");
302
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Y");
303
     }
303
     }
304
     if (TEST(endstop_hit_bits, Z_MIN)) {
304
     if (TEST(endstop_hit_bits, Z_MIN)) {
305
-      SERIAL_ECHOPAIR(" Z:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
305
+      SERIAL_ECHOPAIR(" Z:", endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
306
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z");
306
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z");
307
     }
307
     }
308
     #if ENABLED(Z_MIN_PROBE_ENDSTOP)
308
     #if ENABLED(Z_MIN_PROBE_ENDSTOP)
309
       if (TEST(endstop_hit_bits, Z_MIN_PROBE)) {
309
       if (TEST(endstop_hit_bits, Z_MIN_PROBE)) {
310
-        SERIAL_ECHOPAIR(" Z_MIN_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
310
+        SERIAL_ECHOPAIR(" Z_MIN_PROBE:", endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
311
         LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP");
311
         LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP");
312
       }
312
       }
313
     #endif
313
     #endif

Loading…
Cancel
Save