From 0e72c315a0be49e98758d9744ac0117b0904b7e1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 Feb 2020 17:05:42 -0600 Subject: [PATCH] Minor string storage optimization --- Marlin/src/MarlinCore.cpp | 2 ++ Marlin/src/MarlinCore.h | 2 +- Marlin/src/gcode/config/M200-M205.cpp | 2 +- Marlin/src/gcode/config/M217.cpp | 2 +- Marlin/src/gcode/control/M605.cpp | 2 +- Marlin/src/gcode/feature/mixing/M166.cpp | 2 +- Marlin/src/gcode/queue.cpp | 4 ++-- Marlin/src/module/configuration_store.cpp | 16 ++++++++-------- Marlin/src/module/temperature.cpp | 2 +- 9 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index f571480ff..a1154231c 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -187,6 +187,8 @@ const char NUL_STR[] PROGMEM = "", M21_STR[] PROGMEM = "M21", M23_STR[] PROGMEM = "M23 %s", M24_STR[] PROGMEM = "M24", + SP_P_STR[] PROGMEM = " P", + SP_T_STR[] PROGMEM = " T", SP_X_STR[] PROGMEM = " X", SP_Y_STR[] PROGMEM = " Y", SP_Z_STR[] PROGMEM = " Z", diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index b7f1460ff..85138268b 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -121,4 +121,4 @@ void protected_pin_err(); #endif extern const char NUL_STR[], M112_KILL_STR[], G28_STR[], M21_STR[], M23_STR[], M24_STR[], - SP_X_STR[], SP_Y_STR[], SP_Z_STR[], SP_E_STR[]; + SP_P_STR[], SP_T_STR[], SP_X_STR[], SP_Y_STR[], SP_Z_STR[], SP_E_STR[]; diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp index 14ddb1efc..46a4e6c6c 100644 --- a/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin/src/gcode/config/M200-M205.cpp @@ -96,7 +96,7 @@ void GcodeSuite::M204() { if (!parser.seen("PRST")) { SERIAL_ECHOPAIR("Acceleration: P", planner.settings.acceleration); SERIAL_ECHOPAIR(" R", planner.settings.retract_acceleration); - SERIAL_ECHOLNPAIR(" T", planner.settings.travel_acceleration); + SERIAL_ECHOLNPAIR_P(SP_T_STR, planner.settings.travel_acceleration); } else { //planner.synchronize(); diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 57178950c..d14ceaa0e 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -37,7 +37,7 @@ void M217_report(const bool eeprom=false) { serialprintPGM(eeprom ? PSTR(" M217") : PSTR("Toolchange:")); SERIAL_ECHOPAIR(" S", LINEAR_UNIT(toolchange_settings.swap_length)); SERIAL_ECHOPAIR_P(SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime)); - SERIAL_ECHOPAIR(" P", LINEAR_UNIT(toolchange_settings.prime_speed)); + SERIAL_ECHOPAIR_P(SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed)); SERIAL_ECHOPAIR(" R", LINEAR_UNIT(toolchange_settings.retract_speed)); #if ENABLED(TOOLCHANGE_PARK) diff --git a/Marlin/src/gcode/control/M605.cpp b/Marlin/src/gcode/control/M605.cpp index 007c6fc6b..95d72b65d 100644 --- a/Marlin/src/gcode/control/M605.cpp +++ b/Marlin/src/gcode/control/M605.cpp @@ -137,7 +137,7 @@ DEBUG_EOL(); HOTEND_LOOP() { - DEBUG_ECHOPAIR(" T", int(e)); + DEBUG_ECHOPAIR_P(SP_T_STR, int(e)); LOOP_XYZ(a) DEBUG_ECHOPAIR(" hotend_offset[", int(e), "].", axis_codes[a] | 0x20, "=", hotend_offset[e][a]); DEBUG_EOL(); } diff --git a/Marlin/src/gcode/feature/mixing/M166.cpp b/Marlin/src/gcode/feature/mixing/M166.cpp index cb3541eb8..c1c29a445 100644 --- a/Marlin/src/gcode/feature/mixing/M166.cpp +++ b/Marlin/src/gcode/feature/mixing/M166.cpp @@ -35,7 +35,7 @@ inline void echo_mix() { inline void echo_zt(const int t, const float &z) { mixer.update_mix_from_vtool(t); - SERIAL_ECHOPAIR_P(SP_Z_STR, z, PSTR(" T"), t); + SERIAL_ECHOPAIR_P(SP_Z_STR, z, SP_T_STR, t); echo_mix(); } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index b9b4d1bd9..d58150996 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -254,8 +254,8 @@ void GCodeQueue::ok_to_send() { while (NUMERIC_SIGNED(*p)) SERIAL_ECHO(*p++); } - SERIAL_ECHOPGM(" P"); SERIAL_ECHO(int(BLOCK_BUFFER_SIZE - planner.movesplanned() - 1)); - SERIAL_ECHOPGM(" B"); SERIAL_ECHO(BUFSIZE - length); + SERIAL_ECHOPAIR_P(SP_P_STR, int(BLOCK_BUFFER_SIZE - planner.movesplanned() - 1)); + SERIAL_ECHOPAIR(" B", BUFSIZE - length); #endif SERIAL_EOL(); } diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index 0e4e6cef3..f1c7698a4 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -2922,10 +2922,10 @@ void MarlinSettings::reset() { CONFIG_ECHO_HEADING("Acceleration (units/s2): P R T"); CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR( - " M204 P", LINEAR_UNIT(planner.settings.acceleration) - , " R", LINEAR_UNIT(planner.settings.retract_acceleration) - , " T", LINEAR_UNIT(planner.settings.travel_acceleration) + SERIAL_ECHOLNPAIR_P( + PSTR(" M204 P"), LINEAR_UNIT(planner.settings.acceleration) + , PSTR(" R"), LINEAR_UNIT(planner.settings.retract_acceleration) + , SP_T_STR, LINEAR_UNIT(planner.settings.travel_acceleration) ); if (!forReplay) { @@ -2946,7 +2946,7 @@ void MarlinSettings::reset() { SERIAL_ECHOLNPAIR_P( PSTR(" M205 B"), LINEAR_UNIT(planner.settings.min_segment_time_us) , PSTR(" S"), LINEAR_UNIT(planner.settings.min_feedrate_mm_s) - , PSTR(" T"), LINEAR_UNIT(planner.settings.min_travel_feedrate_mm_s) + , SP_T_STR, LINEAR_UNIT(planner.settings.min_travel_feedrate_mm_s) #if DISABLED(CLASSIC_JERK) , PSTR(" J"), LINEAR_UNIT(planner.junction_deviation_mm) #endif @@ -3089,8 +3089,8 @@ void MarlinSettings::reset() { CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P( PSTR(" M665 S"), delta_segments_per_second - , PSTR(" P"), scara_home_offset.a - , PSTR(" T"), scara_home_offset.b + , SP_P_STR, scara_home_offset.a + , SP_T_STR, scara_home_offset.b , SP_Z_STR, LINEAR_UNIT(scara_home_offset.z) ); @@ -3168,7 +3168,7 @@ void MarlinSettings::reset() { SERIAL_ECHOPAIR_P( #if HOTENDS > 1 && ENABLED(PID_PARAMS_PER_HOTEND) PSTR(" M301 E"), e, - PSTR(" P") + SP_P_STR #else PSTR(" M301 P") #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 4b00b095c..6dc831f71 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1326,7 +1326,7 @@ void Temperature::manage_heater() { const user_thermistor_t &t = user_thermistor[t_index]; SERIAL_ECHOPAIR_F(" R", t.series_res, 1); - SERIAL_ECHOPAIR_F(" T", t.res_25, 1); + SERIAL_ECHOPAIR_F_P(SP_T_STR, t.res_25, 1); SERIAL_ECHOPAIR_F(" B", t.beta, 1); SERIAL_ECHOPAIR_F(" C", t.sh_c_coeff, 9); SERIAL_ECHOPGM(" ; ");