From 11ac75edcb34a2f90b50ca134ff40839f8c29199 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Sep 2018 23:44:33 -0500 Subject: [PATCH] Use PGM_P for PSTR pointers (#11977) --- Marlin/src/HAL/HAL_LPC1768/HAL.cpp | 2 +- .../HAL_LPC1768/persistent_store_sdcard.cpp | 2 +- Marlin/src/Marlin.cpp | 2 +- Marlin/src/Marlin.h | 2 +- Marlin/src/core/serial.cpp | 38 +++++----- Marlin/src/core/serial.h | 52 +++++++------- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 4 +- Marlin/src/feature/bedlevel/ubl/ubl.h | 4 +- Marlin/src/feature/tmc_util.cpp | 2 +- Marlin/src/gcode/calibrate/G33.cpp | 6 +- Marlin/src/gcode/calibrate/M100.cpp | 19 ++--- Marlin/src/gcode/control/M111.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 8 +-- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/gcode/host/M115.cpp | 2 +- Marlin/src/gcode/parser.h | 2 +- Marlin/src/gcode/queue.cpp | 8 +-- Marlin/src/gcode/queue.h | 4 +- .../src/lcd/dogm/status_screen_lite_ST7920.h | 8 +-- .../dogm/status_screen_lite_ST7920_class.h | 2 +- Marlin/src/lcd/fontutils.cpp | 2 +- Marlin/src/lcd/fontutils.h | 2 +- Marlin/src/lcd/lcdprint.h | 4 +- Marlin/src/lcd/lcdprint_hd44780.cpp | 2 +- Marlin/src/lcd/lcdprint_u8g.cpp | 2 +- Marlin/src/lcd/malyanlcd.cpp | 4 +- Marlin/src/lcd/u8g_fontutf8.cpp | 4 +- Marlin/src/lcd/u8g_fontutf8.h | 4 +- Marlin/src/lcd/ultralcd.cpp | 70 +++++++++---------- Marlin/src/lcd/ultralcd.h | 16 ++--- Marlin/src/lcd/ultralcd_impl_DOGM.h | 10 +-- Marlin/src/lcd/ultralcd_impl_HD44780.h | 22 +++--- Marlin/src/libs/vector_3.cpp | 4 +- Marlin/src/libs/vector_3.h | 4 +- Marlin/src/module/endstops.cpp | 2 +- Marlin/src/module/probe.cpp | 2 +- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/module/temperature.h | 2 +- Marlin/src/pins/pinsDebug.h | 2 +- 39 files changed, 166 insertions(+), 165 deletions(-) diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL.cpp b/Marlin/src/HAL/HAL_LPC1768/HAL.cpp index aec9b4ce7..a59442cb1 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/HAL.cpp @@ -74,7 +74,7 @@ void HAL_adc_init(void) { // externals need to make the call to KILL compile #include "../../core/language.h" -extern void kill(const char*); +extern void kill(PGM_P); extern const char errormagic[]; void HAL_adc_enable_channel(int ch) { diff --git a/Marlin/src/HAL/HAL_LPC1768/persistent_store_sdcard.cpp b/Marlin/src/HAL/HAL_LPC1768/persistent_store_sdcard.cpp index 490f16e07..5731333ed 100644 --- a/Marlin/src/HAL/HAL_LPC1768/persistent_store_sdcard.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/persistent_store_sdcard.cpp @@ -79,7 +79,7 @@ bool PersistentStore::access_finish() { // This extra chit-chat goes away soon, but is helpful for now // to see errors that are happening in read_data / write_data static void debug_rw(const bool write, int &pos, const uint8_t *value, const size_t size, const FRESULT s, const size_t total=0) { - const char * const rw_str = write ? PSTR("write") : PSTR("read"); + PGM_P const rw_str = write ? PSTR("write") : PSTR("read"); SERIAL_PROTOCOLCHAR(' '); serialprintPGM(rw_str); SERIAL_PROTOCOLPAIR("_data(", pos); diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 4bb1a1fb9..2a38e4817 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -599,7 +599,7 @@ void idle( * Kill all activity and lock the machine. * After this the machine will need to be reset. */ -void kill(const char* lcd_msg) { +void kill(PGM_P lcd_msg) { SERIAL_ERROR_START(); SERIAL_ERRORLNPGM(MSG_ERR_KILLED); diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h index a233b44a3..0bad8db30 100644 --- a/Marlin/src/Marlin.h +++ b/Marlin/src/Marlin.h @@ -180,7 +180,7 @@ void disable_e_stepper(const uint8_t e); void disable_e_steppers(); void disable_all_steppers(); -void kill(const char*); +void kill(PGM_P); void quickstop_stepper(); diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index d53d730c6..f9da67e18 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -32,30 +32,30 @@ const char echomagic[] PROGMEM = "echo:"; while (char ch = pgm_read_byte(str++)) SERIAL_CHAR_P(p, ch); } - void serial_echopair_PGM_P(const int8_t p, const char* s_P, const char *v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } - void serial_echopair_PGM_P(const int8_t p, const char* s_P, char v) { serialprintPGM_P(p, s_P); SERIAL_CHAR_P(p, v); } - void serial_echopair_PGM_P(const int8_t p, const char* s_P, int v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } - void serial_echopair_PGM_P(const int8_t p, const char* s_P, long v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } - void serial_echopair_PGM_P(const int8_t p, const char* s_P, float v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } - void serial_echopair_PGM_P(const int8_t p, const char* s_P, double v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } - void serial_echopair_PGM_P(const int8_t p, const char* s_P, unsigned int v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } - void serial_echopair_PGM_P(const int8_t p, const char* s_P, unsigned long v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, const char *v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, char v) { serialprintPGM_P(p, s_P); SERIAL_CHAR_P(p, v); } + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, int v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, long v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, float v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, double v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, unsigned int v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); } + 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); } void serial_spaces_P(const int8_t p, uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR_P(p, ' '); } #endif -void serialprintPGM(const char * str) { +void serialprintPGM(PGM_P str) { while (char ch = pgm_read_byte(str++)) SERIAL_CHAR(ch); } -void serial_echopair_PGM(const char* s_P, const char *v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_PGM(const char* s_P, char v) { serialprintPGM(s_P); SERIAL_CHAR(v); } -void serial_echopair_PGM(const char* s_P, int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_PGM(const char* s_P, long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_PGM(const char* s_P, float v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_PGM(const char* s_P, double v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_PGM(const char* s_P, unsigned int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_PGM(const char* s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +void serial_echopair_PGM(PGM_P s_P, const char *v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +void serial_echopair_PGM(PGM_P s_P, char v) { serialprintPGM(s_P); SERIAL_CHAR(v); } +void serial_echopair_PGM(PGM_P s_P, int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +void serial_echopair_PGM(PGM_P s_P, long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +void serial_echopair_PGM(PGM_P s_P, float v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +void serial_echopair_PGM(PGM_P s_P, double v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +void serial_echopair_PGM(PGM_P s_P, unsigned int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +void serial_echopair_PGM(PGM_P s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); } @@ -63,7 +63,7 @@ void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (c #include "enum.h" - void print_xyz(const char* prefix, const char* suffix, const float x, const float y, const float z) { + void print_xyz(PGM_P prefix, PGM_P suffix, const float x, const float y, const float z) { serialprintPGM(prefix); SERIAL_CHAR('('); SERIAL_ECHO(x); @@ -73,7 +73,7 @@ void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (c if (suffix) serialprintPGM(suffix); else SERIAL_EOL(); } - void print_xyz(const char* prefix, const char* suffix, const float xyz[]) { + void print_xyz(PGM_P prefix, PGM_P suffix, const float xyz[]) { print_xyz(prefix, suffix, xyz[X_AXIS], xyz[Y_AXIS], xyz[Z_AXIS]); } diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index bbabdb70e..2b05045c7 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -105,24 +105,24 @@ extern const char errormagic[] PROGMEM; #define SERIAL_ECHOPAIR_F_P(p,pre,value) SERIAL_ECHOPAIR_P(p, pre, FIXFLOAT(value)) #define SERIAL_ECHOLNPAIR_F_P(p,pre, value) SERIAL_ECHOLNPAIR_P(p, pre, FIXFLOAT(value)) - void serial_echopair_PGM_P(const int8_t p, const char* s_P, const char *v); - void serial_echopair_PGM_P(const int8_t p, const char* s_P, char v); - void serial_echopair_PGM_P(const int8_t p, const char* s_P, int v); - void serial_echopair_PGM_P(const int8_t p, const char* s_P, long v); - void serial_echopair_PGM_P(const int8_t p, const char* s_P, float v); - void serial_echopair_PGM_P(const int8_t p, const char* s_P, double v); - void serial_echopair_PGM_P(const int8_t p, const char* s_P, unsigned int v); - void serial_echopair_PGM_P(const int8_t p, const char* s_P, unsigned long v); - FORCE_INLINE void serial_echopair_PGM_P(const int8_t p, const char* s_P, uint8_t v) { serial_echopair_PGM_P(p, s_P, (int)v); } - FORCE_INLINE void serial_echopair_PGM_P(const int8_t p, const char* s_P, bool v) { serial_echopair_PGM_P(p, s_P, (int)v); } - FORCE_INLINE void serial_echopair_PGM_P(const int8_t p, const char* s_P, void *v) { serial_echopair_PGM_P(p, s_P, (unsigned long)v); } + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, const char *v); + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, char v); + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, int v); + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, long v); + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, float v); + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, double v); + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, unsigned int v); + void serial_echopair_PGM_P(const int8_t p, PGM_P s_P, unsigned long v); + 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); } + 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); } + 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); } void serial_spaces_P(const int8_t p, uint8_t count); #define SERIAL_ECHO_SP_P(p,C) serial_spaces_P(p,C) #define SERIAL_ERROR_SP_P(p,C) serial_spaces_P(p,C) #define SERIAL_PROTOCOL_SP_P(p,C) serial_spaces_P(p,C) - void serialprintPGM_P(const int8_t p, const char* str); + void serialprintPGM_P(const int8_t p, PGM_P str); #else #define SERIAL_CHAR_P(p,x) SERIAL_CHAR(x) #define SERIAL_PROTOCOL_P(p,x) SERIAL_PROTOCOL(x) @@ -215,17 +215,17 @@ extern const char errormagic[] PROGMEM; #define SERIAL_ECHOPAIR_F(pre,value) SERIAL_ECHOPAIR(pre, FIXFLOAT(value)) #define SERIAL_ECHOLNPAIR_F(pre, value) SERIAL_ECHOLNPAIR(pre, FIXFLOAT(value)) -void serial_echopair_PGM(const char* s_P, const char *v); -void serial_echopair_PGM(const char* s_P, char v); -void serial_echopair_PGM(const char* s_P, int v); -void serial_echopair_PGM(const char* s_P, long v); -void serial_echopair_PGM(const char* s_P, float v); -void serial_echopair_PGM(const char* s_P, double v); -void serial_echopair_PGM(const char* s_P, unsigned int v); -void serial_echopair_PGM(const char* s_P, unsigned long v); -FORCE_INLINE void serial_echopair_PGM(const char* s_P, uint8_t v) { serial_echopair_PGM(s_P, (int)v); } -FORCE_INLINE void serial_echopair_PGM(const char* s_P, bool v) { serial_echopair_PGM(s_P, (int)v); } -FORCE_INLINE void serial_echopair_PGM(const char* s_P, void *v) { serial_echopair_PGM(s_P, (unsigned long)v); } +void serial_echopair_PGM(PGM_P s_P, const char *v); +void serial_echopair_PGM(PGM_P s_P, char v); +void serial_echopair_PGM(PGM_P s_P, int v); +void serial_echopair_PGM(PGM_P s_P, long v); +void serial_echopair_PGM(PGM_P s_P, float v); +void serial_echopair_PGM(PGM_P s_P, double v); +void serial_echopair_PGM(PGM_P s_P, unsigned int v); +void serial_echopair_PGM(PGM_P s_P, unsigned long v); +FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, uint8_t v) { serial_echopair_PGM(s_P, (int)v); } +FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, bool v) { serial_echopair_PGM(s_P, (int)v); } +FORCE_INLINE void serial_echopair_PGM(PGM_P s_P, void *v) { serial_echopair_PGM(s_P, (unsigned long)v); } void serial_spaces(uint8_t count); #define SERIAL_ECHO_SP(C) serial_spaces(C) @@ -235,11 +235,11 @@ void serial_spaces(uint8_t count); // // Functions for serial printing from PROGMEM. (Saves loads of SRAM.) // -void serialprintPGM(const char* str); +void serialprintPGM(PGM_P str); #if ENABLED(DEBUG_LEVELING_FEATURE) - void print_xyz(const char* prefix, const char* suffix, const float x, const float y, const float z); - void print_xyz(const char* prefix, const char* suffix, const float xyz[]); + void print_xyz(PGM_P prefix, PGM_P suffix, const float x, const float y, const float z); + void print_xyz(PGM_P prefix, PGM_P suffix, const float xyz[]); #define DEBUG_POS(SUFFIX,VAR) do { print_xyz(PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0) #endif diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 143d7a0fc..65235a5f4 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -90,7 +90,7 @@ SERIAL_ECHO_F(destination[X_AXIS], 6); } - void debug_current_and_destination(const char *title) { + void debug_current_and_destination(PGM_P title) { // if the title message starts with a '!' it is so important, we are going to // ignore the status of the g26_debug_flag @@ -127,7 +127,7 @@ SERIAL_ECHOPGM(", "); debug_echo_axis(E_AXIS); SERIAL_ECHOPGM(" ) "); - SERIAL_ECHO(title); + serialprintPGM(title); SERIAL_EOL(); } diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index 2db2b4dd7..2e8af9314 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -40,9 +40,9 @@ // ubl_motion.cpp #if ENABLED(UBL_DEVEL_DEBUGGING) - void debug_current_and_destination(const char * const title); + void debug_current_and_destination(PGM_P const title); #else - FORCE_INLINE void debug_current_and_destination(const char * const title) { UNUSED(title); } + FORCE_INLINE void debug_current_and_destination(PGM_P const title) { UNUSED(title); } #endif // ubl_G29.cpp diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index e4c4872e2..9cc81f9df 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -258,7 +258,7 @@ void _tmc_say_axis(const TMC_AxisEnum axis) { #endif ; - static const char* const tmc_axes[] PROGMEM = { + static PGM_P const tmc_axes[] PROGMEM = { ext_X, ext_Y, ext_Z #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(X_DUAL_STEPPER_DRIVERS) , ext_X2 diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 086a51a0e..047874a9f 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -108,7 +108,7 @@ void ac_cleanup( #endif } -void print_signed_float(const char * const prefix, const float &f) { +void print_signed_float(PGM_P const prefix, const float &f) { SERIAL_PROTOCOLPGM(" "); serialprintPGM(prefix); SERIAL_PROTOCOLCHAR(':'); @@ -517,7 +517,7 @@ void GcodeSuite::G33() { } // Report settings - const char* checkingac = PSTR("Checking... AC"); + PGM_P checkingac = PSTR("Checking... AC"); serialprintPGM(checkingac); if (verbose_level == 0) SERIAL_PROTOCOLPGM(" (DRY-RUN)"); if (set_up) SERIAL_PROTOCOLPGM(" (SET-UP)"); @@ -705,7 +705,7 @@ void GcodeSuite::G33() { } } else { // dry run - const char *enddryrun = PSTR("End DRY-RUN"); + PGM_P enddryrun = PSTR("End DRY-RUN"); serialprintPGM(enddryrun); SERIAL_PROTOCOL_SP(35); SERIAL_PROTOCOLPGM("std dev:"); diff --git a/Marlin/src/gcode/calibrate/M100.cpp b/Marlin/src/gcode/calibrate/M100.cpp index fe6e58689..e24c2c23d 100644 --- a/Marlin/src/gcode/calibrate/M100.cpp +++ b/Marlin/src/gcode/calibrate/M100.cpp @@ -50,8 +50,8 @@ * * Also, there are two support functions that can be called from a developer's C code. * - * uint16_t check_for_free_memory_corruption(const char * const ptr); - * void M100_dump_routine(const char * const title, const char *start, const char *end); + * uint16_t check_for_free_memory_corruption(PGM_P const ptr); + * void M100_dump_routine(PGM_P const title, const char *start, const char *end); * * Initial version by Roxy-3D */ @@ -80,7 +80,7 @@ char* top_of_stack() { // Count the number of test bytes at the specified location. inline int32_t count_test_bytes(const char * const ptr) { for (uint32_t i = 0; i < 32000; i++) - if (((char) ptr[i]) != TEST_BYTE) + if (char(ptr[i]) != TEST_BYTE) return i - 1; return -1; @@ -136,8 +136,9 @@ inline int32_t count_test_bytes(const char * const ptr) { } } - void M100_dump_routine(const char * const title, const char *start, const char *end) { - SERIAL_ECHOLN(title); + void M100_dump_routine(PGM_P const title, const char *start, const char *end) { + serialprintPGM(title); + SERIAL_EOL(); // // Round the start and end locations to produce full lines of output // @@ -148,8 +149,8 @@ inline int32_t count_test_bytes(const char * const ptr) { #endif // M100_FREE_MEMORY_DUMPER -inline int check_for_free_memory_corruption(const char * const title) { - SERIAL_ECHO(title); +inline int check_for_free_memory_corruption(PGM_P const title) { + serialprintPGM(title); char *ptr = END_OF_HEAP(), *sp = top_of_stack(); int n = sp - ptr; @@ -171,7 +172,7 @@ inline int check_for_free_memory_corruption(const char * const title) { // idle(); safe_delay(20); #if ENABLED(M100_FREE_MEMORY_DUMPER) - M100_dump_routine(" Memory corruption detected with spgetPrintCol(), y = pu8g->getPrintRow(), ret = uxg_DrawUtf8StrP(pu8g->getU8g(), x, y, utf8_str_P, max_length); diff --git a/Marlin/src/lcd/malyanlcd.cpp b/Marlin/src/lcd/malyanlcd.cpp index d02a33024..904fd6ded 100644 --- a/Marlin/src/lcd/malyanlcd.cpp +++ b/Marlin/src/lcd/malyanlcd.cpp @@ -81,7 +81,7 @@ int inbound_count; bool last_printing_status = false; // Everything written needs the high bit set. -void write_to_lcd_P(const char * const message) { +void write_to_lcd_P(PGM_P const message) { char encoded_message[MAX_CURLY_COMMAND]; uint8_t message_length = MIN(strlen_P(message), sizeof(encoded_message)); @@ -481,7 +481,7 @@ void lcd_init() { /** * Set an alert. */ -void lcd_setalertstatusPGM(const char* message) { +void lcd_setalertstatusPGM(PGM_P message) { char message_buffer[MAX_CURLY_COMMAND]; sprintf_P(message_buffer, PSTR("{E:%s}"), message); write_to_lcd(message_buffer); diff --git a/Marlin/src/lcd/u8g_fontutf8.cpp b/Marlin/src/lcd/u8g_fontutf8.cpp index b79d9906e..f3944be2a 100644 --- a/Marlin/src/lcd/u8g_fontutf8.cpp +++ b/Marlin/src/lcd/u8g_fontutf8.cpp @@ -233,7 +233,7 @@ unsigned int uxg_DrawUtf8Str(u8g_t *pu8g, unsigned int x, unsigned int y, const * * Draw a ROM UTF-8 string at the specified position */ -unsigned int uxg_DrawUtf8StrP(u8g_t *pu8g, unsigned int x, unsigned int y, const char *utf8_msg, pixel_len_t max_width) { +unsigned int uxg_DrawUtf8StrP(u8g_t *pu8g, unsigned int x, unsigned int y, PGM_P utf8_msg, pixel_len_t max_width) { struct _uxg_drawu8_data_t data; font_group_t *group = &g_fontgroup_root; const font_t *fnt_default = uxg_GetFont(pu8g); @@ -302,7 +302,7 @@ int uxg_GetUtf8StrPixelWidth(u8g_t *pu8g, const char *utf8_msg) { * * Get the screen pixel width of a ROM UTF-8 string */ -int uxg_GetUtf8StrPixelWidthP(u8g_t *pu8g, const char *utf8_msg) { +int uxg_GetUtf8StrPixelWidthP(u8g_t *pu8g, PGM_P utf8_msg) { struct _uxg_drawu8_data_t data; font_group_t *group = &g_fontgroup_root; const font_t *fnt_default = uxg_GetFont(pu8g); diff --git a/Marlin/src/lcd/u8g_fontutf8.h b/Marlin/src/lcd/u8g_fontutf8.h index 80522784c..883b24ca6 100644 --- a/Marlin/src/lcd/u8g_fontutf8.h +++ b/Marlin/src/lcd/u8g_fontutf8.h @@ -30,10 +30,10 @@ int uxg_SetUtf8Fonts (const uxg_fontinfo_t * fntinfo, int number); // fntinfo is unsigned int uxg_DrawWchar (u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t ch, pixel_len_t max_length); unsigned int uxg_DrawUtf8Str (u8g_t *pu8g, unsigned int x, unsigned int y, const char *utf8_msg, pixel_len_t max_length); -unsigned int uxg_DrawUtf8StrP (u8g_t *pu8g, unsigned int x, unsigned int y, const char *utf8_msg, pixel_len_t max_length); +unsigned int uxg_DrawUtf8StrP (u8g_t *pu8g, unsigned int x, unsigned int y, PGM_P utf8_msg, pixel_len_t max_length); int uxg_GetUtf8StrPixelWidth(u8g_t *pu8g, const char *utf8_msg); -int uxg_GetUtf8StrPixelWidthP(u8g_t *pu8g, const char *utf8_msg); +int uxg_GetUtf8StrPixelWidthP(u8g_t *pu8g, PGM_P utf8_msg); #define uxg_GetFont(puxg) ((puxg)->font) diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 7d3a8d0d3..7f50d5d61 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -125,15 +125,15 @@ uint16_t max_display_update_time = 0; #if ENABLED(ULTIPANEL) #define DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(_type, _name, _strFunc) \ - inline void lcd_implementation_drawmenu_setting_edit_ ## _name (const bool sel, const uint8_t row, const char* pstr, const char* pstr2, _type * const data, ...) { \ + inline void lcd_implementation_drawmenu_setting_edit_ ## _name (const bool sel, const uint8_t row, PGM_P pstr, PGM_P pstr2, _type * const data, ...) { \ UNUSED(pstr2); \ DRAWMENU_SETTING_EDIT_GENERIC(_strFunc(*(data))); \ } \ - inline void lcd_implementation_drawmenu_setting_edit_callback_ ## _name (const bool sel, const uint8_t row, const char* pstr, const char* pstr2, _type * const data, ...) { \ + inline void lcd_implementation_drawmenu_setting_edit_callback_ ## _name (const bool sel, const uint8_t row, PGM_P pstr, PGM_P pstr2, _type * const data, ...) { \ UNUSED(pstr2); \ DRAWMENU_SETTING_EDIT_GENERIC(_strFunc(*(data))); \ } \ - inline void lcd_implementation_drawmenu_setting_edit_accessor_ ## _name (const bool sel, const uint8_t row, const char* pstr, const char* pstr2, _type (*pget)(), void (*pset)(_type), ...) { \ + inline void lcd_implementation_drawmenu_setting_edit_accessor_ ## _name (const bool sel, const uint8_t row, PGM_P pstr, PGM_P pstr2, _type (*pget)(), void (*pset)(_type), ...) { \ UNUSED(pstr2); UNUSED(pset); \ DRAWMENU_SETTING_EDIT_GENERIC(_strFunc(pget())); \ } \ @@ -254,16 +254,16 @@ uint16_t max_display_update_time = 0; #define menu_action_back(dummy) _menu_action_back() void _menu_action_back(); void menu_action_submenu(screenFunc_t data); - void menu_action_gcode(const char* pgcode); + void menu_action_gcode(PGM_P pgcode); void menu_action_function(menuAction_t data); #define DECLARE_MENU_EDIT_TYPE(_type, _name) \ bool _menu_edit_ ## _name(); \ void menu_edit_ ## _name(); \ void menu_edit_callback_ ## _name(); \ - void _menu_action_setting_edit_ ## _name(const char * const pstr, _type* const ptr, const _type minValue, const _type maxValue); \ - void menu_action_setting_edit_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue); \ - void menu_action_setting_edit_callback_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue, const screenFunc_t callback=NULL, const bool live=false); \ + void _menu_action_setting_edit_ ## _name(PGM_P const pstr, _type* const ptr, const _type minValue, const _type maxValue); \ + void menu_action_setting_edit_ ## _name(PGM_P const pstr, _type * const ptr, const _type minValue, const _type maxValue); \ + void menu_action_setting_edit_callback_ ## _name(PGM_P const pstr, _type * const ptr, const _type minValue, const _type maxValue, const screenFunc_t callback=NULL, const bool live=false); \ typedef void _name##_void DECLARE_MENU_EDIT_TYPE(int16_t, int3); @@ -277,8 +277,8 @@ uint16_t max_display_update_time = 0; DECLARE_MENU_EDIT_TYPE(float, float62); DECLARE_MENU_EDIT_TYPE(uint32_t, long5); - void menu_action_setting_edit_bool(const char* pstr, bool* ptr); - void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr, screenFunc_t callbackFunc); + void menu_action_setting_edit_bool(PGM_P pstr, bool* ptr); + void menu_action_setting_edit_callback_bool(PGM_P pstr, bool* ptr, screenFunc_t callbackFunc); #if ENABLED(SDSUPPORT) void lcd_sdcard_menu(); @@ -466,7 +466,7 @@ uint16_t max_display_update_time = 0; bool screen_changed, defer_return_to_status; // Value Editing - const char *editLabel; + PGM_P editLabel; void *editValue; int32_t minEditValue, maxEditValue; screenFunc_t callbackFunc; @@ -570,7 +570,7 @@ uint16_t max_display_update_time = 0; * Show "Moving..." till moves are done, then revert to previous display. */ static const char moving[] PROGMEM = MSG_MOVING; - static const char *sync_message = moving; + static PGM_P sync_message = moving; // // Display the synchronize screen until moves are @@ -591,7 +591,7 @@ uint16_t max_display_update_time = 0; // Display the synchronize screen with a custom message // ** This blocks the command queue! ** - void lcd_synchronize(const char * const msg=NULL) { + void lcd_synchronize(PGM_P const msg=NULL) { sync_message = msg ? msg : moving; _lcd_synchronize(); } @@ -772,7 +772,7 @@ void lcd_reset_status() { static const char paused[] PROGMEM = MSG_PRINT_PAUSED; static const char printing[] PROGMEM = MSG_PRINTING; static const char welcome[] PROGMEM = WELCOME_MSG; - const char *msg; + PGM_P msg; if (print_job_timer.isPaused()) msg = paused; #if ENABLED(SDSUPPORT) @@ -792,7 +792,7 @@ void lcd_reset_status() { * draw the kill screen * */ -void kill_screen(const char* lcd_msg) { +void kill_screen(PGM_P lcd_msg) { lcd_init(); lcd_setalertstatusPGM(lcd_msg); lcd_kill_screen(); @@ -1080,7 +1080,7 @@ void lcd_quick_feedback(const bool clear_buttons) { #define _DONE_SCRIPT "" #endif - void _lcd_user_gcode(const char * const cmd) { + void _lcd_user_gcode(PGM_P const cmd) { enqueue_and_echo_commands_P(cmd); #if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK) lcd_completion_feedback(); @@ -1288,7 +1288,7 @@ void lcd_quick_feedback(const bool clear_buttons) { #if ENABLED(BABYSTEPPING) - void _lcd_babystep(const AxisEnum axis, const char* msg) { + void _lcd_babystep(const AxisEnum axis, PGM_P msg) { if (use_click()) { return lcd_goto_previous_menu_no_defer(); } ENCODER_DIRECTION_NORMAL(); if (encoderPosition) { @@ -1373,7 +1373,7 @@ void lcd_quick_feedback(const bool clear_buttons) { // separate value that doesn't lose precision. static int16_t ubl_encoderPosition = 0; - static void _lcd_mesh_fine_tune(const char* msg) { + static void _lcd_mesh_fine_tune(PGM_P msg) { defer_return_to_status = true; if (ubl.encoder_diff) { ubl_encoderPosition = (ubl.encoder_diff > 0) ? 1 : -1; @@ -1937,7 +1937,7 @@ void lcd_quick_feedback(const bool clear_buttons) { no_reentry = false; } - void lcd_enqueue_commands_P(const char * const cmd) { + void lcd_enqueue_commands_P(PGM_P const cmd) { no_reentry = true; enqueue_and_echo_commands_now_P(cmd); no_reentry = false; @@ -3030,7 +3030,7 @@ void lcd_quick_feedback(const bool clear_buttons) { * */ - void _lcd_move_xyz(const char* name, AxisEnum axis) { + void _lcd_move_xyz(PGM_P name, AxisEnum axis) { if (use_click()) { return lcd_goto_previous_menu_no_defer(); } ENCODER_DIRECTION_NORMAL(); if (encoderPosition && !processing_manual_move) { @@ -4508,7 +4508,7 @@ void lcd_quick_feedback(const bool clear_buttons) { static AdvancedPauseMode _change_filament_temp_mode; static int8_t _change_filament_temp_extruder; - static const char* _change_filament_temp_command() { + static PGM_P _change_filament_temp_command() { switch (_change_filament_temp_mode) { case ADVANCED_PAUSE_MODE_LOAD_FILAMENT: return PSTR("M701 T%d"); @@ -4531,7 +4531,7 @@ void lcd_quick_feedback(const bool clear_buttons) { void _lcd_change_filament_temp_2_menu() { _change_filament_temp(PREHEAT_2_TEMP_HOTEND); } void _lcd_change_filament_temp_custom_menu() { _change_filament_temp(thermalManager.target_temperature[_change_filament_temp_extruder]); } - static const char* change_filament_header(const AdvancedPauseMode mode) { + static PGM_P change_filament_header(const AdvancedPauseMode mode) { switch (mode) { case ADVANCED_PAUSE_MODE_LOAD_FILAMENT: return PSTR(MSG_FILAMENTLOAD); @@ -4779,7 +4779,7 @@ void lcd_quick_feedback(const bool clear_buttons) { static AdvancedPauseMode advanced_pause_mode = ADVANCED_PAUSE_MODE_PAUSE_PRINT; static uint8_t hotend_status_extruder = 0; - static const char* advanced_pause_header() { + static PGM_P advanced_pause_header() { switch (advanced_pause_mode) { case ADVANCED_PAUSE_MODE_LOAD_FILAMENT: return PSTR(MSG_FILAMENT_CHANGE_HEADER_LOAD); @@ -5061,9 +5061,9 @@ void lcd_quick_feedback(const bool clear_buttons) { * bool _menu_edit_int3(); * void menu_edit_int3(); // edit int16_t (interactively) * void menu_edit_callback_int3(); // edit int16_t (interactively) with callback on completion - * void _menu_action_setting_edit_int3(const char * const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue); - * void menu_action_setting_edit_int3(const char * const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue); - * void menu_action_setting_edit_callback_int3(const char * const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue, const screenFunc_t callback, const bool live); // edit int16_t with callback + * void _menu_action_setting_edit_int3(PGM_P const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue); + * void menu_action_setting_edit_int3(PGM_P const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue); + * void menu_action_setting_edit_callback_int3(PGM_P const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue, const screenFunc_t callback, const bool live); // edit int16_t with callback * * You can then use one of the menu macros to present the edit interface: * MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_percentage, 10, 999) @@ -5090,7 +5090,7 @@ void lcd_quick_feedback(const bool clear_buttons) { return use_click(); \ } \ void menu_edit_ ## _name() { _menu_edit_ ## _name(); } \ - void _menu_action_setting_edit_ ## _name(const char * const pstr, _type* const ptr, const _type minValue, const _type maxValue) { \ + void _menu_action_setting_edit_ ## _name(PGM_P const pstr, _type* const ptr, const _type minValue, const _type maxValue) { \ lcd_save_previous_screen(); \ lcd_refresh(); \ \ @@ -5100,13 +5100,13 @@ void lcd_quick_feedback(const bool clear_buttons) { maxEditValue = maxValue * _scale - minEditValue; \ encoderPosition = (*ptr) * _scale - minEditValue; \ } \ - void menu_action_setting_edit_callback_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue, const screenFunc_t callback, const bool live) { \ + void menu_action_setting_edit_callback_ ## _name(PGM_P const pstr, _type * const ptr, const _type minValue, const _type maxValue, const screenFunc_t callback, const bool live) { \ _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \ currentScreen = menu_edit_ ## _name; \ callbackFunc = callback; \ liveEdit = live; \ } \ - FORCE_INLINE void menu_action_setting_edit_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue) { \ + FORCE_INLINE void menu_action_setting_edit_ ## _name(PGM_P const pstr, _type * const ptr, const _type minValue, const _type maxValue) { \ menu_action_setting_edit_callback_ ## _name(pstr, ptr, minValue, maxValue); \ } \ typedef void _name##_void @@ -5219,7 +5219,7 @@ void lcd_quick_feedback(const bool clear_buttons) { */ void _menu_action_back() { lcd_goto_previous_menu(); } void menu_action_submenu(screenFunc_t func) { lcd_save_previous_screen(); lcd_goto_screen(func); } - void menu_action_gcode(const char* pgcode) { enqueue_and_echo_commands_P(pgcode); } + void menu_action_gcode(PGM_P pgcode) { enqueue_and_echo_commands_P(pgcode); } void menu_action_function(screenFunc_t func) { (*func)(); } #if ENABLED(SDSUPPORT) @@ -5246,8 +5246,8 @@ void lcd_quick_feedback(const bool clear_buttons) { #endif // SDSUPPORT - void menu_action_setting_edit_bool(const char* pstr, bool* ptr) { UNUSED(pstr); *ptr ^= true; lcd_refresh(); } - void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr, screenFunc_t callback) { + void menu_action_setting_edit_bool(PGM_P pstr, bool* ptr) { UNUSED(pstr); *ptr ^= true; lcd_refresh(); } + void menu_action_setting_edit_callback_bool(PGM_P pstr, bool* ptr, screenFunc_t callback) { menu_action_setting_edit_bool(pstr, ptr); (*callback)(); } @@ -5694,7 +5694,7 @@ void lcd_setstatus(const char * const message, const bool persist) { lcd_finishstatus(persist); } -void lcd_setstatusPGM(const char * const message, int8_t level) { +void lcd_setstatusPGM(PGM_P const message, int8_t level) { if (level < 0) level = lcd_status_message_level = 0; if (level < lcd_status_message_level) return; lcd_status_message_level = level; @@ -5704,7 +5704,7 @@ void lcd_setstatusPGM(const char * const message, int8_t level) { // that there is no cutting in the middle of a multibyte character! // Get a pointer to the null terminator - const char* pend = message + strlen_P(message); + PGM_P pend = message + strlen_P(message); // If length of supplied UTF8 string is greater than // our buffer size, start cutting whole UTF8 chars @@ -5721,7 +5721,7 @@ void lcd_setstatusPGM(const char * const message, int8_t level) { lcd_finishstatus(level > 0); } -void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...) { +void lcd_status_printf_P(const uint8_t level, PGM_P const fmt, ...) { if (level < lcd_status_message_level) return; lcd_status_message_level = level; va_list args; @@ -5731,7 +5731,7 @@ void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...) { lcd_finishstatus(level > 0); } -void lcd_setalertstatusPGM(const char * const message) { +void lcd_setalertstatusPGM(PGM_P const message) { lcd_setstatusPGM(message, 1); #if ENABLED(ULTIPANEL) lcd_return_to_status(); diff --git a/Marlin/src/lcd/ultralcd.h b/Marlin/src/lcd/ultralcd.h index 2cff09f0e..05376cd2c 100644 --- a/Marlin/src/lcd/ultralcd.h +++ b/Marlin/src/lcd/ultralcd.h @@ -29,12 +29,12 @@ void lcd_init(); bool lcd_detected(); void lcd_update(); - void lcd_setalertstatusPGM(const char* message); + void lcd_setalertstatusPGM(PGM_P message); #else inline void lcd_init() {} inline bool lcd_detected() { return true; } inline void lcd_update() {} - inline void lcd_setalertstatusPGM(const char* message) { UNUSED(message); } + inline void lcd_setalertstatusPGM(PGM_P message) { UNUSED(message); } #endif #if ENABLED(ULTRA_LCD) @@ -49,13 +49,13 @@ void lcd_return_to_status(); bool lcd_hasstatus(); void lcd_setstatus(const char* message, const bool persist=false); - void lcd_setstatusPGM(const char* message, const int8_t level=0); - void lcd_setalertstatusPGM(const char* message); + void lcd_setstatusPGM(PGM_P message, const int8_t level=0); + void lcd_setalertstatusPGM(PGM_P message); void lcd_reset_alert_level(); void lcd_reset_status(); - void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...); + void lcd_status_printf_P(const uint8_t level, PGM_P const fmt, ...); void lcd_kill_screen(); - void kill_screen(const char* lcd_msg); + void kill_screen(PGM_P lcd_msg); extern uint8_t lcdDrawUpdate; inline void lcd_refresh() { lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; } @@ -206,8 +206,8 @@ inline void lcd_refresh() {} inline bool lcd_hasstatus() { return false; } inline void lcd_setstatus(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); } - inline void lcd_setstatusPGM(const char* const message, const int8_t level=0) { UNUSED(message); UNUSED(level); } - inline void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...) { UNUSED(level); UNUSED(fmt); } + inline void lcd_setstatusPGM(PGM_P const message, const int8_t level=0) { UNUSED(message); UNUSED(level); } + inline void lcd_status_printf_P(const uint8_t level, PGM_P const fmt, ...) { UNUSED(level); UNUSED(fmt); } inline void lcd_reset_alert_level() {} inline void lcd_reset_status() {} diff --git a/Marlin/src/lcd/ultralcd_impl_DOGM.h b/Marlin/src/lcd/ultralcd_impl_DOGM.h index 16d6c1199..973283da0 100644 --- a/Marlin/src/lcd/ultralcd_impl_DOGM.h +++ b/Marlin/src/lcd/ultralcd_impl_DOGM.h @@ -408,7 +408,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop } // Draw a static line of text in the same idiom as a menu item - static void lcd_implementation_drawmenu_static(const uint8_t row, const char* pstr, const bool center=true, const bool invert=false, const char* valstr=NULL) { + static void lcd_implementation_drawmenu_static(const uint8_t row, PGM_P pstr, const bool center=true, const bool invert=false, const char* valstr=NULL) { if (lcd_implementation_mark_as_selected(row, invert)) { @@ -428,7 +428,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop } // Draw a generic menu item - static void lcd_implementation_drawmenu_generic(const bool isSelected, const uint8_t row, const char* pstr, const char pre_char, const char post_char) { + static void lcd_implementation_drawmenu_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) { UNUSED(pre_char); if (lcd_implementation_mark_as_selected(row, isSelected)) { @@ -449,7 +449,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ') // Draw a menu item with an editable value - static void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, const char* pstr, const char* const data, const bool pgm) { + static void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) { if (lcd_implementation_mark_as_selected(row, isSelected)) { const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen((char*)data)); uint8_t n = LCD_WIDTH - (START_COL) - 2 - vallen; @@ -469,7 +469,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop #define DRAWMENU_SETTING_EDIT_GENERIC(_src) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, _src) #define DRAW_BOOL_SETTING(sel, row, pstr, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF)) - void lcd_implementation_drawedit(const char* const pstr, const char* const value=NULL) { + void lcd_implementation_drawedit(PGM_P const pstr, const char* const value=NULL) { const uint8_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value); @@ -521,7 +521,7 @@ void lcd_implementation_clear() { } // Automatically cleared by Picture Loop #if ENABLED(SDSUPPORT) - static void _drawmenu_sd(const bool isSelected, const uint8_t row, const char* const pstr, CardReader &theCard, const bool isDir) { + static void _drawmenu_sd(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) { UNUSED(pstr); lcd_implementation_mark_as_selected(row, isSelected); diff --git a/Marlin/src/lcd/ultralcd_impl_HD44780.h b/Marlin/src/lcd/ultralcd_impl_HD44780.h index 61437f5c3..709c88a35 100644 --- a/Marlin/src/lcd/ultralcd_impl_HD44780.h +++ b/Marlin/src/lcd/ultralcd_impl_HD44780.h @@ -347,7 +347,7 @@ void lcd_implementation_clear() { lcd.clear(); } } // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line - void lcd_scroll(const uint8_t col, const uint8_t line, const char* const text, const uint8_t len, const int16_t time) { + void lcd_scroll(const uint8_t col, const uint8_t line, PGM_P const text, const uint8_t len, const int16_t time) { uint8_t slen = utf8_strlen_P(text); if (slen < len) { // Fits into, @@ -360,7 +360,7 @@ void lcd_implementation_clear() { lcd.clear(); } safe_delay(time); } else { - const char* p = text; + PGM_P p = text; int dly = time / MAX(slen, 1); for (uint8_t i = 0; i <= slen; i++) { @@ -387,7 +387,7 @@ void lcd_implementation_clear() { lcd.clear(); } } } - static void logo_lines(const char* const extra) { + static void logo_lines(PGM_P const extra) { int16_t indent = (LCD_WIDTH - 8 - utf8_strlen_P(extra)) / 2; lcd_moveto(indent, 0); lcd_put_wchar('\x00'); lcd_put_u8str_P(PSTR( "------" )); lcd_put_wchar('\x01'); lcd_moveto(indent, 1); lcd_put_u8str_P(PSTR("|Marlin|")); lcd_put_u8str_P(extra); @@ -867,7 +867,7 @@ static void lcd_implementation_status_screen() { #endif // ADVANCED_PAUSE_FEATURE - static void lcd_implementation_drawmenu_static(const uint8_t row, const char* pstr, const bool center=true, const bool invert=false, const char *valstr=NULL) { + static void lcd_implementation_drawmenu_static(const uint8_t row, PGM_P pstr, const bool center=true, const bool invert=false, const char *valstr=NULL) { UNUSED(invert); int8_t n = LCD_WIDTH; lcd_moveto(0, row); @@ -880,7 +880,7 @@ static void lcd_implementation_status_screen() { for (; n > 0; --n) lcd_put_wchar(' '); } - static void lcd_implementation_drawmenu_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char post_char) { + static void lcd_implementation_drawmenu_generic(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) { uint8_t n = LCD_WIDTH - 2; lcd_moveto(0, row); lcd_put_wchar(sel ? pre_char : ' '); @@ -889,7 +889,7 @@ static void lcd_implementation_status_screen() { lcd_put_wchar(post_char); } - static void lcd_implementation_drawmenu_setting_edit_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data) { + static void lcd_implementation_drawmenu_setting_edit_generic(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) { uint8_t n = LCD_WIDTH - 2 - utf8_strlen(data); lcd_moveto(0, row); lcd_put_wchar(sel ? pre_char : ' '); @@ -898,7 +898,7 @@ static void lcd_implementation_status_screen() { while (n--) lcd_put_wchar(' '); lcd_put_u8str(data); } - static void lcd_implementation_drawmenu_setting_edit_generic_P(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data) { + static void lcd_implementation_drawmenu_setting_edit_generic_P(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) { uint8_t n = LCD_WIDTH - 2 - utf8_strlen_P(data); lcd_moveto(0, row); lcd_put_wchar(sel ? pre_char : ' '); @@ -911,7 +911,7 @@ static void lcd_implementation_status_screen() { #define DRAWMENU_SETTING_EDIT_GENERIC(_src) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', _src) #define DRAW_BOOL_SETTING(sel, row, pstr, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF)) - void lcd_implementation_drawedit(const char* pstr, const char* const value=NULL) { + void lcd_implementation_drawedit(PGM_P pstr, const char* const value=NULL) { lcd_moveto(1, 1); lcd_put_u8str_P(pstr); if (value != NULL) { @@ -926,7 +926,7 @@ static void lcd_implementation_status_screen() { #if ENABLED(SDSUPPORT) - static void lcd_implementation_drawmenu_sd(const bool sel, const uint8_t row, const char* const pstr, CardReader &theCard, const uint8_t concat, const char post_char) { + static void lcd_implementation_drawmenu_sd(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const uint8_t concat, const char post_char) { UNUSED(pstr); lcd_moveto(0, row); lcd_put_wchar(sel ? '>' : ' '); @@ -960,11 +960,11 @@ static void lcd_implementation_status_screen() { lcd_put_wchar(post_char); } - static void lcd_implementation_drawmenu_sdfile(const bool sel, const uint8_t row, const char* pstr, CardReader &theCard) { + static void lcd_implementation_drawmenu_sdfile(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard) { lcd_implementation_drawmenu_sd(sel, row, pstr, theCard, 2, ' '); } - static void lcd_implementation_drawmenu_sddirectory(const bool sel, const uint8_t row, const char* pstr, CardReader &theCard) { + static void lcd_implementation_drawmenu_sddirectory(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard) { lcd_implementation_drawmenu_sd(sel, row, pstr, theCard, 2, LCD_STR_FOLDER[0]); } diff --git a/Marlin/src/libs/vector_3.cpp b/Marlin/src/libs/vector_3.cpp index 2ef98a436..0338eb1d5 100644 --- a/Marlin/src/libs/vector_3.cpp +++ b/Marlin/src/libs/vector_3.cpp @@ -82,7 +82,7 @@ void vector_3::apply_rotation(const matrix_3x3 &matrix) { z = _x * matrix.matrix[3 * 0 + 2] + _y * matrix.matrix[3 * 1 + 2] + z * matrix.matrix[3 * 2 + 2]; } -void vector_3::debug(const char * const title) { +void vector_3::debug(PGM_P const title) { serialprintPGM(title); SERIAL_PROTOCOLPGM(" x: "); SERIAL_PROTOCOL_F(x, 6); @@ -143,7 +143,7 @@ matrix_3x3 matrix_3x3::transpose(const matrix_3x3 &original) { return new_matrix; } -void matrix_3x3::debug(const char * const title) { +void matrix_3x3::debug(PGM_P const title) { if (title != NULL) { serialprintPGM(title); SERIAL_EOL(); diff --git a/Marlin/src/libs/vector_3.h b/Marlin/src/libs/vector_3.h index 2922ea707..65276a5d3 100644 --- a/Marlin/src/libs/vector_3.h +++ b/Marlin/src/libs/vector_3.h @@ -57,7 +57,7 @@ struct vector_3 { float get_length() const; vector_3 get_normal() const; - void debug(const char * const title); + void debug(PGM_P const title); void apply_rotation(const matrix_3x3 &matrix); }; @@ -70,7 +70,7 @@ struct matrix_3x3 { void set_to_identity(); - void debug(const char * const title); + void debug(PGM_P const title); }; diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 38f0aae0b..0430abb26 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -366,7 +366,7 @@ void Endstops::event_handler() { prev_hit_state = hit_state; } // Endstops::report_state -static void print_es_state(const bool is_hit, const char * const label=NULL) { +static void print_es_state(const bool is_hit, PGM_P const label=NULL) { if (label) serialprintPGM(label); SERIAL_PROTOCOLPGM(": "); serialprintPGM(is_hit ? PSTR(MSG_ENDSTOP_HIT) : PSTR(MSG_ENDSTOP_OPEN)); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 97b2efeff..20f3c665d 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -435,7 +435,7 @@ bool set_probe_deployed(const bool deploy) { BUZZ(100, 659); BUZZ(100, 698); - const char * const ds_str = deploy ? PSTR(MSG_MANUAL_DEPLOY) : PSTR(MSG_MANUAL_STOW); + PGM_P const ds_str = deploy ? PSTR(MSG_MANUAL_DEPLOY) : PSTR(MSG_MANUAL_STOW); lcd_setstatusPGM(ds_str); serialprintPGM(ds_str); SERIAL_EOL(); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 8fcfc1119..b4f5beb72 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -582,7 +582,7 @@ int Temperature::getHeaterPower(const int heater) { // // Temperature Error Handlers // -void Temperature::_temp_error(const int8_t e, const char * const serial_msg, const char * const lcd_msg) { +void Temperature::_temp_error(const int8_t e, PGM_P const serial_msg, PGM_P const lcd_msg) { static bool killed = false; if (IsRunning()) { SERIAL_ERROR_START(); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 53cdcdb5e..ed37fcd14 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -637,7 +637,7 @@ class Temperature { static float get_pid_output_bed(); #endif - static void _temp_error(const int8_t e, const char * const serial_msg, const char * const lcd_msg); + static void _temp_error(const int8_t e, PGM_P const serial_msg, PGM_P const lcd_msg); static void min_temp_error(const int8_t e); static void max_temp_error(const int8_t e); diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index 2ec747cd4..7e8b07df8 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -67,7 +67,7 @@ typedef struct { - const char * const name; + PGM_P const name; pin_t pin; bool is_digital; } PinInfo;