From 5e9a10dbaeaa885a670af0bd7ef3e7c068f5a7b8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 1 Mar 2020 07:36:25 -0600 Subject: [PATCH] Use PSTR for common labels --- Marlin/src/MarlinCore.cpp | 10 +++++++++- Marlin/src/MarlinCore.h | 4 +++- Marlin/src/feature/dac/stepper_dac.cpp | 10 +++++----- Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp | 8 ++++---- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 4 ++-- Marlin/src/lcd/dogm/ultralcd_DOGM.cpp | 6 +++--- Marlin/src/module/planner.cpp | 11 +++++++---- Marlin/src/module/scara.cpp | 6 ++++-- Marlin/src/module/stepper.cpp | 4 ++-- 9 files changed, 39 insertions(+), 24 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 5a527482c..124fb6f03 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -192,7 +192,15 @@ const char NUL_STR[] PROGMEM = "", SP_X_STR[] PROGMEM = " X", SP_Y_STR[] PROGMEM = " Y", SP_Z_STR[] PROGMEM = " Z", - SP_E_STR[] PROGMEM = " E"; + SP_E_STR[] PROGMEM = " E", + X_LBL[] PROGMEM = "X:", + Y_LBL[] PROGMEM = "Y:", + Z_LBL[] PROGMEM = "Z:", + E_LBL[] PROGMEM = "E:", + SP_X_LBL[] PROGMEM = " X:", + SP_Y_LBL[] PROGMEM = " Y:", + SP_Z_LBL[] PROGMEM = " Z:", + SP_E_LBL[] PROGMEM = " E:"; bool Running = true; diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index fd2cbeaba..141ce7156 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -123,4 +123,6 @@ void protected_pin_err(); #endif extern const char NUL_STR[], M112_KILL_STR[], G28_STR[], M21_STR[], M23_STR[], M24_STR[], - SP_P_STR[], SP_T_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[], + X_LBL[], Y_LBL[], Z_LBL[], E_LBL[], SP_X_LBL[], SP_Y_LBL[], SP_Z_LBL[], SP_E_LBL[]; + diff --git a/Marlin/src/feature/dac/stepper_dac.cpp b/Marlin/src/feature/dac/stepper_dac.cpp index cb3856f28..c8c1cb249 100644 --- a/Marlin/src/feature/dac/stepper_dac.cpp +++ b/Marlin/src/feature/dac/stepper_dac.cpp @@ -88,11 +88,11 @@ void dac_print_values() { SERIAL_ECHO_MSG("Stepper current values in % (Amps):"); SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR( - " X:", dac_perc(X_AXIS), " (", dac_amps(X_AXIS), ")" - " Y:", dac_perc(Y_AXIS), " (", dac_amps(Y_AXIS), ")" - " Z:", dac_perc(Z_AXIS), " (", dac_amps(Z_AXIS), ")" - " E:", dac_perc(E_AXIS), " (", dac_amps(E_AXIS), ")" + SERIAL_ECHOLNPAIR_P( + SP_X_LBL, dac_perc(X_AXIS), PSTR(" ("), dac_amps(X_AXIS), PSTR(")") + SP_Y_LBL, dac_perc(Y_AXIS), PSTR(" ("), dac_amps(Y_AXIS), PSTR(")") + SP_Z_LBL, dac_perc(Z_AXIS), PSTR(" ("), dac_amps(Z_AXIS), PSTR(")") + SP_E_LBL, dac_perc(E_AXIS), PSTR(" ("), dac_amps(E_AXIS), PSTR(")") ); } diff --git a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp index 7cee7db4b..0e6374b8d 100644 --- a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp @@ -1212,10 +1212,10 @@ void MarlinUI::draw_status_screen() { #define _LCD_W_POS 12 #define _PLOT_X 1 #define _MAP_X 3 - #define _LABEL(C,X,Y) lcd_put_u8str(X, Y, C) - #define _XLABEL(X,Y) _LABEL("X:",X,Y) - #define _YLABEL(X,Y) _LABEL("Y:",X,Y) - #define _ZLABEL(X,Y) _LABEL("Z:",X,Y) + #define _LABEL(C,X,Y) lcd_put_u8str_P(X, Y, C) + #define _XLABEL(X,Y) _LABEL(X_LBL,X,Y) + #define _YLABEL(X,Y) _LABEL(Y_LBL,X,Y) + #define _ZLABEL(X,Y) _LABEL(Z_LBL,X,Y) #else #define _LCD_W_POS 8 #define _PLOT_X 0 diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 1ea1424d3..908dfdf8f 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -652,11 +652,11 @@ void MarlinUI::draw_status_screen() { } } else if (progress_state == 2 && estimation_string[0]) { - lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, "R:"); + lcd_put_u8str_P(PROGRESS_BAR_X, EXTRAS_BASELINE, PSTR("R:")); lcd_put_u8str(estimation_x_pos, EXTRAS_BASELINE, estimation_string); } else if (elapsed_string[0]) { - lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, "E:"); + lcd_put_u8str_P(PROGRESS_BAR_X, EXTRAS_BASELINE, E_LBL); lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string); } diff --git a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp index 8dd24e273..4bfa3c71b 100644 --- a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp +++ b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp @@ -548,9 +548,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop if (PAGE_UNDER(7)) { const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) }, lpos = pos.asLogical(); - lcd_put_u8str(5, 7, "X:"); + lcd_put_u8str_P(5, 7, X_LBL); lcd_put_u8str(ftostr52(lpos.x)); - lcd_put_u8str(74, 7, "Y:"); + lcd_put_u8str_P(74, 7, Y_LBL); lcd_put_u8str(ftostr52(lpos.y)); } @@ -563,7 +563,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop lcd_put_wchar(')'); // Show the location value - lcd_put_u8str(74, LCD_PIXEL_HEIGHT, "Z:"); + lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL); if (!isnan(ubl.z_values[x_plot][y_plot])) lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); else diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 2067ecc23..fe1eec459 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2628,21 +2628,24 @@ bool Planner::buffer_segment(const float &a, const float &b, const float &c, con SERIAL_ECHOPAIR("->", target.a); SERIAL_ECHOPAIR(") B:", b); #else - SERIAL_ECHOPAIR(" X:", a); + SERIAL_ECHOPAIR_P(SP_X_LBL, a); SERIAL_ECHOPAIR(" (", position.x); SERIAL_ECHOPAIR("->", target.x); - SERIAL_ECHOPAIR(") Y:", b); + SERIAL_CHAR(')'); + SERIAL_ECHOPAIR_P(SP_Y_LBL, b); #endif SERIAL_ECHOPAIR(" (", position.y); SERIAL_ECHOPAIR("->", target.y); #if ENABLED(DELTA) SERIAL_ECHOPAIR(") C:", c); #else - SERIAL_ECHOPAIR(") Z:", c); + SERIAL_CHAR(')'); + SERIAL_ECHOPAIR_P(SP_Z_LBL, c); #endif SERIAL_ECHOPAIR(" (", position.z); SERIAL_ECHOPAIR("->", target.z); - SERIAL_ECHOPAIR(") E:", e); + SERIAL_CHAR(')'); + SERIAL_ECHOPAIR_P(SP_E_LBL, e); SERIAL_ECHOPAIR(" (", position.e); SERIAL_ECHOPAIR("->", target.e); SERIAL_ECHOLNPGM(")"); diff --git a/Marlin/src/module/scara.cpp b/Marlin/src/module/scara.cpp index f7eb8d192..5fbbfd65a 100644 --- a/Marlin/src/module/scara.cpp +++ b/Marlin/src/module/scara.cpp @@ -53,11 +53,13 @@ void scara_set_axis_is_at_home(const AxisEnum axis) { current_position[axis] = cartes[axis]; #else // MP_SCARA uses a Cartesian XY home position - // SERIAL_ECHOLNPAIR("homeposition X:", homeposition.x, " Y:", homeposition.y); + // SERIAL_ECHOPGM("homeposition"); + // SERIAL_ECHOLNPAIR_P(SP_X_LBL, homeposition.x, SP_Y_LBL, homeposition.y); current_position[axis] = homeposition[axis]; #endif - // SERIAL_ECHOLNPAIR("Cartesian X:", current_position.x, " Y:", current_position.y); + // SERIAL_ECHOPGM("Cartesian"); + // SERIAL_ECHOLNPAIR_P(SP_X_LBL, current_position.x, SP_Y_LBL, current_position.y); update_software_endstops(axis); } } diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 68639d40f..d4bbe36f1 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2464,12 +2464,12 @@ void Stepper::report_positions() { #if CORE_IS_XY || CORE_IS_XZ || ENABLED(DELTA) || IS_SCARA SERIAL_ECHOPAIR(STR_COUNT_A, pos.x, " B:", pos.y); #else - SERIAL_ECHOPAIR(STR_COUNT_X, pos.x, " Y:", pos.y); + SERIAL_ECHOPAIR_P(PSTR(STR_COUNT_X), pos.x, SP_Y_LBL, pos.y); #endif #if CORE_IS_XZ || CORE_IS_YZ || ENABLED(DELTA) SERIAL_ECHOLNPAIR(" C:", pos.z); #else - SERIAL_ECHOLNPAIR(" Z:", pos.z); + SERIAL_ECHOLNPAIR_P(SP_Z_LBL, pos.z); #endif }