Use PGM_P for PSTR pointers (#11977)
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user