From dc19b69697263524bb6d563fad8b7dfd5d2efa23 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 6 Apr 2016 22:40:45 -0700 Subject: [PATCH] No casting needed for SERIAL_ECHOPAIR --- Marlin/M100_Free_Mem_Chk.cpp | 10 +++++----- Marlin/Marlin.h | 4 +++- Marlin/Marlin_main.cpp | 21 ++++++++++++--------- Marlin/configuration_store.cpp | 28 ++++++++++++++-------------- Marlin/stepper.cpp | 8 ++++---- 5 files changed, 38 insertions(+), 33 deletions(-) diff --git a/Marlin/M100_Free_Mem_Chk.cpp b/Marlin/M100_Free_Mem_Chk.cpp index 6033c0afe..276df98eb 100644 --- a/Marlin/M100_Free_Mem_Chk.cpp +++ b/Marlin/M100_Free_Mem_Chk.cpp @@ -180,10 +180,10 @@ void gcode_M100() { x = code_value(); SERIAL_ECHOLNPGM("Corrupting free memory block.\n"); ptr = (unsigned char*) __brkval; - SERIAL_ECHOPAIR("\n__brkval : ", (long) ptr); + SERIAL_ECHOPAIR("\n__brkval : ", ptr); ptr += 8; sp = top_of_stack(); - SERIAL_ECHOPAIR("\nStack Pointer : ", (long) sp); + SERIAL_ECHOPAIR("\nStack Pointer : ", sp); SERIAL_ECHOLNPGM("\n"); n = sp - ptr - 64; // -64 just to keep us from finding interrupt activity that // has altered the stack. @@ -204,10 +204,10 @@ void gcode_M100() { if (m100_not_initialized || code_seen('I')) { // If no sub-command is specified, the first time SERIAL_ECHOLNPGM("Initializing free memory block.\n"); // this happens, it will Initialize. ptr = (unsigned char*) __brkval; // Repeated M100 with no sub-command will not destroy the - SERIAL_ECHOPAIR("\n__brkval : ", (long) ptr); // state of the initialized free memory pool. + SERIAL_ECHOPAIR("\n__brkval : ", ptr); // state of the initialized free memory pool. ptr += 8; sp = top_of_stack(); - SERIAL_ECHOPAIR("\nStack Pointer : ", (long) sp); + SERIAL_ECHOPAIR("\nStack Pointer : ", sp); SERIAL_ECHOLNPGM("\n"); n = sp - ptr - 64; // -64 just to keep us from finding interrupt activity that // has altered the stack. @@ -217,7 +217,7 @@ void gcode_M100() { *(ptr + i) = (unsigned char) 0xe5; for (i = 0; i < n; i++) { if (*(ptr + i) != (unsigned char) 0xe5) { - SERIAL_ECHOPAIR("? address : ", (unsigned long) ptr + i); + SERIAL_ECHOPAIR("? address : ", ptr + i); SERIAL_ECHOPAIR("=", *(ptr + i)); SERIAL_ECHOLNPGM("\n"); } diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index c6274056c..61bb33a21 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -101,13 +101,15 @@ extern const char echomagic[] PROGMEM; #define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x) #define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x) -#define SERIAL_ECHOPAIR(name,value) do{ serial_echopair_P(PSTR(name),(value)); }while(0) +#define SERIAL_ECHOPAIR(name,value) (serial_echopair_P(PSTR(name),(value))) void serial_echopair_P(const char* s_P, int v); void serial_echopair_P(const char* s_P, long v); void serial_echopair_P(const char* s_P, float v); void serial_echopair_P(const char* s_P, double v); void serial_echopair_P(const char* s_P, unsigned long v); +FORCE_INLINE void serial_echopair_P(const char* s_P, bool v) { serial_echopair_P(s_P, (int)v); } +FORCE_INLINE void serial_echopair_P(const char* s_P, void *v) { serial_echopair_P(s_P, (unsigned long)v); } // Things to write to serial from Program memory. Saves 400 to 2k of RAM. FORCE_INLINE void serialprintPGM(const char* str) { diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 1deabb477..9e1f9115d 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1170,7 +1170,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); static void set_axis_is_at_home(AxisEnum axis) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { - SERIAL_ECHOPAIR("set_axis_is_at_home(", (unsigned long)axis); + SERIAL_ECHOPAIR("set_axis_is_at_home(", axis); SERIAL_ECHOLNPGM(") >>>"); } #endif @@ -1258,7 +1258,7 @@ static void set_axis_is_at_home(AxisEnum axis) { } #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { - SERIAL_ECHOPAIR("<<< set_axis_is_at_home(", (unsigned long)axis); + SERIAL_ECHOPAIR("<<< set_axis_is_at_home(", axis); SERIAL_ECHOLNPGM(")"); } #endif @@ -1653,7 +1653,7 @@ static void setup_for_endstop_move() { if (doRaise) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { - SERIAL_ECHOPAIR("Raise Z (after) by ", (float)Z_RAISE_AFTER_PROBING); + SERIAL_ECHOPAIR("Raise Z (after) by ", Z_RAISE_AFTER_PROBING); SERIAL_EOL; SERIAL_ECHO("> SERVO_ENDSTOPS > raise_z_after_probing()"); SERIAL_EOL; @@ -1749,7 +1749,7 @@ static void setup_for_endstop_move() { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { SERIAL_ECHOLNPGM("probe_pt >>>"); - SERIAL_ECHOPAIR("> ProbeAction:", (unsigned long)probe_action); + SERIAL_ECHOPAIR("> ProbeAction:", probe_action); SERIAL_EOL; DEBUG_POS("", current_position); } @@ -1970,7 +1970,7 @@ static void setup_for_endstop_move() { static void homeaxis(AxisEnum axis) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { - SERIAL_ECHOPAIR(">>> homeaxis(", (unsigned long)axis); + SERIAL_ECHOPAIR(">>> homeaxis(", axis); SERIAL_ECHOLNPGM(")"); } #endif @@ -2158,7 +2158,7 @@ static void homeaxis(AxisEnum axis) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { - SERIAL_ECHOPAIR("<<< homeaxis(", (unsigned long)axis); + SERIAL_ECHOPAIR("<<< homeaxis(", axis); SERIAL_ECHOLNPGM(")"); } #endif @@ -2486,7 +2486,7 @@ inline void gcode_G28() { feedrate = max_feedrate[Z_AXIS] * 60; // feedrate (mm/m) = max_feedrate (mm/s) #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { - SERIAL_ECHOPAIR("Raise Z (before homing) to ", (float)(MIN_Z_HEIGHT_FOR_HOMING)); + SERIAL_ECHOPAIR("Raise Z (before homing) to ", (MIN_Z_HEIGHT_FOR_HOMING)); SERIAL_EOL; DEBUG_POS("> (home_all_axis || homeZ)", current_position); DEBUG_POS("> (home_all_axis || homeZ)", destination); @@ -3117,7 +3117,7 @@ inline void gcode_G28() { if (probePointCounter) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { - SERIAL_ECHOPAIR("z_before = (between) ", (float)(Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS])); + SERIAL_ECHOPAIR("z_before = (between) ", (Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS])); SERIAL_EOL; } #endif @@ -3125,7 +3125,7 @@ inline void gcode_G28() { else { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { - SERIAL_ECHOPAIR("z_before = (before) ", (float)Z_RAISE_BEFORE_PROBING); + SERIAL_ECHOPAIR("z_before = (before) ", Z_RAISE_BEFORE_PROBING); SERIAL_EOL; } #endif @@ -3483,6 +3483,9 @@ inline void gcode_G92() { inline void gcode_M0_M1() { char* args = current_command_args; + uint8_t test_value = 12; + SERIAL_ECHOPAIR("TEST", test_value); + millis_t codenum = 0; bool hasP = false, hasS = false; if (code_seen('P')) { diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 83bd8450b..3f22b2f8c 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -328,7 +328,7 @@ void Config_StoreSettings() { // Report storage size SERIAL_ECHO_START; - SERIAL_ECHOPAIR("Settings Stored (", (unsigned long)i); + SERIAL_ECHOPAIR("Settings Stored (", i); SERIAL_ECHOLNPGM(" bytes)"); } @@ -507,7 +507,7 @@ void Config_RetrieveSettings() { // Report settings retrieved and length SERIAL_ECHO_START; SERIAL_ECHO(ver); - SERIAL_ECHOPAIR(" stored settings retrieved (", (unsigned long)i); + SERIAL_ECHOPAIR(" stored settings retrieved (", i); SERIAL_ECHOLNPGM(" bytes)"); } @@ -730,9 +730,9 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOLNPGM("Mesh bed leveling:"); CONFIG_ECHO_START; } - SERIAL_ECHOPAIR(" M420 S", (unsigned long)mbl.active); - SERIAL_ECHOPAIR(" X", (unsigned long)MESH_NUM_X_POINTS); - SERIAL_ECHOPAIR(" Y", (unsigned long)MESH_NUM_Y_POINTS); + SERIAL_ECHOPAIR(" M420 S", mbl.active); + SERIAL_ECHOPAIR(" X", MESH_NUM_X_POINTS); + SERIAL_ECHOPAIR(" Y", MESH_NUM_Y_POINTS); SERIAL_EOL; for (uint8_t y = 0; y < MESH_NUM_Y_POINTS; y++) { for (uint8_t x = 0; x < MESH_NUM_X_POINTS; x++) { @@ -783,14 +783,14 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOLNPGM("Material heatup parameters:"); CONFIG_ECHO_START; } - SERIAL_ECHOPAIR(" M145 S0 H", (unsigned long)plaPreheatHotendTemp); - SERIAL_ECHOPAIR(" B", (unsigned long)plaPreheatHPBTemp); - SERIAL_ECHOPAIR(" F", (unsigned long)plaPreheatFanSpeed); + SERIAL_ECHOPAIR(" M145 S0 H", plaPreheatHotendTemp); + SERIAL_ECHOPAIR(" B", plaPreheatHPBTemp); + SERIAL_ECHOPAIR(" F", plaPreheatFanSpeed); SERIAL_EOL; CONFIG_ECHO_START; - SERIAL_ECHOPAIR(" M145 S1 H", (unsigned long)absPreheatHotendTemp); - SERIAL_ECHOPAIR(" B", (unsigned long)absPreheatHPBTemp); - SERIAL_ECHOPAIR(" F", (unsigned long)absPreheatFanSpeed); + SERIAL_ECHOPAIR(" M145 S1 H", absPreheatHotendTemp); + SERIAL_ECHOPAIR(" B", absPreheatHPBTemp); + SERIAL_ECHOPAIR(" F", absPreheatFanSpeed); SERIAL_EOL; #endif // ULTIPANEL @@ -805,7 +805,7 @@ void Config_PrintSettings(bool forReplay) { if (forReplay) { for (uint8_t i = 0; i < EXTRUDERS; i++) { CONFIG_ECHO_START; - SERIAL_ECHOPAIR(" M301 E", (unsigned long)i); + SERIAL_ECHOPAIR(" M301 E", i); SERIAL_ECHOPAIR(" P", PID_PARAM(Kp, i)); SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, i))); SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, i))); @@ -848,7 +848,7 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOLNPGM("LCD Contrast:"); CONFIG_ECHO_START; } - SERIAL_ECHOPAIR(" M250 C", (unsigned long)lcd_contrast); + SERIAL_ECHOPAIR(" M250 C", lcd_contrast); SERIAL_EOL; #endif @@ -882,7 +882,7 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries"); CONFIG_ECHO_START; } - SERIAL_ECHOPAIR(" M209 S", (unsigned long)(autoretract_enabled ? 1 : 0)); + SERIAL_ECHOPAIR(" M209 S", (autoretract_enabled ? 1 : 0)); SERIAL_EOL; #endif // FWRETRACT diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 5d2761f1f..a371361c2 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -294,20 +294,20 @@ void checkHitEndstops() { SERIAL_ECHO_START; SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT); if (TEST(endstop_hit_bits, X_MIN)) { - SERIAL_ECHOPAIR(" X:", (float)endstops_trigsteps[X_AXIS] / axis_steps_per_unit[X_AXIS]); + SERIAL_ECHOPAIR(" X:", endstops_trigsteps[X_AXIS] / axis_steps_per_unit[X_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "X"); } if (TEST(endstop_hit_bits, Y_MIN)) { - SERIAL_ECHOPAIR(" Y:", (float)endstops_trigsteps[Y_AXIS] / axis_steps_per_unit[Y_AXIS]); + SERIAL_ECHOPAIR(" Y:", endstops_trigsteps[Y_AXIS] / axis_steps_per_unit[Y_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Y"); } if (TEST(endstop_hit_bits, Z_MIN)) { - SERIAL_ECHOPAIR(" Z:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); + SERIAL_ECHOPAIR(" Z:", endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z"); } #if ENABLED(Z_MIN_PROBE_ENDSTOP) if (TEST(endstop_hit_bits, Z_MIN_PROBE)) { - SERIAL_ECHOPAIR(" Z_MIN_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); + SERIAL_ECHOPAIR(" Z_MIN_PROBE:", endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP"); } #endif