Browse Source

Use PGM_P for PSTR pointers (#11977)

pull/1/head
Scott Lahteine 6 years ago
committed by GitHub
parent
commit
11ac75edcb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Marlin/src/HAL/HAL_LPC1768/HAL.cpp
  2. 2
      Marlin/src/HAL/HAL_LPC1768/persistent_store_sdcard.cpp
  3. 2
      Marlin/src/Marlin.cpp
  4. 2
      Marlin/src/Marlin.h
  5. 38
      Marlin/src/core/serial.cpp
  6. 52
      Marlin/src/core/serial.h
  7. 4
      Marlin/src/feature/bedlevel/ubl/ubl.cpp
  8. 4
      Marlin/src/feature/bedlevel/ubl/ubl.h
  9. 2
      Marlin/src/feature/tmc_util.cpp
  10. 6
      Marlin/src/gcode/calibrate/G33.cpp
  11. 19
      Marlin/src/gcode/calibrate/M100.cpp
  12. 2
      Marlin/src/gcode/control/M111.cpp
  13. 8
      Marlin/src/gcode/gcode.cpp
  14. 2
      Marlin/src/gcode/gcode.h
  15. 2
      Marlin/src/gcode/host/M115.cpp
  16. 2
      Marlin/src/gcode/parser.h
  17. 8
      Marlin/src/gcode/queue.cpp
  18. 4
      Marlin/src/gcode/queue.h
  19. 8
      Marlin/src/lcd/dogm/status_screen_lite_ST7920.h
  20. 2
      Marlin/src/lcd/dogm/status_screen_lite_ST7920_class.h
  21. 2
      Marlin/src/lcd/fontutils.cpp
  22. 2
      Marlin/src/lcd/fontutils.h
  23. 4
      Marlin/src/lcd/lcdprint.h
  24. 2
      Marlin/src/lcd/lcdprint_hd44780.cpp
  25. 2
      Marlin/src/lcd/lcdprint_u8g.cpp
  26. 4
      Marlin/src/lcd/malyanlcd.cpp
  27. 4
      Marlin/src/lcd/u8g_fontutf8.cpp
  28. 4
      Marlin/src/lcd/u8g_fontutf8.h
  29. 70
      Marlin/src/lcd/ultralcd.cpp
  30. 16
      Marlin/src/lcd/ultralcd.h
  31. 10
      Marlin/src/lcd/ultralcd_impl_DOGM.h
  32. 22
      Marlin/src/lcd/ultralcd_impl_HD44780.h
  33. 4
      Marlin/src/libs/vector_3.cpp
  34. 4
      Marlin/src/libs/vector_3.h
  35. 2
      Marlin/src/module/endstops.cpp
  36. 2
      Marlin/src/module/probe.cpp
  37. 2
      Marlin/src/module/temperature.cpp
  38. 2
      Marlin/src/module/temperature.h
  39. 2
      Marlin/src/pins/pinsDebug.h

2
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) {

2
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);

2
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);

2
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();

38
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]);
}

52
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

4
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();
}

4
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

2
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

6
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:");

19
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 sp<Heap\n", (char*)0x1B80, (char*)0x21FF);
M100_dump_routine(PSTR(" Memory corruption detected with sp<Heap\n"), (char*)0x1B80, (char*)0x21FF);
#endif
}
@ -239,7 +240,7 @@ inline void free_memory_pool_report(char * const ptr, const int32_t size) {
SERIAL_ECHOPAIR("\nLargest free block is ", max_cnt);
SERIAL_ECHOLNPAIR(" bytes at ", hex_address(max_addr));
}
SERIAL_ECHOLNPAIR("check_for_free_memory_corruption() = ", check_for_free_memory_corruption("M100 F "));
SERIAL_ECHOLNPAIR("check_for_free_memory_corruption() = ", check_for_free_memory_corruption(PSTR("M100 F ")));
}
#if ENABLED(M100_FREE_MEMORY_CORRUPTOR)

2
Marlin/src/gcode/control/M111.cpp

@ -38,7 +38,7 @@ void GcodeSuite::M111() {
#endif
;
static const char* const debug_strings[] PROGMEM = {
static PGM_P const debug_strings[] PROGMEM = {
str_debug_1, str_debug_2, str_debug_4, str_debug_8, str_debug_16
#if ENABLED(DEBUG_LEVELING_FEATURE)
, str_debug_32

8
Marlin/src/gcode/gcode.cpp

@ -170,7 +170,7 @@ void GcodeSuite::dwell(millis_t time) {
// Placeholders for non-migrated codes
//
#if ENABLED(M100_FREE_MEMORY_WATCHER)
extern void M100_dump_routine(const char * const title, const char *start, const char *end);
extern void M100_dump_routine(PGM_P const title, const char *start, const char *end);
#endif
/**
@ -700,7 +700,7 @@ void GcodeSuite::process_next_command() {
SERIAL_ECHOLN(current_command);
#if ENABLED(M100_FREE_MEMORY_WATCHER)
SERIAL_ECHOPAIR("slot:", cmd_queue_index_r);
M100_dump_routine(" Command Queue:", (const char*)command_queue, (const char*)(command_queue + sizeof(command_queue)));
M100_dump_routine(PSTR(" Command Queue:"), (const char*)command_queue, (const char*)(command_queue + sizeof(command_queue)));
#endif
}
@ -714,14 +714,14 @@ void GcodeSuite::process_next_command() {
* Run a series of commands, bypassing the command queue to allow
* G-code "macros" to be called from within other G-code handlers.
*/
void GcodeSuite::process_subcommands_now_P(const char *pgcode) {
void GcodeSuite::process_subcommands_now_P(PGM_P pgcode) {
// Save the parser state
char * const saved_cmd = parser.command_ptr;
// Process individual commands in string
while (pgm_read_byte_near(pgcode)) {
// Break up string at '\n' delimiters
const char *delim = strchr_P(pgcode, '\n');
PGM_P const delim = strchr_P(pgcode, '\n');
size_t len = delim ? delim - pgcode : strlen_P(pgcode);
char cmd[len + 1];
strncpy_P(cmd, pgcode, len);

2
Marlin/src/gcode/gcode.h

@ -295,7 +295,7 @@ public:
static void process_next_command();
#if ENABLED(USE_EXECUTE_COMMANDS_IMMEDIATE)
static void process_subcommands_now_P(const char *pgcode);
static void process_subcommands_now_P(PGM_P pgcode);
#endif
FORCE_INLINE static void home_all_axes() { G28(true); }

2
Marlin/src/gcode/host/M115.cpp

@ -28,7 +28,7 @@
#endif
#if ENABLED(EXTENDED_CAPABILITIES_REPORT)
static void cap_line(const char * const name, bool ena=false) {
static void cap_line(PGM_P const name, bool ena=false) {
SERIAL_PROTOCOLPGM("Cap:");
serialprintPGM(name);
SERIAL_CHAR(':');

2
Marlin/src/gcode/parser.h

@ -258,7 +258,7 @@ public:
FORCE_INLINE static char temp_units_code() {
return input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C';
}
FORCE_INLINE static const char* temp_units_name() {
FORCE_INLINE static PGM_P temp_units_name() {
return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius");
}
static inline float to_temp_units(const float &f) {

8
Marlin/src/gcode/queue.cpp

@ -84,7 +84,7 @@ bool send_ok[BUFSIZE];
* Used by Marlin internally to ensure that commands initiated from within
* are enqueued ahead of any pending serial or sd card commands.
*/
static const char *injected_commands_P = NULL;
static PGM_P injected_commands_P = NULL;
void queue_setup() {
// Send "ok" after commands by default
@ -181,7 +181,7 @@ static bool drain_injected_commands_P() {
* Aborts the current queue, if any.
* Note: drain_injected_commands_P() must be called repeatedly to drain the commands afterwards
*/
void enqueue_and_echo_commands_P(const char * const pgcode) {
void enqueue_and_echo_commands_P(PGM_P const pgcode) {
injected_commands_P = pgcode;
(void)drain_injected_commands_P(); // first command executed asap (when possible)
}
@ -197,7 +197,7 @@ void enqueue_and_echo_commands_P(const char * const pgcode) {
/**
* Enqueue from program memory and return only when commands are actually enqueued
*/
void enqueue_and_echo_commands_now_P(const char * const pgcode) {
void enqueue_and_echo_commands_now_P(PGM_P const pgcode) {
enqueue_and_echo_commands_P(pgcode);
while (drain_injected_commands_P()) idle();
}
@ -249,7 +249,7 @@ void flush_and_request_resend() {
ok_to_send();
}
void gcode_line_error(const char* err, uint8_t port) {
void gcode_line_error(PGM_P err, uint8_t port) {
SERIAL_ERROR_START_P(port);
serialprintPGM_P(port, err);
SERIAL_ERRORLN_P(port, gcode_LastN);

4
Marlin/src/gcode/queue.h

@ -90,7 +90,7 @@ void ok_to_send();
* Aborts the current queue, if any.
* Note: drain_injected_commands_P() must be called repeatedly to drain the commands afterwards
*/
void enqueue_and_echo_commands_P(const char * const pgcode);
void enqueue_and_echo_commands_P(PGM_P const pgcode);
/**
* Enqueue with Serial Echo
@ -109,7 +109,7 @@ bool enqueue_and_echo_command(const char* cmd);
/**
* Enqueue from program memory and return only when commands are actually enqueued
*/
void enqueue_and_echo_commands_now_P(const char * const cmd);
void enqueue_and_echo_commands_now_P(PGM_P const cmd);
#endif
#endif

8
Marlin/src/lcd/dogm/status_screen_lite_ST7920.h

@ -75,18 +75,18 @@ void ST7920_Lite_Status_Screen::write_str(const char *str, uint8_t len) {
while (*str && len--) write_byte(*str++);
}
void ST7920_Lite_Status_Screen::write_str_P(const char * const str) {
const char *p_str = (const char *)str;
void ST7920_Lite_Status_Screen::write_str_P(PGM_P const str) {
PGM_P p_str = (PGM_P)str;
while (char c = pgm_read_byte_near(p_str++)) write_byte(c);
}
void ST7920_Lite_Status_Screen::write_str(progmem_str str) {
write_str_P((const char*)str);
write_str_P((PGM_P)str);
}
void ST7920_Lite_Status_Screen::write_number(const int16_t value, const uint8_t digits/*=3*/) {
char str[7];
const char *fmt;
PGM_P fmt;
switch (digits) {
case 6: fmt = PSTR("%6d"); break;
case 5: fmt = PSTR("%5d"); break;

2
Marlin/src/lcd/dogm/status_screen_lite_ST7920_class.h

@ -48,7 +48,7 @@ class ST7920_Lite_Status_Screen {
static void write_str(const char *str);
static void write_str(const char *str, const uint8_t len);
static void write_str_P(const char * const str);
static void write_str_P(PGM_P const str);
static void write_str(progmem_str str);
static void write_number(const int16_t value, const uint8_t digits=3);

2
Marlin/src/lcd/fontutils.cpp

@ -177,7 +177,7 @@ uint8_t utf8_strlen(const char *pstart) {
return utf8_strlen_cb(pstart, read_byte_ram);
}
uint8_t utf8_strlen_P(const char *pstart) {
uint8_t utf8_strlen_P(PGM_P pstart) {
return utf8_strlen_cb(pstart, read_byte_rom);
}

2
Marlin/src/lcd/fontutils.h

@ -44,6 +44,6 @@ uint8_t* get_utf8_value_cb(uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t
/* Returns lenght of string in CHARACTERS, NOT BYTES */
uint8_t utf8_strlen(const char *pstart);
uint8_t utf8_strlen_P(const char *pstart);
uint8_t utf8_strlen_P(PGM_P pstart);
#endif // _FONT_UTILS_H

4
Marlin/src/lcd/lcdprint.h

@ -45,11 +45,11 @@ int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length);
*
* Draw a ROM UTF-8 string
*/
int lcd_put_u8str_max_P(const char * utf8_str_P, pixel_len_t max_length);
int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length);
void lcd_moveto(int col, int row);
inline int lcd_put_u8str_P(const char *str) { return lcd_put_u8str_max_P(str, PIXEL_LEN_NOLIMIT); }
inline int lcd_put_u8str_P(PGM_P str) { return lcd_put_u8str_max_P(str, PIXEL_LEN_NOLIMIT); }
inline int lcd_put_u8str(const char* str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); }

2
Marlin/src/lcd/lcdprint_hd44780.cpp

@ -1036,7 +1036,7 @@ int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
return lcd_put_u8str_max_cb(utf8_str, read_byte_ram, max_length);
}
int lcd_put_u8str_max_P(const char * utf8_str_P, pixel_len_t max_length) {
int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
return lcd_put_u8str_max_cb(utf8_str_P, read_byte_rom, max_length);
}

2
Marlin/src/lcd/lcdprint_u8g.cpp

@ -54,7 +54,7 @@ int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
return ret;
}
int lcd_put_u8str_max_P(const char * utf8_str_P, pixel_len_t max_length) {
int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
unsigned int x = pu8g->getPrintCol(),
y = pu8g->getPrintRow(),
ret = uxg_DrawUtf8StrP(pu8g->getU8g(), x, y, utf8_str_P, max_length);

4
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);

4
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);

4
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)

70
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();

16
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() {}

10
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);

22
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]);
}

4
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();

4
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);
};

2
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));

2
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();

2
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();

2
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);

2
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;

Loading…
Cancel
Save