From 1a8583f4fce492240db5d890825b8edd8217025f Mon Sep 17 00:00:00 2001 From: Robby Candra Date: Wed, 24 Nov 2021 04:19:32 +0700 Subject: [PATCH 001/546] =?UTF-8?q?=F0=9F=90=9B=20Fix=20serial=5Fdata=5Fav?= =?UTF-8?q?ailable=20(#23160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/queue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index d11b2823f2..c638dc17ee 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -281,7 +281,7 @@ void GCodeQueue::flush_and_request_resend(const serial_index_t serial_ind) { static bool serial_data_available(serial_index_t index) { const int a = SERIAL_IMPL.available(index); - #if BOTH(RX_BUFFER_MONITOR, RX_BUFFER_SIZE) + #if ENABLED(RX_BUFFER_MONITOR) && RX_BUFFER_SIZE if (a > RX_BUFFER_SIZE - 2) { PORT_REDIRECT(SERIAL_PORTMASK(index)); SERIAL_ERROR_MSG("RX BUF overflow, increase RX_BUFFER_SIZE: ", a); From 72b99bf1ba24cb9124668b958039b32a164c68cd Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sat, 9 Oct 2021 19:13:19 -0400 Subject: [PATCH 002/546] =?UTF-8?q?=F0=9F=90=9B=20Fix=20IDEX=20Duplication?= =?UTF-8?q?=20Mode=20Positioning=20(#22914)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixing #22538 --- Marlin/src/module/motion.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index a56831c214..c820ce3599 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1194,6 +1194,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { case DXC_DUPLICATION_MODE: if (active_extruder == 0) { // Restore planner to parked head (T1) X position + float x0_pos = current_position.x; xyze_pos_t pos_now = current_position; pos_now.x = inactive_extruder_x; planner.set_position_mm(pos_now); @@ -1201,7 +1202,9 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { // Keep the same X or add the duplication X offset xyze_pos_t new_pos = pos_now; if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) - new_pos.x += duplicate_extruder_x_offset; + new_pos.x = x0_pos + duplicate_extruder_x_offset; + else + new_pos.x = _MIN(X_BED_SIZE - x0_pos, X_MAX_POS); // Move duplicate extruder into the correct position if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Set planner X", inactive_extruder_x, " ... Line to X", new_pos.x); From 170f77fada009bcd77b02edf7b5d55d5173b00e9 Mon Sep 17 00:00:00 2001 From: lukrow80 <64228214+lukrow80@users.noreply.github.com> Date: Tue, 23 Nov 2021 22:30:13 +0100 Subject: [PATCH 003/546] =?UTF-8?q?=F0=9F=90=9B=20Fix=20homing=20current?= =?UTF-8?q?=20for=20extra=20axes=20(#23152)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #19112 --- Marlin/src/gcode/calibrate/G28.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index dc93ba3d2f..01c6050155 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -264,7 +264,7 @@ void GcodeSuite::G28() { reset_stepper_timeout(); #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) - #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z)) + #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || HAS_CURRENT_HOME(I) || HAS_CURRENT_HOME(J) || HAS_CURRENT_HOME(K) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z)) #define HAS_HOMING_CURRENT 1 #endif @@ -292,6 +292,21 @@ void GcodeSuite::G28() { stepperY2.rms_current(Y2_CURRENT_HOME); if (DEBUGGING(LEVELING)) debug_current(PSTR("Y2"), tmc_save_current_Y2, Y2_CURRENT_HOME); #endif + #if HAS_CURRENT_HOME(I) + const int16_t tmc_save_current_I = stepperI.getMilliamps(); + stepperI.rms_current(I_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(AXIS4_STR), tmc_save_current_I, I_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(J) + const int16_t tmc_save_current_J = stepperJ.getMilliamps(); + stepperJ.rms_current(J_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(AXIS5_STR), tmc_save_current_J, J_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(K) + const int16_t tmc_save_current_K = stepperK.getMilliamps(); + stepperK.rms_current(K_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(AXIS6_STR), tmc_save_current_K, K_CURRENT_HOME); + #endif #if HAS_CURRENT_HOME(Z) && ENABLED(DELTA) const int16_t tmc_save_current_Z = stepperZ.getMilliamps(); stepperZ.rms_current(Z_CURRENT_HOME); From 854ce63358f409340863024edd38fb7d1499fd91 Mon Sep 17 00:00:00 2001 From: Robby Candra Date: Sun, 19 Dec 2021 05:33:21 +0700 Subject: [PATCH 004/546] =?UTF-8?q?=F0=9F=90=9B=20Fix=20loud=5Fkill=20heat?= =?UTF-8?q?er=20disable=20(#23314)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 0f6395b127..3a19d60d92 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -953,8 +953,8 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { inline void loud_kill(PGM_P const lcd_msg, const heater_id_t heater_id) { marlin_state = MF_KILLED; + thermalManager.disable_all_heaters(); #if USE_BEEPER - thermalManager.disable_all_heaters(); for (uint8_t i = 20; i--;) { WRITE(BEEPER_PIN, HIGH); delay(25); From 1de265ea5dd09ac4371add0b1bb9c1b595a3c385 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 4 Oct 2021 00:24:41 -0500 Subject: [PATCH 005/546] =?UTF-8?q?=F0=9F=8E=A8=20Axis=20name=20string=20i?= =?UTF-8?q?nterpolation,=20with=20examples=20(#22879)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp | 16 +++++----- Marlin/src/lcd/language/language_cz.h | 3 +- Marlin/src/lcd/language/language_de.h | 3 +- Marlin/src/lcd/language/language_en.h | 15 ++++----- Marlin/src/lcd/language/language_es.h | 3 +- Marlin/src/lcd/language/language_fr.h | 3 +- Marlin/src/lcd/language/language_gl.h | 3 +- Marlin/src/lcd/language/language_hu.h | 3 +- Marlin/src/lcd/language/language_it.h | 5 +-- Marlin/src/lcd/language/language_pl.h | 5 +-- Marlin/src/lcd/language/language_pt_br.h | 3 +- Marlin/src/lcd/language/language_ro.h | 3 +- Marlin/src/lcd/language/language_ru.h | 3 +- Marlin/src/lcd/language/language_sk.h | 6 ++-- Marlin/src/lcd/language/language_sv.h | 3 +- Marlin/src/lcd/language/language_tr.h | 3 +- Marlin/src/lcd/language/language_uk.h | 3 +- Marlin/src/lcd/language/language_zh_CN.h | 3 +- Marlin/src/lcd/language/language_zh_TW.h | 3 +- Marlin/src/lcd/lcdprint.cpp | 6 ++++ Marlin/src/lcd/menu/menu.cpp | 32 ++++++-------------- Marlin/src/lcd/menu/menu.h | 6 ++-- Marlin/src/lcd/menu/menu_configuration.cpp | 8 ++--- Marlin/src/lcd/menu/menu_item.h | 20 ++++++++++-- Marlin/src/lcd/menu/menu_motion.cpp | 24 +++++++-------- Marlin/src/lcd/tft/tft_string.cpp | 21 ++++++------- 26 files changed, 100 insertions(+), 106 deletions(-) diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp b/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp index 89e001b29c..e08d5360db 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp @@ -43,9 +43,11 @@ uint8_t read_byte(uint8_t *byte) { return *byte; } /** * Add a string, applying substitutions for the following characters: * + * $ displays the clipped C-string given by the itemString argument * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) + * @ displays an axis name such as XYZUVW, or E for an extruder */ void DWIN_String::add(uint8_t *string, const int8_t index, uint8_t *itemString/*=nullptr*/) { wchar_t wchar; @@ -62,17 +64,15 @@ void DWIN_String::add(uint8_t *string, const int8_t index, uint8_t *itemString/* if (inum >= 10) { add_character('0' + (inum / 10)); inum %= 10; } add_character('0' + inum); } - else { + else add(index == -2 ? GET_TEXT(MSG_CHAMBER) : GET_TEXT(MSG_BED)); - } - continue; } - else if (ch == '$' && itemString) { + else if (ch == '$' && itemString) add(itemString); - continue; - } - - add_character(ch); + else if (ch == '@') + add_character(axis_codes[index]); + else + add_character(ch); } eol(); } diff --git a/Marlin/src/lcd/language/language_cz.h b/Marlin/src/lcd/language/language_cz.h index 2ee0534f9d..fd064b0834 100644 --- a/Marlin/src/lcd/language/language_cz.h +++ b/Marlin/src/lcd/language/language_cz.h @@ -129,9 +129,8 @@ namespace Language_cz { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplikace"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Zrcadlení"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Plná kontrola"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2. tryska X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2. tryska Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. tryska Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. tryska @"); LSTR MSG_UBL_DOING_G29 = _UxGT("Provádím G29"); LSTR MSG_UBL_TOOLS = _UxGT("UBL nástroje"); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 4aef4ac45c..8160ad4724 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -121,9 +121,8 @@ namespace Language_de { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplizieren"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Spiegelkopie"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("vollstä. Kontrolle"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2. Düse X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2. Düse Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. Düse Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. Düse @"); LSTR MSG_UBL_DOING_G29 = _UxGT("G29 ausführen"); LSTR MSG_UBL_TOOLS = _UxGT("UBL-Werkzeuge"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 8c7a78cd46..c9413d3cea 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -30,9 +30,11 @@ * Substitutions are applied for the following characters when used * in menu items that call lcd_put_u8str_ind_P with an index: * + * $ displays an inserted C-string * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) + * @ displays an axis name such as XYZUVW, or E for an extruder */ #define en 1234 @@ -72,12 +74,7 @@ namespace Language_en { LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Progress Bar Test"); LSTR MSG_HOMING = _UxGT("Homing"); LSTR MSG_AUTO_HOME = _UxGT("Auto Home"); - LSTR MSG_AUTO_HOME_X = _UxGT("Home X"); - LSTR MSG_AUTO_HOME_Y = _UxGT("Home Y"); - LSTR MSG_AUTO_HOME_Z = _UxGT("Home Z"); - LSTR MSG_AUTO_HOME_I = _UxGT("Home ") LCD_STR_I; - LSTR MSG_AUTO_HOME_J = _UxGT("Home ") LCD_STR_J; - LSTR MSG_AUTO_HOME_K = _UxGT("Home ") LCD_STR_K; + LSTR MSG_AUTO_HOME_A = _UxGT("Home @"); LSTR MSG_FILAMENT_SET = _UxGT("Filament Settings"); LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); LSTR MSG_LEVBED_FL = _UxGT("Front Left"); @@ -175,9 +172,8 @@ namespace Language_en { LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Mirrored Copy"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Full Control"); LSTR MSG_IDEX_DUPE_GAP = _UxGT("Duplicate X-Gap"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2nd Nozzle X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2nd Nozzle Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2nd Nozzle Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2nd Nozzle @"); LSTR MSG_UBL_DOING_G29 = _UxGT("Doing G29"); LSTR MSG_UBL_TOOLS = _UxGT("UBL Tools"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); @@ -279,7 +275,7 @@ namespace Language_en { LSTR MSG_MOVING = _UxGT("Moving..."); LSTR MSG_FREE_XY = _UxGT("Free XY"); - LSTR MSG_MOVE_X = _UxGT("Move X"); + LSTR MSG_MOVE_X = _UxGT("Move X"); // Used by draw_edit_screen LSTR MSG_MOVE_Y = _UxGT("Move Y"); LSTR MSG_MOVE_Z = _UxGT("Move Z"); LSTR MSG_MOVE_I = _UxGT("Move ") LCD_STR_I; @@ -303,6 +299,7 @@ namespace Language_en { LSTR MSG_MAXSPEED_Y = _UxGT("Max ") LCD_STR_B _UxGT(" Speed"); LSTR MSG_MAXSPEED_Z = _UxGT("Max ") LCD_STR_C _UxGT(" Speed"); LSTR MSG_MAXSPEED_E = _UxGT("Max ") LCD_STR_E _UxGT(" Speed"); + LSTR MSG_MAXSPEED_A = _UxGT("Max @ Speed"); LSTR MSG_BED_Z = _UxGT("Bed Z"); LSTR MSG_NOZZLE = _UxGT("Nozzle"); LSTR MSG_NOZZLE_N = _UxGT("Nozzle ~"); diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index 315a8413df..62dd69b526 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -124,9 +124,8 @@ namespace Language_es { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplicar"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Copia Reflejada"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Control Total"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2ª Fusor X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2ª Fusor Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2ª Fusor Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2ª Fusor @"); LSTR MSG_UBL_DOING_G29 = _UxGT("Hacer G29"); LSTR MSG_UBL_TOOLS = _UxGT("Herramientas UBL"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Nivelado UBL"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index a99659bf18..77472e4fbb 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -134,9 +134,8 @@ namespace Language_fr { LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Copie miroir"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Contrôle complet"); LSTR MSG_OFFSETS_MENU = _UxGT("Offsets Outil"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("Buse 2 X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("Buse 2 Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("Buse 2 Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("Buse 2 @"); LSTR MSG_G26_HEATING_BED = _UxGT("G26: Chauffage du lit"); LSTR MSG_G26_HEATING_NOZZLE = _UxGT("Buse en chauffe..."); LSTR MSG_G26_MANUAL_PRIME = _UxGT("Amorce manuelle..."); diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index ad85ac9b48..0252cf30ec 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -121,9 +121,8 @@ namespace Language_gl { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplicación"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Copia Espello"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Control Total"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2º Bico X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2º Bico Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2º Bico Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2º Bico @"); LSTR MSG_UBL_DOING_G29 = _UxGT("Executando G29"); LSTR MSG_UBL_TOOLS = _UxGT("Ferramentas UBL"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index 2c06a51c19..4028ab10cd 100644 --- a/Marlin/src/lcd/language/language_hu.h +++ b/Marlin/src/lcd/language/language_hu.h @@ -156,9 +156,8 @@ namespace Language_hu { LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Tükrözött másolás"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Teljes felügyelet"); LSTR MSG_IDEX_DUPE_GAP = _UxGT("X-hézag másolása"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2. fej X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2. fej Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. fej Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. fej @"); LSTR MSG_UBL_DOING_G29 = _UxGT("Szintezz! G29"); LSTR MSG_UBL_TOOLS = _UxGT("UBL eszköz"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Egységes ágy szint"); diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index e005567985..2e2529a845 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -30,9 +30,11 @@ * Substitutions are applied for the following characters when used * in menu items that call lcd_put_u8str_ind_P with an index: * + * $ displays an inserted C-string * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) + * @ displays an axis name such as XYZUVW, or E for an extruder */ #define DISPLAY_CHARSET_ISO10646_1 @@ -160,9 +162,8 @@ namespace Language_it { LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Copia speculare"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Pieno controllo"); LSTR MSG_IDEX_DUPE_GAP = _UxGT("X-Gap-X duplicato"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2° ugello X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2° ugello Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2° ugello Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2° ugello @"); LSTR MSG_UBL_DOING_G29 = _UxGT("G29 in corso"); LSTR MSG_UBL_TOOLS = _UxGT("Strumenti UBL"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Livel.letto unificato"); diff --git a/Marlin/src/lcd/language/language_pl.h b/Marlin/src/lcd/language/language_pl.h index b37e1d80cf..2dde747378 100644 --- a/Marlin/src/lcd/language/language_pl.h +++ b/Marlin/src/lcd/language/language_pl.h @@ -30,9 +30,11 @@ * Substitutions are applied for the following characters when used * in menu items that call lcd_put_u8str_ind_P with an index: * + * $ displays an inserted C-string * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) + * @ displays an axis name such as XYZUVW, or E for an extruder */ #define DISPLAY_CHARSET_ISO10646_PL @@ -133,9 +135,8 @@ namespace Language_pl { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplikowanie"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Kopia lustrzana"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Pełne sterowanie"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2ga dysza X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2ga dysza Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2ga dysza Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2ga dysza @"); LSTR MSG_UBL_DOING_G29 = _UxGT("Wykonywanie G29"); LSTR MSG_UBL_TOOLS = _UxGT("Narzędzia UBL"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Punkt pochylenia"); diff --git a/Marlin/src/lcd/language/language_pt_br.h b/Marlin/src/lcd/language/language_pt_br.h index 45e1879d4c..7d97d48336 100644 --- a/Marlin/src/lcd/language/language_pt_br.h +++ b/Marlin/src/lcd/language/language_pt_br.h @@ -111,9 +111,8 @@ namespace Language_pt_br { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplicação"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Cópia espelhada"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Controle Total"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2o bico X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2o bico Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2o bico Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2o bico @"); LSTR MSG_UBL_DOING_G29 = _UxGT("Executando G29"); LSTR MSG_UBL_TOOLS = _UxGT("Ferramentas UBL"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Nivel. Mesa Unif."); diff --git a/Marlin/src/lcd/language/language_ro.h b/Marlin/src/lcd/language/language_ro.h index 6db2fe38fa..2eb4c0b996 100644 --- a/Marlin/src/lcd/language/language_ro.h +++ b/Marlin/src/lcd/language/language_ro.h @@ -120,9 +120,8 @@ namespace Language_ro { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplication"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Mirrored Copy"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Full Control"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2nd Nozzle X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2nd Nozzle Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2nd Nozzle Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2nd Nozzle @"); LSTR MSG_UBL_DOING_G29 = _UxGT("Doing G29"); LSTR MSG_UBL_TOOLS = _UxGT("UBL Tools"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index 25ea5fd471..2de45e7d8d 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -197,9 +197,8 @@ namespace Language_ru { LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Полный контроль"); LSTR MSG_IDEX_DUPE_GAP = _UxGT("Дублировать X-зазор"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2-е сопло X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2-е сопло Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2-е сопло Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2-е сопло @"); LSTR MSG_UBL_DOING_G29 = _UxGT("Выполняем G29"); LSTR MSG_UBL_TOOLS = _UxGT("Инструменты UBL"); diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index 3a9eb23a8f..81fb9a3d01 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -34,9 +34,11 @@ * Substitutions are applied for the following characters when used * in menu items that call lcd_put_u8str_ind_P with an index: * + * $ displays an inserted C-string * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) + * @ displays an axis name such as XYZUVW, or E for an extruder */ #define DISPLAY_CHARSET_ISO10646_SK @@ -172,9 +174,8 @@ namespace Language_sk { LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Zrkadlená kópia"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Plná kontrola"); LSTR MSG_IDEX_DUPE_GAP = _UxGT("Duplik. medz.-X"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2. tryska X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2. tryska Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. tryska Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. tryska @"); LSTR MSG_UBL_DOING_G29 = _UxGT("Vykonávam G29"); LSTR MSG_UBL_TOOLS = _UxGT("Nástroje UBL"); LSTR MSG_UBL_LEVEL_BED = _UxGT("UBL rovnanie"); @@ -300,6 +301,7 @@ namespace Language_sk { LSTR MSG_MAXSPEED_Y = _UxGT("Max rýchl. ") LCD_STR_B; LSTR MSG_MAXSPEED_Z = _UxGT("Max rýchl. ") LCD_STR_C; LSTR MSG_MAXSPEED_E = _UxGT("Max rýchl. ") LCD_STR_E; + LSTR MSG_MAXSPEED_A = _UxGT("Max rýchl. @"); LSTR MSG_BED_Z = _UxGT("Výška podl."); LSTR MSG_NOZZLE = _UxGT("Tryska"); LSTR MSG_NOZZLE_N = _UxGT("Tryska ~"); diff --git a/Marlin/src/lcd/language/language_sv.h b/Marlin/src/lcd/language/language_sv.h index 91a842fe2d..3b4d6c24c1 100644 --- a/Marlin/src/lcd/language/language_sv.h +++ b/Marlin/src/lcd/language/language_sv.h @@ -145,9 +145,8 @@ namespace Language_sv { LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Speglad Kopia"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Full Kontroll"); LSTR MSG_IDEX_DUPE_GAP = _UxGT("Duplicera X-Avstånd"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2:a Munstycke X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2:a Munstycke Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2:a Munstycke Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2:a Munstycke @"); LSTR MSG_UBL_DOING_G29 = _UxGT("Utför G29"); LSTR MSG_UBL_TOOLS = _UxGT("UBL Verktyg"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Enad Bädd Nivellering (UBL)"); diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index 9525a952a1..d6f2f52a0c 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -123,9 +123,8 @@ namespace Language_tr { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Kopyala"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Yansıtılmış kopya"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Tam Kontrol"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2. nozul X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2. nozul Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. nozul Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. nozul @"); LSTR MSG_UBL_DOING_G29 = _UxGT("G29 Çalışıyor"); LSTR MSG_UBL_TOOLS = _UxGT("UBL Araçları"); LSTR MSG_UBL_LEVEL_BED = _UxGT("UBL Yatak Hizalama"); diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index 4cfe969307..581a501b49 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -198,9 +198,8 @@ namespace Language_uk { LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Повний контроль"); LSTR MSG_IDEX_DUPE_GAP = _UxGT("Дублюв. X-проміжок"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("Друге сопло X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("Друге сопло Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("Друге сопло Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("Друге сопло @"); LSTR MSG_UBL_DOING_G29 = _UxGT("Виконується G29"); LSTR MSG_UBL_TOOLS = _UxGT("Інструменти UBL"); diff --git a/Marlin/src/lcd/language/language_zh_CN.h b/Marlin/src/lcd/language/language_zh_CN.h index 60ffb27337..afa51689cf 100644 --- a/Marlin/src/lcd/language/language_zh_CN.h +++ b/Marlin/src/lcd/language/language_zh_CN.h @@ -119,9 +119,8 @@ namespace Language_zh_CN { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("复制"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("镜像复制"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("完全控制"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("第二喷头是X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("第二喷头是Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("第二喷头是Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("第二喷头是@"); LSTR MSG_UBL_DOING_G29 = _UxGT("执行G29"); // "Doing G29" LSTR MSG_UBL_TOOLS = _UxGT("UBL工具"); // "UBL Tools" LSTR MSG_UBL_LEVEL_BED = _UxGT("统一热床调平(UBL)"); // "Unified Bed Leveling" diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index fd43fefd29..01b11225e3 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -116,9 +116,8 @@ namespace Language_zh_TW { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplication"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Mirrored Copy"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Full Control"); - LSTR MSG_HOTEND_OFFSET_X = _UxGT("2nd Nozzle X"); - LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2nd Nozzle Y"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2nd Nozzle Z"); + LSTR MSG_HOTEND_OFFSET_A = _UxGT("2nd Nozzle @"); LSTR MSG_UBL_DOING_G29 = _UxGT("執行G29"); // "Doing G29" LSTR MSG_UBL_TOOLS = _UxGT("UBL工具"); // "UBL Tools" LSTR MSG_UBL_LEVEL_BED = _UxGT("統一熱床調平(UBL)"); // "Unified Bed Leveling" diff --git a/Marlin/src/lcd/lcdprint.cpp b/Marlin/src/lcd/lcdprint.cpp index b2c939557d..498b478b12 100644 --- a/Marlin/src/lcd/lcdprint.cpp +++ b/Marlin/src/lcd/lcdprint.cpp @@ -36,9 +36,11 @@ * * Print a string with an index substituted within it: * + * $ displays the clipped C-string given by the inStr argument * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) + * @ displays an axis name such as XYZUVW, or E for an extruder */ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const inStr/*=nullptr*/, const lcd_uint_t maxlen/*=LCD_WIDTH*/) { const uint8_t prop = USE_WIDE_GLYPH ? 2 : 1; @@ -72,6 +74,10 @@ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const i else if (ch == '$' && inStr) { n -= lcd_put_u8str_max_P(inStr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH); } + else if (ch == '@') { + lcd_put_wchar(axis_codes[ind]); + n--; + } else { lcd_put_wchar(ch); n -= ch > 255 ? prop : 1; diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 61a1a16c6a..a24ad883f7 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -103,42 +103,28 @@ void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_b /////////// Menu Editing Actions /////////// //////////////////////////////////////////// -/** - * Functions for editing single values - * - * The "DEFINE_MENU_EDIT_ITEM" macro generates the classes needed to edit a numerical value. - * - * The prerequisite is that in the header the type was already declared: - * - * DEFINE_MENU_EDIT_ITEM_TYPE(int3, int16_t, i16tostr3rj, 1) - * - * For example, DEFINE_MENU_EDIT_ITEM(int3) expands into: - * - * template class TMenuEditItem - * - * You can then use one of the menu macros to present the edit interface: - * EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999) - * - * This expands into a more primitive menu item: - * _MENU_ITEM_P(int3, false, GET_TEXT(MSG_SPEED), &feedrate_percentage, 10, 999) - * - * ...which calls: - * MenuItem_int3::action(plabel, &feedrate_percentage, 10, 999) - * MenuItem_int3::draw(encoderLine == _thisItemNr, _lcdLineNr, plabel, &feedrate_percentage, 10, 999) - */ +// All Edit Screens run the same way, but `draw_edit_screen` is implementation-specific void MenuEditItemBase::edit_screen(strfunc_t strfunc, loadfunc_t loadfunc) { + // Reset repeat_delay for Touch Buttons TERN_(HAS_TOUCH_BUTTONS, ui.repeat_delay = BUTTON_DELAY_EDIT); + // Constrain ui.encoderPosition to 0 ... maxEditValue (calculated in encoder steps) if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0; if (int32_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue; + // If drawing is flagged then redraw the (whole) edit screen if (ui.should_draw()) draw_edit_screen(strfunc(ui.encoderPosition + minEditValue)); + // If there was a click or "live editing" and encoder moved... if (ui.lcd_clicked || (liveEdit && ui.should_draw())) { + // Pass the editValue pointer to the loadfunc along with the encoder plus min if (editValue) loadfunc(editValue, ui.encoderPosition + minEditValue); + // If a callbackFunc was set, call it for click or always for "live editing" if (callbackFunc && (liveEdit || ui.lcd_clicked)) (*callbackFunc)(); + // Use up the click to finish editing and go to the previous screen if (ui.use_click()) ui.goto_previous_screen(); } } +// Going to an edit screen sets up some persistent values first void MenuEditItemBase::goto_edit_screen( PGM_P const el, // Edit label void * const ev, // Edit value pointer diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 50842dcaf8..44b0e89aca 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -60,7 +60,9 @@ class MenuItemBase { // Store the index of the item ahead of use by indexed items FORCE_INLINE static void init(const int8_t ind=0, PGM_P const pstr=nullptr) { itemIndex = ind; itemString = pstr; } + // Implementation-specific: // Draw an item either selected (pre_char) or not (space) with post_char + // Menus may set up itemIndex, itemString and pass them to string-building or string-emitting functions static void _draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char); // Draw an item either selected ('>') or not (space) with post_char @@ -167,11 +169,11 @@ class MenuEditItemBase : public MenuItemBase { ); static void edit_screen(strfunc_t, loadfunc_t); // Edit value handler public: - // Implemented for HD44780 and DOGM + // Implementation-specific: // Draw the current item at specified row with edit data static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const inStr, const bool pgm=false); - // Implemented for HD44780 and DOGM + // Implementation-specific: // This low-level method is good to draw from anywhere static void draw_edit_screen(PGM_P const pstr, const char * const value); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index c9227724ab..7021a0e667 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -174,12 +174,12 @@ void menu_advanced_settings(); START_MENU(); BACK_ITEM(MSG_CONFIGURATION); #if ENABLED(DUAL_X_CARRIAGE) - EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_X, &hotend_offset[1].x, float(X2_HOME_POS - 25), float(X2_HOME_POS + 25), _recalc_offsets); + EDIT_ITEM_FAST_N(float42_52, X_AXIS, MSG_HOTEND_OFFSET_A, &hotend_offset[1].x, float(X2_HOME_POS - 25), float(X2_HOME_POS + 25), _recalc_offsets); #else - EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_X, &hotend_offset[1].x, -99.0, 99.0, _recalc_offsets); + EDIT_ITEM_FAST_N(float42_52, X_AXIS, MSG_HOTEND_OFFSET_A, &hotend_offset[1].x, -99.0, 99.0, _recalc_offsets); #endif - EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_Y, &hotend_offset[1].y, -99.0, 99.0, _recalc_offsets); - EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_Z, &hotend_offset[1].z, Z_PROBE_LOW_POINT, 10.0, _recalc_offsets); + EDIT_ITEM_FAST_N(float42_52, Y_AXIS, MSG_HOTEND_OFFSET_A, &hotend_offset[1].y, -99.0, 99.0, _recalc_offsets); + EDIT_ITEM_FAST_N(float42_52, Z_AXIS, MSG_HOTEND_OFFSET_A, &hotend_offset[1].z, Z_PROBE_LOW_POINT, 10.0, _recalc_offsets); #if ENABLED(EEPROM_SETTINGS) ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings); #endif diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 0a4f4bb7d1..a2f7c5bec2 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -106,9 +106,23 @@ class TMenuEditItem : MenuEditItemBase { } }; -// Provide a set of Edit Item Types which encompass a primitive -// type, a string function, and a scale factor for edit and display. -// These items call the Edit Item draw method passing the prepared string. +/** + * DEFINE_MENU_EDIT_ITEM_TYPE(int3, int16_t, i16tostr3rj, 1) + * + * Define struct types for use by EDIT_ITEM(...) macros, which encompass + * a primitive storage type, a string function, and a scale factor for edit / display. + * The EDIT_ITEM macros take care of calling action and draw methods as needed. + * + * For example, DEFINE_MENU_EDIT_ITEM_TYPE(percent, uint8_t, ui8tostr4pctrj, 100.f/255.f, +0.5f) expands into: + * + * struct MenuEditItemInfo_percent { + * typedef uint8_t type_t; + * static inline float scale(const_float_t value) { return value * (100.f/255.f) +0.5f; } + * static inline float unscale(const_float_t value) { return value / (100.f/255.f) +0.5f; } + * static inline const char* strfunc(const_float_t value) { return ui8tostr4pctrj(_DOFIX(uint8_t,value)); } + * }; + * typedef TMenuEditItem MenuItem_percent + */ #define __DOFIXfloat PROBE() #define _DOFIX(TYPE,V) TYPE(TERN(IS_PROBE(__DOFIX##TYPE),FIXFLOAT(V),(V))) #define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, ETC...) \ diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 948c8807b2..7191e637d1 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -329,21 +329,21 @@ void menu_move() { BACK_ITEM(MSG_MOTION); GCODES_ITEM(MSG_AUTO_HOME, G28_STR); - GCODES_ITEM(MSG_AUTO_HOME_X, PSTR("G28X")); + GCODES_ITEM_N(X_AXIS, MSG_AUTO_HOME_A, PSTR("G28X")); #if HAS_Y_AXIS - GCODES_ITEM(MSG_AUTO_HOME_Y, PSTR("G28Y")); + GCODES_ITEM_N(Y_AXIS, MSG_AUTO_HOME_A, PSTR("G28Y")); #endif #if HAS_Z_AXIS - GCODES_ITEM(MSG_AUTO_HOME_Z, PSTR("G28Z")); + GCODES_ITEM_N(Z_AXIS, MSG_AUTO_HOME_A, PSTR("G28Z")); #endif #if LINEAR_AXES >= 4 - GCODES_ITEM(MSG_AUTO_HOME_I, PSTR("G28" AXIS4_STR)); + GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS4_STR)); #endif #if LINEAR_AXES >= 5 - GCODES_ITEM(MSG_AUTO_HOME_J, PSTR("G28" AXIS5_STR)); + GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS5_STR)); #endif #if LINEAR_AXES >= 6 - GCODES_ITEM(MSG_AUTO_HOME_K, PSTR("G28" AXIS6_STR)); + GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS6_STR)); #endif END_MENU(); @@ -382,21 +382,21 @@ void menu_motion() { #else GCODES_ITEM(MSG_AUTO_HOME, G28_STR); #if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU) - GCODES_ITEM(MSG_AUTO_HOME_X, PSTR("G28X")); + GCODES_ITEM_N(X_AXIS, MSG_AUTO_HOME_A, PSTR("G28X")); #if HAS_Y_AXIS - GCODES_ITEM(MSG_AUTO_HOME_Y, PSTR("G28Y")); + GCODES_ITEM_N(Y_AXIS, MSG_AUTO_HOME_A, PSTR("G28Y")); #endif #if HAS_Z_AXIS - GCODES_ITEM(MSG_AUTO_HOME_Z, PSTR("G28Z")); + GCODES_ITEM_N(Z_AXIS, MSG_AUTO_HOME_A, PSTR("G28Z")); #endif #if LINEAR_AXES >= 4 - GCODES_ITEM(MSG_AUTO_HOME_I, PSTR("G28" AXIS4_STR)); + GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS4_STR)); #endif #if LINEAR_AXES >= 5 - GCODES_ITEM(MSG_AUTO_HOME_J, PSTR("G28" AXIS5_STR)); + GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS5_STR)); #endif #if LINEAR_AXES >= 6 - GCODES_ITEM(MSG_AUTO_HOME_K, PSTR("G28" AXIS6_STR)); + GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS6_STR)); #endif #endif #endif diff --git a/Marlin/src/lcd/tft/tft_string.cpp b/Marlin/src/lcd/tft/tft_string.cpp index 6f2d8690b2..d5ccfe323a 100644 --- a/Marlin/src/lcd/tft/tft_string.cpp +++ b/Marlin/src/lcd/tft/tft_string.cpp @@ -89,11 +89,13 @@ uint8_t read_byte(uint8_t *byte) { return *byte; } /** * Add a string, applying substitutions for the following characters: * + * $ displays an inserted C-string given by the itemString parameter * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) + * @ displays an axis name such as XYZUVW, or E for an extruder */ -void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString) { +void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString/*=nullptr*/) { wchar_t wchar; while (*string) { @@ -108,17 +110,15 @@ void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString) { if (inum >= 10) { add_character('0' + (inum / 10)); inum %= 10; } add_character('0' + inum); } - else { + else add(index == -2 ? GET_TEXT(MSG_CHAMBER) : GET_TEXT(MSG_BED)); - } - continue; } - else if (ch == '$' && itemString) { + else if (ch == '$' && itemString) add(itemString); - continue; - } - - add_character(ch); + else if (ch == '@') + add_character(axis_codes[index]); + else + add_character(ch); } eol(); } @@ -150,9 +150,8 @@ void TFT_String::rtrim(uint8_t character) { span -= glyph(data[length])->DWidth; eol(); } - else { + else break; - } } } From 433a27e475584e73195a89d59ed5ecc20303d53d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 25 Sep 2021 18:22:37 -0500 Subject: [PATCH 006/546] =?UTF-8?q?=F0=9F=8E=A8=20Update=20F=20string=20de?= =?UTF-8?q?clarations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/shared/Marduino.h | 7 +++++++ Marlin/src/HAL/shared/progmem.h | 3 ++- Marlin/src/core/types.h | 7 ------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Marlin/src/HAL/shared/Marduino.h b/Marlin/src/HAL/shared/Marduino.h index ddc3451fbe..3b5a68a373 100644 --- a/Marlin/src/HAL/shared/Marduino.h +++ b/Marlin/src/HAL/shared/Marduino.h @@ -87,3 +87,10 @@ #endif #include "progmem.h" + +class __FlashStringHelper; +typedef const __FlashStringHelper* FSTR_P; +#ifndef FPSTR + #define FPSTR(S) (reinterpret_cast(S)) +#endif +#define FTOP(S) (reinterpret_cast(S)) diff --git a/Marlin/src/HAL/shared/progmem.h b/Marlin/src/HAL/shared/progmem.h index 539d02705e..a76b379bb8 100644 --- a/Marlin/src/HAL/shared/progmem.h +++ b/Marlin/src/HAL/shared/progmem.h @@ -38,7 +38,8 @@ #define PSTR(str) (str) #endif #ifndef F -#define F(str) (str) +class __FlashStringHelper; +#define F(str) (reinterpret_cast(PSTR(str))) #endif #ifndef _SFR_BYTE #define _SFR_BYTE(n) (n) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index e11a6cd03e..72099fb408 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -26,13 +26,6 @@ #include "../inc/MarlinConfigPre.h" -class __FlashStringHelper; -typedef const __FlashStringHelper* FSTR_P; -#ifndef FPSTR - #define FPSTR(S) (reinterpret_cast(S)) -#endif -#define FTOP(S) (reinterpret_cast(S)) - // // Conditional type assignment magic. For example... // From 2b9ae0cc33a1996cb6dd1092743d4a3123c1d4c1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 25 Sep 2021 18:43:52 -0500 Subject: [PATCH 007/546] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20F()=20to=20G-cod?= =?UTF-8?q?e=20subcommands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 14 +- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 2 +- Marlin/src/feature/power.cpp | 4 +- Marlin/src/feature/powerloss.cpp | 12 +- Marlin/src/gcode/bedlevel/G35.cpp | 2 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 4 +- Marlin/src/gcode/calibrate/G34.cpp | 4 +- Marlin/src/gcode/calibrate/G34_M422.cpp | 2 +- Marlin/src/gcode/calibrate/G425.cpp | 4 +- Marlin/src/gcode/calibrate/G76_M192_M871.cpp | 2 +- Marlin/src/gcode/control/M605.cpp | 2 +- Marlin/src/gcode/feature/L6470/M916-918.cpp | 14 +- Marlin/src/gcode/feature/clean/G12.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 9 +- Marlin/src/gcode/gcode.h | 4 +- Marlin/src/gcode/motion/G2_G3.cpp | 2 +- Marlin/src/gcode/queue.cpp | 8 +- Marlin/src/gcode/sd/M1001.cpp | 6 +- Marlin/src/lcd/e3v2/enhanced/dwin.cpp | 10 +- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 131 +++++++++--------- .../lcd/extui/dgus/mks/DGUSScreenHandler.cpp | 2 +- .../generic/spinner_dialog_box.cpp | 2 +- .../lcd/extui/mks_ui/draw_baby_stepping.cpp | 12 +- .../lcd/extui/mks_ui/draw_filament_change.cpp | 2 +- .../src/lcd/extui/mks_ui/draw_number_key.cpp | 2 +- Marlin/src/lcd/extui/mks_ui/draw_printing.cpp | 2 +- .../lcd/extui/mks_ui/printer_operation.cpp | 4 +- Marlin/src/module/tool_change.cpp | 6 +- 28 files changed, 136 insertions(+), 134 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 00cb5ed738..7b2280fcde 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -281,10 +281,10 @@ bool unified_bed_leveling::sanity_check() { } #endif - process_subcommands_now_P(G28_STR); // Home - process_subcommands_now_P(PSTR(ALIGN_GCODE "\n" // Align multi z axis if available - PROBE_GCODE "\n" // Build mesh with available hardware - "G29P3\nG29P3")); // Ensure mesh is complete by running smart fill twice + process_subcommands_now(FPSTR(G28_STR)); // Home + process_subcommands_now(F(ALIGN_GCODE "\n" // Align multi z axis if available + PROBE_GCODE "\n" // Build mesh with available hardware + "G29P3\nG29P3")); // Ensure mesh is complete by running smart fill twice if (parser.seenval('S')) { char umw_gcode[32]; @@ -292,9 +292,9 @@ bool unified_bed_leveling::sanity_check() { queue.inject(umw_gcode); } - process_subcommands_now_P(PSTR("G29A\nG29F10\n" // Set UBL Active & Fade 10 - "M140S0\nM104S0\n" // Turn off heaters - "M500")); // Store settings + process_subcommands_now(F("G29A\nG29F10\n" // Set UBL Active & Fade 10 + "M140S0\nM104S0\n" // Turn off heaters + "M500")); // Store settings } #endif // UBL_MESH_WIZARD diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 750c63f7c6..9b85b5b972 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -656,7 +656,7 @@ void unified_bed_leveling::G29() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Probe End Script: ", Z_PROBE_END_SCRIPT); if (probe_deployed) { planner.synchronize(); - gcode.process_subcommands_now_P(PSTR(Z_PROBE_END_SCRIPT)); + gcode.process_subcommands_now(F(Z_PROBE_END_SCRIPT)); } #else UNUSED(probe_deployed); diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index 8116bd2e44..fabe35b989 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -82,7 +82,7 @@ void Power::power_on() { TERN_(HAS_TRINAMIC_CONFIG, safe_delay(PSU_POWERUP_DELAY)); #ifdef PSU_POWERUP_GCODE - GcodeSuite::process_subcommands_now_P(PSTR(PSU_POWERUP_GCODE)); + gcode.process_subcommands_now(F(PSU_POWERUP_GCODE)); #endif } @@ -95,7 +95,7 @@ void Power::power_off() { if (!psu_on) return; #ifdef PSU_POWEROFF_GCODE - GcodeSuite::process_subcommands_now_P(PSTR(PSU_POWEROFF_GCODE)); + gcode.process_subcommands_now(F(PSU_POWEROFF_GCODE)); #endif #if ENABLED(PS_OFF_SOUND) diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 8db31daa40..a551ba4c8b 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -244,7 +244,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW #if POWER_LOSS_RETRACT_LEN // Retract filament now - gcode.process_subcommands_now_P(PSTR("G1 F3000 E-" STRINGIFY(POWER_LOSS_RETRACT_LEN))); + gcode.process_subcommands_now(F("G1 F3000 E-" STRINGIFY(POWER_LOSS_RETRACT_LEN))); #endif #if POWER_LOSS_ZRAISE @@ -337,7 +337,7 @@ void PrintJobRecovery::resume() { #if HAS_LEVELING // Make sure leveling is off before any G92 and G28 - gcode.process_subcommands_now_P(PSTR("M420 S0 Z0")); + gcode.process_subcommands_now(F("M420 S0 Z0")); #endif #if HAS_HEATED_BED @@ -373,7 +373,7 @@ void PrintJobRecovery::resume() { // establish the current position as best we can. // - gcode.process_subcommands_now_P(PSTR("G92.9E0")); // Reset E to 0 + gcode.process_subcommands_now(F("G92.9E0")); // Reset E to 0 #if Z_HOME_TO_MAX @@ -410,7 +410,7 @@ void PrintJobRecovery::resume() { } // Home XY with no Z raise, and also home Z here if Z isn't homing down below. - gcode.process_subcommands_now_P(PSTR("G28R0" TERN_(HOME_XY_ONLY, "XY"))); // No raise during G28 + gcode.process_subcommands_now(F("G28R0" TERN_(HOME_XY_ONLY, "XY"))); // No raise during G28 #endif @@ -513,7 +513,7 @@ void PrintJobRecovery::resume() { // Un-retract if there was a retract at outage #if ENABLED(BACKUP_POWER_SUPPLY) && POWER_LOSS_RETRACT_LEN > 0 - gcode.process_subcommands_now_P(PSTR("G1E" STRINGIFY(POWER_LOSS_RETRACT_LEN) "F3000")); + gcode.process_subcommands_now(F("G1E" STRINGIFY(POWER_LOSS_RETRACT_LEN) "F3000")); #endif // Additional purge on resume if configured @@ -523,7 +523,7 @@ void PrintJobRecovery::resume() { #endif #if ENABLED(NOZZLE_CLEAN_FEATURE) - gcode.process_subcommands_now_P(PSTR("G12")); + gcode.process_subcommands_now(F("G12")); #endif // Move back over to the saved XY diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 8d5c057361..cb634d973b 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -92,7 +92,7 @@ void GcodeSuite::G35() { TERN_(HAS_DUPLICATION_MODE, set_duplication_enabled(false)); // Home only Z axis when X and Y is trusted, otherwise all axes, if needed before this procedure - if (!all_axes_trusted()) process_subcommands_now_P(PSTR("G28Z")); + if (!all_axes_trusted()) process_subcommands_now(F("G28Z")); bool err_break = false; diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 0eb13dba96..03b0450c6b 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -244,7 +244,7 @@ G29_TYPE GcodeSuite::G29() { // Send 'N' to force homing before G29 (internal only) if (parser.seen_test('N')) - process_subcommands_now_P(TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR)); + process_subcommands_now(TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR))); // Don't allow auto-leveling without homing first if (homing_needed_error()) G29_RETURN(false); @@ -882,7 +882,7 @@ G29_TYPE GcodeSuite::G29() { #ifdef Z_PROBE_END_SCRIPT if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Probe End Script: ", Z_PROBE_END_SCRIPT); planner.synchronize(); - process_subcommands_now_P(PSTR(Z_PROBE_END_SCRIPT)); + process_subcommands_now(F(Z_PROBE_END_SCRIPT)); #endif TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedLeveling()); diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp index f335a12311..98a0bdef88 100644 --- a/Marlin/src/gcode/calibrate/G34.cpp +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -47,7 +47,7 @@ void GcodeSuite::G34() { TemporaryGlobalEndstopsState unlock_z(false); #ifdef GANTRY_CALIBRATION_COMMANDS_PRE - gcode.process_subcommands_now_P(PSTR(GANTRY_CALIBRATION_COMMANDS_PRE)); + process_subcommands_now(F(GANTRY_CALIBRATION_COMMANDS_PRE)); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Sub Commands Processed"); #endif @@ -148,7 +148,7 @@ void GcodeSuite::G34() { #ifdef GANTRY_CALIBRATION_COMMANDS_POST if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Running Post Commands"); - gcode.process_subcommands_now_P(PSTR(GANTRY_CALIBRATION_COMMANDS_POST)); + process_subcommands_now(F(GANTRY_CALIBRATION_COMMANDS_POST)); #endif SET_SOFT_ENDSTOP_LOOSE(false); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index dd1dd5622a..63d839c847 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -433,7 +433,7 @@ void GcodeSuite::G34() { // After this operation the z position needs correction set_axis_never_homed(Z_AXIS); // Home Z after the alignment procedure - process_subcommands_now_P(PSTR("G28Z")); + process_subcommands_now(F("G28Z")); #else // Use the probed height from the last iteration to determine the Z height. // z_measured_min is used, because all steppers are aligned to z_measured_min. diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 23a66dd0c5..88c906f493 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -709,7 +709,7 @@ inline void calibrate_all() { void GcodeSuite::G425() { #ifdef CALIBRATION_SCRIPT_PRE - GcodeSuite::process_subcommands_now_P(PSTR(CALIBRATION_SCRIPT_PRE)); + process_subcommands_now(F(CALIBRATION_SCRIPT_PRE)); #endif if (homing_needed_error()) return; @@ -745,7 +745,7 @@ void GcodeSuite::G425() { SET_SOFT_ENDSTOP_LOOSE(false); #ifdef CALIBRATION_SCRIPT_POST - GcodeSuite::process_subcommands_now_P(PSTR(CALIBRATION_SCRIPT_POST)); + process_subcommands_now(F(CALIBRATION_SCRIPT_POST)); #endif } diff --git a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp index 946701050e..0fcd686a06 100644 --- a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp @@ -158,7 +158,7 @@ void GcodeSuite::G76() { return; } - process_subcommands_now_P(G28_STR); + process_subcommands_now(FPSTR(G28_STR)); } remember_feedrate_scaling_off(); diff --git a/Marlin/src/gcode/control/M605.cpp b/Marlin/src/gcode/control/M605.cpp index 08efaab59d..788659e7e2 100644 --- a/Marlin/src/gcode/control/M605.cpp +++ b/Marlin/src/gcode/control/M605.cpp @@ -110,7 +110,7 @@ set_duplication_enabled(false); #ifdef EVENT_GCODE_IDEX_AFTER_MODECHANGE - gcode.process_subcommands_now_P(PSTR(EVENT_GCODE_IDEX_AFTER_MODECHANGE)); + process_subcommands_now(F(EVENT_GCODE_IDEX_AFTER_MODECHANGE)); #endif } else if (!parser.seen('W')) // if no S or W parameter, the DXC mode gets reset to the user's default diff --git a/Marlin/src/gcode/feature/L6470/M916-918.cpp b/Marlin/src/gcode/feature/L6470/M916-918.cpp index ad0a91111d..8d614603ed 100644 --- a/Marlin/src/gcode/feature/L6470/M916-918.cpp +++ b/Marlin/src/gcode/feature/L6470/M916-918.cpp @@ -138,10 +138,10 @@ void GcodeSuite::M916() { do { // turn the motor(s) both directions sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(final_feedrate)); - gcode.process_subcommands_now_P(gcode_string); + process_subcommands_now(gcode_string); sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(final_feedrate)); - gcode.process_subcommands_now_P(gcode_string); + process_subcommands_now(gcode_string); // get the status after the motors have stopped planner.synchronize(); @@ -266,10 +266,10 @@ void GcodeSuite::M917() { DEBUG_ECHOLNPGM(" OCD threshold : ", (OCD_TH_val + 1) * 375); sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(final_feedrate)); - gcode.process_subcommands_now_P(gcode_string); + process_subcommands_now(gcode_string); sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(final_feedrate)); - gcode.process_subcommands_now_P(gcode_string); + process_subcommands_now(gcode_string); planner.synchronize(); @@ -308,7 +308,7 @@ void GcodeSuite::M917() { L64xxManager.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); } DEBUG_ECHOLNPGM("."); - gcode.reset_stepper_timeout(); // keep steppers powered + reset_stepper_timeout(); // keep steppers powered watchdog_refresh(); safe_delay(5000); status_composite_temp = 0; @@ -615,10 +615,10 @@ void GcodeSuite::M918() { DEBUG_ECHOLNPGM("...feedrate = ", current_feedrate); sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(current_feedrate)); - gcode.process_subcommands_now_P(gcode_string); + process_subcommands_now(gcode_string); sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(current_feedrate)); - gcode.process_subcommands_now_P(gcode_string); + process_subcommands_now(gcode_string); planner.synchronize(); diff --git a/Marlin/src/gcode/feature/clean/G12.cpp b/Marlin/src/gcode/feature/clean/G12.cpp index b19932eb98..a0b87b1abc 100644 --- a/Marlin/src/gcode/feature/clean/G12.cpp +++ b/Marlin/src/gcode/feature/clean/G12.cpp @@ -50,7 +50,7 @@ void GcodeSuite::G12() { #ifdef WIPE_SEQUENCE_COMMANDS if (!parser.seen_any()) { - gcode.process_subcommands_now_P(PSTR(WIPE_SEQUENCE_COMMANDS)); + process_subcommands_now(F(WIPE_SEQUENCE_COMMANDS)); return; } #endif diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 126ceadb3b..acc79cb154 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -243,7 +243,7 @@ void GcodeSuite::dwell(millis_t time) { host_action(PSTR(ACTION_ON_G29_RECOVER)); #endif #ifdef G29_RECOVER_COMMANDS - process_subcommands_now_P(PSTR(G29_RECOVER_COMMANDS)); + process_subcommands_now(F(G29_RECOVER_COMMANDS)); #endif } @@ -256,7 +256,7 @@ void GcodeSuite::dwell(millis_t time) { host_action(PSTR(ACTION_ON_G29_FAILURE)); #endif #ifdef G29_FAILURE_COMMANDS - process_subcommands_now_P(PSTR(G29_FAILURE_COMMANDS)); + process_subcommands_now(F(G29_FAILURE_COMMANDS)); #endif #if ENABLED(G29_HALT_ON_FAILURE) #ifdef ACTION_ON_CANCEL @@ -286,7 +286,7 @@ void GcodeSuite::dwell(millis_t time) { TERN_(HOST_PROMPT_SUPPORT, host_action_prompt_end()); #ifdef G29_SUCCESS_COMMANDS - process_subcommands_now_P(PSTR(G29_SUCCESS_COMMANDS)); + process_subcommands_now(F(G29_SUCCESS_COMMANDS)); #endif } @@ -1101,7 +1101,8 @@ void GcodeSuite::process_next_command() { * G-code "macros" to be called from within other G-code handlers. */ -void GcodeSuite::process_subcommands_now_P(PGM_P pgcode) { +void GcodeSuite::process_subcommands_now(FSTR_P fgcode) { + PGM_P pgcode = FTOP(fgcode); char * const saved_cmd = parser.command_ptr; // Save the parser state for (;;) { PGM_P const delim = strchr_P(pgcode, '\n'); // Get address of next newline diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 2173c5cab1..0106f002c2 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -397,11 +397,11 @@ public: static void process_next_command(); // Execute G-code in-place, preserving current G-code parameters - static void process_subcommands_now_P(PGM_P pgcode); + static void process_subcommands_now(FSTR_P fgcode); static void process_subcommands_now(char * gcode); static inline void home_all_axes(const bool keep_leveling=false) { - process_subcommands_now_P(keep_leveling ? G28_STR : TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR)); + process_subcommands_now(keep_leveling ? FPSTR(G28_STR) : TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR))); } #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE) diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index 33167d9dff..0c7bdc7a3a 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -403,7 +403,7 @@ void GcodeSuite::G2_G3(const bool clockwise) { else { #if ENABLED(CNC_WORKSPACE_PLANES) char achar, bchar; - switch (gcode.workspace_plane) { + switch (workspace_plane) { default: case GcodeSuite::PLANE_XY: achar = 'I'; bchar = 'J'; break; case GcodeSuite::PLANE_YZ: achar = 'J'; bchar = 'K'; break; diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index c638dc17ee..a75d4cd816 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -693,8 +693,8 @@ void GCodeQueue::advance() { void GCodeQueue::report_buffer_statistics() { SERIAL_ECHOLNPGM("D576" - " P:", planner.moves_free(), " ", -queue.planner_buffer_underruns, " (", queue.max_planner_buffer_empty_duration, ")" - " B:", BUFSIZE - ring_buffer.length, " ", -queue.command_buffer_underruns, " (", queue.max_command_buffer_empty_duration, ")" + " P:", planner.moves_free(), " ", -planner_buffer_underruns, " (", max_planner_buffer_empty_duration, ")" + " B:", BUFSIZE - ring_buffer.length, " ", -command_buffer_underruns, " (", max_command_buffer_empty_duration, ")" ); command_buffer_underruns = planner_buffer_underruns = 0; max_command_buffer_empty_duration = max_planner_buffer_empty_duration = 0; @@ -717,8 +717,8 @@ void GCodeQueue::advance() { NOLESS(max_planner_buffer_empty_duration, planner_buffer_empty_duration); // if it's longer than the currently tracked max duration, replace it } - if (queue.auto_buffer_report_interval && ELAPSED(ms, queue.next_buffer_report_ms)) { - queue.next_buffer_report_ms = ms + 1000UL * queue.auto_buffer_report_interval; + if (auto_buffer_report_interval && ELAPSED(ms, next_buffer_report_ms)) { + next_buffer_report_ms = ms + 1000UL * auto_buffer_report_interval; PORT_REDIRECT(SERIAL_BOTH); report_buffer_statistics(); PORT_RESTORE(); diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index 032ec1f198..c5003cabac 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -78,10 +78,10 @@ void GcodeSuite::M1001() { // Report total print time const bool long_print = print_job_timer.duration() > 60; - if (long_print) gcode.process_subcommands_now_P(PSTR("M31")); + if (long_print) process_subcommands_now(F("M31")); // Stop the print job timer - gcode.process_subcommands_now_P(PSTR("M77")); + process_subcommands_now(F("M77")); // Set the progress bar "done" state TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress_done()); @@ -105,7 +105,7 @@ void GcodeSuite::M1001() { // Inject SD_FINISHED_RELEASECOMMAND, if any #ifdef SD_FINISHED_RELEASECOMMAND - gcode.process_subcommands_now_P(PSTR(SD_FINISHED_RELEASECOMMAND)); + process_subcommands_now(F(SD_FINISHED_RELEASECOMMAND)); #endif TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished()); diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp b/Marlin/src/lcd/e3v2/enhanced/dwin.cpp index 065dce713b..df0fbfcb6e 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp +++ b/Marlin/src/lcd/e3v2/enhanced/dwin.cpp @@ -2181,7 +2181,7 @@ void SetMoveZto0() { dtostrf(Y_CENTER, 1, 1, str_2) #endif ); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); ui.set_status_P(PSTR("Now adjust Z Offset")); HMI_AudioFeedback(true); @@ -2194,7 +2194,7 @@ void SetPID(celsius_t t, heater_id_t h) { dtostrf(X_CENTER, 1, 1, str_1), dtostrf(Y_CENTER, 1, 1, str_2) ); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); thermalManager.PID_autotune(t, h, HMI_data.PidCycles, true); } @@ -2385,7 +2385,7 @@ void LevBed(uint8_t point) { #if HAS_ONESTEP_LEVELING planner.synchronize(); - gcode.process_subcommands_now_P(PSTR("M420S0\nG28O")); + gcode.process_subcommands_now(F("M420S0\nG28O")); planner.synchronize(); zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW); sprintf_P(cmd, PSTR(fmt), @@ -2411,7 +2411,7 @@ void LevBedC () { LevBed(4); } void ManualMeshStart(){ ui.set_status_P(GET_TEXT(MSG_UBL_BUILD_MESH_MENU)); - gcode.process_subcommands_now_P(PSTR("G28 XYO\nG28 Z\nM211 S0\nG29S1")); + gcode.process_subcommands_now(F("G28 XYO\nG28 Z\nM211 S0\nG29S1")); planner.synchronize(); #ifdef MANUAL_PROBE_START_Z const uint8_t line = CurrentMenu->line(MMeshMoveZItem->pos); @@ -2429,7 +2429,7 @@ void LevBedC () { LevBed(4); } void SetMMeshMoveZ() { SetPFloatOnClick(-1, 1, 2, planner.synchronize, LiveMeshMoveZ);} void ManualMeshContinue(){ - gcode.process_subcommands_now_P(PSTR("G29S2")); + gcode.process_subcommands_now(F("G29S2")); planner.synchronize(); MMeshMoveZItem->draw(CurrentMenu->line(MMeshMoveZItem->pos)); } diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 9f50b2f287..3edd1e919b 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -207,7 +207,7 @@ CrealityDWINClass CrealityDWIN; void manual_value_update(bool undefined=false) { sprintf_P(cmd, PSTR("M421 I%i J%i Z%s %s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1), undefined ? "N" : ""); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); } @@ -267,7 +267,7 @@ CrealityDWINClass CrealityDWIN; void manual_value_update() { sprintf_P(cmd, PSTR("G29 I%i J%i Z%s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); } @@ -283,9 +283,9 @@ CrealityDWINClass CrealityDWIN; else { CrealityDWIN.Popup_Handler(MoveWait); sprintf_P(cmd, PSTR("G0 F300 Z%s"), dtostrf(Z_CLEARANCE_BETWEEN_PROBES, 1, 3, str_1)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); sprintf_P(cmd, PSTR("G42 F4000 I%i J%i"), mesh_x, mesh_y); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); current_position.z = goto_mesh_value ? Z_VALUES_ARR[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); @@ -1132,7 +1132,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } Popup_Handler(FilChange); sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); } #endif } @@ -1172,7 +1172,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_MoveX, F("Home X")); else { Popup_Handler(Home); - gcode.process_subcommands_now_P(PSTR("G28 X")); + gcode.process_subcommands_now(F("G28 X")); planner.synchronize(); Redraw_Menu(); } @@ -1182,7 +1182,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_MoveY, F("Home Y")); else { Popup_Handler(Home); - gcode.process_subcommands_now_P(PSTR("G28 Y")); + gcode.process_subcommands_now(F("G28 Y")); planner.synchronize(); Redraw_Menu(); } @@ -1192,7 +1192,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_MoveZ, F("Home Z")); else { Popup_Handler(Home); - gcode.process_subcommands_now_P(PSTR("G28 Z")); + gcode.process_subcommands_now(F("G28 Z")); planner.synchronize(); Redraw_Menu(); } @@ -1201,7 +1201,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_SetHome, F("Set Home Position")); else { - gcode.process_subcommands_now_P(PSTR("G92 X0 Y0 Z0")); + gcode.process_subcommands_now(F("G92 X0 Y0 Z0")); AudioFeedback(); } break; @@ -1366,14 +1366,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (use_probe) { #if HAS_BED_PROBE sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MIN, 1, 3, str_1), dtostrf(PROBE_Y_MIN, 1, 3, str_2)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); Popup_Handler(ManualProbing); #endif } else { sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(corner_pos, 1, 3, str_1), dtostrf(corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } @@ -1387,14 +1387,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (use_probe) { #if HAS_BED_PROBE sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MIN, 1, 3, str_1), dtostrf(PROBE_Y_MAX, 1, 3, str_2)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); Popup_Handler(ManualProbing); #endif } else { sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(corner_pos, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) - corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } @@ -1408,14 +1408,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (use_probe) { #if HAS_BED_PROBE sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MAX, 1, 3, str_1), dtostrf(PROBE_Y_MAX, 1, 3, str_2)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); Popup_Handler(ManualProbing); #endif } else { sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf((X_BED_SIZE + X_MIN_POS) - corner_pos, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) - corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } @@ -1429,14 +1429,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (use_probe) { #if HAS_BED_PROBE sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MAX, 1, 3, str_1), dtostrf(PROBE_Y_MIN, 1, 3, str_2)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); Popup_Handler(ManualProbing); #endif } else { sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf((X_BED_SIZE + X_MIN_POS) - corner_pos, 1, 3, str_1), dtostrf(corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } @@ -1450,14 +1450,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (use_probe) { #if HAS_BED_PROBE sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(X_MAX_POS / 2.0f - probe.offset.x, 1, 3, str_1), dtostrf(Y_MAX_POS / 2.0f - probe.offset.y, 1, 3, str_2)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); Popup_Handler(ManualProbing); #endif } else { sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } @@ -1500,16 +1500,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_Homing, F("Home Z Axis")); else { Popup_Handler(Home); - gcode.process_subcommands_now_P(PSTR("G28 Z")); + gcode.process_subcommands_now(F("G28 Z")); Popup_Handler(MoveWait); #if ENABLED(Z_SAFE_HOMING) planner.synchronize(); sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 3, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 3, str_2)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); #else - gcode.process_subcommands_now_P(PSTR("G0 F4000 X117.5 Y117.5")); + gcode.process_subcommands_now(F("G0 F4000 X117.5 Y117.5")); #endif - gcode.process_subcommands_now_P(PSTR("G0 F300 Z0")); + gcode.process_subcommands_now(F("G0 F300 Z0")); planner.synchronize(); Redraw_Menu(); } @@ -1529,11 +1529,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(Z_SAFE_HOMING) planner.synchronize(); sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 3, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 3, str_2)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); #else - gcode.process_subcommands_now_P(PSTR("G0 F4000 X117.5 Y117.5")); + gcode.process_subcommands_now(F("G0 F4000 X117.5 Y117.5")); #endif - gcode.process_subcommands_now_P(PSTR("G0 F300 Z0")); + gcode.process_subcommands_now(F("G0 F300 Z0")); planner.synchronize(); Redraw_Menu(); } @@ -1555,7 +1555,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ else { if (zoffsetvalue < MAX_Z_OFFSET) { if (liveadjust) { - gcode.process_subcommands_now_P(PSTR("M290 Z0.01")); + gcode.process_subcommands_now(F("M290 Z0.01")); planner.synchronize(); } zoffsetvalue += 0.01; @@ -1569,7 +1569,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ else { if (zoffsetvalue > MIN_Z_OFFSET) { if (liveadjust) { - gcode.process_subcommands_now_P(PSTR("M290 Z-0.01")); + gcode.process_subcommands_now(F("M290 Z-0.01")); planner.synchronize(); } zoffsetvalue -= 0.01; @@ -1737,7 +1737,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ thermalManager.wait_for_hotend(0); } Popup_Handler(FilLoad); - gcode.process_subcommands_now_P(PSTR("M701")); + gcode.process_subcommands_now(F("M701")); planner.synchronize(); Redraw_Menu(); } @@ -1756,7 +1756,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ thermalManager.wait_for_hotend(0); } Popup_Handler(FilLoad, true); - gcode.process_subcommands_now_P(PSTR("M702")); + gcode.process_subcommands_now(F("M702")); planner.synchronize(); Redraw_Menu(); } @@ -1775,7 +1775,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } Popup_Handler(FilChange); sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); } } break; @@ -2032,7 +2032,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ else { Popup_Handler(PIDWait); sprintf_P(cmd, PSTR("M303 E0 C%i S%i U1"), PID_cycles, PID_e_temp); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } @@ -2099,7 +2099,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ else { Popup_Handler(PIDWait); sprintf_P(cmd, PSTR("M303 E-1 C%i S%i U1"), PID_cycles, PID_bed_temp); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); planner.synchronize(); Redraw_Menu(); } @@ -3045,7 +3045,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_StepY, F("M48 Probe Test")); else { sprintf_P(cmd, PSTR("G28O\nM48 X%s Y%s P%i"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2), testcount); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); } break; case PROBE_TEST_COUNT: @@ -3157,11 +3157,12 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Popup_Handler(Home); gcode.home_all_axes(true); Popup_Handler(Level); - if (mesh_conf.tilt_grid > 1) + if (mesh_conf.tilt_grid > 1) { sprintf_P(cmd, PSTR("G29 J%i"), mesh_conf.tilt_grid); + gcode.process_subcommands_now(cmd); + } else - sprintf_P(cmd, PSTR("G29 J")); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(F("G29 J")); planner.synchronize(); Redraw_Menu(); } @@ -3189,8 +3190,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif #if HAS_BED_PROBE Popup_Handler(Level); - gcode.process_subcommands_now_P(PSTR("G29 P0\nG29 P1")); - gcode.process_subcommands_now_P(PSTR("G29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nM420 S1")); + gcode.process_subcommands_now(F("G29 P0\nG29 P1")); + gcode.process_subcommands_now(F("G29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nM420 S1")); planner.synchronize(); Update_Status("Probed all reachable points"); Popup_Handler(SaveLevel); @@ -3205,7 +3206,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #endif #elif HAS_BED_PROBE Popup_Handler(Level); - gcode.process_subcommands_now_P(PSTR("G29")); + gcode.process_subcommands_now(F("G29")); planner.synchronize(); Popup_Handler(SaveLevel); #else @@ -3213,7 +3214,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ set_bed_leveling_enabled(false); gridpoint = 1; Popup_Handler(MoveWait); - gcode.process_subcommands_now_P(PSTR("G29")); + gcode.process_subcommands_now(F("G29")); planner.synchronize(); Draw_Menu(ManualMesh); #endif @@ -3296,7 +3297,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Popup_Handler(MeshSlot); break; } - gcode.process_subcommands_now_P(PSTR("G29 L")); + gcode.process_subcommands_now(F("G29 L")); planner.synchronize(); AudioFeedback(true); } @@ -3309,7 +3310,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Popup_Handler(MeshSlot); break; } - gcode.process_subcommands_now_P(PSTR("G29 S")); + gcode.process_subcommands_now(F("G29 S")); planner.synchronize(); AudioFeedback(true); } @@ -3405,7 +3406,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Convert Mesh to Plane")); else { if (mesh_conf.create_plane_from_mesh()) break; - gcode.process_subcommands_now_P(PSTR("M420 S1")); + gcode.process_subcommands_now(F("M420 S1")); planner.synchronize(); AudioFeedback(true); } @@ -3513,7 +3514,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_Axis, F("Microstep Up")); else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) { Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01; - gcode.process_subcommands_now_P(PSTR("M290 Z0.01")); + gcode.process_subcommands_now(F("M290 Z0.01")); planner.synchronize(); current_position.z += 0.01f; sync_plan_position(); @@ -3525,7 +3526,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_AxisD, F("Microstep Down")); else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) { Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01; - gcode.process_subcommands_now_P(PSTR("M290 Z-0.01")); + gcode.process_subcommands_now(F("M290 Z-0.01")); planner.synchronize(); current_position.z -= 0.01f; sync_plan_position(); @@ -3596,7 +3597,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ mesh_conf.manual_move(); } else { - gcode.process_subcommands_now_P(PSTR("G29 S")); + gcode.process_subcommands_now(F("G29 S")); planner.synchronize(); AudioFeedback(true); Draw_Menu(Leveling, LEVELING_GET_MESH); @@ -3634,7 +3635,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_Axis, F("Microstep Up")); else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) { Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01; - gcode.process_subcommands_now_P(PSTR("M290 Z0.01")); + gcode.process_subcommands_now(F("M290 Z0.01")); planner.synchronize(); current_position.z += 0.01f; sync_plan_position(); @@ -3646,7 +3647,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_Axis, F("Microstep Down")); else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) { Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01; - gcode.process_subcommands_now_P(PSTR("M290 Z-0.01")); + gcode.process_subcommands_now(F("M290 Z-0.01")); planner.synchronize(); current_position.z -= 0.01f; sync_plan_position(); @@ -3673,7 +3674,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_Back, F("Cancel")); else { - gcode.process_subcommands_now_P(PSTR("G29 A")); + gcode.process_subcommands_now(F("G29 A")); planner.synchronize(); set_bed_leveling_enabled(level_state); Draw_Menu(Leveling, LEVELING_GET_MESH); @@ -3688,13 +3689,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } else if (gridpoint < GRID_MAX_POINTS) { Popup_Handler(MoveWait); - gcode.process_subcommands_now_P(PSTR("G29")); + gcode.process_subcommands_now(F("G29")); planner.synchronize(); gridpoint++; Redraw_Menu(); } else { - gcode.process_subcommands_now_P(PSTR("G29")); + gcode.process_subcommands_now(F("G29")); planner.synchronize(); AudioFeedback(settings.save()); Draw_Menu(Leveling, LEVELING_GET_MESH); @@ -3713,7 +3714,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_Axis, F("Microstep Up")); else if (current_position.z < MAX_Z_OFFSET) { - gcode.process_subcommands_now_P(PSTR("M290 Z0.01")); + gcode.process_subcommands_now(F("M290 Z0.01")); planner.synchronize(); current_position.z += 0.01f; sync_plan_position(); @@ -3724,7 +3725,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_AxisD, F("Microstep Down")); else if (current_position.z > MIN_Z_OFFSET) { - gcode.process_subcommands_now_P(PSTR("M290 Z-0.01")); + gcode.process_subcommands_now(F("M290 Z-0.01")); planner.synchronize(); current_position.z -= 0.01f; sync_plan_position(); @@ -3845,7 +3846,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_Axis, F("Z-Offset Up")); else if (zoffsetvalue < MAX_Z_OFFSET) { - gcode.process_subcommands_now_P(PSTR("M290 Z0.01")); + gcode.process_subcommands_now(F("M290 Z0.01")); zoffsetvalue += 0.01; Draw_Float(zoffsetvalue, row - 1, false, 100); } @@ -3854,7 +3855,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_AxisD, F("Z-Offset Down")); else if (zoffsetvalue > MIN_Z_OFFSET) { - gcode.process_subcommands_now_P(PSTR("M290 Z-0.01")); + gcode.process_subcommands_now(F("M290 Z-0.01")); zoffsetvalue -= 0.01; Draw_Float(zoffsetvalue, row - 2, false, 100); } @@ -3932,27 +3933,27 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case Prepare: Popup_Handler(FilChange); sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); break; #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) case ChangeFilament: switch (last_selection) { case CHANGEFIL_LOAD: Popup_Handler(FilLoad); - gcode.process_subcommands_now_P("M701"); + gcode.process_subcommands_now(F("M701")); planner.synchronize(); Redraw_Menu(true, true, true); break; case CHANGEFIL_UNLOAD: Popup_Handler(FilLoad, true); - gcode.process_subcommands_now_P("M702"); + gcode.process_subcommands_now(F("M702")); planner.synchronize(); Redraw_Menu(true, true, true); break; case CHANGEFIL_CHANGE: Popup_Handler(FilChange); sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); break; } break; @@ -4291,7 +4292,7 @@ void CrealityDWINClass::Value_Control() { } else if (active_menu == Tune && selection == TUNE_ZOFFSET) { sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((tempvalue / valueunit - zoffsetvalue), 1, 3, str_1)); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); } if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Ki) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Ki)) tempvalue = scalePID_i(tempvalue); @@ -4490,11 +4491,11 @@ void CrealityDWINClass::Print_Screen_Control() { char cmnd[20]; #if HAS_HEATED_BED cmnd[sprintf_P(cmnd, PSTR("M140 S%i"), pausebed)] = '\0'; - gcode.process_subcommands_now_P(PSTR(cmnd)); + gcode.process_subcommands_now(cmnd); #endif #if HAS_EXTRUDERS cmnd[sprintf_P(cmnd, PSTR("M109 S%i"), pausetemp)] = '\0'; - gcode.process_subcommands_now_P(PSTR(cmnd)); + gcode.process_subcommands_now(cmnd); #endif TERN_(HAS_FAN, thermalManager.fan_speed[0] = pausefan); planner.synchronize(); @@ -4619,7 +4620,7 @@ void CrealityDWINClass::Popup_Control() { } Popup_Handler(FilChange); sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target); - gcode.process_subcommands_now_P(cmd); + gcode.process_subcommands_now(cmd); } } else @@ -4642,7 +4643,7 @@ void CrealityDWINClass::Popup_Control() { case SaveLevel: if (selection == 0) { #if ENABLED(AUTO_BED_LEVELING_UBL) - gcode.process_subcommands_now_P(PSTR("G29 S")); + gcode.process_subcommands_now(F("G29 S")); planner.synchronize(); AudioFeedback(true); #else diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 60c3790882..2ec67b2727 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -262,7 +262,7 @@ void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { void DGUSScreenHandler::SDPrintingFinished() { if (DGUSAutoTurnOff) { queue.exhaust(); - gcode.process_subcommands_now_P(PSTR("M81")); + gcode.process_subcommands_now(F("M81")); } GotoScreen(MKSLCD_SCREEN_PrintDone); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.cpp index 9117bcee10..2493de795a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.cpp @@ -99,7 +99,7 @@ void SpinnerDialogBox::enqueueAndWait(FSTR_P message, char *commands) { } void SpinnerDialogBox::onIdle() { - if (mydata.auto_hide && !commandsInQueue() && TERN1(HOST_KEEPALIVE_FEATURE, GcodeSuite::busy_state == GcodeSuite::NOT_BUSY)) { + if (mydata.auto_hide && !commandsInQueue() && TERN1(HOST_KEEPALIVE_FEATURE, gcode.busy_state == gcode.NOT_BUSY)) { mydata.auto_hide = false; hide(); } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp b/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp index c7e6a62341..65617fa9bb 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp @@ -65,32 +65,32 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_BABY_STEP_X_P: sprintf_P(baby_buf, PSTR("M290 X%s"), dtostrf(babystep_dist, 1, 3, str_1)); - gcode.process_subcommands_now_P(PSTR(baby_buf)); + gcode.process_subcommands_now(F(baby_buf)); has_adjust_z = 1; break; case ID_BABY_STEP_X_N: sprintf_P(baby_buf, PSTR("M290 X%s"), dtostrf(-babystep_dist, 1, 3, str_1)); - gcode.process_subcommands_now_P(PSTR(baby_buf)); + gcode.process_subcommands_now(F(baby_buf)); has_adjust_z = 1; break; case ID_BABY_STEP_Y_P: sprintf_P(baby_buf, PSTR("M290 Y%s"), dtostrf(babystep_dist, 1, 3, str_1)); - gcode.process_subcommands_now_P(PSTR(baby_buf)); + gcode.process_subcommands_now(F(baby_buf)); has_adjust_z = 1; break; case ID_BABY_STEP_Y_N: sprintf_P(baby_buf, PSTR("M290 Y%s"), dtostrf(-babystep_dist, 1, 3, str_1)); - gcode.process_subcommands_now_P(PSTR(baby_buf)); + gcode.process_subcommands_now(F(baby_buf)); has_adjust_z = 1; break; case ID_BABY_STEP_Z_P: sprintf_P(baby_buf, PSTR("M290 Z%s"), dtostrf(babystep_dist, 1, 3, str_1)); - gcode.process_subcommands_now_P(PSTR(baby_buf)); + gcode.process_subcommands_now(F(baby_buf)); has_adjust_z = 1; break; case ID_BABY_STEP_Z_N: sprintf_P(baby_buf, PSTR("M290 Z%s"), dtostrf(-babystep_dist, 1, 3, str_1)); - gcode.process_subcommands_now_P(PSTR(baby_buf)); + gcode.process_subcommands_now(F(baby_buf)); has_adjust_z = 1; break; case ID_BABY_STEP_DIST: diff --git a/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp index 8432c74b1a..61d212303b 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp @@ -94,7 +94,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_FILAMNT_RETURN: #if HAS_MULTI_EXTRUDER if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED) - gcode.process_subcommands_now_P(uiCfg.extruderIndexBak == 1 ? PSTR("T1") : PSTR("T0")); + gcode.process_subcommands_now(uiCfg.extruderIndexBak == 1 ? F("T1") : F("T0")); #endif feedrate_mm_s = (float)uiCfg.moveSpeed_bak; if (uiCfg.print_state == PAUSED) diff --git a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp index a3cb7f6c1c..630bb4efef 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp @@ -404,7 +404,7 @@ static void set_value_confirm() { case z_sensitivity: TERN_(Z_SENSORLESS, stepperZ.homing_threshold(atoi(key_value))); break; case z2_sensitivity: TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(atoi(key_value))); break; } - gcode.process_subcommands_now_P(PSTR("M500")); + gcode.process_subcommands_now(F("M500")); } static void event_handler(lv_obj_t *obj, lv_event_t event) { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp index 58bbbfbd5b..322d0581ca 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp @@ -307,7 +307,7 @@ void setProBarRate() { #if HAS_SUICIDE if (gCfgItems.finish_power_off) { - gcode.process_subcommands_now_P(PSTR("M1001")); + gcode.process_subcommands_now(F("M1001")); queue.inject_P(PSTR("M81")); marlin_state = MF_RUNNING; } diff --git a/Marlin/src/lcd/extui/mks_ui/printer_operation.cpp b/Marlin/src/lcd/extui/mks_ui/printer_operation.cpp index 04d8f16fcc..8f5b89cf34 100644 --- a/Marlin/src/lcd/extui/mks_ui/printer_operation.cpp +++ b/Marlin/src/lcd/extui/mks_ui/printer_operation.cpp @@ -53,7 +53,7 @@ void printer_state_polling() { uiCfg.waitEndMoves = 0; planner.synchronize(); - gcode.process_subcommands_now_P(PSTR("M25")); + gcode.process_subcommands_now(F("M25")); // save the position uiCfg.current_x_position_bak = current_position.x; @@ -93,7 +93,7 @@ void printer_state_polling() { sprintf_P(public_buf_m, PSTR("G1 Z%s"), dtostrf(uiCfg.current_z_position_bak, 1, 1, str_1)); gcode.process_subcommands_now(public_buf_m); } - gcode.process_subcommands_now_P(M24_STR); + gcode.process_subcommands_now(FPSTR(M24_STR)); uiCfg.print_state = WORKING; start_print_time(); diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 8f419205f3..e1998cdb2e 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1310,17 +1310,17 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (ENABLED(EVENT_GCODE_TOOLCHANGE_ALWAYS_RUN) || !no_move) { #ifdef EVENT_GCODE_TOOLCHANGE_T0 if (new_tool == 0) - gcode.process_subcommands_now_P(PSTR(EVENT_GCODE_TOOLCHANGE_T0)); + gcode.process_subcommands_now(F(EVENT_GCODE_TOOLCHANGE_T0)); #endif #ifdef EVENT_GCODE_TOOLCHANGE_T1 if (new_tool == 1) - gcode.process_subcommands_now_P(PSTR(EVENT_GCODE_TOOLCHANGE_T1)); + gcode.process_subcommands_now(F(EVENT_GCODE_TOOLCHANGE_T1)); #endif #ifdef EVENT_GCODE_AFTER_TOOLCHANGE if (TERN1(DUAL_X_CARRIAGE, dual_x_carriage_mode == DXC_AUTO_PARK_MODE)) - gcode.process_subcommands_now_P(PSTR(EVENT_GCODE_AFTER_TOOLCHANGE)); + gcode.process_subcommands_now(F(EVENT_GCODE_AFTER_TOOLCHANGE)); #endif } From 46c53f67307f78fc2a42a926a0b8f1f6db2d7ea9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 25 Sep 2021 21:11:31 -0500 Subject: [PATCH 008/546] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20F()=20to=20G-cod?= =?UTF-8?q?e=20suite=20and=20queue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 10 ++-- Marlin/src/feature/mmu/mmu2.cpp | 2 +- Marlin/src/feature/powerloss.cpp | 2 +- Marlin/src/feature/runout.cpp | 2 +- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 2 +- Marlin/src/gcode/queue.cpp | 8 +-- Marlin/src/gcode/queue.h | 8 +-- Marlin/src/lcd/e3v2/creality/dwin.cpp | 16 +++--- Marlin/src/lcd/e3v2/enhanced/dwin.cpp | 26 ++++----- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 14 ++--- .../src/lcd/extui/dgus/DGUSScreenHandler.cpp | 2 +- .../extui/dgus/fysetc/DGUSScreenHandler.cpp | 4 +- .../extui/dgus/hiprecy/DGUSScreenHandler.cpp | 4 +- .../lcd/extui/dgus/mks/DGUSScreenHandler.cpp | 54 +++++++++---------- .../extui/dgus/origin/DGUSScreenHandler.cpp | 4 +- .../lcd/extui/dgus_reloaded/DGUSRxHandler.cpp | 18 +++---- .../extui/dgus_reloaded/DGUSSetupHandler.cpp | 6 +-- Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp | 2 +- .../src/lcd/extui/mks_ui/draw_extrusion.cpp | 4 +- Marlin/src/lcd/extui/mks_ui/draw_home.cpp | 10 ++-- Marlin/src/lcd/extui/mks_ui/draw_more.cpp | 12 ++--- Marlin/src/lcd/extui/mks_ui/draw_printing.cpp | 2 +- Marlin/src/lcd/extui/mks_ui/draw_set.cpp | 2 +- Marlin/src/lcd/extui/mks_ui/draw_tool.cpp | 2 +- Marlin/src/lcd/extui/mks_ui/wifi_module.cpp | 4 +- Marlin/src/lcd/marlinui.cpp | 6 +-- Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- Marlin/src/lcd/menu/menu_bed_corners.cpp | 2 +- Marlin/src/lcd/menu/menu_bed_leveling.cpp | 8 +-- Marlin/src/lcd/menu/menu_configuration.cpp | 6 +-- Marlin/src/lcd/menu/menu_filament.cpp | 2 +- Marlin/src/lcd/menu/menu_item.h | 6 +-- Marlin/src/lcd/menu/menu_job_recovery.cpp | 2 +- Marlin/src/lcd/menu/menu_main.cpp | 6 +-- Marlin/src/lcd/menu/menu_probe_offset.cpp | 2 +- Marlin/src/lcd/menu/menu_tramming.cpp | 2 +- Marlin/src/lcd/tft/ui_1024x600.cpp | 2 +- Marlin/src/lcd/tft/ui_320x240.cpp | 2 +- Marlin/src/lcd/tft/ui_480x320.cpp | 2 +- 39 files changed, 136 insertions(+), 134 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 1b9c8885b1..6309f9f0d5 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -357,15 +357,15 @@ void startOrResumeJob() { TERN_(POWER_LOSS_RECOVERY, recovery.purge()); #ifdef EVENT_GCODE_SD_ABORT - queue.inject_P(PSTR(EVENT_GCODE_SD_ABORT)); + queue.inject(F(EVENT_GCODE_SD_ABORT)); #endif TERN_(PASSWORD_AFTER_SD_PRINT_ABORT, password.lock_machine()); } inline void finishSDPrinting() { - if (queue.enqueue_one_P(PSTR("M1001"))) { // Keep trying until it gets queued - marlin_state = MF_RUNNING; // Signal to stop trying + if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued + marlin_state = MF_RUNNING; // Signal to stop trying TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine()); TERN_(DGUS_LCD_UI_MKS, ScreenHandler.SDPrintingFinished()); } @@ -493,7 +493,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { if (ELAPSED(ms, next_cub_ms_##N)) { \ next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \ CODE; \ - queue.inject_P(PSTR(BUTTON##N##_GCODE)); \ + queue.inject(F(BUTTON##N##_GCODE)); \ TERN_(HAS_LCD_MENU, ui.quick_feedback()); \ } \ } \ @@ -1521,7 +1521,7 @@ void setup() { #ifdef STARTUP_COMMANDS SETUP_LOG("STARTUP_COMMANDS"); - queue.inject_P(PSTR(STARTUP_COMMANDS)); + queue.inject(F(STARTUP_COMMANDS)); #endif #if ENABLED(HOST_PROMPT_SUPPORT) diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 3727c8c86d..d9a4c07d57 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -842,7 +842,7 @@ void MMU2::set_filament_type(const uint8_t index, const uint8_t filamentType) { } void MMU2::filament_runout() { - queue.inject_P(PSTR(MMU2_FILAMENT_RUNOUT_SCRIPT)); + queue.inject(F(MMU2_FILAMENT_RUNOUT_SCRIPT)); planner.synchronize(); } diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index a551ba4c8b..9808113ecc 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -109,7 +109,7 @@ void PrintJobRecovery::check() { if (card.isMounted()) { load(); if (!valid()) return cancel(); - queue.inject_P(PSTR("M1000S")); + queue.inject(F("M1000S")); } } diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 1c56378359..85280d7cb1 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -140,7 +140,7 @@ void event_filament_runout(const uint8_t extruder) { SERIAL_ECHOPGM("Runout Command: "); SERIAL_ECHOLNPGM(FILAMENT_RUNOUT_SCRIPT); #endif - queue.inject_P(PSTR(FILAMENT_RUNOUT_SCRIPT)); + queue.inject(F(FILAMENT_RUNOUT_SCRIPT)); #endif } } diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 11e503f013..930953ea14 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -103,7 +103,7 @@ void GcodeSuite::G29() { mbl.reset(); mbl_probe_index = 0; if (!ui.wait_for_move) { - queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : PSTR("G29S2")); + queue.inject(parser.seen_test('N') ? F("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : F("G29S2")); TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart()); return; } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index a75d4cd816..8b8468bee4 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -126,7 +126,7 @@ bool GCodeQueue::RingBuffer::enqueue(const char *cmd, bool skip_ok/*=true*/ * Enqueue with Serial Echo * Return true if the command was consumed */ -bool GCodeQueue::enqueue_one(const char *cmd) { +bool GCodeQueue::enqueue_one(const char * const cmd) { //SERIAL_ECHOLNPGM("enqueue_one(\"", cmd, "\")"); if (*cmd == 0 || ISEOL(*cmd)) return true; @@ -195,15 +195,15 @@ bool GCodeQueue::process_injected_command() { * Enqueue and return only when commands are actually enqueued. * Never call this from a G-code handler! */ -void GCodeQueue::enqueue_one_now(const char *cmd) { while (!enqueue_one(cmd)) idle(); } +void GCodeQueue::enqueue_one_now(const char * const cmd) { while (!enqueue_one(cmd)) idle(); } /** * Attempt to enqueue a single G-code command * and return 'true' if successful. */ -bool GCodeQueue::enqueue_one_P(PGM_P const pgcode) { +bool GCodeQueue::enqueue_one(FSTR_P const fgcode) { size_t i = 0; - PGM_P p = pgcode; + PGM_P p = FTOP(fgcode); char c; while ((c = pgm_read_byte(&p[i])) && c != '\n') i++; char cmd[i + 1]; diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 6bcf4a97e4..71a710b8cb 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -127,6 +127,7 @@ public: * Aborts the current PROGMEM queue so only use for one or two commands. */ static inline void inject_P(PGM_P const pgcode) { injected_commands_P = pgcode; } + static inline void inject(FSTR_P const fgcode) { inject_P(FTOP(fgcode)); } /** * Enqueue command(s) to run from SRAM. Drained by process_injected_command(). @@ -139,18 +140,19 @@ public: /** * Enqueue and return only when commands are actually enqueued */ - static void enqueue_one_now(const char *cmd); + static void enqueue_one_now(const char * const cmd); /** * Attempt to enqueue a single G-code command * and return 'true' if successful. */ - static bool enqueue_one_P(PGM_P const pgcode); + static bool enqueue_one(FSTR_P const fgcode); /** * Enqueue from program memory and return only when commands are actually enqueued */ - static void enqueue_now_P(PGM_P const cmd); + static void enqueue_now_P(PGM_P const pcmd); + static inline void enqueue_now(FSTR_P const fcmd) { enqueue_now_P(FTOP(fcmd)); } /** * Check whether there are any commands yet to be executed diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index 54fa6f941b..5b1d36fdae 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -2352,7 +2352,7 @@ void HMI_PauseOrStop() { if (select_print.now == PRINT_PAUSE_RESUME) { if (HMI_flag.select_flag) { HMI_flag.pause_action = true; - queue.inject_P(PSTR("M25")); + queue.inject(F("M25")); } Goto_PrintProcess(); } @@ -2711,7 +2711,7 @@ void HMI_Prepare() { #endif break; - case PREPARE_CASE_DISA: queue.inject_P(PSTR("M84")); break; + case PREPARE_CASE_DISA: queue.inject(F("M84")); break; case PREPARE_CASE_HOME: // Homing checkkey = Last_Prepare; @@ -2729,7 +2729,7 @@ void HMI_Prepare() { EncoderRate.enabled = true; #else // Apply workspace offset, making the current position 0,0,0 - queue.inject_P(PSTR("G92 X0 Y0 Z0")); + queue.inject(F("G92 X0 Y0 Z0")); HMI_AudioFeedback(); #endif break; @@ -2944,7 +2944,7 @@ void HMI_Control() { void HMI_Leveling() { Popup_Window_Leveling(); DWIN_UpdateLCD(); - queue.inject_P(PSTR("G28O\nG29")); + queue.inject(F("G28O\nG29")); } #endif @@ -3803,7 +3803,7 @@ void HMI_Tune() { EncoderRate.enabled = true; #else // Apply workspace offset, making the current position 0,0,0 - queue.inject_P(PSTR("G92 X0 Y0 Z0")); + queue.inject(F("G92 X0 Y0 Z0")); HMI_AudioFeedback(); #endif break; @@ -4112,7 +4112,7 @@ void EachMomentUpdate() { TERN_(HAS_HEATED_BED, resume_bed_temp = thermalManager.degTargetBed()); thermalManager.disable_all_heaters(); #endif - queue.inject_P(PSTR("G1 F1200 X0 Y0")); + queue.inject(F("G1 F1200 X0 Y0")); } if (card.isPrinting() && checkkey == PrintProcess) { // print process @@ -4182,7 +4182,7 @@ void EachMomentUpdate() { if (encoder_diffState == ENCODER_DIFF_ENTER) { recovery_flag = false; if (HMI_flag.select_flag) break; - TERN_(POWER_LOSS_RECOVERY, queue.inject_P(PSTR("M1000C"))); + TERN_(POWER_LOSS_RECOVERY, queue.inject(F("M1000C"))); HMI_StartFrame(true); return; } @@ -4195,7 +4195,7 @@ void EachMomentUpdate() { select_print.set(0); HMI_ValueStruct.show_mode = 0; - queue.inject_P(PSTR("M1000")); + queue.inject(F("M1000")); Goto_PrintProcess(); Draw_Status_Area(true); } diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp b/Marlin/src/lcd/e3v2/enhanced/dwin.cpp index df0fbfcb6e..3768150f8e 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp +++ b/Marlin/src/lcd/e3v2/enhanced/dwin.cpp @@ -1157,7 +1157,7 @@ void HMI_MainMenu() { case PAGE_INFO_LEVELING: #if HAS_ONESTEP_LEVELING - queue.inject_P(PSTR("G28XYO\nG28Z\nG29")); // TODO: 'G29' should be homing when needed. Does it make sense for every LCD to do this differently? + queue.inject(F("G28XYO\nG28Z\nG29")); // TODO: 'G29' should be homing when needed. Does it make sense for every LCD to do this differently? #else checkkey = Info; Draw_Info_Menu(); @@ -1376,7 +1376,7 @@ void HMI_PauseOrStop() { if (HMI_flag.select_flag) { HMI_flag.pause_action = true; ICON_Resume(); - queue.inject_P(PSTR("M25")); + queue.inject(F("M25")); } else { // cancel pause @@ -1510,7 +1510,7 @@ void EachMomentUpdate() { TERN_(HAS_FAN, resume_fan = thermalManager.fan_speed[0]); #endif IF_DISABLED(ADVANCED_PAUSE_FEATURE, thermalManager.disable_all_heaters()); - IF_DISABLED(PARK_HEAD_ON_PAUSE, queue.inject_P(PSTR("G1 F1200 X0 Y0"))); + IF_DISABLED(PARK_HEAD_ON_PAUSE, queue.inject(F("G1 F1200 X0 Y0"))); } if (checkkey == PrintProcess) { // print process @@ -1588,7 +1588,7 @@ void EachMomentUpdate() { if (encoder_diffState == ENCODER_DIFF_ENTER) { recovery_flag = false; if (HMI_flag.select_flag) break; - TERN_(POWER_LOSS_RECOVERY, queue.inject_P(PSTR("M1000C"))); + TERN_(POWER_LOSS_RECOVERY, queue.inject(F("M1000C"))); return HMI_StartFrame(true); } else @@ -1600,7 +1600,7 @@ void EachMomentUpdate() { } select_print.set(PRINT_SETUP); - queue.inject_P(PSTR("M1000")); + queue.inject(F("M1000")); sdprint = true; Goto_PrintProcess(); Draw_Status_Area(true); @@ -2088,13 +2088,13 @@ void Goto_InfoMenu(){ Draw_Info_Menu(); } -void DisableMotors() { queue.inject_P(PSTR("M84")); } +void DisableMotors() { queue.inject(F("M84")); } void AutoHome() { queue.inject_P(G28_STR); } void SetHome() { // Apply workspace offset, making the current position 0,0,0 - queue.inject_P(PSTR("G92 X0 Y0 Z0")); + queue.inject(F("G92 X0 Y0 Z0")); HMI_AudioFeedback(); } @@ -2241,7 +2241,7 @@ void Goto_LockScreen() { DWIN_LockScreen(true); } void SetProbeOffsetZ() { SetPFloatOnClick(-10, 10, 2); } void ProbeTest() { ui.set_status_P(GET_TEXT(MSG_M48_TEST)); - queue.inject_P(PSTR("G28O\nM48 P10")); + queue.inject(F("G28O\nM48 P10")); } #endif @@ -2321,23 +2321,23 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } void ChangeFilament() { HMI_SaveProcessID(NothingToDo); - queue.inject_P(PSTR("M600 B2")); + queue.inject(F("M600 B2")); } void ParkHead(){ ui.set_status_P(GET_TEXT(MSG_FILAMENT_PARK_ENABLED)); - queue.inject_P(PSTR("G28O\nG27")); + queue.inject(F("G28O\nG27")); } #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) void UnloadFilament(){ ui.set_status_P(GET_TEXT(MSG_FILAMENTUNLOAD)); - queue.inject_P(PSTR("M702 Z20")); + queue.inject(F("M702 Z20")); } void LoadFilament(){ ui.set_status_P(GET_TEXT(MSG_FILAMENTLOAD)); - queue.inject_P(PSTR("M701 Z20")); + queue.inject(F("M701 Z20")); } #endif @@ -2436,7 +2436,7 @@ void LevBedC () { LevBed(4); } void ManualMeshSave(){ ui.set_status_P(GET_TEXT(MSG_UBL_STORAGE_MESH_MENU)); - queue.inject_P(PSTR("M211 S1\nM500")); + queue.inject(F("M211 S1\nM500")); } #endif // MESH_BED_LEVELING diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 3edd1e919b..ddf7b6dcd4 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -1055,7 +1055,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_CloseMotor, F("Disable Stepper")); else - queue.inject_P(PSTR("M84")); + queue.inject(F("M84")); break; case PREPARE_HOME: if (draw) @@ -4499,7 +4499,7 @@ void CrealityDWINClass::Print_Screen_Control() { #endif TERN_(HAS_FAN, thermalManager.fan_speed[0] = pausefan); planner.synchronize(); - TERN_(SDSUPPORT, queue.inject_P(PSTR("M24"))); + TERN_(SDSUPPORT, queue.inject(F("M24"))); #endif } else { @@ -4541,10 +4541,10 @@ void CrealityDWINClass::Popup_Control() { if (IS_SD_PRINTING()) card.pauseSDPrint(); #endif planner.synchronize(); - queue.inject_P(PSTR("M125")); + queue.inject(F("M125")); planner.synchronize(); #else - queue.inject_P(PSTR("M25")); + queue.inject(F("M25")); TERN_(HAS_HOTEND, pausetemp = thermalManager.temp_hotend[0].target); TERN_(HAS_HEATED_BED, pausebed = thermalManager.temp_bed.target); TERN_(HAS_FAN, pausefan = thermalManager.fan_speed[0]); @@ -4574,9 +4574,9 @@ void CrealityDWINClass::Popup_Control() { break; case Resume: if (selection == 0) - queue.inject_P(PSTR("M1000")); + queue.inject(F("M1000")); else { - queue.inject_P(PSTR("M1000 C")); + queue.inject(F("M1000 C")); Draw_Main_Menu(); } break; @@ -5008,7 +5008,7 @@ void CrealityDWINClass::Load_Settings(const char *buff) { static bool init = true; if (init) { init = false; - queue.inject_P(PSTR("M1000 S")); + queue.inject(F("M1000 S")); } #endif } diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp index 16576f7039..06b350ff77 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp @@ -683,7 +683,7 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr void DGUSScreenHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) { uint16_t value = swap16(*(uint16_t*)val_ptr); if (value) { - queue.inject_P(PSTR("M1000")); + queue.inject(F("M1000")); dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), 32, true); GotoScreen(PLR_SCREEN_RECOVER); } diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp index 60a0f6c5bb..2f08136cbb 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp @@ -205,7 +205,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { bool old_relative_mode = relative_mode; if (!relative_mode) { //DEBUG_ECHOPGM(" G91"); - queue.enqueue_now_P(PSTR("G91")); + queue.enqueue_now(F("G91")); //DEBUG_ECHOPGM(" ✓ "); } char buf[32]; // G1 X9999.99 F12345 @@ -227,7 +227,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { //DEBUG_ECHOLNPGM(" ✓ "); if (!old_relative_mode) { //DEBUG_ECHOPGM("G90"); - queue.enqueue_now_P(PSTR("G90")); + queue.enqueue_now(F("G90")); //DEBUG_ECHOPGM(" ✓ "); } } diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp index 83f7a39c28..f72a9f439d 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp @@ -205,7 +205,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { bool old_relative_mode = relative_mode; if (!relative_mode) { //DEBUG_ECHOPGM(" G91"); - queue.enqueue_now_P(PSTR("G91")); + queue.enqueue_now(F("G91")); //DEBUG_ECHOPGM(" ✓ "); } char buf[32]; // G1 X9999.99 F12345 @@ -227,7 +227,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { //DEBUG_ECHOLNPGM(" ✓ "); if (!old_relative_mode) { //DEBUG_ECHOPGM("G90"); - queue.enqueue_now_P(PSTR("G90")); + queue.enqueue_now(F("G90")); //DEBUG_ECHOPGM(" ✓ "); } } diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 2ec67b2727..0dc1e2245e 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -450,7 +450,7 @@ void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) { a_first_level = 0; queue.enqueue_now_P(G28_STR); } - queue.enqueue_now_P(PSTR("G29")); + queue.enqueue_now(F("G29")); #elif ENABLED(MESH_BED_LEVELING) @@ -512,10 +512,10 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { Deci2 = offset * 100; Deci2 = Deci2 % 10; soft_endstop._enabled = false; - queue.enqueue_now_P(PSTR("G91")); + queue.enqueue_now(F("G91")); snprintf_P(cmd_buf, 30, PSTR("G1 Z%d.%d%d"), integer, Deci, Deci2); queue.enqueue_one_now(cmd_buf); - queue.enqueue_now_P(PSTR("G90")); + queue.enqueue_now(F("G90")); //soft_endstop._enabled = true; break; @@ -527,17 +527,17 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { Deci2 = offset * 100; Deci2 = Deci2 % 10; soft_endstop._enabled = false; - queue.enqueue_now_P(PSTR("G91")); + queue.enqueue_now(F("G91")); snprintf_P(cmd_buf, 30, PSTR("G1 Z-%d.%d%d"), integer, Deci, Deci2); queue.enqueue_one_now(cmd_buf); - queue.enqueue_now_P(PSTR("G90")); + queue.enqueue_now(F("G90")); break; case 2: if (mesh_point_count == GRID_MAX_POINTS) { // The first point - queue.enqueue_now_P(PSTR("G28")); - queue.enqueue_now_P(PSTR("G29S1")); + queue.enqueue_now(F("G28")); + queue.enqueue_now(F("G29S1")); mesh_point_count--; if (mks_language_index == MKS_English) { @@ -550,7 +550,7 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { } } else if (mesh_point_count > 1) { // 倒数第二个点 - queue.enqueue_now_P(PSTR("G29S2")); + queue.enqueue_now(F("G29S2")); mesh_point_count--; if (mks_language_index == MKS_English) { const char level_buf_en2[] = "Next Point"; @@ -562,7 +562,7 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { } } else if (mesh_point_count == 1) { - queue.enqueue_now_P(PSTR("G29S2")); + queue.enqueue_now(F("G29S2")); mesh_point_count--; if (mks_language_index == MKS_English) { const char level_buf_en2[] = "Level Finsh"; @@ -620,13 +620,13 @@ void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_pt }; if (WITHIN(point_value, 0x0001, 0x0005)) - queue.enqueue_now_P(PSTR("G1Z10")); + queue.enqueue_now(F("G1Z10")); switch (point_value) { case 0x0001: enqueue_corner_move(X_MIN_POS + ABS(mks_corner_offsets[0].x), Y_MIN_POS + ABS(mks_corner_offsets[0].y), level_speed); - queue.enqueue_now_P(PSTR("G28Z")); + queue.enqueue_now(F("G28Z")); break; case 0x0002: enqueue_corner_move(X_MAX_POS - ABS(mks_corner_offsets[1].x), @@ -647,8 +647,8 @@ void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_pt } if (WITHIN(point_value, 0x0002, 0x0005)) { - //queue.enqueue_now_P(PSTR("G28Z")); - queue.enqueue_now_P(PSTR("G1Z-10")); + //queue.enqueue_now(F("G28Z")); + queue.enqueue_now(F("G1Z-10")); } } @@ -856,7 +856,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { if (!relative_mode) { //DEBUG_ECHOPGM(" G91"); - queue.enqueue_now_P(PSTR("G91")); + queue.enqueue_now(F("G91")); //DEBUG_ECHOPGM(" ✓ "); } char buf[32]; // G1 X9999.99 F12345 @@ -878,8 +878,8 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { //DEBUG_ECHOLNPGM(" ✓ "); if (!old_relative_mode) { //DEBUG_ECHOPGM("G90"); - //queue.enqueue_now_P(PSTR("G90")); - queue.enqueue_now_P(PSTR("G90")); + //queue.enqueue_now(F("G90")); + queue.enqueue_now(F("G90")); //DEBUG_ECHOPGM(" ✓ "); } } @@ -1133,30 +1133,30 @@ void DGUSScreenHandler::HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr switch (flag) { case 0: if (step == 0.01) - queue.inject_P(PSTR("M290 Z-0.01")); + queue.inject(F("M290 Z-0.01")); else if (step == 0.1) - queue.inject_P(PSTR("M290 Z-0.1")); + queue.inject(F("M290 Z-0.1")); else if (step == 0.5) - queue.inject_P(PSTR("M290 Z-0.5")); + queue.inject(F("M290 Z-0.5")); else if (step == 1) - queue.inject_P(PSTR("M290 Z-1")); + queue.inject(F("M290 Z-1")); else - queue.inject_P(PSTR("M290 Z-0.01")); + queue.inject(F("M290 Z-0.01")); z_offset_add = z_offset_add - ZOffset_distance; break; case 1: if (step == 0.01) - queue.inject_P(PSTR("M290 Z0.01")); + queue.inject(F("M290 Z0.01")); else if (step == 0.1) - queue.inject_P(PSTR("M290 Z0.1")); + queue.inject(F("M290 Z0.1")); else if (step == 0.5) - queue.inject_P(PSTR("M290 Z0.5")); + queue.inject(F("M290 Z0.5")); else if (step == 1) - queue.inject_P(PSTR("M290 Z1")); + queue.inject(F("M290 Z1")); else - queue.inject_P(PSTR("M290 Z-0.01")); + queue.inject(F("M290 Z-0.01")); z_offset_add = z_offset_add + ZOffset_distance; break; @@ -1486,7 +1486,7 @@ void DGUSScreenHandler::DGUS_Runout_Idle(void) { case RUNOUT_STATUS: runout_mks.runout_status = RUNOUT_BEGIN_STATUS; - queue.inject_P(PSTR("M25")); + queue.inject(F("M25")); GotoScreen(MKSLCD_SCREEN_PAUSE); sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please change filament!"), nullptr, true, true, true, true); diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp index db467d7b34..82404ead94 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp @@ -205,7 +205,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { bool old_relative_mode = relative_mode; if (!relative_mode) { //DEBUG_ECHOPGM(" G91"); - queue.enqueue_now_P(PSTR("G91")); + queue.enqueue_now(F("G91")); //DEBUG_ECHOPGM(" ✓ "); } char buf[32]; // G1 X9999.99 F12345 @@ -227,7 +227,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { //DEBUG_ECHOLNPGM(" ✓ "); if (!old_relative_mode) { //DEBUG_ECHOPGM("G90"); - queue.enqueue_now_P(PSTR("G90")); + queue.enqueue_now(F("G90")); //DEBUG_ECHOPGM(" ✓ "); } } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp index baae2538a0..8c76648bf1 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp @@ -523,9 +523,9 @@ void DGUSRxHandler::Probe(DGUS_VP &vp, void *data_ptr) { dgus_screen_handler.TriggerScreenChange(DGUS_Screen::LEVELING_PROBING); #if ENABLED(AUTO_BED_LEVELING_UBL) - queue.enqueue_now_P(PSTR("G29P1\nG29P3\nG29P5C")); + queue.enqueue_now(F("G29P1\nG29P3\nG29P5C")); #else - queue.enqueue_now_P(PSTR("G29")); + queue.enqueue_now(F("G29")); #endif queue.enqueue_now_P(DGUS_CMD_EEPROM_SAVE); } @@ -634,13 +634,13 @@ void DGUSRxHandler::Home(DGUS_VP &vp, void *data_ptr) { switch (axis) { case DGUS_Data::Axis::X_Y_Z: - queue.enqueue_now_P(PSTR("G28XYZ")); + queue.enqueue_now(F("G28XYZ")); break; case DGUS_Data::Axis::X_Y: - queue.enqueue_now_P(PSTR("G28XY")); + queue.enqueue_now(F("G28XY")); break; case DGUS_Data::Axis::Z: - queue.enqueue_now_P(PSTR("G28Z")); + queue.enqueue_now(F("G28Z")); break; } } @@ -784,7 +784,7 @@ void DGUSRxHandler::ResetEEPROM(DGUS_VP &vp, void *data_ptr) { return; } - queue.enqueue_now_P(PSTR("M502")); + queue.enqueue_now(F("M502")); queue.enqueue_now_P(DGUS_CMD_EEPROM_SAVE); } @@ -802,7 +802,7 @@ void DGUSRxHandler::SettingsExtra(DGUS_VP &vp, void *data_ptr) { return; } - queue.enqueue_now_P(PSTR(DGUS_RESET_BLTOUCH)); + queue.enqueue_now(F(DGUS_RESET_BLTOUCH)); #else dgus_screen_handler.TriggerScreenChange(DGUS_Screen::INFOS); #endif @@ -942,7 +942,7 @@ void DGUSRxHandler::PIDRun(DGUS_VP &vp, void *data_ptr) { dgus_screen_handler.TriggerScreenChange(DGUS_Screen::HOME); - queue.enqueue_now_P(PSTR("M1000C")); + queue.enqueue_now(F("M1000C")); } void DGUSRxHandler::PowerLossResume(DGUS_VP &vp, void *data_ptr) { @@ -966,7 +966,7 @@ void DGUSRxHandler::PIDRun(DGUS_VP &vp, void *data_ptr) { dgus_screen_handler.TriggerScreenChange(DGUS_Screen::PRINT_STATUS); - queue.enqueue_now_P(PSTR("M1000")); + queue.enqueue_now(F("M1000")); } #endif // POWER_LOSS_RECOVERY diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.cpp index 48bea1cdc0..d8395d0182 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.cpp @@ -74,7 +74,7 @@ bool DGUSSetupHandler::LevelingMenu() { if (ExtUI::isPositionKnown()) { if (ExtUI::getAxisPosition_mm(ExtUI::Z) < 10.0f) { - queue.enqueue_now_P(PSTR("G0Z10")); + queue.enqueue_now(F("G0Z10")); } return true; @@ -124,14 +124,14 @@ bool DGUSSetupHandler::LevelingOffset() { if (ExtUI::isPositionKnown()) { if (ExtUI::getAxisPosition_mm(ExtUI::Z) < 4.0f) { - queue.enqueue_now_P(PSTR("G0Z4")); + queue.enqueue_now(F("G0Z4")); } char buffer[20]; snprintf_P(buffer, sizeof(buffer), PSTR("G0X%dY%d"), DGUS_LEVEL_CENTER_X, DGUS_LEVEL_CENTER_Y); queue.enqueue_one_now(buffer); - queue.enqueue_now_P(PSTR("G0Z0")); + queue.enqueue_now(F("G0Z0")); return true; } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp index a390bd92e3..3cdb07b608 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp @@ -201,7 +201,7 @@ static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) { draw_return_ui(); } else if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING)) { - queue.enqueue_one_P(PSTR("M410")); + queue.enqueue_one(F("M410")); uiCfg.filament_rate = 0; uiCfg.filament_loading_completed = false; uiCfg.filament_unloading_completed = false; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp index b18bd28339..f3204eb962 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp @@ -74,11 +74,11 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { if (ENABLED(HAS_MULTI_EXTRUDER)) { if (uiCfg.extruderIndex == 0) { uiCfg.extruderIndex = 1; - queue.inject_P(PSTR("T1")); + queue.inject(F("T1")); } else { uiCfg.extruderIndex = 0; - queue.inject_P(PSTR("T0")); + queue.inject(F("T0")); } } else diff --git a/Marlin/src/lcd/extui/mks_ui/draw_home.cpp b/Marlin/src/lcd/extui/mks_ui/draw_home.cpp index 8dba33756a..04ebd95a09 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_home.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_home.cpp @@ -52,19 +52,19 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { queue.inject_P(G28_STR); break; case ID_H_X: - queue.inject_P(PSTR("G28X")); + queue.inject(F("G28X")); break; case ID_H_Y: - queue.inject_P(PSTR("G28Y")); + queue.inject(F("G28Y")); break; case ID_H_Z: - queue.inject_P(PSTR("G28Z")); + queue.inject(F("G28Z")); break; case ID_H_OFF_ALL: - queue.inject_P(PSTR("M84")); + queue.inject(F("M84")); break; case ID_H_OFF_XY: - queue.inject_P(PSTR("M84XY")); + queue.inject(F("M84XY")); break; case ID_H_RETURN: clear_cur_ui(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_more.cpp b/Marlin/src/lcd/extui/mks_ui/draw_more.cpp index 6c5fa2fa3d..a9c1dc1ec6 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_more.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_more.cpp @@ -62,22 +62,22 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_GCODE: lv_clear_more(); lv_draw_gcode(true); break; #if HAS_USER_ITEM(1) - case ID_CUSTOM_1: queue.inject_P(PSTR(MAIN_MENU_ITEM_1_GCODE)); break; + case ID_CUSTOM_1: queue.inject(F(MAIN_MENU_ITEM_1_GCODE)); break; #endif #if HAS_USER_ITEM(2) - case ID_CUSTOM_2: queue.inject_P(PSTR(MAIN_MENU_ITEM_2_GCODE)); break; + case ID_CUSTOM_2: queue.inject(F(MAIN_MENU_ITEM_2_GCODE)); break; #endif #if HAS_USER_ITEM(3) - case ID_CUSTOM_3: queue.inject_P(PSTR(MAIN_MENU_ITEM_3_GCODE)); break; + case ID_CUSTOM_3: queue.inject(F(MAIN_MENU_ITEM_3_GCODE)); break; #endif #if HAS_USER_ITEM(4) - case ID_CUSTOM_4: queue.inject_P(PSTR(MAIN_MENU_ITEM_4_GCODE)); break; + case ID_CUSTOM_4: queue.inject(F(MAIN_MENU_ITEM_4_GCODE)); break; #endif #if HAS_USER_ITEM(5) - case ID_CUSTOM_5: queue.inject_P(PSTR(MAIN_MENU_ITEM_5_GCODE)); break; + case ID_CUSTOM_5: queue.inject(F(MAIN_MENU_ITEM_5_GCODE)); break; #endif #if HAS_USER_ITEM(6) - case ID_CUSTOM_6: queue.inject_P(PSTR(MAIN_MENU_ITEM_6_GCODE)); break; + case ID_CUSTOM_6: queue.inject(F(MAIN_MENU_ITEM_6_GCODE)); break; #endif case ID_M_RETURN: lv_clear_more(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp index 322d0581ca..be596c8740 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp @@ -308,7 +308,7 @@ void setProBarRate() { #if HAS_SUICIDE if (gCfgItems.finish_power_off) { gcode.process_subcommands_now(F("M1001")); - queue.inject_P(PSTR("M81")); + queue.inject(F("M81")); marlin_state = MF_RUNNING; } #endif diff --git a/Marlin/src/lcd/extui/mks_ui/draw_set.cpp b/Marlin/src/lcd/extui/mks_ui/draw_set.cpp index 2dd3a9dfd9..aadf0d98f0 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_set.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_set.cpp @@ -57,7 +57,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; if (obj->mks_obj_id == ID_S_CONTINUE) return; if (obj->mks_obj_id == ID_S_MOTOR_OFF) { - TERN(HAS_SUICIDE, suicide(), queue.enqueue_now_P(PSTR("M84"))); + TERN(HAS_SUICIDE, suicide(), queue.enqueue_now(F("M84"))); return; } lv_clear_set(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_tool.cpp b/Marlin/src/lcd/extui/mks_ui/draw_tool.cpp index 9a0462f148..66b30342b2 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_tool.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_tool.cpp @@ -62,7 +62,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) get_gcode_command(AUTO_LEVELING_COMMAND_ADDR, (uint8_t *)public_buf_m); public_buf_m[sizeof(public_buf_m) - 1] = 0; - queue.inject_P(PSTR(public_buf_m)); + queue.inject(public_buf_m); #else uiCfg.leveling_first_time = true; lv_draw_manualLevel(); diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index e4140edc79..f0d0156151 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -1169,7 +1169,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { } send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); - queue.enqueue_one_P(PSTR("M105")); + queue.enqueue_one(F("M105")); break; case 992: @@ -2035,7 +2035,7 @@ void get_wifi_commands() { #endif // Add the command to the queue - queue.enqueue_one_P(wifi_line_buffer); + queue.enqueue_one(wifi_line_buffer); } else if (wifi_read_count >= MAX_CMD_SIZE - 1) { diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 5c8298cf52..e8a86730aa 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1542,7 +1542,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if BOTH(PSU_CONTROL, PS_OFF_CONFIRM) void MarlinUI::poweroff() { - queue.inject_P(PSTR("M81")); + queue.inject(F("M81")); goto_previous_screen(); } #endif @@ -1570,9 +1570,9 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if ENABLED(PARK_HEAD_ON_PAUSE) pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT); // Show message immediately to let user know about pause in progress - queue.inject_P(PSTR("M25 P\nM24")); + queue.inject(F("M25 P\nM24")); #elif ENABLED(SDSUPPORT) - queue.inject_P(PSTR("M25")); + queue.inject(F("M25")); #elif defined(ACTION_ON_PAUSE) host_action_pause(); #endif diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 8d87a876b9..9d424feb75 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -557,7 +557,7 @@ void menu_advanced_settings() { // // Set Home Offsets // - ACTION_ITEM(MSG_SET_HOME_OFFSETS, []{ queue.inject_P(PSTR("M428")); ui.return_to_status(); }); + ACTION_ITEM(MSG_SET_HOME_OFFSETS, []{ queue.inject(F("M428")); ui.return_to_status(); }); #endif // M203 / M205 - Feedrate items diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index ea9ef75aa1..1c7ab35e44 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -212,7 +212,7 @@ static void _lcd_level_bed_corners_get_next_position() { void _lcd_draw_level_prompt() { if (!ui.should_draw()) return; MenuItem_confirm::confirm_screen( - []{ queue.inject_P(TERN(HAS_LEVELING, PSTR("G29N"), G28_STR)); ui.return_to_status(); } + []{ queue.inject(TERN(HAS_LEVELING, F("G29N"), FPSTR(G28_STR))); ui.return_to_status(); } , []{ ui.goto_previous_screen_no_defer(); } , GET_TEXT(MSG_BED_TRAMMING_IN_RANGE) , (const char*)nullptr, PSTR("?") diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index f01c7899fb..eb286f96b9 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -103,9 +103,9 @@ ui.wait_for_move = true; ui.goto_screen(_lcd_level_bed_done); #if ENABLED(MESH_BED_LEVELING) - queue.inject_P(PSTR("G29S2")); + queue.inject(F("G29S2")); #elif ENABLED(PROBE_MANUALLY) - queue.inject_P(PSTR("G29V1")); + queue.inject(F("G29V1")); #endif } else @@ -155,9 +155,9 @@ // G29 Records Z, moves, and signals when it pauses ui.wait_for_move = true; #if ENABLED(MESH_BED_LEVELING) - queue.inject_P(manual_probe_index ? PSTR("G29S2") : PSTR("G29S1")); + queue.inject(manual_probe_index ? F("G29S2") : F("G29S1")); #elif ENABLED(PROBE_MANUALLY) - queue.inject_P(PSTR("G29V1")); + queue.inject(F("G29V1")); #endif } diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 7021a0e667..0e11cd211a 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -341,8 +341,8 @@ void menu_advanced_settings(); #if ENABLED(CUSTOM_MENU_CONFIG) - void _lcd_custom_menus_configuration_gcode(PGM_P const cmd) { - queue.inject_P(cmd); + void _lcd_custom_menus_configuration_gcode(FSTR_P const fstr) { + queue.inject(fstr); TERN_(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback()); TERN_(CUSTOM_MENU_CONFIG_SCRIPT_RETURN, ui.return_to_status()); } @@ -358,7 +358,7 @@ void menu_advanced_settings(); #else #define _DONE_SCRIPT "" #endif - #define GCODE_LAMBDA_CONF(N) []{ _lcd_custom_menus_configuration_gcode(PSTR(CONFIG_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); } + #define GCODE_LAMBDA_CONF(N) []{ _lcd_custom_menus_configuration_gcode(F(CONFIG_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); } #define _CUSTOM_ITEM_CONF(N) ACTION_ITEM_P(PSTR(CONFIG_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_CONF(N)); #define _CUSTOM_ITEM_CONF_CONFIRM(N) \ SUBMENU_P(PSTR(CONFIG_MENU_ITEM_##N##_DESC), []{ \ diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index 53fd67dbb2..7d0d2dc72c 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -209,7 +209,7 @@ void menu_change_filament() { #else if (thermalManager.targetHotEnoughToExtrude(active_extruder)) - queue.inject_P(PSTR("M600B0")); + queue.inject(F("M600B0")); else ui.goto_screen([]{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, 0); }); diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index a2f7c5bec2..56138a15bd 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -23,7 +23,7 @@ #include "menu.h" #include "../marlinui.h" -#include "../../gcode/queue.h" // for inject_P +#include "../../gcode/queue.h" // for inject #include "../../inc/MarlinConfigPre.h" @@ -64,8 +64,8 @@ class MenuItem_gcode : public MenuItem_button { FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { _draw(sel, row, pstr, '>', ' '); } - static void action(PGM_P const, PGM_P const pgcode) { queue.inject_P(pgcode); } - static inline void action(PGM_P const pstr, const uint8_t, const char * const pgcode) { action(pstr, pgcode); } + static void action(PGM_P const, PGM_P const pgcode) { queue.inject(FPSTR(pgcode)); } + static inline void action(PGM_P const pstr, const uint8_t, PGM_P const pgcode) { action(pstr, pgcode); } }; //////////////////////////////////////////// diff --git a/Marlin/src/lcd/menu/menu_job_recovery.cpp b/Marlin/src/lcd/menu/menu_job_recovery.cpp index 7cd2949d62..963806b1d6 100644 --- a/Marlin/src/lcd/menu/menu_job_recovery.cpp +++ b/Marlin/src/lcd/menu/menu_job_recovery.cpp @@ -35,7 +35,7 @@ static void lcd_power_loss_recovery_resume() { ui.return_to_status(); - queue.inject_P(PSTR("M1000")); + queue.inject(F("M1000")); } void lcd_power_loss_recovery_cancel() { diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 1bf6645e2e..f39e008cd7 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -106,8 +106,8 @@ void menu_configuration(); #if ENABLED(CUSTOM_MENU_MAIN) - void _lcd_custom_menu_main_gcode(PGM_P const cmd) { - queue.inject_P(cmd); + void _lcd_custom_menu_main_gcode(FSTR_P const fstr) { + queue.inject(fstr); TERN_(CUSTOM_MENU_MAIN_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback()); TERN_(CUSTOM_MENU_MAIN_SCRIPT_RETURN, ui.return_to_status()); } @@ -123,7 +123,7 @@ void menu_configuration(); #else #define _DONE_SCRIPT "" #endif - #define GCODE_LAMBDA_MAIN(N) []{ _lcd_custom_menu_main_gcode(PSTR(MAIN_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); } + #define GCODE_LAMBDA_MAIN(N) []{ _lcd_custom_menu_main_gcode(F(MAIN_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); } #define _CUSTOM_ITEM_MAIN(N) ACTION_ITEM_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_MAIN(N)); #define _CUSTOM_ITEM_MAIN_CONFIRM(N) \ SUBMENU_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), []{ \ diff --git a/Marlin/src/lcd/menu/menu_probe_offset.cpp b/Marlin/src/lcd/menu/menu_probe_offset.cpp index 5ed217131a..12b55969a3 100644 --- a/Marlin/src/lcd/menu/menu_probe_offset.cpp +++ b/Marlin/src/lcd/menu/menu_probe_offset.cpp @@ -111,7 +111,7 @@ void probe_offset_wizard_menu() { // If wizard-homing was done by probe with PROBE_OFFSET_WIZARD_START_Z #if HOMING_Z_WITH_PROBE && defined(PROBE_OFFSET_WIZARD_START_Z) set_axis_never_homed(Z_AXIS); // On cancel the Z position needs correction - queue.inject_P(PSTR("G28Z")); + queue.inject(F("G28Z")); #else // Otherwise do a Z clearance move like after Homing z_clearance_move(); #endif diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 9bc799129e..5cdcf75c1e 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -96,7 +96,7 @@ void goto_tramming_wizard() { // Inject G28, wait for homing to complete, set_all_unhomed(); - queue.inject_P(TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR)); + queue.inject(TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR))); ui.goto_screen([]{ _lcd_draw_homing(); diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index 456bd32758..3f0c70ab4c 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -785,7 +785,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } static void disable_steppers() { quick_feedback(); - queue.inject_P(PSTR("M84")); + queue.inject(F("M84")); } static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) { diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 15d477c485..1ef4c5881c 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -770,7 +770,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } static void disable_steppers() { quick_feedback(); - queue.inject_P(PSTR("M84")); + queue.inject(F("M84")); } static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) { diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 424f29a182..f6591d682d 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -772,7 +772,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } static void disable_steppers() { quick_feedback(); - queue.inject_P(PSTR("M84")); + queue.inject(F("M84")); } static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) { From 433eedd50fb0b1da04a0153de483088c8de9295d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Sep 2021 11:03:07 -0500 Subject: [PATCH 009/546] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20F()=20to=20seria?= =?UTF-8?q?l=20macros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp | 8 +- Marlin/src/core/debug_out.h | 8 +- Marlin/src/core/debug_section.h | 16 +-- Marlin/src/core/serial.cpp | 24 ++-- Marlin/src/core/serial.h | 126 ++++++++++++------ Marlin/src/core/utility.cpp | 6 +- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 8 +- Marlin/src/feature/encoder_i2c.cpp | 2 +- Marlin/src/feature/meatpack.cpp | 5 +- Marlin/src/feature/pause.cpp | 2 +- Marlin/src/feature/probe_temp_comp.cpp | 6 +- Marlin/src/feature/runout.h | 4 +- Marlin/src/feature/tmc_util.cpp | 15 +-- Marlin/src/gcode/bedlevel/G35.cpp | 2 +- Marlin/src/gcode/bedlevel/M420.cpp | 8 +- Marlin/src/gcode/config/M217.cpp | 4 +- Marlin/src/gcode/config/M302.cpp | 2 +- Marlin/src/gcode/control/M211.cpp | 4 +- Marlin/src/gcode/control/M80_M81.cpp | 2 +- Marlin/src/gcode/feature/L6470/M122.cpp | 6 +- Marlin/src/gcode/feature/L6470/M906.cpp | 2 +- Marlin/src/gcode/feature/powerloss/M413.cpp | 4 +- Marlin/src/gcode/feature/trinamic/M569.cpp | 2 +- Marlin/src/gcode/geometry/G17-G19.cpp | 8 +- Marlin/src/gcode/parser.h | 4 +- Marlin/src/gcode/units/M149.cpp | 2 +- .../lcd/extui/anycubic_chiron/chiron_tft.cpp | 10 +- Marlin/src/module/temperature.cpp | 38 +++--- Marlin/src/sd/cardreader.cpp | 4 +- docs/Serial.md | 2 +- 30 files changed, 187 insertions(+), 147 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp b/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp index 6570a599a4..1991d79719 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp @@ -90,15 +90,15 @@ bool PersistentStore::access_finish() { // 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) { #if ENABLED(DEBUG_SD_EEPROM_EMULATION) - PGM_P const rw_str = write ? PSTR("write") : PSTR("read"); + FSTR_P const rw_str = write ? F("write") : F("read"); SERIAL_CHAR(' '); - SERIAL_ECHOPGM_P(rw_str); + SERIAL_ECHOF(rw_str); SERIAL_ECHOLNPGM("_data(", pos, ",", *value, ",", size, ", ...)"); if (total) { SERIAL_ECHOPGM(" f_"); - SERIAL_ECHOPGM_P(rw_str); + SERIAL_ECHOF(rw_str); SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_"); - SERIAL_ECHOLNPGM_P(write ? PSTR("written=") : PSTR("read="), total); + SERIAL_ECHOLNF(write ? F("written=") : F("read="), total); } else SERIAL_ECHOLNPGM(" f_lseek()=", s); diff --git a/Marlin/src/core/debug_out.h b/Marlin/src/core/debug_out.h index 4e30a5306e..eb1c91e507 100644 --- a/Marlin/src/core/debug_out.h +++ b/Marlin/src/core/debug_out.h @@ -36,6 +36,8 @@ #undef DEBUG_ECHOLN #undef DEBUG_ECHOPGM #undef DEBUG_ECHOLNPGM +#undef DEBUG_ECHOF +#undef DEBUG_ECHOLNF #undef DEBUG_ECHOPGM_P #undef DEBUG_ECHOLNPGM_P #undef DEBUG_ECHOPAIR_F @@ -54,7 +56,7 @@ #if DEBUG_OUT #include "debug_section.h" - #define DEBUG_SECTION(N,S,D) SectionLog N(PSTR(S),D) + #define DEBUG_SECTION(N,S,D) SectionLog N(F(S),D) #define DEBUG_ECHO_START SERIAL_ECHO_START #define DEBUG_ERROR_START SERIAL_ERROR_START @@ -65,6 +67,8 @@ #define DEBUG_ECHOLN SERIAL_ECHOLN #define DEBUG_ECHOPGM SERIAL_ECHOPGM #define DEBUG_ECHOLNPGM SERIAL_ECHOLNPGM + #define DEBUG_ECHOF SERIAL_ECHOF + #define DEBUG_ECHOLNF SERIAL_ECHOLNF #define DEBUG_ECHOPGM SERIAL_ECHOPGM #define DEBUG_ECHOPGM_P SERIAL_ECHOPGM_P #define DEBUG_ECHOPAIR_F SERIAL_ECHOPAIR_F @@ -94,6 +98,8 @@ #define DEBUG_ECHOLN(...) NOOP #define DEBUG_ECHOPGM(...) NOOP #define DEBUG_ECHOLNPGM(...) NOOP + #define DEBUG_ECHOF(...) NOOP + #define DEBUG_ECHOLNF(...) NOOP #define DEBUG_ECHOPGM_P(...) NOOP #define DEBUG_ECHOLNPGM_P(...) NOOP #define DEBUG_ECHOPAIR_F(...) NOOP diff --git a/Marlin/src/core/debug_section.h b/Marlin/src/core/debug_section.h index ef1511e6f0..6e23d9e4ed 100644 --- a/Marlin/src/core/debug_section.h +++ b/Marlin/src/core/debug_section.h @@ -26,22 +26,22 @@ class SectionLog { public: - SectionLog(PGM_P const msg=nullptr, bool inbug=true) { - the_msg = msg; - if ((debug = inbug)) echo_msg(PSTR(">>>")); + SectionLog(FSTR_P const fmsg=nullptr, bool inbug=true) { + the_msg = fmsg; + if ((debug = inbug)) echo_msg(F(">>>")); } - ~SectionLog() { if (debug) echo_msg(PSTR("<<<")); } + ~SectionLog() { if (debug) echo_msg(F("<<<")); } private: - PGM_P the_msg; + FSTR_P the_msg; bool debug; - void echo_msg(PGM_P const pre) { - SERIAL_ECHOPGM_P(pre); + void echo_msg(FSTR_P const fpre) { + SERIAL_ECHOF(fpre); if (the_msg) { SERIAL_CHAR(' '); - SERIAL_ECHOPGM_P(the_msg); + SERIAL_ECHOF(the_msg); } SERIAL_CHAR(' '); print_pos(current_position); diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 8c9f4a8e4d..9cd862df70 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -69,23 +69,23 @@ PGMSTR(SP_I_LBL, " " AXIS4_STR ":"); PGMSTR(SP_J_LBL, " " AXIS5_STR ":"); PGMSTR #endif -void serialprintPGM(PGM_P str) { +void serial_print_P(PGM_P str) { while (const char c = pgm_read_byte(str++)) SERIAL_CHAR(c); } -void serial_echo_start() { static PGMSTR(echomagic, "echo:"); serialprintPGM(echomagic); } -void serial_error_start() { static PGMSTR(errormagic, "Error:"); serialprintPGM(errormagic); } +void serial_echo_start() { static PGMSTR(echomagic, "echo:"); serial_print_P(echomagic); } +void serial_error_start() { static PGMSTR(errormagic, "Error:"); serial_print_P(errormagic); } void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); } -void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post/*=nullptr*/) { - if (pre) serialprintPGM(pre); - serialprintPGM(onoff ? on : off); - if (post) serialprintPGM(post); +void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post/*=nullptr*/) { + if (pre) serial_print(pre); + serial_print(onoff ? on : off); + if (post) serial_print(post); } -void serialprint_onoff(const bool onoff) { serialprintPGM(onoff ? PSTR(STR_ON) : PSTR(STR_OFF)); } +void serialprint_onoff(const bool onoff) { serial_print(onoff ? F(STR_ON) : F(STR_OFF)); } void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); } -void serialprint_truefalse(const bool tf) { serialprintPGM(tf ? PSTR("true") : PSTR("false")); } +void serialprint_truefalse(const bool tf) { serial_print(tf ? F("true") : F("false")); } void print_bin(uint16_t val) { for (uint8_t i = 16; i--;) { @@ -94,10 +94,10 @@ void print_bin(uint16_t val) { } } -void print_pos(LINEAR_AXIS_ARGS(const_float_t), PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) { - if (prefix) serialprintPGM(prefix); +void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix/*=nullptr*/, FSTR_P const suffix/*=nullptr*/) { + if (prefix) serial_print(prefix); SERIAL_ECHOPGM_P( LIST_N(DOUBLE(LINEAR_AXES), SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z, SP_I_STR, i, SP_J_STR, j, SP_K_STR, k) ); - if (suffix) serialprintPGM(suffix); else SERIAL_EOL(); + if (suffix) serial_print(suffix); else SERIAL_EOL(); } diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 05d80a4829..e058f1e5cd 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -167,13 +167,10 @@ inline void SERIAL_ECHO(serial_char_t x) { SERIAL_IMPL.write(x.c); } #define AS_CHAR(C) serial_char_t(C) #define AS_DIGIT(C) AS_CHAR('0' + (C)) -// SERIAL_ECHO_F prints a floating point value with optional precision -inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); } - template void SERIAL_ECHOLN(T x) { SERIAL_IMPL.println(x); } -// SERIAL_PRINT works like SERIAL_ECHO but allow to specify the encoding base of the number printed +// SERIAL_PRINT works like SERIAL_ECHO but also takes the numeric base template void SERIAL_PRINT(T x, U y) { SERIAL_IMPL.print(x, y); } @@ -184,8 +181,20 @@ void SERIAL_PRINTLN(T x, PrintBase y) { SERIAL_IMPL.println(x, y); } inline void SERIAL_FLUSH() { SERIAL_IMPL.flush(); } inline void SERIAL_FLUSHTX() { SERIAL_IMPL.flushTX(); } -// Print a single PROGMEM string to serial -void serialprintPGM(PGM_P str); +// Serial echo and error prefixes +#define SERIAL_ECHO_START() serial_echo_start() +#define SERIAL_ERROR_START() serial_error_start() + +// Serial end-of-line +#define SERIAL_EOL() SERIAL_CHAR('\n') + +// Print a single PROGMEM, PGM_P, or PSTR() string. +void serial_print_P(PGM_P str); +inline void serial_println_P(PGM_P str) { serial_print_P(str); SERIAL_EOL(); } + +// Print a single FSTR_P, F(), or FPSTR() string. +inline void serial_print(FSTR_P const fstr) { serial_print_P(FTOP(fstr)); } +inline void serial_println(FSTR_P const fstr) { serial_println_P(FTOP(fstr)); } // // SERIAL_ECHOPGM... macros are used to output string-value pairs. @@ -195,8 +204,8 @@ void serialprintPGM(PGM_P str); #define __SEP_N(N,V...) _SEP_##N(V) #define _SEP_N(N,V...) __SEP_N(N,V) #define _SEP_N_REF() _SEP_N -#define _SEP_1(s) serialprintPGM(PSTR(s)); -#define _SEP_2(s,v) serial_echopair_PGM(PSTR(s),v); +#define _SEP_1(s) serial_print(F(s)); +#define _SEP_2(s,v) serial_echopair(F(s),v); #define _SEP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SEP_N_REF)()(TWO_ARGS(V),V); #define SERIAL_ECHOPGM(V...) do{ EVAL(_SEP_N(TWO_ARGS(V),V)); }while(0) @@ -204,8 +213,8 @@ void serialprintPGM(PGM_P str); #define __SELP_N(N,V...) _SELP_##N(V) #define _SELP_N(N,V...) __SELP_N(N,V) #define _SELP_N_REF() _SELP_N -#define _SELP_1(s) serialprintPGM(PSTR(s "\n")); -#define _SELP_2(s,v) serial_echopair_PGM(PSTR(s),v); SERIAL_EOL(); +#define _SELP_1(s) serial_print(F(s "\n")); +#define _SELP_2(s,v) serial_echolnpair(F(s),v); #define _SELP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SELP_N_REF)()(TWO_ARGS(V),V); #define SERIAL_ECHOLNPGM(V...) do{ EVAL(_SELP_N(TWO_ARGS(V),V)); }while(0) @@ -213,8 +222,8 @@ void serialprintPGM(PGM_P str); #define __SEP_N_P(N,V...) _SEP_##N##_P(V) #define _SEP_N_P(N,V...) __SEP_N_P(N,V) #define _SEP_N_P_REF() _SEP_N_P -#define _SEP_1_P(p) serialprintPGM(p); -#define _SEP_2_P(p,v) serial_echopair_PGM(p,v); +#define _SEP_1_P(p) serial_print_P(p); +#define _SEP_2_P(p,v) serial_echopair_P(p,v); #define _SEP_3_P(p,v,V...) _SEP_2_P(p,v); DEFER2(_SEP_N_P_REF)()(TWO_ARGS(V),V); #define SERIAL_ECHOPGM_P(V...) do{ EVAL(_SEP_N_P(TWO_ARGS(V),V)); }while(0) @@ -222,11 +231,29 @@ void serialprintPGM(PGM_P str); #define __SELP_N_P(N,V...) _SELP_##N##_P(V) #define _SELP_N_P(N,V...) __SELP_N_P(N,V) #define _SELP_N_P_REF() _SELP_N_P -#define _SELP_1_P(p) { serialprintPGM(p); SERIAL_EOL(); } -#define _SELP_2_P(p,v) { serial_echopair_PGM(p,v); SERIAL_EOL(); } +#define _SELP_1_P(p) serial_println_P(p) +#define _SELP_2_P(p,v) serial_echolnpair_P(p,v) #define _SELP_3_P(p,v,V...) { _SEP_2_P(p,v); DEFER2(_SELP_N_P_REF)()(TWO_ARGS(V),V); } #define SERIAL_ECHOLNPGM_P(V...) do{ EVAL(_SELP_N_P(TWO_ARGS(V),V)); }while(0) +// Print up to 20 pairs of values. Odd elements must be FSTR_P, F(), or FPSTR(). +#define __SEP_N_F(N,V...) _SEP_##N##_F(V) +#define _SEP_N_F(N,V...) __SEP_N_F(N,V) +#define _SEP_N_F_REF() _SEP_N_F +#define _SEP_1_F(p) serial_print(p); +#define _SEP_2_F(p,v) serial_echopair(p,v); +#define _SEP_3_F(p,v,V...) _SEP_2_F(p,v); DEFER2(_SEP_N_F_REF)()(TWO_ARGS(V),V); +#define SERIAL_ECHOF(V...) do{ EVAL(_SEP_N_F(TWO_ARGS(V),V)); }while(0) + +// Print up to 20 pairs of values followed by newline. Odd elements must be FSTR_P, F(), or FPSTR(). +#define __SELP_N_F(N,V...) _SELP_##N##_F(V) +#define _SELP_N_F(N,V...) __SELP_N_F(N,V) +#define _SELP_N_F_REF() _SELP_N_F +#define _SELP_1_F(p) serial_println(p) +#define _SELP_2_F(p,v) serial_echolnpair(p,v) +#define _SELP_3_F(p,v,V...) { _SEP_2_F(p,v); DEFER2(_SELP_N_F_REF)()(TWO_ARGS(V),V); } +#define SERIAL_ECHOLNF(V...) do{ EVAL(_SELP_N_F(TWO_ARGS(V),V)); }while(0) + #ifdef AllowDifferentTypeInList inline void SERIAL_ECHOLIST_IMPL() {} @@ -236,47 +263,49 @@ void serialprintPGM(PGM_P str); template void SERIAL_ECHOLIST_IMPL(T && t, Args && ... args) { SERIAL_IMPL.print(t); - serialprintPGM(PSTR(", ")); + serial_print(F(", ")); SERIAL_ECHOLIST_IMPL(args...); } template - void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) { - SERIAL_IMPL.print(str); + void SERIAL_ECHOLIST(FSTR_P const str, Args && ... args) { + SERIAL_IMPL.print(FTOP(str)); SERIAL_ECHOLIST_IMPL(args...); } #else // Optimization if the listed type are all the same (seems to be the case in the codebase so use that instead) template - void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) { - serialprintPGM(str); + void SERIAL_ECHOLIST(FSTR_P const fstr, Args && ... args) { + serial_print(fstr); typename Private::first_type_of::type values[] = { args... }; constexpr size_t argsSize = sizeof...(args); for (size_t i = 0; i < argsSize; i++) { - if (i) serialprintPGM(PSTR(", ")); + if (i) serial_print(F(", ")); SERIAL_IMPL.print(values[i]); } } #endif -#define SERIAL_ECHOPAIR_F_P(P,V...) do{ serialprintPGM(P); SERIAL_ECHO_F(V); }while(0) -#define SERIAL_ECHOLNPAIR_F_P(V...) do{ SERIAL_ECHOPAIR_F_P(V); SERIAL_EOL(); }while(0) +// SERIAL_ECHO_F prints a floating point value with optional precision +inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); } + +#define SERIAL_ECHOPAIR_F_P(P,V...) do{ serial_print_P(P); SERIAL_ECHO_F(V); }while(0) +#define SERIAL_ECHOLNPAIR_F_P(P,V...) do{ SERIAL_ECHOPAIR_F_P(P,V); SERIAL_EOL(); }while(0) -#define SERIAL_ECHOPAIR_F(S,V...) SERIAL_ECHOPAIR_F_P(PSTR(S),V) -#define SERIAL_ECHOLNPAIR_F(V...) do{ SERIAL_ECHOPAIR_F(V); SERIAL_EOL(); }while(0) +#define SERIAL_ECHOPAIR_F_F(S,V...) do{ serial_print(S); SERIAL_ECHO_F(V); }while(0) +#define SERIAL_ECHOLNPAIR_F_F(S,V...) do{ SERIAL_ECHOPAIR_F_F(S,V); SERIAL_EOL(); }while(0) -#define SERIAL_ECHO_START() serial_echo_start() -#define SERIAL_ERROR_START() serial_error_start() -#define SERIAL_EOL() SERIAL_CHAR('\n') +#define SERIAL_ECHOPAIR_F(S,V...) SERIAL_ECHOPAIR_F_F(F(S),V) +#define SERIAL_ECHOLNPAIR_F(V...) do{ SERIAL_ECHOPAIR_F(V); SERIAL_EOL(); }while(0) -#define SERIAL_ECHO_MSG(V...) do{ SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(V); }while(0) -#define SERIAL_ERROR_MSG(V...) do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(V); }while(0) +#define SERIAL_ECHO_MSG(V...) do{ SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(V); }while(0) +#define SERIAL_ERROR_MSG(V...) do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(V); }while(0) -#define SERIAL_ECHO_SP(C) serial_spaces(C) +#define SERIAL_ECHO_SP(C) serial_spaces(C) -#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, PSTR(PRE), PSTR(ON), PSTR(OFF), PSTR(POST)) +#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, F(PRE), F(ON), F(OFF), F(POST)) #if SERIAL_FLOAT_PRECISION #define SERIAL_DECIMAL(V) SERIAL_PRINT(V, SERIAL_FLOAT_PRECISION) @@ -287,33 +316,42 @@ void serialprintPGM(PGM_P str); // // Functions for serial printing from PROGMEM. (Saves loads of SRAM.) // -inline void serial_echopair_PGM(PGM_P const s_P, serial_char_t v) { serialprintPGM(s_P); SERIAL_CHAR(v.c); } - -inline void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); } -inline void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); } -inline void serial_echopair_PGM(PGM_P const s_P, const char *v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +inline void serial_echopair_P(PGM_P const pstr, serial_char_t v) { serial_print_P(pstr); SERIAL_CHAR(v.c); } +inline void serial_echopair_P(PGM_P const pstr, float v) { serial_print_P(pstr); SERIAL_DECIMAL(v); } +inline void serial_echopair_P(PGM_P const pstr, double v) { serial_print_P(pstr); SERIAL_DECIMAL(v); } +//inline void serial_echopair_P(PGM_P const pstr, const char *v) { serial_print_P(pstr); SERIAL_ECHO(v); } +inline void serial_echopair_P(PGM_P const pstr, FSTR_P v) { serial_print_P(pstr); SERIAL_ECHOF(v); } // Default implementation for types without a specialization. Handles integers. template -void serial_echopair_PGM(PGM_P const s_P, T v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +inline void serial_echopair_P(PGM_P const pstr, T v) { serial_print_P(pstr); SERIAL_ECHO(v); } + +// Add a newline. +template +inline void serial_echolnpair_P(PGM_P const pstr, T v) { serial_echopair_P(pstr, v); SERIAL_EOL(); } + +// Catch-all for __FlashStringHelper * +template +inline void serial_echopair(FSTR_P const fstr, T v) { serial_echopair_P(FTOP(fstr), v); } -inline void serial_echopair_PGM(PGM_P const s_P, bool v) { serial_echopair_PGM(s_P, (int)v); } -inline void serial_echopair_PGM(PGM_P const s_P, void *v) { serial_echopair_PGM(s_P, (uintptr_t)v); } +// Add a newline to the serial output +template +inline void serial_echolnpair(FSTR_P const fstr, T v) { serial_echolnpair_P(FTOP(fstr), v); } void serial_echo_start(); void serial_error_start(); -void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post=nullptr); +void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr); void serialprint_onoff(const bool onoff); void serialprintln_onoff(const bool onoff); void serialprint_truefalse(const bool tf); void serial_spaces(uint8_t count); void print_bin(const uint16_t val); -void print_pos(LINEAR_AXIS_ARGS(const_float_t), PGM_P const prefix=nullptr, PGM_P const suffix=nullptr); +void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr); -inline void print_pos(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) { +inline void print_pos(const xyz_pos_t &xyz, FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr) { print_pos(LINEAR_AXIS_ELEM(xyz), prefix, suffix); } -#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n")); }while(0) -#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, PSTR(PREFIX), nullptr); }while(0) +#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, F(" " STRINGIFY(VAR) "="), F(" : " SUFFIX "\n")); }while(0) +#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, F(PREFIX)); }while(0) diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 8aeec89f02..b70e2fa9a9 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -92,9 +92,9 @@ void safe_delay(millis_t ms) { SERIAL_ECHOPGM(" (Aligned With"); if (probe.offset_xy.y > 0) - SERIAL_ECHOPGM_P(ENABLED(IS_SCARA) ? PSTR("-Distal") : PSTR("-Back")); + SERIAL_ECHOF(F(TERN(IS_SCARA, "-Distal", "-Back"))); else if (probe.offset_xy.y < 0) - SERIAL_ECHOPGM_P(ENABLED(IS_SCARA) ? PSTR("-Proximal") : PSTR("-Front")); + SERIAL_ECHOF(F(TERN(IS_SCARA, "-Proximal", "-Front"))); else if (probe.offset_xy.x != 0) SERIAL_ECHOPGM("-Center"); @@ -102,7 +102,7 @@ void safe_delay(millis_t ms) { #endif - SERIAL_ECHOPGM_P(probe.offset.z < 0 ? PSTR("Below") : probe.offset.z > 0 ? PSTR("Above") : PSTR("Same Z as")); + SERIAL_ECHOF(probe.offset.z < 0 ? F("Below") : probe.offset.z > 0 ? F("Above") : F("Same Z as")); SERIAL_ECHOLNPGM(" Nozzle)"); #endif diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 7b2280fcde..964f1123fe 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -180,10 +180,8 @@ void unified_bed_leveling::display_map(const uint8_t map_type) { SERIAL_EOL(); serial_echo_column_labels(eachsp - 2); } - else { - SERIAL_ECHOPGM(" for "); - SERIAL_ECHOPGM_P(csv ? PSTR("CSV:\n") : PSTR("LCD:\n")); - } + else + SERIAL_ECHOPGM(" for ", csv ? F("CSV:\n") : F("LCD:\n")); // Add XY probe offset from extruder because probe.probe_at_point() subtracts them when // moving to the XY position to be measured. This ensures better agreement between @@ -213,7 +211,7 @@ void unified_bed_leveling::display_map(const uint8_t map_type) { // TODO: Display on Graphical LCD } else if (isnan(f)) - SERIAL_ECHOPGM_P(human ? PSTR(" . ") : PSTR("NAN")); + SERIAL_ECHOF(human ? F(" . ") : F("NAN")); else if (human || csv) { if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0) SERIAL_ECHO_F(f, 3); // Positive: 5 digits, Negative: 6 digits diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index bed24f0525..f843011b5d 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -232,7 +232,7 @@ bool I2CPositionEncoder::passes_test(const bool report) { if (report) { if (H != I2CPE_MAG_SIG_GOOD) SERIAL_ECHOPGM("Warning. "); SERIAL_CHAR(axis_codes[encoderAxis]); - serial_ternary(H == I2CPE_MAG_SIG_BAD, PSTR(" axis "), PSTR("magnetic strip "), PSTR("encoder ")); + serial_ternary(H == I2CPE_MAG_SIG_BAD, F(" axis "), F("magnetic strip "), F("encoder ")); switch (H) { case I2CPE_MAG_SIG_GOOD: case I2CPE_MAG_SIG_MID: diff --git a/Marlin/src/feature/meatpack.cpp b/Marlin/src/feature/meatpack.cpp index 2edcd7478a..b2899243b2 100644 --- a/Marlin/src/feature/meatpack.cpp +++ b/Marlin/src/feature/meatpack.cpp @@ -169,10 +169,9 @@ void MeatPack::handle_command(const MeatPack_Command c) { void MeatPack::report_state() { // NOTE: if any configuration vars are added below, the outgoing sync text for host plugin // should not contain the "PV' substring, as this is used to indicate protocol version - SERIAL_ECHOPGM("[MP] "); - SERIAL_ECHOPGM(MeatPack_ProtocolVersion " "); + SERIAL_ECHOPGM("[MP] " MeatPack_ProtocolVersion " "); serialprint_onoff(TEST(state, MPConfig_Bit_Active)); - SERIAL_ECHOPGM_P(TEST(state, MPConfig_Bit_NoSpaces) ? PSTR(" NSP\n") : PSTR(" ESP\n")); + SERIAL_ECHOF(TEST(state, MPConfig_Bit_NoSpaces) ? F(" NSP\n") : F(" ESP\n")); } /** diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index d54326116e..28f5caa3cb 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -486,7 +486,7 @@ void show_continue_prompt(const bool is_reload) { ui.pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING); SERIAL_ECHO_START(); - SERIAL_ECHOPGM_P(is_reload ? PSTR(_PMSG(STR_FILAMENT_CHANGE_INSERT) "\n") : PSTR(_PMSG(STR_FILAMENT_CHANGE_WAIT) "\n")); + SERIAL_ECHOF(is_reload ? F(_PMSG(STR_FILAMENT_CHANGE_INSERT) "\n") : F(_PMSG(STR_FILAMENT_CHANGE_WAIT) "\n")); } void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep_count/*=0*/ DXC_ARGS) { diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index deae447568..5f3bc985e6 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -71,11 +71,11 @@ void ProbeTempComp::print_offsets() { LOOP_L_N(s, TSI_COUNT) { celsius_t temp = cali_info[s].start_temp; for (int16_t i = -1; i < cali_info[s].measurements; ++i) { - SERIAL_ECHOPGM_P(s == TSI_BED ? PSTR("Bed") : + SERIAL_ECHOF(s == TSI_BED ? F("Bed") : #if ENABLED(USE_TEMP_EXT_COMPENSATION) - s == TSI_EXT ? PSTR("Extruder") : + s == TSI_EXT ? F("Extruder") : #endif - PSTR("Probe") + F("Probe") ); SERIAL_ECHOLNPGM( " temp: ", temp, diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 918e65bb22..8065e51555 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -317,7 +317,7 @@ class FilamentSensorBase { static uint8_t was_out; // = 0 if (out != TEST(was_out, s)) { TBI(was_out, s); - SERIAL_ECHOLNPGM_P(PSTR("Filament Sensor "), '0' + s, out ? PSTR(" OUT") : PSTR(" IN")); + SERIAL_ECHOLNF(F("Filament Sensor "), AS_DIGIT(s), out ? F(" OUT") : F(" IN")); } #endif } @@ -352,7 +352,7 @@ class FilamentSensorBase { if (ELAPSED(ms, t)) { t = millis() + 1000UL; LOOP_L_N(i, NUM_RUNOUT_SENSORS) - SERIAL_ECHOPGM_P(i ? PSTR(", ") : PSTR("Remaining mm: "), runout_mm_countdown[i]); + SERIAL_ECHOF(i ? F(", ") : F("Remaining mm: "), runout_mm_countdown[i]); SERIAL_EOL(); } #endif diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index 97fedf13c5..6848d81003 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -561,7 +561,7 @@ }; template - static void print_vsense(TMC &st) { SERIAL_ECHOPGM_P(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); } + static void print_vsense(TMC &st) { SERIAL_ECHOF(st.vsense() ? F("1=.18") : F("0=.325")); } #if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC5130) static void _tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) { @@ -732,7 +732,7 @@ SERIAL_ECHO(st.cs()); SERIAL_ECHOPGM("/31"); break; - case TMC_VSENSE: SERIAL_ECHOPGM_P(st.vsense() ? PSTR("1=.165") : PSTR("0=.310")); break; + case TMC_VSENSE: SERIAL_ECHOF(st.vsense() ? F("1=.165") : F("0=.310")); break; case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break; //case TMC_OTPW: serialprint_truefalse(st.otpw()); break; //case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break; @@ -1256,15 +1256,14 @@ static bool test_connection(TMC &st) { if (test_result > 0) SERIAL_ECHOPGM("Error: All "); - const char *stat; + FSTR_P stat; switch (test_result) { default: - case 0: stat = PSTR("OK"); break; - case 1: stat = PSTR("HIGH"); break; - case 2: stat = PSTR("LOW"); break; + case 0: stat = F("OK"); break; + case 1: stat = F("HIGH"); break; + case 2: stat = F("LOW"); break; } - SERIAL_ECHOPGM_P(stat); - SERIAL_EOL(); + SERIAL_ECHOLNF(stat); return test_result; } diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index cb634d973b..e45e18b7fb 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -116,7 +116,7 @@ void GcodeSuite::G35() { if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM("Probing point ", i + 1, " ("); - DEBUG_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i])); + DEBUG_ECHOF(FPSTR(pgm_read_ptr(&tramming_point_name[i]))); DEBUG_CHAR(')'); DEBUG_ECHOLNPGM_P(SP_X_STR, tramming_points[i].x, SP_Y_STR, tramming_points[i].y, SP_Z_STR, z_probed_height); } diff --git a/Marlin/src/gcode/bedlevel/M420.cpp b/Marlin/src/gcode/bedlevel/M420.cpp index d76e08dee6..1240b14fd2 100644 --- a/Marlin/src/gcode/bedlevel/M420.cpp +++ b/Marlin/src/gcode/bedlevel/M420.cpp @@ -246,12 +246,12 @@ void GcodeSuite::M420_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, PSTR( TERN(MESH_BED_LEVELING, "Mesh Bed Leveling", TERN(AUTO_BED_LEVELING_UBL, "Unified Bed Leveling", "Auto Bed Leveling")) )); - SERIAL_ECHOPGM_P( - PSTR(" M420 S"), planner.leveling_active + SERIAL_ECHOF( + F(" M420 S"), planner.leveling_active #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - , SP_Z_STR, LINEAR_UNIT(planner.z_fade_height) + , FPSTR(SP_Z_STR), LINEAR_UNIT(planner.z_fade_height) #endif - , PSTR(" ; Leveling ") + , F(" ; Leveling ") ); serialprintln_onoff(planner.leveling_active); } diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 923a27d7df..1299259b53 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -138,8 +138,8 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) { #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) SERIAL_ECHOPGM(" S", LINEAR_UNIT(toolchange_settings.swap_length)); SERIAL_ECHOPGM_P(SP_B_STR, LINEAR_UNIT(toolchange_settings.extra_resume), - SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime), - SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed)); + SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime), + SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed)); SERIAL_ECHOPGM(" R", LINEAR_UNIT(toolchange_settings.retract_speed), " U", LINEAR_UNIT(toolchange_settings.unretract_speed), " F", toolchange_settings.fan_speed, diff --git a/Marlin/src/gcode/config/M302.cpp b/Marlin/src/gcode/config/M302.cpp index 57c049e194..e271dcd469 100644 --- a/Marlin/src/gcode/config/M302.cpp +++ b/Marlin/src/gcode/config/M302.cpp @@ -55,7 +55,7 @@ void GcodeSuite::M302() { // Report current state SERIAL_ECHO_START(); SERIAL_ECHOPGM("Cold extrudes are "); - SERIAL_ECHOPGM_P(thermalManager.allow_cold_extrude ? PSTR("en") : PSTR("dis")); + SERIAL_ECHOF(thermalManager.allow_cold_extrude ? F("en") : F("dis")); SERIAL_ECHOLNPGM("abled (min temp ", thermalManager.extrude_min_temp, "C)"); } } diff --git a/Marlin/src/gcode/control/M211.cpp b/Marlin/src/gcode/control/M211.cpp index a837d79533..d108070279 100644 --- a/Marlin/src/gcode/control/M211.cpp +++ b/Marlin/src/gcode/control/M211.cpp @@ -47,8 +47,8 @@ void GcodeSuite::M211_report(const bool forReplay/*=true*/) { report_echo_start(forReplay); const xyz_pos_t l_soft_min = soft_endstop.min.asLogical(), l_soft_max = soft_endstop.max.asLogical(); - print_pos(l_soft_min, PSTR(STR_SOFT_MIN), PSTR(" ")); - print_pos(l_soft_max, PSTR(STR_SOFT_MAX)); + print_pos(l_soft_min, F(STR_SOFT_MIN), F(" ")); + print_pos(l_soft_max, F(STR_SOFT_MAX)); } #endif // HAS_SOFTWARE_ENDSTOPS diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index 149613ee15..c11acb4380 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -48,7 +48,7 @@ // S: Report the current power supply state and exit if (parser.seen('S')) { - SERIAL_ECHOPGM_P(powerManager.psu_on ? PSTR("PS:1\n") : PSTR("PS:0\n")); + SERIAL_ECHOF(powerManager.psu_on ? F("PS:1\n") : F("PS:0\n")); return; } diff --git a/Marlin/src/gcode/feature/L6470/M122.cpp b/Marlin/src/gcode/feature/L6470/M122.cpp index 1e5b37e4b7..4a5629b049 100644 --- a/Marlin/src/gcode/feature/L6470/M122.cpp +++ b/Marlin/src/gcode/feature/L6470/M122.cpp @@ -47,10 +47,10 @@ inline void L6470_say_status(const L64XX_axis_t axis) { } #endif SERIAL_ECHOPGM("\n...OUTPUT: "); - SERIAL_ECHOPGM_P(sh.STATUS_AXIS & STATUS_HIZ ? PSTR("OFF") : PSTR("ON ")); + SERIAL_ECHOF(sh.STATUS_AXIS & STATUS_HIZ ? F("OFF") : F("ON ")); SERIAL_ECHOPGM(" BUSY: "); echo_yes_no((sh.STATUS_AXIS & STATUS_BUSY) == 0); SERIAL_ECHOPGM(" DIR: "); - SERIAL_ECHOPGM_P((((sh.STATUS_AXIS & STATUS_DIR) >> 4) ^ L64xxManager.index_to_dir[axis]) ? PSTR("FORWARD") : PSTR("REVERSE")); + SERIAL_ECHOF((((sh.STATUS_AXIS & STATUS_DIR) >> 4) ^ L64xxManager.index_to_dir[axis]) ? F("FORWARD") : F("REVERSE")); if (sh.STATUS_AXIS_LAYOUT == L6480_STATUS_LAYOUT) { SERIAL_ECHOPGM(" Last Command: "); if (sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD) SERIAL_ECHOPGM("VALID"); @@ -67,7 +67,7 @@ inline void L6470_say_status(const L64XX_axis_t axis) { SERIAL_ECHOPGM(" Last Command: "); if (!(sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD)) SERIAL_ECHOPGM("IN"); SERIAL_ECHOPGM("VALID "); - SERIAL_ECHOPGM_P(sh.STATUS_AXIS & sh.STATUS_AXIS_NOTPERF_CMD ? PSTR("COMPLETED ") : PSTR("Not PERFORMED")); + SERIAL_ECHOF(sh.STATUS_AXIS & sh.STATUS_AXIS_NOTPERF_CMD ? F("COMPLETED ") : F("Not PERFORMED")); SERIAL_ECHOPGM("\n...THERMAL: ", !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_SD) ? "SHUTDOWN " : !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_WRN) ? "WARNING " : "OK "); } SERIAL_ECHOPGM(" OVERCURRENT:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_OCD) == 0); diff --git a/Marlin/src/gcode/feature/L6470/M906.cpp b/Marlin/src/gcode/feature/L6470/M906.cpp index bab355fe38..d058ce5501 100644 --- a/Marlin/src/gcode/feature/L6470/M906.cpp +++ b/Marlin/src/gcode/feature/L6470/M906.cpp @@ -107,7 +107,7 @@ void L64XX_report_current(L64XX &motor, const L64XX_axis_t axis) { SERIAL_ECHOPGM("...MicroSteps: ", MicroSteps, " ADC_OUT: ", L6470_ADC_out); SERIAL_ECHOPGM(" Vs_compensation: "); - SERIAL_ECHOPGM_P((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_EN_VSCOMP) ? PSTR("ENABLED ") : PSTR("DISABLED")); + SERIAL_ECHOF((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_EN_VSCOMP) ? F("ENABLED ") : F("DISABLED")); SERIAL_ECHOLNPGM(" Compensation coefficient: ~", comp_coef * 0.01f); SERIAL_ECHOPGM("...KVAL_HOLD: ", motor.GetParam(L6470_KVAL_HOLD), diff --git a/Marlin/src/gcode/feature/powerloss/M413.cpp b/Marlin/src/gcode/feature/powerloss/M413.cpp index 7c714dad25..9bf109559f 100644 --- a/Marlin/src/gcode/feature/powerloss/M413.cpp +++ b/Marlin/src/gcode/feature/powerloss/M413.cpp @@ -51,8 +51,8 @@ void GcodeSuite::M413() { #if PIN_EXISTS(POWER_LOSS) if (parser.seen_test('O')) recovery._outage(); #endif - if (parser.seen_test('E')) SERIAL_ECHOPGM_P(recovery.exists() ? PSTR("PLR Exists\n") : PSTR("No PLR\n")); - if (parser.seen_test('V')) SERIAL_ECHOPGM_P(recovery.valid() ? PSTR("Valid\n") : PSTR("Invalid\n")); + if (parser.seen_test('E')) SERIAL_ECHOF(recovery.exists() ? F("PLR Exists\n") : F("No PLR\n")); + if (parser.seen_test('V')) SERIAL_ECHOF(recovery.valid() ? F("Valid\n") : F("Invalid\n")); #endif } diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index 05730eabfd..00aadd4756 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -32,7 +32,7 @@ template void tmc_say_stealth_status(TMC &st) { st.printLabel(); SERIAL_ECHOPGM(" driver mode:\t"); - SERIAL_ECHOLNPGM_P(st.get_stealthChop() ? PSTR("stealthChop") : PSTR("spreadCycle")); + SERIAL_ECHOLNF(st.get_stealthChop() ? F("stealthChop") : F("spreadCycle")); } template void tmc_set_stealthChop(TMC &st, const bool enable) { diff --git a/Marlin/src/gcode/geometry/G17-G19.cpp b/Marlin/src/gcode/geometry/G17-G19.cpp index 0154598ccb..fbac7470ca 100644 --- a/Marlin/src/gcode/geometry/G17-G19.cpp +++ b/Marlin/src/gcode/geometry/G17-G19.cpp @@ -29,10 +29,10 @@ inline void report_workspace_plane() { SERIAL_ECHO_START(); SERIAL_ECHOPGM("Workspace Plane "); - SERIAL_ECHOPGM_P( - gcode.workspace_plane == GcodeSuite::PLANE_YZ ? PSTR("YZ\n") - : gcode.workspace_plane == GcodeSuite::PLANE_ZX ? PSTR("ZX\n") - : PSTR("XY\n") + SERIAL_ECHOF( + gcode.workspace_plane == GcodeSuite::PLANE_YZ ? F("YZ\n") + : gcode.workspace_plane == GcodeSuite::PLANE_ZX ? F("ZX\n") + : F("XY\n") ); } diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index ad550765ec..83fda54836 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -351,8 +351,8 @@ public: static inline char temp_units_code() { return input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C'; } - static inline PGM_P temp_units_name() { - return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius"); + static inline FSTR_P temp_units_name() { + return input_temp_units == TEMPUNIT_K ? F("Kelvin") : input_temp_units == TEMPUNIT_F ? F("Fahrenheit") : F("Celsius"); } #if HAS_LCD_MENU && DISABLED(DISABLE_M503) diff --git a/Marlin/src/gcode/units/M149.cpp b/Marlin/src/gcode/units/M149.cpp index 20b3781ead..b1cfbb2511 100644 --- a/Marlin/src/gcode/units/M149.cpp +++ b/Marlin/src/gcode/units/M149.cpp @@ -39,7 +39,7 @@ void GcodeSuite::M149() { void GcodeSuite::M149_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, PSTR(STR_TEMPERATURE_UNITS)); SERIAL_ECHOPGM(" M149 ", AS_CHAR(parser.temp_units_code()), " ; Units in "); - SERIAL_ECHOLNPGM_P(parser.temp_units_name()); + SERIAL_ECHOLNF(parser.temp_units_name()); } #endif // TEMPERATURE_UNITS_SUPPORT diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index 1b572367f2..e7b3941928 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -306,7 +306,7 @@ void ChironTFT::PowerLossRecovery() { printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover. last_error = AC_error_powerloss; PlayTune(BEEPER_PIN, SOS, 1); - SERIAL_ECHOLNPGM_P(AC_msg_powerloss_recovery); + SERIAL_ECHOLNF(AC_msg_powerloss_recovery); } void ChironTFT::PrintComplete() { @@ -488,7 +488,7 @@ void ChironTFT::ProcessPanelRequest() { if (tpos != -1) { if (panel_command[tpos+1]== 'X' && panel_command[tpos+2]=='Y') { panel_type = AC_panel_standard; - SERIAL_ECHOLNPGM_P(AC_msg_old_panel_detected); + SERIAL_ECHOLNF(AC_msg_old_panel_detected); } } else { @@ -496,7 +496,7 @@ void ChironTFT::ProcessPanelRequest() { if (tpos != -1) { if (panel_command[tpos+1]== '0' && panel_command[tpos+2]==']') { panel_type = AC_panel_new; - SERIAL_ECHOLNPGM_P(AC_msg_new_panel_detected); + SERIAL_ECHOLNF(AC_msg_new_panel_detected); } } } @@ -825,7 +825,7 @@ void ChironTFT::PanelProcess(uint8_t req) { if (!isPrinting()) { injectCommands_P(PSTR("M501\nM420 S1")); selectedmeshpoint.x = selectedmeshpoint.y = 99; - SERIAL_ECHOLNPGM_P(AC_msg_mesh_changes_abandoned); + SERIAL_ECHOLNF(AC_msg_mesh_changes_abandoned); } } @@ -833,7 +833,7 @@ void ChironTFT::PanelProcess(uint8_t req) { if (!isPrinting()) { setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made injectCommands_P(PSTR("M500")); - SERIAL_ECHOLNPGM_P(AC_msg_mesh_changes_saved); + SERIAL_ECHOLNF(AC_msg_mesh_changes_saved); selectedmeshpoint.x = selectedmeshpoint.y = 99; } } diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 3a19d60d92..e85f5f4644 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -755,10 +755,10 @@ volatile bool Temperature::raw_temps_ready = false; SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_FINISHED); #if EITHER(PIDTEMPBED, PIDTEMPCHAMBER) - PGM_P const estring = GHV(PSTR("chamber"), PSTR("bed"), NUL_STR); - say_default_(); SERIAL_ECHOPGM_P(estring); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp); - say_default_(); SERIAL_ECHOPGM_P(estring); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki); - say_default_(); SERIAL_ECHOPGM_P(estring); SERIAL_ECHOLNPGM("Kd ", tune_pid.Kd); + FSTR_P const estring = GHV(F("chamber"), F("bed"), FPSTR(NUL_STR)); + say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp); + say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki); + say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kd ", tune_pid.Kd); #else say_default_(); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp); say_default_(); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki); @@ -1737,21 +1737,21 @@ void Temperature::manage_heater() { SERIAL_ECHOPAIR_F_P(SP_B_STR, t.beta, 1); SERIAL_ECHOPAIR_F_P(SP_C_STR, t.sh_c_coeff, 9); SERIAL_ECHOPGM(" ; "); - SERIAL_ECHOPGM_P( - TERN_(TEMP_SENSOR_0_IS_CUSTOM, t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :) - TERN_(TEMP_SENSOR_1_IS_CUSTOM, t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :) - TERN_(TEMP_SENSOR_2_IS_CUSTOM, t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :) - TERN_(TEMP_SENSOR_3_IS_CUSTOM, t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :) - TERN_(TEMP_SENSOR_4_IS_CUSTOM, t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :) - TERN_(TEMP_SENSOR_5_IS_CUSTOM, t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :) - TERN_(TEMP_SENSOR_6_IS_CUSTOM, t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :) - TERN_(TEMP_SENSOR_7_IS_CUSTOM, t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :) - TERN_(TEMP_SENSOR_BED_IS_CUSTOM, t_index == CTI_BED ? PSTR("BED") :) - TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :) - TERN_(TEMP_SENSOR_COOLER_IS_CUSTOM, t_index == CTI_COOLER ? PSTR("COOLER") :) - TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? PSTR("PROBE") :) - TERN_(TEMP_SENSOR_BOARD_IS_CUSTOM, t_index == CTI_BOARD ? PSTR("BOARD") :) - TERN_(TEMP_SENSOR_REDUNDANT_IS_CUSTOM, t_index == CTI_REDUNDANT ? PSTR("REDUNDANT") :) + SERIAL_ECHOF( + TERN_(TEMP_SENSOR_0_IS_CUSTOM, t_index == CTI_HOTEND_0 ? F("HOTEND 0") :) + TERN_(TEMP_SENSOR_1_IS_CUSTOM, t_index == CTI_HOTEND_1 ? F("HOTEND 1") :) + TERN_(TEMP_SENSOR_2_IS_CUSTOM, t_index == CTI_HOTEND_2 ? F("HOTEND 2") :) + TERN_(TEMP_SENSOR_3_IS_CUSTOM, t_index == CTI_HOTEND_3 ? F("HOTEND 3") :) + TERN_(TEMP_SENSOR_4_IS_CUSTOM, t_index == CTI_HOTEND_4 ? F("HOTEND 4") :) + TERN_(TEMP_SENSOR_5_IS_CUSTOM, t_index == CTI_HOTEND_5 ? F("HOTEND 5") :) + TERN_(TEMP_SENSOR_6_IS_CUSTOM, t_index == CTI_HOTEND_6 ? F("HOTEND 6") :) + TERN_(TEMP_SENSOR_7_IS_CUSTOM, t_index == CTI_HOTEND_7 ? F("HOTEND 7") :) + TERN_(TEMP_SENSOR_BED_IS_CUSTOM, t_index == CTI_BED ? F("BED") :) + TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? F("CHAMBER") :) + TERN_(TEMP_SENSOR_COOLER_IS_CUSTOM, t_index == CTI_COOLER ? F("COOLER") :) + TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? F("PROBE") :) + TERN_(TEMP_SENSOR_BOARD_IS_CUSTOM, t_index == CTI_BOARD ? F("BOARD") :) + TERN_(TEMP_SENSOR_REDUNDANT_IS_CUSTOM, t_index == CTI_REDUNDANT ? F("REDUNDANT") :) nullptr ); SERIAL_EOL(); diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 9f8aac634b..26a6d736eb 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -614,7 +614,7 @@ void announceOpen(const uint8_t doing, const char * const path) { PORT_REDIRECT(SerialMask::All); SERIAL_ECHO_START(); SERIAL_ECHOPGM("Now "); - SERIAL_ECHOPGM_P(doing == 1 ? PSTR("doing") : PSTR("fresh")); + SERIAL_ECHOF(doing == 1 ? F("doing") : F("fresh")); SERIAL_ECHOLNPGM(" file: ", path); } } @@ -1325,7 +1325,7 @@ void CardReader::fileHasFinished() { removeFile(recovery.filename); #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) SERIAL_ECHOPGM("Power-loss file delete"); - SERIAL_ECHOPGM_P(jobRecoverFileExists() ? PSTR(" failed.\n") : PSTR("d.\n")); + SERIAL_ECHOF(jobRecoverFileExists() ? F(" failed.\n") : F("d.\n")); #endif } } diff --git a/docs/Serial.md b/docs/Serial.md index ff8f84ef99..be3b23e87d 100644 --- a/docs/Serial.md +++ b/docs/Serial.md @@ -62,7 +62,7 @@ The following macros are defined (in `serial.h`) to output data to the serial po | `SERIAL_ECHOLNPGM` | Same as `SERIAL_ECHOPGM` | Do `SERIAL_ECHOPGM`, adding a newline | `SERIAL_ECHOPGM("Alice", 56);` | `alice56` | | `SERIAL_ECHOPGM_P` | Like `SERIAL_ECHOPGM` but takes PGM strings | Print a series of PGM strings and values alternately | `SERIAL_ECHOPGM_P(GET_TEXT(MSG_HELLO), 123);` | `Hello123` | | `SERIAL_ECHOLNPGM_P` | Same as `SERIAL_ECHOPGM_P` | Do `SERIAL_ECHOPGM_P`, adding a newline | `SERIAL_ECHOLNPGM_P(PSTR("Alice"), 78);` | `alice78\n` | -| `SERIAL_ECHOLIST` | String literal, values | Print a string literal and a list of values | `SERIAL_ECHOLIST("Key ", 1, 2, 3);` | `Key 1, 2, 3` | +| `SERIAL_ECHOLIST` | String literal, values | Print a string literal and a list of values | `SERIAL_ECHOLIST(F("Key "), 1, 2, 3);` | `Key 1, 2, 3` | | `SERIAL_ECHO_START` | None | Prefix an echo line | `SERIAL_ECHO_START();` | `echo:` | | `SERIAL_ECHO_MSG` | Same as `SERIAL_ECHOLN_PAIR` | Print a full echo line | `SERIAL_ECHO_MSG("Count is ", count);` | `echo:Count is 3` | | `SERIAL_ERROR_START`| None | Prefix an error line | `SERIAL_ERROR_START();` | `Error:` | From 360311f2320d6e5a94d17c6ff830146675be732e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 25 Sep 2021 17:05:11 -0500 Subject: [PATCH 010/546] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20F()=20to=20statu?= =?UTF-8?q?s=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 10 +-- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 38 +++++------ Marlin/src/feature/cancel_object.cpp | 2 +- Marlin/src/feature/hotend_idle.cpp | 2 +- Marlin/src/feature/mmu/mmu2.cpp | 24 +++---- Marlin/src/feature/pause.cpp | 4 +- Marlin/src/feature/stepper_driver_safety.cpp | 2 +- Marlin/src/feature/tmc_util.cpp | 2 +- Marlin/src/gcode/bedlevel/G26.cpp | 14 ++-- Marlin/src/gcode/bedlevel/abl/G29.cpp | 4 +- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 4 +- Marlin/src/gcode/calibrate/G28.cpp | 2 +- Marlin/src/gcode/calibrate/G33.cpp | 6 +- Marlin/src/gcode/calibrate/G34_M422.cpp | 8 +-- Marlin/src/gcode/calibrate/G76_M192_M871.cpp | 2 +- Marlin/src/gcode/calibrate/M48.cpp | 6 +- Marlin/src/gcode/control/M17_M18_M84.cpp | 2 +- Marlin/src/gcode/control/M80_M81.cpp | 4 +- Marlin/src/gcode/geometry/M206_M428.cpp | 4 +- Marlin/src/gcode/lcd/M0_M1.cpp | 2 +- Marlin/src/gcode/motion/G4.cpp | 2 +- Marlin/src/gcode/queue.cpp | 2 +- Marlin/src/gcode/temp/M140_M190.cpp | 2 +- Marlin/src/gcode/temp/M141_M191.cpp | 2 +- Marlin/src/gcode/temp/M143_M193.cpp | 2 +- Marlin/src/gcode/temp/M303.cpp | 2 +- Marlin/src/lcd/e3v2/creality/dwin.cpp | 12 ++-- Marlin/src/lcd/e3v2/creality/dwin.h | 4 +- Marlin/src/lcd/e3v2/enhanced/dwin.cpp | 58 ++++++++--------- Marlin/src/lcd/e3v2/enhanced/dwin.h | 6 +- Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp | 2 +- Marlin/src/lcd/extui/mks_ui/wifi_module.cpp | 2 +- Marlin/src/lcd/marlinui.cpp | 65 ++++++++++--------- Marlin/src/lcd/marlinui.h | 23 +++---- Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- Marlin/src/lcd/menu/menu_mixer.cpp | 2 +- Marlin/src/lcd/menu/menu_mmu2.cpp | 8 +-- Marlin/src/module/endstops.cpp | 4 +- Marlin/src/module/probe.cpp | 12 ++-- Marlin/src/module/settings.cpp | 6 +- Marlin/src/module/temperature.cpp | 14 ++-- Marlin/src/module/tool_change.cpp | 4 +- Marlin/src/sd/cardreader.cpp | 2 +- .../sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 10 +-- 44 files changed, 194 insertions(+), 196 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 6309f9f0d5..8a15c45f83 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -474,7 +474,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { if (!IS_SD_PRINTING() && !READ(HOME_PIN)) { // HOME_PIN goes LOW when pressed if (ELAPSED(ms, next_home_key_ms)) { next_home_key_ms = ms + HOME_DEBOUNCE_DELAY; - LCD_MESSAGEPGM(MSG_AUTO_HOME); + LCD_MESSAGE(MSG_AUTO_HOME); queue.inject_P(G28_STR); } } @@ -499,8 +499,8 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { } \ }while(0) - #define CHECK_CUSTOM_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, NOOP) - #define CHECK_BETTER_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, if (strlen(BUTTON##N##_DESC)) LCD_MESSAGEPGM_P(PSTR(BUTTON##N##_DESC))) + #define CHECK_CUSTOM_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, NOOP) + #define CHECK_BETTER_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, if (strlen(BUTTON##N##_DESC)) LCD_MESSAGE_F(BUTTON##N##_DESC)) #if HAS_BETTER_USER_BUTTON(1) CHECK_BETTER_USER_BUTTON(1); @@ -935,7 +935,7 @@ void stop() { if (!IsStopped()) { SERIAL_ERROR_MSG(STR_ERR_STOPPED); - LCD_MESSAGEPGM(MSG_STOPPED); + LCD_MESSAGE(MSG_STOPPED); safe_delay(350); // allow enough time for messages to get out before stopping marlin_state = MF_STOPPED; } @@ -1551,7 +1551,7 @@ void setup() { HMI_Init(); HMI_SetLanguageCache(); HMI_StartFrame(true); - DWIN_StatusChanged_P(GET_TEXT(WELCOME_MSG)); + DWIN_StatusChanged(GET_TEXT_F(WELCOME_MSG)); #endif #if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 9b85b5b972..051cb6a4d6 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -736,7 +736,7 @@ void unified_bed_leveling::shift_mesh_height() { const uint8_t point_num = (GRID_MAX_POINTS - count) + 1; SERIAL_ECHOLNPGM("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, "."); - TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), point_num, int(GRID_MAX_POINTS))); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), point_num, int(GRID_MAX_POINTS))); #if HAS_LCD_MENU if (ui.button_pressed()) { @@ -789,12 +789,12 @@ void unified_bed_leveling::shift_mesh_height() { #endif // HAS_BED_PROBE -void set_message_with_feedback(PGM_P const msg_P) { +void set_message_with_feedback(FSTR_P const fstr) { #if HAS_LCD_MENU - ui.set_status_P(msg_P); + ui.set_status(fstr); ui.quick_feedback(); #else - UNUSED(msg_P); + UNUSED(fstr); #endif } @@ -850,7 +850,7 @@ void set_message_with_feedback(PGM_P const msg_P) { planner.synchronize(); SERIAL_ECHOPGM("Place shim under nozzle"); - LCD_MESSAGEPGM(MSG_UBL_BC_INSERT); + LCD_MESSAGE(MSG_UBL_BC_INSERT); ui.return_to_status(); echo_and_take_a_measurement(); @@ -859,7 +859,7 @@ void set_message_with_feedback(PGM_P const msg_P) { planner.synchronize(); SERIAL_ECHOPGM("Remove shim"); - LCD_MESSAGEPGM(MSG_UBL_BC_REMOVE); + LCD_MESSAGE(MSG_UBL_BC_REMOVE); echo_and_take_a_measurement(); const float z2 = measure_point_with_encoder(); @@ -905,7 +905,7 @@ void set_message_with_feedback(PGM_P const msg_P) { if (!position_is_reachable(ppos)) break; // SHOULD NOT OCCUR (find_closest_mesh_point only returns reachable points) - LCD_MESSAGEPGM(MSG_UBL_MOVING_TO_NEXT); + LCD_MESSAGE(MSG_UBL_MOVING_TO_NEXT); do_blocking_move_to(ppos); do_z_clearance(z_clearance); @@ -917,11 +917,11 @@ void set_message_with_feedback(PGM_P const msg_P) { if (parser.seen_test('B')) { SERIAL_ECHOPGM("Place Shim & Measure"); - LCD_MESSAGEPGM(MSG_UBL_BC_INSERT); + LCD_MESSAGE(MSG_UBL_BC_INSERT); } else { SERIAL_ECHOPGM("Measure"); - LCD_MESSAGEPGM(MSG_UBL_BC_INSERT2); + LCD_MESSAGE(MSG_UBL_BC_INSERT2); } const float z_step = 0.01f; // 0.01mm per encoder tick, occasionally step @@ -974,7 +974,7 @@ void set_message_with_feedback(PGM_P const msg_P) { save_ubl_active_state_and_disable(); - LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH); + LCD_MESSAGE(MSG_UBL_FINE_TUNE_MESH); ui.capture(); // Take over control of the LCD encoder do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_PROBES); // Move to the given XY with probe clearance @@ -1039,7 +1039,7 @@ void set_message_with_feedback(PGM_P const msg_P) { if (_click_and_hold([]{ ui.return_to_status(); do_z_clearance(Z_CLEARANCE_BETWEEN_PROBES); - set_message_with_feedback(GET_TEXT(MSG_EDITING_STOPPED)); + set_message_with_feedback(GET_TEXT_F(MSG_EDITING_STOPPED)); })) break; // TODO: Disable leveling here so the Z value becomes the 'native' Z value. @@ -1060,7 +1060,7 @@ void set_message_with_feedback(PGM_P const msg_P) { do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_PROBES); - LCD_MESSAGEPGM(MSG_UBL_DONE_EDITING_MESH); + LCD_MESSAGE(MSG_UBL_DONE_EDITING_MESH); SERIAL_ECHOLNPGM("Done Editing Mesh"); if (lcd_map_control) @@ -1077,7 +1077,7 @@ void set_message_with_feedback(PGM_P const msg_P) { bool unified_bed_leveling::G29_parse_parameters() { bool err_flag = false; - set_message_with_feedback(GET_TEXT(MSG_UBL_DOING_G29)); + set_message_with_feedback(GET_TEXT_F(MSG_UBL_DOING_G29)); param.C_constant = 0; param.R_repetition = 0; @@ -1200,7 +1200,7 @@ void unified_bed_leveling::save_ubl_active_state_and_disable() { ubl_state_recursion_chk++; if (ubl_state_recursion_chk != 1) { SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row."); - set_message_with_feedback(GET_TEXT(MSG_UBL_SAVE_ERROR)); + set_message_with_feedback(GET_TEXT_F(MSG_UBL_SAVE_ERROR)); return; } #endif @@ -1213,7 +1213,7 @@ void unified_bed_leveling::restore_ubl_active_state_and_leave() { #if ENABLED(UBL_DEVEL_DEBUGGING) if (--ubl_state_recursion_chk) { SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times."); - set_message_with_feedback(GET_TEXT(MSG_UBL_RESTORE_ERROR)); + set_message_with_feedback(GET_TEXT_F(MSG_UBL_RESTORE_ERROR)); return; } #endif @@ -1438,7 +1438,7 @@ void unified_bed_leveling::smart_fill_mesh() { if (do_3_pt_leveling) { SERIAL_ECHOLNPGM("Tilting mesh (1/3)"); - TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, param.V_verbosity); if (isnan(measured_z)) @@ -1457,7 +1457,7 @@ void unified_bed_leveling::smart_fill_mesh() { if (!abort_flag) { SERIAL_ECHOLNPGM("Tilting mesh (2/3)"); - TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, param.V_verbosity); #ifdef VALIDATE_MESH_TILT @@ -1477,7 +1477,7 @@ void unified_bed_leveling::smart_fill_mesh() { if (!abort_flag) { SERIAL_ECHOLNPGM("Tilting mesh (3/3)"); - TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); measured_z = probe.probe_at_point(points[2], PROBE_PT_LAST_STOW, param.V_verbosity); #ifdef VALIDATE_MESH_TILT @@ -1518,7 +1518,7 @@ void unified_bed_leveling::smart_fill_mesh() { if (!abort_flag) { SERIAL_ECHOLNPGM("Tilting mesh point ", point_num, "/", total_points, "\n"); - TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points)); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points)); measured_z = probe.probe_at_point(rpos, parser.seen_test('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling diff --git a/Marlin/src/feature/cancel_object.cpp b/Marlin/src/feature/cancel_object.cpp index 9d50bfc0d4..bffd2bb720 100644 --- a/Marlin/src/feature/cancel_object.cpp +++ b/Marlin/src/feature/cancel_object.cpp @@ -46,7 +46,7 @@ void CancelObject::set_active_object(const int8_t obj) { #if BOTH(HAS_STATUS_MESSAGE, CANCEL_OBJECTS_REPORTING) if (active_object >= 0) - ui.status_printf_P(0, PSTR(S_FMT " %i"), GET_TEXT(MSG_PRINTING_OBJECT), int(active_object)); + ui.status_printf(0, F(S_FMT " %i"), GET_TEXT(MSG_PRINTING_OBJECT), int(active_object)); else ui.reset_status(); #endif diff --git a/Marlin/src/feature/hotend_idle.cpp b/Marlin/src/feature/hotend_idle.cpp index b962743ed0..4b137f42da 100644 --- a/Marlin/src/feature/hotend_idle.cpp +++ b/Marlin/src/feature/hotend_idle.cpp @@ -77,7 +77,7 @@ void HotendIdleProtection::check() { void HotendIdleProtection::timed_out() { next_protect_ms = 0; SERIAL_ECHOLNPGM("Hotend Idle Timeout"); - LCD_MESSAGEPGM(MSG_HOTEND_IDLE_TIMEOUT); + LCD_MESSAGE(MSG_HOTEND_IDLE_TIMEOUT); HOTEND_LOOP() { if ((HOTEND_IDLE_NOZZLE_TARGET) < thermalManager.degTargetHotend(e)) thermalManager.setTargetHotend(HOTEND_IDLE_NOZZLE_TARGET, e); diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index d9a4c07d57..7362530e35 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -451,7 +451,7 @@ void MMU2::check_version() { } static void mmu2_not_responding() { - LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING); + LCD_MESSAGE(MSG_MMU2_NOT_RESPONDING); BUZZ(100, 659); BUZZ(200, 698); BUZZ(100, 659); @@ -487,7 +487,7 @@ static void mmu2_not_responding() { if (index != extruder) { stepper.disable_extruder(); - ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); + ui.status_printf(0, GET_TEXT_F(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); command(MMU_CMD_T0 + index); manage_response(true, true); @@ -573,7 +573,7 @@ static void mmu2_not_responding() { command(MMU_CMD_U0); manage_response(true, true); } - ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); + ui.status_printf(0, GET_TEXT_F(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); mmu_loading_flag = true; command(MMU_CMD_T0 + index); manage_response(true, true); @@ -671,7 +671,7 @@ static void mmu2_not_responding() { if (index != extruder) { stepper.disable_extruder(); - ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); + ui.status_printf(0, GET_TEXT_F(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); command(MMU_CMD_T0 + index); manage_response(true, true); command(MMU_CMD_C0); @@ -808,14 +808,14 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { if (turn_off_nozzle && resume_hotend_temp) { thermalManager.setTargetHotend(resume_hotend_temp, active_extruder); - LCD_MESSAGEPGM(MSG_HEATING); + LCD_MESSAGE(MSG_HEATING); BUZZ(200, 40); while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(1000); } if (move_axes && all_axes_homed()) { - LCD_MESSAGEPGM(MSG_MMU2_RESUMING); + LCD_MESSAGE(MSG_MMU2_RESUMING); BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); // Move XY to starting position, then Z @@ -826,7 +826,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { } else { BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); - LCD_MESSAGEPGM(MSG_MMU2_RESUMING); + LCD_MESSAGE(MSG_MMU2_RESUMING); } } } @@ -908,7 +908,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) { if (thermalManager.tooColdToExtrude(active_extruder)) { BUZZ(200, 404); - LCD_ALERTMESSAGEPGM(MSG_HOTEND_TOO_COLD); + LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -944,11 +944,11 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { if (thermalManager.tooColdToExtrude(active_extruder)) { BUZZ(200, 404); - LCD_ALERTMESSAGEPGM(MSG_HOTEND_TOO_COLD); + LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } - LCD_MESSAGEPGM(MSG_MMU2_EJECTING_FILAMENT); + LCD_MESSAGE(MSG_MMU2_EJECTING_FILAMENT); stepper.enable_extruder(); current_position.e -= MMU2_FILAMENTCHANGE_EJECT_FEED; @@ -958,7 +958,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { manage_response(false, false); if (recover) { - LCD_MESSAGEPGM(MSG_MMU2_EJECT_RECOVER); + LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER); BUZZ(200, 404); TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("MMU2 Eject Recover"), CONTINUE_STR)); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover"))); @@ -993,7 +993,7 @@ bool MMU2::unload() { if (thermalManager.tooColdToExtrude(active_extruder)) { BUZZ(200, 404); - LCD_ALERTMESSAGEPGM(MSG_HOTEND_TOO_COLD); + LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 28f5caa3cb..75255d87ac 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -538,7 +538,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, ui.set_status_P(GET_TEXT(MSG_REHEATING))); + TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATING)); // Re-enable the heaters if they timed out HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e); @@ -556,7 +556,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_REHEATDONE), CONTINUE_STR)); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_REHEATDONE))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, ui.set_status_P(GET_TEXT(MSG_REHEATDONE))); + TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATDONE)); IF_DISABLED(PAUSE_REHEAT_FAST_RESUME, wait_for_user = true); diff --git a/Marlin/src/feature/stepper_driver_safety.cpp b/Marlin/src/feature/stepper_driver_safety.cpp index c7da5d2ff7..8ba0968cd2 100644 --- a/Marlin/src/feature/stepper_driver_safety.cpp +++ b/Marlin/src/feature/stepper_driver_safety.cpp @@ -32,7 +32,7 @@ void stepper_driver_backward_error(PGM_P str) { SERIAL_ERROR_START(); SERIAL_ECHOPGM_P(str); SERIAL_ECHOLNPGM(" driver is backward!"); - ui.status_printf_P(2, PSTR(S_FMT S_FMT), str, GET_TEXT(MSG_DRIVER_BACKWARD)); + ui.status_printf(2, F(S_FMT S_FMT), str, GET_TEXT(MSG_DRIVER_BACKWARD)); } void stepper_driver_backward_check() { diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index 6848d81003..c11d2e5f6d 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -1341,7 +1341,7 @@ void test_tmc_connection(LOGICAL_AXIS_ARGS(const bool)) { #endif } - if (axis_connection) LCD_MESSAGEPGM(MSG_ERROR_TMC); + if (axis_connection) LCD_MESSAGE(MSG_ERROR_TMC); } #endif // HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index ba14e6f0b4..e111bcd8aa 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -163,7 +163,7 @@ float g26_random_deviation = 0.0; */ bool user_canceled() { if (!ui.button_pressed()) return false; // Return if the button isn't pressed - ui.set_status_P(GET_TEXT(MSG_G26_CANCELED), 99); + ui.set_status(GET_TEXT_F(MSG_G26_CANCELED), 99); TERN_(HAS_LCD_MENU, ui.quick_feedback()); ui.wait_for_release(); return true; @@ -323,7 +323,7 @@ typedef struct { if (bed_temp > 25) { #if HAS_WIRED_LCD - ui.set_status_P(GET_TEXT(MSG_G26_HEATING_BED), 99); + ui.set_status(GET_TEXT_F(MSG_G26_HEATING_BED), 99); ui.quick_feedback(); TERN_(HAS_LCD_MENU, ui.capture()); #endif @@ -342,7 +342,7 @@ typedef struct { // Start heating the active nozzle #if HAS_WIRED_LCD - ui.set_status_P(GET_TEXT(MSG_G26_HEATING_NOZZLE), 99); + ui.set_status(GET_TEXT_F(MSG_G26_HEATING_NOZZLE), 99); ui.quick_feedback(); #endif thermalManager.setTargetHotend(hotend_temp, active_extruder); @@ -372,7 +372,7 @@ typedef struct { if (prime_flag == -1) { // The user wants to control how much filament gets purged ui.capture(); - ui.set_status_P(GET_TEXT(MSG_G26_MANUAL_PRIME), 99); + ui.set_status(GET_TEXT_F(MSG_G26_MANUAL_PRIME), 99); ui.chirp(); destination = current_position; @@ -399,7 +399,7 @@ typedef struct { ui.wait_for_release(); - ui.set_status_P(GET_TEXT(MSG_G26_PRIME_DONE), 99); + ui.set_status(GET_TEXT_F(MSG_G26_PRIME_DONE), 99); ui.quick_feedback(); ui.release(); } @@ -407,7 +407,7 @@ typedef struct { #endif { #if HAS_WIRED_LCD - ui.set_status_P(GET_TEXT(MSG_G26_FIXED_LENGTH), 99); + ui.set_status(GET_TEXT_F(MSG_G26_FIXED_LENGTH), 99); ui.quick_feedback(); #endif destination = current_position; @@ -854,7 +854,7 @@ void GcodeSuite::G26() { } while (--g26_repeats && location.valid()); LEAVE: - ui.set_status_P(GET_TEXT(MSG_G26_LEAVING), -1); + ui.set_status(GET_TEXT_F(MSG_G26_LEAVING), -1); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, ExtUI::G26_FINISH)); g26.retract_filament(destination); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 03b0450c6b..07aefe8aed 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -636,7 +636,7 @@ G29_TYPE GcodeSuite::G29() { if (TERN0(IS_KINEMATIC, !probe.can_reach(abl.probePos))) continue; if (abl.verbose_level) SERIAL_ECHOLNPGM("Probing mesh point ", pt_index, "/", abl.abl_points, "."); - TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), int(pt_index), int(abl.abl_points))); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), int(pt_index), int(abl.abl_points))); abl.measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level); @@ -681,7 +681,7 @@ G29_TYPE GcodeSuite::G29() { LOOP_L_N(i, 3) { if (abl.verbose_level) SERIAL_ECHOLNPGM("Probing point ", i + 1, "/3."); - TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_POINT), int(i + 1))); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_POINT), int(i + 1))); // Retain the last probe position abl.probePos = xy_pos_t(points[i]); diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 930953ea14..eec89f73ac 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -152,7 +152,7 @@ void GcodeSuite::G29() { // After recording the last point, activate home and activate mbl_probe_index = -1; SERIAL_ECHOLNPGM("Mesh probing done."); - TERN_(HAS_STATUS_MESSAGE, ui.set_status(GET_TEXT(MSG_MESH_DONE))); + TERN_(HAS_STATUS_MESSAGE, LCD_MESSAGE(MSG_MESH_DONE)); BUZZ(100, 659); BUZZ(100, 698); @@ -214,7 +214,7 @@ void GcodeSuite::G29() { if (state == MeshNext) { SERIAL_ECHOLNPGM("MBL G29 point ", _MIN(mbl_probe_index, GRID_MAX_POINTS), " of ", GRID_MAX_POINTS); - if (mbl_probe_index > 0) TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), _MIN(mbl_probe_index, GRID_MAX_POINTS), int(GRID_MAX_POINTS))); + if (mbl_probe_index > 0) TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), _MIN(mbl_probe_index, GRID_MAX_POINTS), int(GRID_MAX_POINTS))); } report_current_position(); diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 01c6050155..1c7e839f45 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -156,7 +156,7 @@ homeaxis(Z_AXIS); } else { - LCD_MESSAGEPGM(MSG_ZPROBE_OUT); + LCD_MESSAGE(MSG_ZPROBE_OUT); SERIAL_ECHO_MSG(STR_ZPROBE_OUT_SER); } } diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 24a985299f..4ac25c2cf1 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -477,11 +477,11 @@ void GcodeSuite::G33() { SERIAL_ECHOLNPGM("G33 Auto Calibrate"); // Report settings - PGM_P const checkingac = PSTR("Checking... AC"); - SERIAL_ECHOPGM_P(checkingac); + FSTR_P const checkingac = F("Checking... AC"); + SERIAL_ECHOF(checkingac); if (verbose_level == 0) SERIAL_ECHOPGM(" (DRY-RUN)"); SERIAL_EOL(); - ui.set_status_P(checkingac); + ui.set_status(checkingac); print_calibration_settings(_endstop_results, _angle_results); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 63d839c847..25855e6a4e 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -31,7 +31,7 @@ #include "../../module/stepper.h" #include "../../module/planner.h" #include "../../module/probe.h" -#include "../../lcd/marlinui.h" // for LCD_MESSAGEPGM +#include "../../lcd/marlinui.h" // for LCD_MESSAGE #if HAS_LEVELING #include "../../feature/bedlevel/bedlevel.h" @@ -229,7 +229,7 @@ void GcodeSuite::G34() { const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true, false); if (isnan(z_probed_height)) { SERIAL_ECHOLNPGM("Probing failed"); - LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED); + LCD_MESSAGE(MSG_LCD_PROBING_FAILED); err_break = true; break; } @@ -328,7 +328,7 @@ void GcodeSuite::G34() { auto decreasing_accuracy = [](const_float_t v1, const_float_t v2) { if (v1 < v2 * 0.7f) { SERIAL_ECHOLNPGM("Decreasing Accuracy Detected."); - LCD_MESSAGEPGM(MSG_DECREASING_ACCURACY); + LCD_MESSAGE(MSG_DECREASING_ACCURACY); return true; } return false; @@ -411,7 +411,7 @@ void GcodeSuite::G34() { if (success_break) { SERIAL_ECHOLNPGM("Target accuracy achieved."); - LCD_MESSAGEPGM(MSG_ACCURACY_ACHIEVED); + LCD_MESSAGE(MSG_ACCURACY_ACHIEVED); break; } diff --git a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp index 0fcd686a06..0fc41ed929 100644 --- a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp @@ -351,7 +351,7 @@ void GcodeSuite::M192() { } const celsius_t target_temp = parser.value_celsius(); - ui.set_status_P(thermalManager.isProbeBelowTemp(target_temp) ? GET_TEXT(MSG_PROBE_HEATING) : GET_TEXT(MSG_PROBE_COOLING)); + ui.set_status(thermalManager.isProbeBelowTemp(target_temp) ? GET_TEXT_F(MSG_PROBE_HEATING) : GET_TEXT_F(MSG_PROBE_COOLING)); thermalManager.wait_for_probe(target_temp, no_wait_for_cooling); } diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 9db90c76ac..913ffe30d4 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -79,7 +79,7 @@ void GcodeSuite::M48() { }; if (!probe.can_reach(test_position)) { - ui.set_status_P(GET_TEXT(MSG_M48_OUT_OF_BOUNDS), 99); + ui.set_status(GET_TEXT_F(MSG_M48_OUT_OF_BOUNDS), 99); SERIAL_ECHOLNPGM("? (X,Y) out of bounds."); return; } @@ -144,7 +144,7 @@ void GcodeSuite::M48() { LOOP_L_N(n, n_samples) { #if HAS_STATUS_MESSAGE // Display M48 progress in the status bar - ui.status_printf_P(0, PSTR(S_FMT ": %d/%d"), GET_TEXT(MSG_M48_POINT), int(n + 1), int(n_samples)); + ui.status_printf(0, F(S_FMT ": %d/%d"), GET_TEXT(MSG_M48_POINT), int(n + 1), int(n_samples)); #endif // When there are "legs" of movement move around the point before probing @@ -260,7 +260,7 @@ void GcodeSuite::M48() { #if HAS_STATUS_MESSAGE // Display M48 results in the status bar char sigma_str[8]; - ui.status_printf_P(0, PSTR(S_FMT ": %s"), GET_TEXT(MSG_M48_DEVIATION), dtostrf(sigma, 2, 6, sigma_str)); + ui.status_printf(0, F(S_FMT ": %s"), GET_TEXT(MSG_M48_DEVIATION), dtostrf(sigma, 2, 6, sigma_str)); #endif } diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index 82df20ac45..4683786f1f 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -136,7 +136,7 @@ void GcodeSuite::M17() { } } else { - LCD_MESSAGEPGM(MSG_NO_MOVE); + LCD_MESSAGE(MSG_NO_MOVE); stepper.enable_all_steppers(); } } diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index c11acb4380..2a1b3b34b9 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -25,7 +25,7 @@ #include "../../module/temperature.h" #include "../../module/planner.h" // for planner.finish_and_disable #include "../../module/printcounter.h" // for print_job_timer.stop -#include "../../lcd/marlinui.h" // for LCD_MESSAGEPGM_P +#include "../../lcd/marlinui.h" // for LCD_MESSAGE_F #include "../../inc/MarlinConfig.h" @@ -95,5 +95,5 @@ void GcodeSuite::M81() { powerManager.power_off_soon(); #endif - LCD_MESSAGEPGM_P(PSTR(MACHINE_NAME " " STR_OFF ".")); + LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF "."); } diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index 416b3f7634..8dba238d09 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -91,7 +91,7 @@ void GcodeSuite::M428() { diff[i] = -current_position[i]; if (!WITHIN(diff[i], -20, 20)) { SERIAL_ERROR_MSG(STR_ERR_M428_TOO_FAR); - LCD_ALERTMESSAGEPGM_P(PSTR("Err: Too far!")); + LCD_ALERTMESSAGE_F("Err: Too far!"); BUZZ(200, 40); return; } @@ -99,7 +99,7 @@ void GcodeSuite::M428() { LOOP_LINEAR_AXES(i) set_home_offset((AxisEnum)i, diff[i]); report_current_position(); - LCD_MESSAGEPGM(MSG_HOME_OFFSETS_APPLIED); + LCD_MESSAGE(MSG_HOME_OFFSETS_APPLIED); BUZZ(100, 659); BUZZ(100, 698); } diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 241f11c813..32df8dd9c3 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -59,7 +59,7 @@ void GcodeSuite::M0_M1() { if (parser.string_arg) ui.set_status(parser.string_arg, true); else { - LCD_MESSAGEPGM(MSG_USERWAIT); + LCD_MESSAGE(MSG_USERWAIT); #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0 ui.reset_progress_bar_timeout(); #endif diff --git a/Marlin/src/gcode/motion/G4.cpp b/Marlin/src/gcode/motion/G4.cpp index 724ed7f1ca..df3f5b010e 100644 --- a/Marlin/src/gcode/motion/G4.cpp +++ b/Marlin/src/gcode/motion/G4.cpp @@ -38,7 +38,7 @@ void GcodeSuite::G4() { SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP); #endif - if (!ui.has_status()) LCD_MESSAGEPGM(MSG_DWELL); + if (!ui.has_status()) LCD_MESSAGE(MSG_DWELL); dwell(dwell_ms); } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 8b8468bee4..983833c025 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -513,7 +513,7 @@ void GCodeQueue::get_serial_commands() { TERN_(BEZIER_CURVE_SUPPORT, case 5:) PORT_REDIRECT(SERIAL_PORTMASK(p)); // Reply to the serial port that sent the command SERIAL_ECHOLNPGM(STR_ERR_STOPPED); - LCD_MESSAGEPGM(MSG_STOPPED); + LCD_MESSAGE(MSG_STOPPED); break; } } diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index 857e11dde5..edc15b9cba 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -83,7 +83,7 @@ void GcodeSuite::M140_M190(const bool isM190) { thermalManager.setTargetBed(temp); - ui.set_status_P(thermalManager.isHeatingBed() ? GET_TEXT(MSG_BED_HEATING) : GET_TEXT(MSG_BED_COOLING)); + ui.set_status(thermalManager.isHeatingBed() ? GET_TEXT_F(MSG_BED_HEATING) : GET_TEXT_F(MSG_BED_COOLING)); // with PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.auto_job_check_timer(isM190, !isM190)); diff --git a/Marlin/src/gcode/temp/M141_M191.cpp b/Marlin/src/gcode/temp/M141_M191.cpp index ed7637c92a..81a078318a 100644 --- a/Marlin/src/gcode/temp/M141_M191.cpp +++ b/Marlin/src/gcode/temp/M141_M191.cpp @@ -69,7 +69,7 @@ void GcodeSuite::M191() { const bool is_heating = thermalManager.isHeatingChamber(); if (is_heating || !no_wait_for_cooling) { - ui.set_status_P(is_heating ? GET_TEXT(MSG_CHAMBER_HEATING) : GET_TEXT(MSG_CHAMBER_COOLING)); + ui.set_status(is_heating ? GET_TEXT_F(MSG_CHAMBER_HEATING) : GET_TEXT_F(MSG_CHAMBER_COOLING)); thermalManager.wait_for_chamber(false); } } diff --git a/Marlin/src/gcode/temp/M143_M193.cpp b/Marlin/src/gcode/temp/M143_M193.cpp index aef4350e60..e4b29bee5f 100644 --- a/Marlin/src/gcode/temp/M143_M193.cpp +++ b/Marlin/src/gcode/temp/M143_M193.cpp @@ -58,7 +58,7 @@ void GcodeSuite::M193() { cooler.enable(); thermalManager.setTargetCooler(parser.value_celsius()); if (thermalManager.isLaserCooling()) { - ui.set_status_P(GET_TEXT(MSG_LASER_COOLING)); + LCD_MESSAGE(MSG_LASER_COOLING); thermalManager.wait_for_cooler(true); } } diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index 0d0ce478ee..f823aefbed 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -85,7 +85,7 @@ void GcodeSuite::M303() { KEEPALIVE_STATE(NOT_BUSY); #endif - LCD_MESSAGEPGM(MSG_PID_AUTOTUNE); + LCD_MESSAGE(MSG_PID_AUTOTUNE); thermalManager.PID_autotune(temp, hid, c, u); ui.reset_status(); } diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index 5b1d36fdae..d5abe977e5 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -4287,16 +4287,16 @@ void DWIN_CompletedLeveling() { if (checkkey == Leveling) Goto_MainMenu(); } -void DWIN_StatusChanged(const char *text) { +void DWIN_StatusChanged(const char * const cstr/*=nullptr*/) { DWIN_Draw_Rectangle(1, Color_Bg_Blue, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 24); - const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(text) * MENU_CHR_W) / 2; - DWIN_Draw_String(false, font8x16, Color_White, Color_Bg_Blue, x, STATUS_Y + 3, F(text)); + const int8_t x = _MAX(0U, DWIN_WIDTH - strlen(cstr) * MENU_CHR_W) / 2; + DWIN_Draw_String(false, font8x16, Color_White, Color_Bg_Blue, x, STATUS_Y + 3, cstr); DWIN_UpdateLCD(); } -void DWIN_StatusChanged_P(PGM_P const pstr) { - char str[strlen_P((const char*)pstr) + 1]; - strcpy_P(str, (const char*)pstr); +void DWIN_StatusChanged(FSTR_P const fstr) { + char str[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(str, FTOP(fstr)); DWIN_StatusChanged(str); } diff --git a/Marlin/src/lcd/e3v2/creality/dwin.h b/Marlin/src/lcd/e3v2/creality/dwin.h index d4afe46a7d..d9ac0aa5fa 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.h +++ b/Marlin/src/lcd/e3v2/creality/dwin.h @@ -244,8 +244,8 @@ void HMI_Init(); void DWIN_Update(); void EachMomentUpdate(); void DWIN_HandleScreen(); -void DWIN_StatusChanged(const char *text); -void DWIN_StatusChanged_P(PGM_P const pstr); +void DWIN_StatusChanged(const char * const cstr=nullptr); +void DWIN_StatusChanged(FSTR_P const fstr); inline void DWIN_StartHoming() { HMI_flag.home_flag = true; } diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp b/Marlin/src/lcd/e3v2/enhanced/dwin.cpp index 3768150f8e..064ebbd47d 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp +++ b/Marlin/src/lcd/e3v2/enhanced/dwin.cpp @@ -713,7 +713,7 @@ void Draw_Main_Menu() { void Goto_Main_Menu() { checkkey = MainMenu; - DWIN_StatusChanged(nullptr); + DWIN_StatusChanged(); Draw_Main_Menu(); } @@ -1758,20 +1758,20 @@ void DWIN_Startup() { HMI_SetLanguage(); } -void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text) { +void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char * const text/*=nullptr*/) { DWIN_Draw_Rectangle(1, bgcolor, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); if (text) DWINUI::Draw_CenteredString(color, STATUS_Y + 2, text); DWIN_UpdateLCD(); } // Update Status line -void DWIN_StatusChanged(const char *text) { - DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, text); +void DWIN_StatusChanged(const char * const cstr/*=nullptr*/) { + DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, cstr); } -void DWIN_StatusChanged_P(PGM_P const pstr) { - char str[strlen_P((const char*)pstr) + 1]; - strcpy_P(str, (const char*)pstr); +void DWIN_StatusChanged(FSTR_P const fstr) { + char str[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(str, FTOP(fstr)); DWIN_StatusChanged(str); } @@ -1806,7 +1806,7 @@ void DWIN_Progress_Update() { #if HAS_FILAMENT_SENSOR // Filament Runout process - void DWIN_FilamentRunout(const uint8_t extruder) { ui.set_status_P(GET_TEXT(MSG_RUNOUT_SENSOR)); } + void DWIN_FilamentRunout(const uint8_t extruder) { LCD_MESSAGE(MSG_RUNOUT_SENSOR); } #endif void DWIN_SetColorDefaults() { @@ -1891,7 +1891,7 @@ void DWIN_Redraw_screen() { case PAUSE_MESSAGE_OPTION: DWIN_Popup_FilamentPurge(); break; case PAUSE_MESSAGE_RESUME: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_RESUME)); break; case PAUSE_MESSAGE_HEAT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), ICON_Continue_E); break; - case PAUSE_MESSAGE_HEATING: ui.set_status_P(GET_TEXT(MSG_FILAMENT_CHANGE_HEATING)); break; + case PAUSE_MESSAGE_HEATING: LCD_MESSAGE(MSG_FILAMENT_CHANGE_HEATING); break; case PAUSE_MESSAGE_STATUS: HMI_ReturnScreen(); break; default: break; } @@ -2183,7 +2183,7 @@ void SetMoveZto0() { ); gcode.process_subcommands_now(cmd); planner.synchronize(); - ui.set_status_P(PSTR("Now adjust Z Offset")); + LCD_MESSAGE_F("Now adjust Z Offset"); HMI_AudioFeedback(true); } @@ -2240,7 +2240,7 @@ void Goto_LockScreen() { DWIN_LockScreen(true); } void SetProbeOffsetY() { SetPFloatOnClick(-50, 50, UNITFDIGITS); } void SetProbeOffsetZ() { SetPFloatOnClick(-10, 10, 2); } void ProbeTest() { - ui.set_status_P(GET_TEXT(MSG_M48_TEST)); + LCD_MESSAGE(MSG_M48_TEST); queue.inject(F("G28O\nM48 P10")); } #endif @@ -2297,7 +2297,7 @@ void DWIN_ApplyColor() { DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); Draw_Status_Area(false); Draw_SelectColors_Menu(); - ui.set_status_P(PSTR("Colors applied")); + LCD_MESSAGE_F("Colors applied"); } void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } @@ -2325,18 +2325,18 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } } void ParkHead(){ - ui.set_status_P(GET_TEXT(MSG_FILAMENT_PARK_ENABLED)); + LCD_MESSAGE(MSG_FILAMENT_PARK_ENABLED); queue.inject(F("G28O\nG27")); } #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) void UnloadFilament(){ - ui.set_status_P(GET_TEXT(MSG_FILAMENTUNLOAD)); + LCD_MESSAGE(MSG_FILAMENTUNLOAD); queue.inject(F("M702 Z20")); } void LoadFilament(){ - ui.set_status_P(GET_TEXT(MSG_FILAMENTLOAD)); + LCD_MESSAGE(MSG_FILAMENTLOAD); queue.inject(F("M701 Z20")); } #endif @@ -2362,23 +2362,23 @@ void LevBed(uint8_t point) { switch (point) { case 0: - ui.set_status_P(GET_TEXT(MSG_LEVBED_FL)); + LCD_MESSAGE(MSG_LEVBED_FL); xpos = ypos = margin; break; case 1: - ui.set_status_P(GET_TEXT(MSG_LEVBED_FR)); + LCD_MESSAGE(MSG_LEVBED_FR); xpos = X_BED_SIZE - margin; ypos = margin; break; case 2: - ui.set_status_P(GET_TEXT(MSG_LEVBED_BR)); + LCD_MESSAGE(MSG_LEVBED_BR); xpos = X_BED_SIZE - margin; ypos = Y_BED_SIZE - margin; break; case 3: - ui.set_status_P(GET_TEXT(MSG_LEVBED_BL)); + LCD_MESSAGE(MSG_LEVBED_BL); xpos = margin; ypos = Y_BED_SIZE - margin; break; case 4: - ui.set_status_P(GET_TEXT(MSG_LEVBED_C)); + LCD_MESSAGE(MSG_LEVBED_C); xpos = X_BED_SIZE / 2; ypos = Y_BED_SIZE / 2; break; } @@ -2393,7 +2393,7 @@ void LevBed(uint8_t point) { dtostrf(ypos, 1, 1, str_2), dtostrf(zval, 1, 2, str_3) ); - ui.set_status_P(cmd); + ui.set_status(cmd); #else planner.synchronize(); sprintf_P(cmd, PSTR(fmt), xpos, ypos); @@ -2410,7 +2410,7 @@ void LevBedC () { LevBed(4); } #if ENABLED(MESH_BED_LEVELING) void ManualMeshStart(){ - ui.set_status_P(GET_TEXT(MSG_UBL_BUILD_MESH_MENU)); + LCD_MESSAGE(MSG_UBL_BUILD_MESH_MENU); gcode.process_subcommands_now(F("G28 XYO\nG28 Z\nM211 S0\nG29S1")); planner.synchronize(); #ifdef MANUAL_PROBE_START_Z @@ -2435,7 +2435,7 @@ void LevBedC () { LevBed(4); } } void ManualMeshSave(){ - ui.set_status_P(GET_TEXT(MSG_UBL_STORAGE_MESH_MENU)); + LCD_MESSAGE(MSG_UBL_STORAGE_MESH_MENU); queue.inject(F("M211 S1\nM500")); } @@ -3092,11 +3092,11 @@ void HMI_SetPFloat() { // Menu Creation and Drawing functions ====================================================== -void SetMenuTitle(frame_rect_t cn, frame_rect_t en, const __FlashStringHelper* text) { +void SetMenuTitle(frame_rect_t cn, frame_rect_t en, const __FlashStringHelper* fstr) { if (HMI_IsChinese() && (cn.w != 0)) CurrentMenu->MenuTitle.SetFrame(cn.x, cn.y, cn.w, cn.h); else - CurrentMenu->MenuTitle.SetCaption(text); + CurrentMenu->MenuTitle.SetCaption(fstr); } void Draw_Prepare_Menu() { @@ -3234,7 +3234,7 @@ void Draw_Move_Menu() { #endif } CurrentMenu->draw(); - if (!all_axes_trusted()) ui.set_status_P(PSTR("WARNING: position is unknow")); + if (!all_axes_trusted()) LCD_MESSAGE_F("WARNING: position is unknown"); } #if HAS_HOME_OFFSET @@ -3440,11 +3440,11 @@ void Draw_Motion_Menu() { #if HAS_PREHEAT - void Draw_Preheat_Menu(frame_rect_t cn, frame_rect_t en, const __FlashStringHelper* text) { + void Draw_Preheat_Menu(frame_rect_t cn, frame_rect_t en, const __FlashStringHelper* fstr) { checkkey = Menu; if (CurrentMenu != PreheatMenu) { CurrentMenu = PreheatMenu; - SetMenuTitle(cn, en, text); + SetMenuTitle(cn, en, fstr); DWINUI::MenuItemsPrepare(5); ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Temperature_Menu); #if HAS_HOTEND @@ -3648,7 +3648,7 @@ void Draw_Steps_Menu() { ADDMENUITEM_P(ICON_Zoffset, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); } CurrentMenu->draw(); - if (!axis_is_trusted(Z_AXIS)) ui.set_status_P(PSTR("WARNING: Z position is unknow, move Z to home")); + if (!axis_is_trusted(Z_AXIS)) LCD_MESSAGE_F("WARNING: Z position unknown, move Z to home"); } #endif diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.h b/Marlin/src/lcd/e3v2/enhanced/dwin.h index f71d54b482..0908417117 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.h +++ b/Marlin/src/lcd/e3v2/enhanced/dwin.h @@ -179,9 +179,9 @@ void EachMomentUpdate(); void update_variable(); void DWIN_HandleScreen(); void DWIN_Update(); -void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text); -void DWIN_StatusChanged(const char * const text); -void DWIN_StatusChanged_P(PGM_P const text); +void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text=nullptr); +void DWIN_StatusChanged(const char * const cstr=nullptr); +void DWIN_StatusChanged(FSTR_P const fstr); void DWIN_StartHoming(); void DWIN_CompletedHoming(); #if HAS_MESH diff --git a/Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp b/Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp index 88ab504a54..8d6b5fa2c0 100644 --- a/Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp +++ b/Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp @@ -66,7 +66,7 @@ void MeshViewerClass::Draw() { } } char str_1[6], str_2[6] = ""; - ui.status_printf_P(0, PSTR("Mesh minZ: %s, maxZ: %s"), + ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), dtostrf((float)minz / 100, 1, 2, str_1), dtostrf((float)maxz / 100, 1, 2, str_2) ); diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index f0d0156151..96b0f2a086 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -2018,7 +2018,7 @@ void get_wifi_commands() { TERN_(ARC_SUPPORT, case 2 ... 3:) TERN_(BEZIER_CURVE_SUPPORT, case 5:) SERIAL_ECHOLNPGM(STR_ERR_STOPPED); - LCD_MESSAGEPGM(MSG_STOPPED); + LCD_MESSAGE(MSG_STOPPED); break; } } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index e8a86730aa..009931d428 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -665,7 +665,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::kill_screen(PGM_P lcd_error, PGM_P lcd_component) { init(); - status_printf_P(1, PSTR(S_FMT ": " S_FMT), lcd_error, lcd_component); + status_printf(1, F(S_FMT ": " S_FMT), lcd_error, lcd_component); TERN_(HAS_LCD_MENU, return_to_status()); // RED ALERT. RED ALERT. @@ -1393,76 +1393,77 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if SERVICE_INTERVAL_3 > 0 static PGMSTR(service3, "> " SERVICE_NAME_3 "!"); #endif - PGM_P msg; + FSTR_P msg; if (printingIsPaused()) - msg = GET_TEXT(MSG_PRINT_PAUSED); + msg = GET_TEXT_F(MSG_PRINT_PAUSED); #if ENABLED(SDSUPPORT) else if (IS_SD_PRINTING()) return set_status(card.longest_filename(), true); #endif else if (print_job_timer.isRunning()) - msg = GET_TEXT(MSG_PRINTING); + msg = GET_TEXT_F(MSG_PRINTING); #if SERVICE_INTERVAL_1 > 0 - else if (print_job_timer.needsService(1)) msg = service1; + else if (print_job_timer.needsService(1)) msg = FPSTR(service1); #endif #if SERVICE_INTERVAL_2 > 0 - else if (print_job_timer.needsService(2)) msg = service2; + else if (print_job_timer.needsService(2)) msg = FPSTR(service2); #endif #if SERVICE_INTERVAL_3 > 0 - else if (print_job_timer.needsService(3)) msg = service3; + else if (print_job_timer.needsService(3)) msg = FPSTR(service3); #endif else if (!no_welcome) - msg = GET_TEXT(WELCOME_MSG); + msg = GET_TEXT_F(WELCOME_MSG); else return; - set_status_P(msg, -1); + set_status(msg, -1); } - void MarlinUI::set_status_P(PGM_P const message, int8_t level) { + void MarlinUI::set_status(FSTR_P const fstr, int8_t level) { + PGM_P const pstr = FTOP(fstr); if (level < 0) level = alert_level = 0; if (level < alert_level) return; alert_level = level; - TERN_(HOST_PROMPT_SUPPORT, host_action_notify_P(message)); + TERN_(HOST_PROMPT_SUPPORT, host_action_notify_P(pstr)); // Since the message is encoded in UTF8 it must // only be cut on a character boundary. // Get a pointer to the null terminator - PGM_P pend = message + strlen_P(message); + PGM_P pend = pstr + strlen_P(pstr); // If length of supplied UTF8 string is greater than // the buffer size, start cutting whole UTF8 chars - while ((pend - message) > MAX_MESSAGE_LENGTH) { + while ((pend - pstr) > MAX_MESSAGE_LENGTH) { --pend; while (!START_OF_UTF8_CHAR(pgm_read_byte(pend))) --pend; }; // At this point, we have the proper cut point. Use it - uint8_t maxLen = pend - message; - strncpy_P(status_message, message, maxLen); + uint8_t maxLen = pend - pstr; + strncpy_P(status_message, pstr, maxLen); status_message[maxLen] = '\0'; finish_status(level > 0); } - void MarlinUI::set_alert_status_P(PGM_P const message) { - set_status_P(message, 1); + void MarlinUI::set_alert_status(FSTR_P const fstr) { + set_status(fstr, 1); TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); TERN_(HAS_LCD_MENU, return_to_status()); } #include - void MarlinUI::status_printf_P(const uint8_t level, PGM_P const fmt, ...) { + void MarlinUI::status_printf(const uint8_t level, FSTR_P const fmt, ...) { if (level < alert_level) return; alert_level = level; va_list args; - va_start(args, fmt); - vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, fmt, args); + va_start(args, FTOP(fmt)); + vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, FTOP(fmt), args); va_end(args); finish_status(level > 0); } @@ -1536,7 +1537,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif IF_DISABLED(SDSUPPORT, print_job_timer.stop()); TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("UI Aborted"), DISMISS_STR)); - LCD_MESSAGEPGM(MSG_PRINT_ABORTED); + LCD_MESSAGE(MSG_PRINT_ABORTED); TERN_(HAS_LCD_MENU, return_to_status()); } @@ -1548,7 +1549,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif void MarlinUI::flow_fault() { - LCD_ALERTMESSAGEPGM(MSG_FLOWMETER_FAULT); + LCD_ALERTMESSAGE(MSG_FLOWMETER_FAULT); TERN_(HAS_BUZZER, buzz(1000, 440)); TERN_(HAS_LCD_MENU, return_to_status()); } @@ -1566,7 +1567,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"))); - LCD_MESSAGEPGM(MSG_PRINT_PAUSED); + LCD_MESSAGE(MSG_PRINT_PAUSED); #if ENABLED(PARK_HEAD_ON_PAUSE) pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT); // Show message immediately to let user know about pause in progress @@ -1637,14 +1638,14 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; // // Send the status line as a host notification // - void MarlinUI::set_status(const char * const message, const bool) { - TERN(HOST_PROMPT_SUPPORT, host_action_notify(message), UNUSED(message)); + void MarlinUI::set_status(const char * const cstr, const bool) { + TERN(HOST_PROMPT_SUPPORT, host_action_notify(cstr), UNUSED(cstr)); } - void MarlinUI::set_status_P(PGM_P message, const int8_t) { - TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(message), UNUSED(message)); + void MarlinUI::set_status(FSTR_P const fstr, const int8_t) { + TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(FTOP(fstr)), UNUSED(fstr)); } - void MarlinUI::status_printf_P(const uint8_t, PGM_P const message, ...) { - TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(message), UNUSED(message)); + void MarlinUI::status_printf(const uint8_t, FSTR_P const fstr, ...) { + TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(FPSTR(fstr)), UNUSED(fstr)); } #endif // !HAS_DISPLAY && !HAS_STATUS_MESSAGE @@ -1670,7 +1671,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; quick_feedback(); goto_screen(MEDIA_MENU_GATEWAY); #else - LCD_MESSAGEPGM(MSG_MEDIA_INSERTED); + LCD_MESSAGE(MSG_MEDIA_INSERTED); #endif } } @@ -1679,7 +1680,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if ENABLED(EXTENSIBLE_UI) ExtUI::onMediaRemoved(); #elif PIN_EXISTS(SD_DETECT) - LCD_MESSAGEPGM(MSG_MEDIA_REMOVED); + LCD_MESSAGE(MSG_MEDIA_REMOVED); #if HAS_LCD_MENU if (!defer_return_to_status) return_to_status(); #endif @@ -1802,7 +1803,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; ); }); #else - set_status_P(eeprom_err(msgid)); + set_status(FPSTR(eeprom_err(msgid))); #endif } diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 02d5bf06bd..bc8442c576 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -342,21 +342,19 @@ public: static bool has_status(); static void reset_status(const bool no_welcome=false); - static void set_status(const char * const message, const bool persist=false); - static void set_status_P(PGM_P const message, const int8_t level=0); - static void status_printf_P(const uint8_t level, PGM_P const fmt, ...); - static void set_alert_status_P(PGM_P const message); + static void set_alert_status(FSTR_P const fstr); static inline void reset_alert_level() { alert_level = 0; } #else static constexpr bool has_status() { return false; } static inline void reset_status(const bool=false) {} - static void set_status(const char *message, const bool=false); - static void set_status_P(PGM_P message, const int8_t=0); - static void status_printf_P(const uint8_t, PGM_P message, ...); - static inline void set_alert_status_P(PGM_P const) {} + static inline void set_alert_status(FSTR_P const) {} static inline void reset_alert_level() {} #endif + static void set_status(const char * const cstr, const bool persist=false); + static void set_status(FSTR_P const fstr, const int8_t level=0); + static void status_printf(const uint8_t level, FSTR_P const fmt, ...); + #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) static void kill_screen(PGM_P const lcd_error, PGM_P const lcd_component); #else @@ -740,8 +738,7 @@ private: extern MarlinUI ui; -#define LCD_MESSAGEPGM_P(x) ui.set_status_P(x) -#define LCD_ALERTMESSAGEPGM_P(x) ui.set_alert_status_P(x) - -#define LCD_MESSAGEPGM(x) LCD_MESSAGEPGM_P(GET_TEXT(x)) -#define LCD_ALERTMESSAGEPGM(x) LCD_ALERTMESSAGEPGM_P(GET_TEXT(x)) +#define LCD_MESSAGE_F(S) ui.set_status(F(S)) +#define LCD_MESSAGE(M) ui.set_status(GET_TEXT_F(M)) +#define LCD_ALERTMESSAGE_F(S) ui.set_alert_status(F(S)) +#define LCD_ALERTMESSAGE(M) ui.set_alert_status(GET_TEXT_F(M)) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 9d424feb75..8b688ab2ab 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -630,7 +630,7 @@ void menu_advanced_settings() { didset = settings.set_sd_update_status(new_state); ui.completion_feedback(didset); ui.return_to_status(); - if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status(); + if (new_state) LCD_MESSAGE(MSG_RESET_PRINTER); else ui.reset_status(); }); #endif diff --git a/Marlin/src/lcd/menu/menu_mixer.cpp b/Marlin/src/lcd/menu/menu_mixer.cpp index d07b89c7c0..694fd54813 100644 --- a/Marlin/src/lcd/menu/menu_mixer.cpp +++ b/Marlin/src/lcd/menu/menu_mixer.cpp @@ -253,7 +253,7 @@ void menu_mixer() { MSG_BUTTON_RESET, MSG_BUTTON_CANCEL, []{ mixer.reset_vtools(); - LCD_MESSAGEPGM(MSG_VTOOLS_RESET); + LCD_MESSAGE(MSG_VTOOLS_RESET); ui.return_to_status(); }, nullptr, diff --git a/Marlin/src/lcd/menu/menu_mmu2.cpp b/Marlin/src/lcd/menu/menu_mmu2.cpp index 425a8ca751..99e5c06245 100644 --- a/Marlin/src/lcd/menu/menu_mmu2.cpp +++ b/Marlin/src/lcd/menu/menu_mmu2.cpp @@ -36,14 +36,14 @@ inline void action_mmu2_load_filament_to_nozzle(const uint8_t tool) { ui.reset_status(); ui.return_to_status(); - ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(tool + 1)); + ui.status_printf(0, GET_TEXT_F(MSG_MMU2_LOADING_FILAMENT), int(tool + 1)); if (mmu2.load_filament_to_nozzle(tool)) ui.reset_status(); ui.return_to_status(); } void _mmu2_load_filament(uint8_t index) { ui.return_to_status(); - ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); + ui.status_printf(0, GET_TEXT_F(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); mmu2.load_filament(index); ui.reset_status(); } @@ -74,14 +74,14 @@ void menu_mmu2_load_to_nozzle() { void _mmu2_eject_filament(uint8_t index) { ui.reset_status(); ui.return_to_status(); - ui.status_printf_P(0, GET_TEXT(MSG_MMU2_EJECTING_FILAMENT), int(index + 1)); + ui.status_printf(0, GET_TEXT_F(MSG_MMU2_EJECTING_FILAMENT), int(index + 1)); if (mmu2.eject_filament(index, true)) ui.reset_status(); } void action_mmu2_unload_filament() { ui.reset_status(); ui.return_to_status(); - LCD_MESSAGEPGM(MSG_MMU2_UNLOADING_FILAMENT); + LCD_MESSAGE(MSG_MMU2_UNLOADING_FILAMENT); idle(); if (mmu2.unload()) ui.reset_status(); } diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index d29fd3ecb3..b5f270ee63 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -460,8 +460,8 @@ void Endstops::event_handler() { SERIAL_EOL(); TERN_(HAS_STATUS_MESSAGE, - ui.status_printf_P(0, - PSTR(S_FMT GANG_N_1(LINEAR_AXES, " %c") " %c"), + ui.status_printf(0, + F(S_FMT GANG_N_1(LINEAR_AXES, " %c") " %c"), GET_TEXT(MSG_LCD_ENDSTOPS), LINEAR_AXIS_LIST(chrX, chrY, chrZ, chrI, chrJ, chrK), chrP ) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 638bb6be81..5accbc8edd 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -137,7 +137,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() #if ENABLED(TOUCH_MI_MANUAL_DEPLOY) const screenFunc_t prev_screen = ui.currentScreen; - LCD_MESSAGEPGM(MSG_MANUAL_DEPLOY_TOUCHMI); + LCD_MESSAGE(MSG_MANUAL_DEPLOY_TOUCHMI); ui.return_to_status(); TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Deploy TouchMI"), CONTINUE_STR)); @@ -290,10 +290,10 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { BUZZ(100, 659); BUZZ(100, 698); - PGM_P const ds_str = deploy ? GET_TEXT(MSG_MANUAL_DEPLOY) : GET_TEXT(MSG_MANUAL_STOW); + FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW); ui.return_to_status(); // To display the new status message - ui.set_status_P(ds_str, 99); - SERIAL_ECHOLNPGM_P(ds_str); + ui.set_status(ds_str, 99); + SERIAL_ECHOLNF(ds_str); TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Stow Probe"), CONTINUE_STR)); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Stow Probe"))); @@ -439,7 +439,7 @@ bool Probe::set_deployed(const bool deploy) { if (PROBE_TRIGGERED() == deploy) { // Unchanged after deploy/stow action? if (IsRunning()) { SERIAL_ERROR_MSG("Z-Probe failed"); - LCD_ALERTMESSAGEPGM_P(PSTR("Err: ZPROBE")); + LCD_ALERTMESSAGE_F("Err: ZPROBE"); } stop(); return true; @@ -793,7 +793,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai if (isnan(measured_z)) { stow(); - LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED); + LCD_MESSAGE(MSG_LCD_PROBING_FAILED); #if DISABLED(G29_RETRY_AND_RECOVER) SERIAL_ERROR_MSG(STR_ERR_PROBING_FAILED); #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index a4b8bb19e6..4f15dceba8 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1471,7 +1471,7 @@ void MarlinSettings::postprocess() { store_mesh(ubl.storage_slot); #endif - if (!eeprom_error) LCD_MESSAGEPGM(MSG_SETTINGS_STORED); + if (!eeprom_error) LCD_MESSAGE(MSG_SETTINGS_STORED); TERN_(EXTENSIBLE_UI, ExtUI::onConfigurationStoreWritten(!eeprom_error)); @@ -1497,7 +1497,7 @@ void MarlinSettings::postprocess() { stored_ver[1] = '\0'; } DEBUG_ECHO_MSG("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); - TERN_(DWIN_CREALITY_LCD_ENHANCED, ui.set_status(GET_TEXT(MSG_ERR_EEPROM_VERSION))); + TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_ERR_EEPROM_VERSION)); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_version()); eeprom_error = true; @@ -2362,7 +2362,7 @@ void MarlinSettings::postprocess() { else if (working_crc != stored_crc) { eeprom_error = true; DEBUG_ERROR_MSG("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); - TERN_(DWIN_CREALITY_LCD_ENHANCED, ui.set_status(GET_TEXT(MSG_ERR_EEPROM_CRC))); + TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_ERR_EEPROM_CRC)); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_crc()); } else if (!validating) { diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index e85f5f4644..aa81ea5d96 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -635,7 +635,7 @@ volatile bool Temperature::raw_temps_ready = false; // PID Tuning loop wait_for_heatup = true; // Can be interrupted with M108 - TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT), "Wait for heat up...")); + TERN_(HAS_STATUS_MESSAGE, ui.set_status(F("Wait for heat up..."))); while (wait_for_heatup) { const millis_t ms = millis(); @@ -696,7 +696,7 @@ volatile bool Temperature::raw_temps_ready = false; } } SHV((bias + d) >> 1); - TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PID_CYCLE), cycles, ncycles)); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PID_CYCLE), cycles, ncycles)); cycles++; minT = target; } @@ -3603,11 +3603,11 @@ void Temperature::isr() { #if HAS_HOTEND && HAS_STATUS_MESSAGE void Temperature::set_heating_message(const uint8_t e) { const bool heating = isHeatingHotend(e); - ui.status_printf_P(0, + ui.status_printf(0, #if HAS_MULTI_HOTEND - PSTR("E%c " S_FMT), '1' + e + F("E%c " S_FMT), '1' + e #else - PSTR("E1 " S_FMT) + F("E1 " S_FMT) #endif , heating ? GET_TEXT(MSG_HEATING) : GET_TEXT(MSG_COOLING) ); @@ -3744,7 +3744,7 @@ void Temperature::isr() { void Temperature::wait_for_hotend_heating(const uint8_t target_extruder) { if (isHeatingHotend(target_extruder)) { SERIAL_ECHOLNPGM("Wait for hotend heating..."); - LCD_MESSAGEPGM(MSG_HEATING); + LCD_MESSAGE(MSG_HEATING); wait_for_hotend(target_extruder); ui.reset_status(); } @@ -3874,7 +3874,7 @@ void Temperature::isr() { void Temperature::wait_for_bed_heating() { if (isHeatingBed()) { SERIAL_ECHOLNPGM("Wait for bed heating..."); - LCD_MESSAGEPGM(MSG_BED_HEATING); + LCD_MESSAGE(MSG_BED_HEATING); wait_for_bed(); ui.reset_status(); } diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index e1998cdb2e..2f387abad4 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -490,12 +490,12 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. #endif if (check_tool_sensor_stats(0)) { - ui.set_status_P("TC error"); + LCD_MESSAGE_F("TC error"); switching_toolhead_lock(false); while (check_tool_sensor_stats(0)) { /* nada */ } switching_toolhead_lock(true); } - ui.set_status_P("TC Success"); + LCD_MESSAGE_F("TC Success"); #endif } diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 26a6d736eb..6b8d2338c1 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -457,7 +457,7 @@ void CardReader::mount() { cdroot(); #if ENABLED(USB_FLASH_DRIVE_SUPPORT) || PIN_EXISTS(SD_DETECT) else if (marlin_state != MF_INITIALIZING) - ui.set_status_P(GET_TEXT(MSG_SD_INIT_FAIL), -1); + ui.set_status(GET_TEXT_F(MSG_SD_INIT_FAIL), -1); #endif ui.refresh(); diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index 5991a9fb83..05671167c8 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -126,7 +126,7 @@ bool DiskIODriver_USBFlash::usbStartup() { SERIAL_ECHOPGM("Starting USB host..."); if (!UHS_START) { SERIAL_ECHOLNPGM(" failed."); - LCD_MESSAGEPGM(MSG_MEDIA_USB_FAILED); + LCD_MESSAGE(MSG_MEDIA_USB_FAILED); return false; } @@ -221,7 +221,7 @@ void DiskIODriver_USBFlash::idle() { #if USB_DEBUG >= 1 SERIAL_ECHOLNPGM("Waiting for media"); #endif - LCD_MESSAGEPGM(MSG_MEDIA_WAITING); + LCD_MESSAGE(MSG_MEDIA_WAITING); GOTO_STATE_AFTER_DELAY(state, 2000); } break; @@ -236,7 +236,7 @@ void DiskIODriver_USBFlash::idle() { SERIAL_ECHOLNPGM("USB device removed"); #endif if (state != MEDIA_READY) - LCD_MESSAGEPGM(MSG_MEDIA_USB_REMOVED); + LCD_MESSAGE(MSG_MEDIA_USB_REMOVED); GOTO_STATE_AFTER_DELAY(WAIT_FOR_DEVICE, 0); } @@ -245,12 +245,12 @@ void DiskIODriver_USBFlash::idle() { #if USB_DEBUG >= 1 SERIAL_ECHOLNPGM("Media removed"); #endif - LCD_MESSAGEPGM(MSG_MEDIA_REMOVED); + LCD_MESSAGE(MSG_MEDIA_REMOVED); GOTO_STATE_AFTER_DELAY(WAIT_FOR_DEVICE, 0); } else if (task_state == UHS_STATE(ERROR)) { - LCD_MESSAGEPGM(MSG_MEDIA_READ_ERROR); + LCD_MESSAGE(MSG_MEDIA_READ_ERROR); GOTO_STATE_AFTER_DELAY(MEDIA_ERROR, 0); } } From 7626d859a65417f03494c1e99d3d29e79b84fd3d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Sep 2021 11:55:08 -0500 Subject: [PATCH 011/546] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20F()=20to=20Host?= =?UTF-8?q?=20Actions=20strings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/host_actions.cpp | 64 ++++++++++---------- Marlin/src/feature/host_actions.h | 18 +++--- Marlin/src/feature/mmu/mmu2.cpp | 2 +- Marlin/src/feature/pause.cpp | 16 ++--- Marlin/src/feature/runout.cpp | 4 +- Marlin/src/gcode/config/M43.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 6 +- Marlin/src/gcode/lcd/M0_M1.cpp | 2 +- Marlin/src/gcode/sd/M1001.cpp | 2 +- Marlin/src/gcode/sd/M24_M25.cpp | 4 +- Marlin/src/lcd/marlinui.cpp | 22 +++---- Marlin/src/lcd/menu/menu_delta_calibrate.cpp | 2 +- Marlin/src/module/probe.cpp | 4 +- 13 files changed, 74 insertions(+), 74 deletions(-) diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index 62e60320f7..9f5a1481f1 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -37,33 +37,33 @@ #include "runout.h" #endif -void host_action(PGM_P const pstr, const bool eol) { +void host_action(FSTR_P const fstr, const bool eol) { PORT_REDIRECT(SerialMask::All); SERIAL_ECHOPGM("//action:"); - SERIAL_ECHOPGM_P(pstr); + SERIAL_ECHOF(fstr); if (eol) SERIAL_EOL(); } #ifdef ACTION_ON_KILL - void host_action_kill() { host_action(PSTR(ACTION_ON_KILL)); } + void host_action_kill() { host_action(F(ACTION_ON_KILL)); } #endif #ifdef ACTION_ON_PAUSE - void host_action_pause(const bool eol/*=true*/) { host_action(PSTR(ACTION_ON_PAUSE), eol); } + void host_action_pause(const bool eol/*=true*/) { host_action(F(ACTION_ON_PAUSE), eol); } #endif #ifdef ACTION_ON_PAUSED - void host_action_paused(const bool eol/*=true*/) { host_action(PSTR(ACTION_ON_PAUSED), eol); } + void host_action_paused(const bool eol/*=true*/) { host_action(F(ACTION_ON_PAUSED), eol); } #endif #ifdef ACTION_ON_RESUME - void host_action_resume() { host_action(PSTR(ACTION_ON_RESUME)); } + void host_action_resume() { host_action(F(ACTION_ON_RESUME)); } #endif #ifdef ACTION_ON_RESUMED - void host_action_resumed() { host_action(PSTR(ACTION_ON_RESUMED)); } + void host_action_resumed() { host_action(F(ACTION_ON_RESUMED)); } #endif #ifdef ACTION_ON_CANCEL - void host_action_cancel() { host_action(PSTR(ACTION_ON_CANCEL)); } + void host_action_cancel() { host_action(F(ACTION_ON_CANCEL)); } #endif #ifdef ACTION_ON_START - void host_action_start() { host_action(PSTR(ACTION_ON_START)); } + void host_action_start() { host_action(F(ACTION_ON_START)); } #endif #if ENABLED(HOST_PROMPT_SUPPORT) @@ -77,60 +77,60 @@ void host_action(PGM_P const pstr, const bool eol) { PromptReason host_prompt_reason = PROMPT_NOT_DEFINED; - void host_action_notify(const char * const message) { + void host_action_notify(const char * const cstr) { PORT_REDIRECT(SerialMask::All); - host_action(PSTR("notification "), false); - SERIAL_ECHOLN(message); + host_action(F("notification "), false); + SERIAL_ECHOLN(cstr); } - void host_action_notify_P(PGM_P const message) { + void host_action_notify(FSTR_P const fstr) { PORT_REDIRECT(SerialMask::All); - host_action(PSTR("notification "), false); - SERIAL_ECHOLNPGM_P(message); + host_action(F("notification "), false); + SERIAL_ECHOLNF(fstr); } - void host_action_prompt(PGM_P const ptype, const bool eol=true) { + void host_action_prompt(FSTR_P const ptype, const bool eol=true) { PORT_REDIRECT(SerialMask::All); - host_action(PSTR("prompt_"), false); - SERIAL_ECHOPGM_P(ptype); + host_action(F("prompt_"), false); + SERIAL_ECHOF(ptype); if (eol) SERIAL_EOL(); } - void host_action_prompt_plus(PGM_P const ptype, PGM_P const pstr, const char extra_char='\0') { + void host_action_prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char='\0') { host_action_prompt(ptype, false); PORT_REDIRECT(SerialMask::All); SERIAL_CHAR(' '); - SERIAL_ECHOPGM_P(pstr); + SERIAL_ECHOF(fstr); if (extra_char != '\0') SERIAL_CHAR(extra_char); SERIAL_EOL(); } - void host_action_prompt_begin(const PromptReason reason, PGM_P const pstr, const char extra_char/*='\0'*/) { + void host_action_prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char/*='\0'*/) { host_action_prompt_end(); host_prompt_reason = reason; - host_action_prompt_plus(PSTR("begin"), pstr, extra_char); + host_action_prompt_plus(F("begin"), fstr, extra_char); } - void host_action_prompt_button(PGM_P const pstr) { host_action_prompt_plus(PSTR("button"), pstr); } - void host_action_prompt_end() { host_action_prompt(PSTR("end")); } - void host_action_prompt_show() { host_action_prompt(PSTR("show")); } + void host_action_prompt_button(FSTR_P const fstr) { host_action_prompt_plus(F("button"), fstr); } + void host_action_prompt_end() { host_action_prompt(F("end")); } + void host_action_prompt_show() { host_action_prompt(F("show")); } - void _host_prompt_show(PGM_P const btn1/*=nullptr*/, PGM_P const btn2/*=nullptr*/) { + void _host_prompt_show(FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { if (btn1) host_action_prompt_button(btn1); if (btn2) host_action_prompt_button(btn2); host_action_prompt_show(); } - void host_prompt_do(const PromptReason reason, PGM_P const pstr, PGM_P const btn1/*=nullptr*/, PGM_P const btn2/*=nullptr*/) { - host_action_prompt_begin(reason, pstr); + void host_prompt_do(const PromptReason reason, FSTR_P const fstr, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { + host_action_prompt_begin(reason, fstr); _host_prompt_show(btn1, btn2); } - void host_prompt_do(const PromptReason reason, PGM_P const pstr, const char extra_char, PGM_P const btn1/*=nullptr*/, PGM_P const btn2/*=nullptr*/) { - host_action_prompt_begin(reason, pstr, extra_char); + void host_prompt_do(const PromptReason reason, FSTR_P const fstr, const char extra_char, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { + host_action_prompt_begin(reason, fstr, extra_char); _host_prompt_show(btn1, btn2); } void filament_load_host_prompt() { const bool disable_to_continue = TERN0(HAS_FILAMENT_SENSOR, runout.filament_ran_out); - host_prompt_do(PROMPT_FILAMENT_RUNOUT, PSTR("Paused"), PSTR("PurgeMore"), - disable_to_continue ? PSTR("DisableRunout") : CONTINUE_STR + host_prompt_do(PROMPT_FILAMENT_RUNOUT, F("Paused"), F("PurgeMore"), + disable_to_continue ? F("DisableRunout") : FPSTR(CONTINUE_STR) ); } diff --git a/Marlin/src/feature/host_actions.h b/Marlin/src/feature/host_actions.h index 065b59d755..fb19618b1a 100644 --- a/Marlin/src/feature/host_actions.h +++ b/Marlin/src/feature/host_actions.h @@ -24,7 +24,7 @@ #include "../inc/MarlinConfigPre.h" #include "../HAL/shared/Marduino.h" -void host_action(PGM_P const pstr, const bool eol=true); +void host_action(FSTR_P const fstr, const bool eol=true); #ifdef ACTION_ON_KILL void host_action_kill(); @@ -64,16 +64,16 @@ void host_action(PGM_P const pstr, const bool eol=true); extern PromptReason host_prompt_reason; void host_response_handler(const uint8_t response); - void host_action_notify(const char * const message); - void host_action_notify_P(PGM_P const message); - void host_action_prompt_begin(const PromptReason reason, PGM_P const pstr, const char extra_char='\0'); - void host_action_prompt_button(PGM_P const pstr); + void host_action_notify(const char * const cstr); + void host_action_notify(FSTR_P const fstr); + void host_action_prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char='\0'); + void host_action_prompt_button(FSTR_P const fstr); void host_action_prompt_end(); void host_action_prompt_show(); - void host_prompt_do(const PromptReason reason, PGM_P const pstr, PGM_P const btn1=nullptr, PGM_P const btn2=nullptr); - void host_prompt_do(const PromptReason reason, PGM_P const pstr, const char extra_char, PGM_P const btn1=nullptr, PGM_P const btn2=nullptr); - inline void host_prompt_open(const PromptReason reason, PGM_P const pstr, PGM_P const btn1=nullptr, PGM_P const btn2=nullptr) { - if (host_prompt_reason == PROMPT_NOT_DEFINED) host_prompt_do(reason, pstr, btn1, btn2); + void host_prompt_do(const PromptReason reason, FSTR_P const fstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); + void host_prompt_do(const PromptReason reason, FSTR_P const fstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); + inline void host_prompt_open(const PromptReason reason, FSTR_P const fstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) { + if (host_prompt_reason == PROMPT_NOT_DEFINED) host_prompt_do(reason, fstr, btn1, btn2); } void filament_load_host_prompt(); diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 7362530e35..14f2623e14 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -960,7 +960,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { if (recover) { LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER); BUZZ(200, 404); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("MMU2 Eject Recover"), CONTINUE_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("MMU2 Eject Recover"), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover"))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); BUZZ(200, 404); diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 75255d87ac..9b7404d852 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -198,7 +198,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load #if ENABLED(HOST_PROMPT_SUPPORT) const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, active_extruder); - host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Load Filament T"), tool, CONTINUE_STR); + host_prompt_do(PROMPT_USER_CONTINUE, F("Load Filament T"), tool, FPSTR(CONTINUE_STR)); #endif while (wait_for_user) { @@ -253,7 +253,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_PURGE); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_PURGE))); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_FILAMENT_CHANGE_PURGE), CONTINUE_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE), FPSTR(CONTINUE_STR))); TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT(MSG_FILAMENT_CHANGE_PURGE), CONTINUE_STR)); wait_for_user = true; // A click or M108 breaks the purge_length loop for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count) @@ -403,7 +403,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool #endif #endif - TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Pause"), DISMISS_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, F("Pause"), FPSTR(DISMISS_STR))); // Indicate that the printer is paused ++did_pause_print; @@ -512,7 +512,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep // Wait for filament insert by user and press button KEEPALIVE_STATE(PAUSED_FOR_USER); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_NOZZLE_PARKED), CONTINUE_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_NOZZLE_PARKED), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_NOZZLE_PARKED))); wait_for_user = true; // LCD click or M108 will clear this while (wait_for_user) { @@ -528,13 +528,13 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep ui.pause_show_message(PAUSE_MESSAGE_HEAT); SERIAL_ECHO_MSG(_PMSG(STR_FILAMENT_CHANGE_HEAT)); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_HEATER_TIMEOUT), GET_TEXT(MSG_REHEAT))); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_HEATER_TIMEOUT), GET_TEXT_F(MSG_REHEAT))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_HEATER_TIMEOUT))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(0, true)); // Wait for LCD click or M108 - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, GET_TEXT(MSG_REHEATING))); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, GET_TEXT_F(MSG_REHEATING))); TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING))); @@ -554,7 +554,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep HOTEND_LOOP() thermalManager.heater_idle[e].start(nozzle_timeout); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_REHEATDONE), CONTINUE_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_REHEATDONE), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_REHEATDONE))); TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATDONE)); @@ -671,7 +671,7 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ --did_pause_print; - TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Resuming"), DISMISS_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, F("Resuming"), FPSTR(DISMISS_STR))); // Resume the print job timer if it was running if (print_job_timer.isPaused()) print_job_timer.start(); diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 85280d7cb1..e53c229e70 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -96,7 +96,7 @@ void event_filament_runout(const uint8_t extruder) { //action:out_of_filament #if ENABLED(HOST_PROMPT_SUPPORT) - host_action_prompt_begin(PROMPT_FILAMENT_RUNOUT, PSTR("FilamentRunout T"), tool); + host_action_prompt_begin(PROMPT_FILAMENT_RUNOUT, F("FilamentRunout T"), tool); host_action_prompt_show(); #endif @@ -115,7 +115,7 @@ void event_filament_runout(const uint8_t extruder) { // Legacy Repetier command for use until newer version supports standard dialog // To be removed later when pause command also triggers dialog #ifdef ACTION_ON_FILAMENT_RUNOUT - host_action(PSTR(ACTION_ON_FILAMENT_RUNOUT " T"), false); + host_action(F(ACTION_ON_FILAMENT_RUNOUT " T"), false); SERIAL_CHAR(tool); SERIAL_EOL(); #endif diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index 08b45efa15..ca9f5405ce 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -344,7 +344,7 @@ void GcodeSuite::M43() { #if HAS_RESUME_CONTINUE KEEPALIVE_STATE(PAUSED_FOR_USER); wait_for_user = true; - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("M43 Wait Called"), CONTINUE_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("M43 Wait Called"), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("M43 Wait Called"))); #endif diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index acc79cb154..e23315e9f5 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -238,9 +238,9 @@ void GcodeSuite::dwell(millis_t time) { #if ENABLED(G29_RETRY_AND_RECOVER) void GcodeSuite::event_probe_recover() { - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, PSTR("G29 Retrying"), DISMISS_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, F("G29 Retrying"), FPSTR(DISMISS_STR))); #ifdef ACTION_ON_G29_RECOVER - host_action(PSTR(ACTION_ON_G29_RECOVER)); + host_action(F(ACTION_ON_G29_RECOVER)); #endif #ifdef G29_RECOVER_COMMANDS process_subcommands_now(F(G29_RECOVER_COMMANDS)); @@ -253,7 +253,7 @@ void GcodeSuite::dwell(millis_t time) { void GcodeSuite::event_probe_failure() { #ifdef ACTION_ON_G29_FAILURE - host_action(PSTR(ACTION_ON_G29_FAILURE)); + host_action(F(ACTION_ON_G29_FAILURE)); #endif #ifdef G29_FAILURE_COMMANDS process_subcommands_now(F(G29_FAILURE_COMMANDS)); diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 32df8dd9c3..952b24a2d1 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -84,7 +84,7 @@ void GcodeSuite::M0_M1() { #endif - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? PSTR("M1 Stop") : PSTR("M0 Stop"), CONTINUE_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? F("M1 Stop") : F("M0 Stop"), FPSTR(CONTINUE_STR))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(ms)); diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index c5003cabac..633a98e04e 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -97,7 +97,7 @@ void GcodeSuite::M1001() { if (long_print) { printerEventLEDs.onPrintCompleted(); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_PRINT_DONE))); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_PRINT_DONE), CONTINUE_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_PRINT_DONE), FPSTR(CONTINUE_STR))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_LCD_MENU, PE_LEDS_COMPLETED_TIME, 30)))); printerEventLEDs.onResumeAfterWait(); } diff --git a/Marlin/src/gcode/sd/M24_M25.cpp b/Marlin/src/gcode/sd/M24_M25.cpp index 4cb040feb3..21e43b033e 100644 --- a/Marlin/src/gcode/sd/M24_M25.cpp +++ b/Marlin/src/gcode/sd/M24_M25.cpp @@ -79,7 +79,7 @@ void GcodeSuite::M24() { #ifdef ACTION_ON_RESUME host_action_resume(); #endif - TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Resuming SD"), DISMISS_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, F("Resuming SD"), FPSTR(DISMISS_STR))); #endif ui.reset_status(); @@ -116,7 +116,7 @@ void GcodeSuite::M25() { IF_DISABLED(DWIN_CREALITY_LCD, ui.reset_status()); #if ENABLED(HOST_ACTION_COMMANDS) - TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("Pause SD"), PSTR("Resume"))); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, F("Pause SD"), F("Resume"))); #ifdef ACTION_ON_PAUSE host_action_pause(); #endif diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 009931d428..0401ae2794 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1352,28 +1352,28 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; bool MarlinUI::has_status() { return (status_message[0] != '\0'); } - void MarlinUI::set_status(const char * const message, const bool persist) { + void MarlinUI::set_status(const char * const cstr, const bool persist) { if (alert_level) return; - TERN_(HOST_PROMPT_SUPPORT, host_action_notify(message)); + TERN_(HOST_PROMPT_SUPPORT, host_action_notify(cstr)); // Here we have a problem. The message is encoded in UTF8, so // arbitrarily cutting it will be a problem. We MUST be sure // that there is no cutting in the middle of a multibyte character! // Get a pointer to the null terminator - const char* pend = message + strlen(message); + const char* pend = cstr + strlen(cstr); // If length of supplied UTF8 string is greater than // our buffer size, start cutting whole UTF8 chars - while ((pend - message) > MAX_MESSAGE_LENGTH) { + while ((pend - cstr) > MAX_MESSAGE_LENGTH) { --pend; while (!START_OF_UTF8_CHAR(*pend)) --pend; }; // At this point, we have the proper cut point. Use it - uint8_t maxLen = pend - message; - strncpy(status_message, message, maxLen); + uint8_t maxLen = pend - cstr; + strncpy(status_message, cstr, maxLen); status_message[maxLen] = '\0'; finish_status(persist); @@ -1427,7 +1427,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; if (level < alert_level) return; alert_level = level; - TERN_(HOST_PROMPT_SUPPORT, host_action_notify_P(pstr)); + TERN_(HOST_PROMPT_SUPPORT, host_action_notify(fstr)); // Since the message is encoded in UTF8 it must // only be cut on a character boundary. @@ -1536,7 +1536,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; host_action_cancel(); #endif IF_DISABLED(SDSUPPORT, print_job_timer.stop()); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("UI Aborted"), DISMISS_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, F("UI Aborted"), FPSTR(DISMISS_STR))); LCD_MESSAGE(MSG_PRINT_ABORTED); TERN_(HAS_LCD_MENU, return_to_status()); } @@ -1565,7 +1565,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"))); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, F("UI Pause"), F("Resume"))); LCD_MESSAGE(MSG_PRINT_PAUSED); @@ -1642,10 +1642,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; TERN(HOST_PROMPT_SUPPORT, host_action_notify(cstr), UNUSED(cstr)); } void MarlinUI::set_status(FSTR_P const fstr, const int8_t) { - TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(FTOP(fstr)), UNUSED(fstr)); + TERN(HOST_PROMPT_SUPPORT, host_action_notify(fstr), UNUSED(fstr)); } void MarlinUI::status_printf(const uint8_t, FSTR_P const fstr, ...) { - TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(FPSTR(fstr)), UNUSED(fstr)); + TERN(HOST_PROMPT_SUPPORT, host_action_notify(fstr), UNUSED(fstr)); } #endif // !HAS_DISPLAY && !HAS_STATUS_MESSAGE diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index c9bcb895fc..0990ac504d 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -64,7 +64,7 @@ void _man_probe_pt(const xy_pos_t &xy) { float lcd_probe_pt(const xy_pos_t &xy) { _man_probe_pt(xy); ui.defer_status_screen(); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Delta Calibration in progress"), CONTINUE_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("Delta Calibration in progress"), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Delta Calibration in progress"))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); ui.goto_previous_screen_no_defer(); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 5accbc8edd..18e72f401c 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -140,7 +140,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() LCD_MESSAGE(MSG_MANUAL_DEPLOY_TOUCHMI); ui.return_to_status(); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Deploy TouchMI"), CONTINUE_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("Deploy TouchMI"), FPSTR(CONTINUE_STR))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); ui.reset_status(); ui.goto_screen(prev_screen); @@ -295,7 +295,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { ui.set_status(ds_str, 99); SERIAL_ECHOLNF(ds_str); - TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Stow Probe"), CONTINUE_STR)); + TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("Stow Probe"), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Stow Probe"))); TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, PSTR("Stow Probe"), CONTINUE_STR)); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); From c3ae221a109cb99bde634899f5b1b0ff690f29ab Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 25 Sep 2021 22:11:48 -0500 Subject: [PATCH 012/546] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20F()=20to=20some?= =?UTF-8?q?=20ExtUI=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/mmu/mmu2.cpp | 2 +- Marlin/src/feature/pause.cpp | 12 +-- Marlin/src/gcode/config/M43.cpp | 2 +- Marlin/src/gcode/lcd/M0_M1.cpp | 2 +- Marlin/src/gcode/sd/M1001.cpp | 2 +- .../extui/anycubic_chiron/FileNavigator.cpp | 2 +- .../lcd/extui/anycubic_chiron/chiron_tft.cpp | 85 ++++++++--------- .../lcd/extui/anycubic_chiron/chiron_tft.h | 10 +- .../extui/anycubic_chiron/chiron_tft_defs.h | 94 +++++++++---------- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 58 ++++++------ .../lcd/extui/dgus_reloaded/DGUSRxHandler.cpp | 68 +++++++------- .../extui/dgus_reloaded/DGUSScreenHandler.cpp | 31 +++--- .../extui/dgus_reloaded/DGUSScreenHandler.h | 2 +- .../extui/dgus_reloaded/DGUSSetupHandler.cpp | 10 +- .../bioprinter/status_screen.cpp | 4 +- .../cocoa_press/leveling_menu.cpp | 2 +- .../cocoa_press/main_menu.cpp | 2 +- .../cocoa_press/preheat_menu.cpp | 12 +-- .../generic/bed_mesh_edit_screen.cpp | 4 +- .../generic/bed_mesh_view_screen.cpp | 4 +- .../confirm_auto_calibration_dialog_box.cpp | 2 +- .../generic/custom_user_menus.cpp | 2 +- .../generic/leveling_menu.cpp | 4 +- .../ftdi_eve_touch_ui/generic/main_menu.cpp | 4 +- .../generic/restore_failsafe_dialog_box.cpp | 2 +- .../generic/save_settings_dialog_box.cpp | 2 +- .../generic/spinner_dialog_box.cpp | 14 +-- .../generic/stress_test_screen.cpp | 4 +- .../src/lcd/extui/nextion/FileNavigator.cpp | 36 +++---- Marlin/src/lcd/extui/nextion/nextion_tft.cpp | 14 +-- Marlin/src/lcd/extui/nextion/nextion_tft.h | 6 +- .../src/lcd/extui/nextion/nextion_tft_defs.h | 14 +-- Marlin/src/lcd/extui/ui_api.cpp | 12 +-- Marlin/src/lcd/extui/ui_api.h | 5 +- Marlin/src/lcd/marlinui.cpp | 22 ++--- Marlin/src/lcd/menu/menu_delta_calibrate.cpp | 2 +- Marlin/src/module/probe.cpp | 2 +- 37 files changed, 277 insertions(+), 278 deletions(-) diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 14f2623e14..363e4d5505 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -961,7 +961,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER); BUZZ(200, 404); TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("MMU2 Eject Recover"), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover"))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("MMU2 Eject Recover"))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); BUZZ(200, 404); BUZZ(200, 404); diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 9b7404d852..8a35a87eeb 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -194,7 +194,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load KEEPALIVE_STATE(PAUSED_FOR_USER); wait_for_user = true; // LCD click or M108 will clear this - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Load Filament"))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Load Filament"))); #if ENABLED(HOST_PROMPT_SUPPORT) const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, active_extruder); @@ -252,7 +252,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_PURGE); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_PURGE))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE))); TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE), FPSTR(CONTINUE_STR))); TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT(MSG_FILAMENT_CHANGE_PURGE), CONTINUE_STR)); wait_for_user = true; // A click or M108 breaks the purge_length loop @@ -513,7 +513,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep // Wait for filament insert by user and press button KEEPALIVE_STATE(PAUSED_FOR_USER); TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_NOZZLE_PARKED), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_NOZZLE_PARKED))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_NOZZLE_PARKED))); wait_for_user = true; // LCD click or M108 will clear this while (wait_for_user) { impatient_beep(max_beep_count); @@ -530,13 +530,13 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_HEATER_TIMEOUT), GET_TEXT_F(MSG_REHEAT))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_HEATER_TIMEOUT))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_HEATER_TIMEOUT))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(0, true)); // Wait for LCD click or M108 TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, GET_TEXT_F(MSG_REHEATING))); - TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING))); + TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(GET_TEXT_F(MSG_REHEATING))); TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATING)); @@ -555,7 +555,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep HOTEND_LOOP() thermalManager.heater_idle[e].start(nozzle_timeout); TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_REHEATDONE), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_REHEATDONE))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_REHEATDONE))); TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATDONE)); IF_DISABLED(PAUSE_REHEAT_FAST_RESUME, wait_for_user = true); diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index ca9f5405ce..82089b7d97 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -345,7 +345,7 @@ void GcodeSuite::M43() { KEEPALIVE_STATE(PAUSED_FOR_USER); wait_for_user = true; TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("M43 Wait Called"), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("M43 Wait Called"))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("M43 Wait Called"))); #endif for (;;) { diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 952b24a2d1..17481f0198 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -69,7 +69,7 @@ void GcodeSuite::M0_M1() { if (parser.string_arg) ExtUI::onUserConfirmRequired(parser.string_arg); // Can this take an SRAM string?? else - ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_USERWAIT)); + ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_USERWAIT)); #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) if (parser.string_arg) DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg, GET_TEXT_F(MSG_USERWAIT)); diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index 633a98e04e..374b100f59 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -96,7 +96,7 @@ void GcodeSuite::M1001() { #if HAS_LEDS_OFF_FLAG if (long_print) { printerEventLEDs.onPrintCompleted(); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_PRINT_DONE))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_PRINT_DONE))); TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_PRINT_DONE), FPSTR(CONTINUE_STR))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_LCD_MENU, PE_LEDS_COMPLETED_TIME, 30)))); printerEventLEDs.onResumeAfterWait(); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp b/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp index 1339c39f3f..f49b17acc1 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp @@ -157,7 +157,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) { // The new panel ignores entries that don't end in .GCO or .gcode so add and pad them. if (paneltype == AC_panel_new) { TFTSer.println("<<.GCO"); - Chiron.SendtoTFTLN(PSTR(".. .gcode")); + Chiron.SendtoTFTLN(F(".. .gcode")); } else { TFTSer.println("<<"); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index e7b3941928..483da200e8 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -99,7 +99,7 @@ void ChironTFT::Startup() { // Enable leveling and Disable end stops during print // as Z home places nozzle above the bed so we need to allow it past the end stops - injectCommands_P(AC_cmnd_enable_leveling); + injectCommands(AC_cmnd_enable_leveling); // Startup tunes are defined in Tunes.h PlayTune(BEEPER_PIN, TERN(AC_DEFAULT_STARTUP_TUNE, Anycubic_PowerOn, GB_PowerOn), 1); @@ -244,7 +244,7 @@ void ChironTFT::StatusChange(const char * const msg) { // If probing completes ok save the mesh and park // Ignore the custom machine name if (strcmp_P(msg + strlen(CUSTOM_MACHINE_NAME), MARLIN_msg_ready) == 0) { - injectCommands_P(PSTR("M500\nG27")); + injectCommands(F("M500\nG27")); SendtoTFTLN(AC_msg_probing_complete); printer_state = AC_printer_idle; msg_matched = true; @@ -252,7 +252,7 @@ void ChironTFT::StatusChange(const char * const msg) { // If probing fails don't save the mesh raise the probe above the bad point if (strcmp_P(msg, MARLIN_msg_probing_failed) == 0) { PlayTune(BEEPER_PIN, BeepBeepBeeep, 1); - injectCommands_P(PSTR("G1 Z50 F500")); + injectCommands(F("G1 Z50 F500")); SendtoTFTLN(AC_msg_probing_complete); printer_state = AC_printer_idle; msg_matched = true; @@ -315,19 +315,20 @@ void ChironTFT::PrintComplete() { setSoftEndstopState(true); // enable endstops } -void ChironTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEM string to the panel +void ChironTFT::SendtoTFT(FSTR_P const fstr) { // A helper to print PROGMEM string to the panel #if ACDEBUG(AC_SOME) - SERIAL_ECHOPGM_P(str); + SERIAL_ECHOF(fstr); #endif + PGM_P str = FTOP(fstr); while (const char c = pgm_read_byte(str++)) TFTSer.write(c); } -void ChironTFT::SendtoTFTLN(PGM_P str = nullptr) { - if (str) { +void ChironTFT::SendtoTFTLN(FSTR_P const fstr) { + if (fstr) { #if ACDEBUG(AC_SOME) SERIAL_ECHOPGM("> "); #endif - SendtoTFT(str); + SendtoTFT(fstr); #if ACDEBUG(AC_SOME) SERIAL_EOL(); #endif @@ -426,9 +427,9 @@ void ChironTFT::SendFileList(int8_t startindex) { #if ACDEBUG(AC_INFO) SERIAL_ECHOLNPGM("## SendFileList ## ", startindex); #endif - SendtoTFTLN(PSTR("FN ")); + SendtoTFTLN(F("FN ")); filenavigator.getFiles(startindex, panel_type, 4); - SendtoTFTLN(PSTR("END")); + SendtoTFTLN(F("END")); } void ChironTFT::SelectFile() { @@ -512,55 +513,55 @@ void ChironTFT::PanelInfo(uint8_t req) { // information requests A0-A8 and A33 switch (req) { case 0: // A0 Get HOTEND Temp - SendtoTFT(PSTR("A0V ")); + SendtoTFT(F("A0V ")); TFTSer.println(getActualTemp_celsius(E0)); break; case 1: // A1 Get HOTEND Target Temp - SendtoTFT(PSTR("A1V ")); + SendtoTFT(F("A1V ")); TFTSer.println(getTargetTemp_celsius(E0)); break; case 2: // A2 Get BED Temp - SendtoTFT(PSTR("A2V ")); + SendtoTFT(F("A2V ")); TFTSer.println(getActualTemp_celsius(BED)); break; case 3: // A3 Get BED Target Temp - SendtoTFT(PSTR("A3V ")); + SendtoTFT(F("A3V ")); TFTSer.println(getTargetTemp_celsius(BED)); break; case 4: // A4 Get FAN Speed - SendtoTFT(PSTR("A4V ")); + SendtoTFT(F("A4V ")); TFTSer.println(getActualFan_percent(FAN0)); break; case 5: // A5 Get Current Coordinates - SendtoTFT(PSTR("A5V X: ")); + SendtoTFT(F("A5V X: ")); TFTSer.print(getAxisPosition_mm(X)); - SendtoTFT(PSTR(" Y: ")); + SendtoTFT(F(" Y: ")); TFTSer.print(getAxisPosition_mm(Y)); - SendtoTFT(PSTR(" Z: ")); + SendtoTFT(F(" Z: ")); TFTSer.println(getAxisPosition_mm(Z)); break; case 6: // A6 Get printing progress if (isPrintingFromMedia()) { - SendtoTFT(PSTR("A6V ")); + SendtoTFT(F("A6V ")); TFTSer.println(ui8tostr2(getProgress_percent())); } else - SendtoTFTLN(PSTR("A6V ---")); + SendtoTFTLN(F("A6V ---")); break; case 7: { // A7 Get Printing Time uint32_t time = getProgress_seconds_elapsed() / 60; - SendtoTFT(PSTR("A7V ")); + SendtoTFT(F("A7V ")); TFTSer.print(ui8tostr2(time / 60)); - SendtoTFT(PSTR(" H ")); + SendtoTFT(F(" H ")); TFTSer.print(ui8tostr2(time % 60)); - SendtoTFT(PSTR(" M")); + SendtoTFT(F(" M")); #if ACDEBUG(AC_ALL) SERIAL_ECHOLNPGM("Print time ", ui8tostr2(time / 60), ":", ui8tostr2(time % 60)); #endif @@ -575,9 +576,9 @@ void ChironTFT::PanelInfo(uint8_t req) { break; case 33: // A33 Get firmware info - SendtoTFT(PSTR("J33 ")); + SendtoTFT(F("J33 ")); // If there is an error recorded, show that instead of the FW version - if (!GetLastError()) SendtoTFTLN(PSTR(SHORT_BUILD_VERSION)); + if (!GetLastError()) SendtoTFTLN(F(SHORT_BUILD_VERSION)); break; } } @@ -608,7 +609,7 @@ void ChironTFT::PanelAction(uint8_t req) { } else { if (printer_state == AC_printer_resuming_from_power_outage) - injectCommands_P(PSTR("M1000 C")); // Cancel recovery + injectCommands(F("M1000 C")); // Cancel recovery SendtoTFTLN(AC_msg_stop); printer_state = AC_printer_idle; } @@ -625,7 +626,7 @@ void ChironTFT::PanelAction(uint8_t req) { case 14: { // A14 Start Printing // Allows printer to restart the job if we don't want to recover if (printer_state == AC_printer_resuming_from_power_outage) { - injectCommands_P(PSTR("M1000 C")); // Cancel recovery + injectCommands(F("M1000 C")); // Cancel recovery printer_state = AC_printer_idle; } #if ACDebugLevel >= 1 @@ -638,8 +639,8 @@ void ChironTFT::PanelAction(uint8_t req) { case 15: // A15 Resuming from outage if (printer_state == AC_printer_resuming_from_power_outage) { // Need to home here to restore the Z position - injectCommands_P(AC_cmnd_power_loss_recovery); - injectCommands_P(PSTR("M1000")); // home and start recovery + injectCommands(AC_cmnd_power_loss_recovery); + injectCommands(F("M1000")); // home and start recovery } break; @@ -675,7 +676,7 @@ void ChironTFT::PanelAction(uint8_t req) { if (panel_command[4] == 'S') setFeedrate_percent(atoi(&panel_command[5])); else { - SendtoTFT(PSTR("A20V ")); + SendtoTFT(F("A20V ")); TFTSer.println(getFeedrate_percent()); } break; @@ -683,9 +684,9 @@ void ChironTFT::PanelAction(uint8_t req) { case 21: // A21 Home Axis A21 X if (!isPrinting()) { switch ((char)panel_command[4]) { - case 'X': injectCommands_P(PSTR("G28X")); break; - case 'Y': injectCommands_P(PSTR("G28Y")); break; - case 'Z': injectCommands_P(PSTR("G28Z")); break; + case 'X': injectCommands(F("G28X")); break; + case 'Y': injectCommands(F("G28Y")); break; + case 'Z': injectCommands(F("G28Z")); break; case 'C': injectCommands_P(G28_STR); break; } } @@ -771,7 +772,7 @@ void ChironTFT::PanelProcess(uint8_t req) { pos.y = atoi(&panel_command[FindToken('Y')+1]); pos_z = getMeshPoint(pos); - SendtoTFT(PSTR("A29V ")); + SendtoTFT(F("A29V ")); TFTSer.println(pos_z * 100); if (!isPrinting()) { setSoftEndstopState(true); // disable endstops @@ -809,7 +810,7 @@ void ChironTFT::PanelProcess(uint8_t req) { SendtoTFTLN(AC_msg_start_probing); - injectCommands_P(PSTR("G28\nG29")); + injectCommands(F("G28\nG29")); printer_state = AC_printer_probing; } } @@ -823,7 +824,7 @@ void ChironTFT::PanelProcess(uint8_t req) { if (FindToken('C') != -1) { // Restore and apply original offsets if (!isPrinting()) { - injectCommands_P(PSTR("M501\nM420 S1")); + injectCommands(F("M501\nM420 S1")); selectedmeshpoint.x = selectedmeshpoint.y = 99; SERIAL_ECHOLNF(AC_msg_mesh_changes_abandoned); } @@ -832,14 +833,14 @@ void ChironTFT::PanelProcess(uint8_t req) { else if (FindToken('D') != -1) { // Save Z Offset tables and restore leveling state if (!isPrinting()) { setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made - injectCommands_P(PSTR("M500")); + injectCommands(F("M500")); SERIAL_ECHOLNF(AC_msg_mesh_changes_saved); selectedmeshpoint.x = selectedmeshpoint.y = 99; } } else if (FindToken('G') != -1) { // Get current offset - SendtoTFT(PSTR("A31V ")); + SendtoTFT(F("A31V ")); // When printing use the live z Offset position // we will use babystepping to move the print head if (isPrinting()) @@ -874,7 +875,7 @@ void ChironTFT::PanelProcess(uint8_t req) { babystepAxis_steps(steps, Z); live_Zoffset += Zshift; } - SendtoTFT(PSTR("A31V ")); + SendtoTFT(F("A31V ")); TFTSer.println(live_Zoffset); } else { @@ -892,7 +893,7 @@ void ChironTFT::PanelProcess(uint8_t req) { #endif setZOffset_mm(currZOffset + Zshift); - SendtoTFT(PSTR("A31V ")); + SendtoTFT(F("A31V ")); TFTSer.println(getZOffset_mm()); if (isAxisPositionKnown(Z)) { @@ -911,7 +912,7 @@ void ChironTFT::PanelProcess(uint8_t req) { case 32: { // A32 clean leveling beep flag // Ignore request if printing //if (isPrinting()) break; - //injectCommands_P(PSTR("M500\nM420 S1\nG1 Z10 F240\nG1 X0 Y0 F6000")); + //injectCommands(F("M500\nM420 S1\nG1 Z10 F240\nG1 X0 Y0 F6000")); //TFTSer.println(); } break; @@ -919,7 +920,7 @@ void ChironTFT::PanelProcess(uint8_t req) { case 34: { // A34 Adjust single mesh point A34 C/S X1 Y1 V123 if (panel_command[3] == 'C') { // Restore original offsets - injectCommands_P(PSTR("M501\nM420 S1")); + injectCommands(F("M501\nM420 S1")); selectedmeshpoint.x = selectedmeshpoint.y = 99; //printer_state = AC_printer_idle; } diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h index 7eb0049993..a80763e372 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h @@ -59,16 +59,16 @@ class ChironTFT { public: static void Startup(); static void IdleLoop(); - static void PrinterKilled(PGM_P,PGM_P); + static void PrinterKilled(PGM_P, PGM_P); static void MediaEvent(media_event_t); static void TimerEvent(timer_event_t); static void FilamentRunout(); - static void ConfirmationRequest(const char * const ); - static void StatusChange(const char * const ); + static void ConfirmationRequest(const char * const); + static void StatusChange(const char * const); static void PowerLossRecovery(); static void PrintComplete(); - static void SendtoTFT(PGM_P); - static void SendtoTFTLN(PGM_P); + static void SendtoTFT(FSTR_P const); + static void SendtoTFTLN(FSTR_P const); private: static void DetectPanelType(); static bool ReadTFTCommand(); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h index d9157fc4e6..0fd7770cdd 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h @@ -57,46 +57,46 @@ #define AC_LOWEST_MESHPOINT_VAL -10 // The lowest value you can set for a single mesh point offset // TFT panel commands -#define AC_msg_sd_card_inserted PSTR("J00") -#define AC_msg_sd_card_removed PSTR("J01") -#define AC_msg_no_sd_card PSTR("J02") -#define AC_msg_usb_connected PSTR("J03") -#define AC_msg_print_from_sd_card PSTR("J04") -#define AC_msg_pause PSTR("J05") -#define AC_msg_nozzle_heating PSTR("J06") -#define AC_msg_nozzle_heating_done PSTR("J07") -#define AC_msg_bed_heating PSTR("J08") -#define AC_msg_bed_heating_done PSTR("J09") -#define AC_msg_nozzle_temp_abnormal PSTR("J10") -#define AC_msg_kill_lcd PSTR("J11") -#define AC_msg_ready PSTR("J12") -#define AC_msg_low_nozzle_temp PSTR("J13") -#define AC_msg_print_complete PSTR("J14") -#define AC_msg_filament_out_alert PSTR("J15") -#define AC_msg_stop PSTR("J16") -#define AC_msg_main_board_has_reset PSTR("J17") -#define AC_msg_paused PSTR("J18") -#define AC_msg_j19_unknown PSTR("J19") -#define AC_msg_sd_file_open_success PSTR("J20") -#define AC_msg_sd_file_open_failed PSTR("J21") -#define AC_msg_level_monitor_finished PSTR("J22") -#define AC_msg_filament_out_block PSTR("J23") -#define AC_msg_probing_not_allowed PSTR("J24") -#define AC_msg_probing_complete PSTR("J25") -#define AC_msg_start_probing PSTR("J26") -#define AC_msg_version PSTR("J27") -#define AC_msg_mesh_changes_abandoned PSTR("Mesh changes abandoned, previous mesh restored.") -#define AC_msg_mesh_changes_saved PSTR("Mesh changes saved.") -#define AC_msg_old_panel_detected PSTR("Standard TFT panel detected!") -#define AC_msg_new_panel_detected PSTR("New TFT panel detected!") -#define AC_msg_powerloss_recovery PSTR("Resuming from power outage! select the same SD file then press resume") +#define AC_msg_sd_card_inserted F("J00") +#define AC_msg_sd_card_removed F("J01") +#define AC_msg_no_sd_card F("J02") +#define AC_msg_usb_connected F("J03") +#define AC_msg_print_from_sd_card F("J04") +#define AC_msg_pause F("J05") +#define AC_msg_nozzle_heating F("J06") +#define AC_msg_nozzle_heating_done F("J07") +#define AC_msg_bed_heating F("J08") +#define AC_msg_bed_heating_done F("J09") +#define AC_msg_nozzle_temp_abnormal F("J10") +#define AC_msg_kill_lcd F("J11") +#define AC_msg_ready F("J12") +#define AC_msg_low_nozzle_temp F("J13") +#define AC_msg_print_complete F("J14") +#define AC_msg_filament_out_alert F("J15") +#define AC_msg_stop F("J16") +#define AC_msg_main_board_has_reset F("J17") +#define AC_msg_paused F("J18") +#define AC_msg_j19_unknown F("J19") +#define AC_msg_sd_file_open_success F("J20") +#define AC_msg_sd_file_open_failed F("J21") +#define AC_msg_level_monitor_finished F("J22") +#define AC_msg_filament_out_block F("J23") +#define AC_msg_probing_not_allowed F("J24") +#define AC_msg_probing_complete F("J25") +#define AC_msg_start_probing F("J26") +#define AC_msg_version F("J27") +#define AC_msg_mesh_changes_abandoned F("Mesh changes abandoned, previous mesh restored.") +#define AC_msg_mesh_changes_saved F("Mesh changes saved.") +#define AC_msg_old_panel_detected F("Standard TFT panel detected!") +#define AC_msg_new_panel_detected F("New TFT panel detected!") +#define AC_msg_powerloss_recovery F("Resuming from power outage! select the same SD file then press resume") // Error messages must not contain spaces -#define AC_msg_error_bed_temp PSTR("Abnormal_bed_temp") -#define AC_msg_error_hotend_temp PSTR("Abnormal_hotend_temp") -#define AC_msg_error_sd_card PSTR("SD_card_error") -#define AC_msg_filament_out PSTR("Filament_runout") -#define AC_msg_power_loss PSTR("Power_failure") -#define AC_msg_eeprom_version PSTR("EEPROM_ver_wrong") +#define AC_msg_error_bed_temp F("Abnormal_bed_temp") +#define AC_msg_error_hotend_temp F("Abnormal_hotend_temp") +#define AC_msg_error_sd_card F("SD_card_error") +#define AC_msg_filament_out F("Filament_runout") +#define AC_msg_power_loss F("Power_failure") +#define AC_msg_eeprom_version F("EEPROM_ver_wrong") #define MARLIN_msg_start_probing PSTR("Probing Point 1/25") #define MARLIN_msg_probing_failed PSTR("Probing Failed") @@ -113,16 +113,16 @@ #define MARLIN_msg_filament_purging PSTR("Filament Purging...") #define MARLIN_msg_special_pause PSTR("PB") -#define AC_cmnd_auto_unload_filament PSTR("M701") // Use Marlin unload routine -#define AC_cmnd_auto_load_filament PSTR("M702 M0 PB") // Use Marlin load routing then pause for user to clean nozzle +#define AC_cmnd_auto_unload_filament F("M701") // Use Marlin unload routine +#define AC_cmnd_auto_load_filament F("M702 M0 PB") // Use Marlin load routing then pause for user to clean nozzle -#define AC_cmnd_manual_load_filament PSTR("M83\nG1 E50 F700\nM82") // replace the manual panel commands with something a little faster -#define AC_cmnd_manual_unload_filament PSTR("M83\nG1 E-50 F1200\nM82") -#define AC_cmnd_enable_leveling PSTR("M420SV") -#define AC_cmnd_power_loss_recovery PSTR("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position +#define AC_cmnd_manual_load_filament F("M83\nG1 E50 F700\nM82") // replace the manual panel commands with something a little faster +#define AC_cmnd_manual_unload_filament F("M83\nG1 E-50 F1200\nM82") +#define AC_cmnd_enable_leveling F("M420SV") +#define AC_cmnd_power_loss_recovery F("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position -#define AC_Test_for_OldPanel PSTR("SIZE") // An old panel will respond with 'SXY 480 320' a new panel wont respond. -#define AC_Test_for_NewPanel PSTR("J200") // A new panel will respond with '[0]=0 [1]=0' to '[19]=0 ' an old panel wont respond +#define AC_Test_for_OldPanel F("SIZE") // An old panel will respond with 'SXY 480 320' a new panel wont respond. +#define AC_Test_for_NewPanel F("J200") // A new panel will respond with '[0]=0 [1]=0' to '[19]=0 ' an old panel wont respond namespace Anycubic { enum heater_state_t : uint8_t { diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp index e07e377dfc..5bbcfd0b5e 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -104,7 +104,7 @@ void AnycubicTFTClass::OnSetup() { SelectedFile[0] = 0; #if ENABLED(STARTUP_CHIME) - injectCommands_P(PSTR("M300 P250 S554\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P500 S831")); + injectCommands(F("M300 P250 S554\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P500 S831")); #endif #if ENABLED(ANYCUBIC_LCD_DEBUG) SERIAL_ECHOLNPGM("TFT Serial Debug: Finished startup"); @@ -122,7 +122,7 @@ void AnycubicTFTClass::OnCommandScan() { #endif mediaPrintingState = AMPRINTSTATE_NOT_PRINTING; mediaPauseState = AMPAUSESTATE_NOT_PAUSED; - injectCommands_P(PSTR("M84\nM27")); // disable stepper motors and force report of SD status + injectCommands(F("M84\nM27")); // disable stepper motors and force report of SD status delay_ms(200); // tell printer to release resources of print to indicate it is done SENDLINE_DBG_PGM("J14", "TFT Serial Debug: SD Print Stopped... J14"); @@ -249,48 +249,48 @@ void AnycubicTFTClass::HandleSpecialMenu() { switch (SelectedDirectory[2]) { case '1': // "<01ZUp0.1>" SERIAL_ECHOLNPGM("Special Menu: Z Up 0.1"); - injectCommands_P(PSTR("G91\nG1 Z+0.1\nG90")); + injectCommands(F("G91\nG1 Z+0.1\nG90")); break; case '2': // "<02ZUp0.02>" SERIAL_ECHOLNPGM("Special Menu: Z Up 0.02"); - injectCommands_P(PSTR("G91\nG1 Z+0.02\nG90")); + injectCommands(F("G91\nG1 Z+0.02\nG90")); break; case '3': // "<03ZDn0.02>" SERIAL_ECHOLNPGM("Special Menu: Z Down 0.02"); - injectCommands_P(PSTR("G91\nG1 Z-0.02\nG90")); + injectCommands(F("G91\nG1 Z-0.02\nG90")); break; case '4': // "<04ZDn0.1>" SERIAL_ECHOLNPGM("Special Menu: Z Down 0.1"); - injectCommands_P(PSTR("G91\nG1 Z-0.1\nG90")); + injectCommands(F("G91\nG1 Z-0.1\nG90")); break; case '5': // "<05PrehtBed>" SERIAL_ECHOLNPGM("Special Menu: Preheat Bed"); - injectCommands_P(PSTR("M140 S65")); + injectCommands(F("M140 S65")); break; case '6': // "<06SMeshLvl>" SERIAL_ECHOLNPGM("Special Menu: Start Mesh Leveling"); - injectCommands_P(PSTR("G29S1")); + injectCommands(F("G29S1")); break; case '7': // "<07MeshNPnt>" SERIAL_ECHOLNPGM("Special Menu: Next Mesh Point"); - injectCommands_P(PSTR("G29S2")); + injectCommands(F("G29S2")); break; case '8': // "<08HtEndPID>" SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotend PID"); // need to dwell for half a second to give the fan a chance to start before the pid tuning starts - injectCommands_P(PSTR("M106 S204\nG4 P500\nM303 E0 S215 C15 U1")); + injectCommands(F("M106 S204\nG4 P500\nM303 E0 S215 C15 U1")); break; case '9': // "<09HtBedPID>" SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotbed Pid"); - injectCommands_P(PSTR("M303 E-1 S65 C6 U1")); + injectCommands(F("M303 E-1 S65 C6 U1")); break; default: @@ -302,12 +302,12 @@ void AnycubicTFTClass::HandleSpecialMenu() { switch (SelectedDirectory[2]) { case '0': // "<10FWDeflts>" SERIAL_ECHOLNPGM("Special Menu: Load FW Defaults"); - injectCommands_P(PSTR("M502\nM300 P105 S1661\nM300 P210 S1108")); + injectCommands(F("M502\nM300 P105 S1661\nM300 P210 S1108")); break; case '1': // "<11SvEEPROM>" SERIAL_ECHOLNPGM("Special Menu: Save EEPROM"); - injectCommands_P(PSTR("M500\nM300 P105 S1108\nM300 P210 S1661")); + injectCommands(F("M500\nM300 P105 S1108\nM300 P210 S1661")); break; default: @@ -319,38 +319,38 @@ void AnycubicTFTClass::HandleSpecialMenu() { switch (SelectedDirectory[2]) { case '1': // "<01PrehtBed>" SERIAL_ECHOLNPGM("Special Menu: Preheat Bed"); - injectCommands_P(PSTR("M140 S65")); + injectCommands(F("M140 S65")); break; case '2': // "<02ABL>" SERIAL_ECHOLNPGM("Special Menu: Auto Bed Leveling"); - injectCommands_P(PSTR("G29N")); + injectCommands(F("G29N")); break; case '3': // "<03HtendPID>" SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotend PID"); // need to dwell for half a second to give the fan a chance to start before the pid tuning starts - injectCommands_P(PSTR("M106 S204\nG4 P500\nM303 E0 S215 C15 U1")); + injectCommands(F("M106 S204\nG4 P500\nM303 E0 S215 C15 U1")); break; case '4': // "<04HtbedPID>" SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotbed Pid"); - injectCommands_P(PSTR("M303 E-1 S65 C6 U1")); + injectCommands(F("M303 E-1 S65 C6 U1")); break; case '5': // "<05FWDeflts>" SERIAL_ECHOLNPGM("Special Menu: Load FW Defaults"); - injectCommands_P(PSTR("M502\nM300 P105 S1661\nM300 P210 S1108")); + injectCommands(F("M502\nM300 P105 S1661\nM300 P210 S1108")); break; case '6': // "<06SvEEPROM>" SERIAL_ECHOLNPGM("Special Menu: Save EEPROM"); - injectCommands_P(PSTR("M500\nM300 P105 S1108\nM300 P210 S1661")); + injectCommands(F("M500\nM300 P105 S1108\nM300 P210 S1661")); break; case '7': // <07SendM108> SERIAL_ECHOLNPGM("Special Menu: Send User Confirmation"); - injectCommands_P(PSTR("M108")); + injectCommands(F("M108")); break; default: @@ -705,7 +705,7 @@ void AnycubicTFTClass::GetCommandFromTFT() { } else if (CodeSeen('C') && !isPrinting()) { if (getAxisPosition_mm(Z) < 10) - injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS + injectCommands(F("G1 Z10")); // RASE Z AXIS tempvalue = constrain(CodeValue(), 0, 275); setTargetTemp_celsius(tempvalue, (extruder_t)E0); } @@ -756,11 +756,11 @@ void AnycubicTFTClass::GetCommandFromTFT() { if (!isPrinting() && !isPrintingFromMediaPaused()) { if (CodeSeen('X') || CodeSeen('Y') || CodeSeen('Z')) { if (CodeSeen('X')) - injectCommands_P(PSTR("G28X")); + injectCommands(F("G28X")); if (CodeSeen('Y')) - injectCommands_P(PSTR("G28Y")); + injectCommands(F("G28Y")); if (CodeSeen('Z')) - injectCommands_P(PSTR("G28Z")); + injectCommands(F("G28Z")); } else if (CodeSeen('C')) { injectCommands_P(G28_STR); @@ -831,7 +831,7 @@ void AnycubicTFTClass::GetCommandFromTFT() { case 23: // A23 preheat pla if (!isPrinting()) { if (getAxisPosition_mm(Z) < 10) - injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS + injectCommands(F("G1 Z10")); // RASE Z AXIS setTargetTemp_celsius(PREHEAT_1_TEMP_BED, (heater_t)BED); setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, (extruder_t)E0); @@ -842,7 +842,7 @@ void AnycubicTFTClass::GetCommandFromTFT() { case 24:// A24 preheat abs if (!isPrinting()) { if (getAxisPosition_mm(Z) < 10) - injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS + injectCommands(F("G1 Z10")); // RASE Z AXIS setTargetTemp_celsius(PREHEAT_2_TEMP_BED, (heater_t)BED); setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, (extruder_t)E0); @@ -933,7 +933,7 @@ void AnycubicTFTClass::DoFilamentRunoutCheck() { if (READ(FIL_RUNOUT1_PIN)) { if (mediaPrintingState == AMPRINTSTATE_PRINTING || mediaPrintingState == AMPRINTSTATE_PAUSED || mediaPrintingState == AMPRINTSTATE_PAUSE_REQUESTED) { // play tone to indicate filament is out - injectCommands_P(PSTR("\nM300 P200 S1567\nM300 P200 S1174\nM300 P200 S1567\nM300 P200 S1174\nM300 P2000 S1567")); + injectCommands(F("\nM300 P200 S1567\nM300 P200 S1174\nM300 P200 S1567\nM300 P200 S1174\nM300 P2000 S1567")); // tell the user that the filament has run out and wait SENDLINE_DBG_PGM("J23", "TFT Serial Debug: Blocking filament prompt... J23"); @@ -969,7 +969,7 @@ void AnycubicTFTClass::PausePrint() { SENDLINE_DBG_PGM("J05", "TFT Serial Debug: SD print pause started... J05"); // J05 printing pause // for some reason pausing the print doesn't retract the extruder so force a manual one here - injectCommands_P(PSTR("G91\nG1 E-2 F1800\nG90")); + injectCommands(F("G91\nG1 E-2 F1800\nG90")); pausePrint(); } #endif @@ -1018,7 +1018,7 @@ void AnycubicTFTClass::StopPrint() { SENDLINE_DBG_PGM("J16", "TFT Serial Debug: SD print stop called... J16"); // for some reason stopping the print doesn't retract the extruder so force a manual one here - injectCommands_P(PSTR("G91\nG1 E-2 F1800\nG90")); + injectCommands(F("G91\nG1 E-2 F1800\nG90")); stopPrint(); #endif } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp index 8c76648bf1..f0844dc785 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp @@ -52,26 +52,26 @@ void DGUSRxHandler::ScreenChange(DGUS_VP &vp, void *data_ptr) { #endif if (!ExtUI::isMediaInserted()) { - dgus_screen_handler.SetStatusMessagePGM(GET_TEXT(MSG_NO_MEDIA)); + dgus_screen_handler.SetStatusMessage(GET_TEXT_F(MSG_NO_MEDIA)); return; } card.cdroot(); #else - dgus_screen_handler.SetStatusMessagePGM(GET_TEXT(MSG_NO_MEDIA)); + dgus_screen_handler.SetStatusMessage(GET_TEXT_F(MSG_NO_MEDIA)); return; #endif } if (vp.addr == DGUS_Addr::SCREENCHANGE_Idle && (ExtUI::isPrinting() || ExtUI::isPrintingPaused())) { - dgus_screen_handler.SetStatusMessagePGM(PSTR("Impossible while printing")); + dgus_screen_handler.SetStatusMessage(F("Impossible while printing")); return; } if (vp.addr == DGUS_Addr::SCREENCHANGE_Printing && (!ExtUI::isPrinting() && !ExtUI::isPrintingPaused())) { - dgus_screen_handler.SetStatusMessagePGM(PSTR("Impossible while idle")); + dgus_screen_handler.SetStatusMessage(F("Impossible while idle")); return; } @@ -139,7 +139,7 @@ void DGUSRxHandler::ScreenChange(DGUS_VP &vp, void *data_ptr) { UNUSED(data_ptr); if (dgus_screen_handler.filelist_selected < 0) { - dgus_screen_handler.SetStatusMessagePGM(PSTR("No file selected")); + dgus_screen_handler.SetStatusMessage(F("No file selected")); return; } @@ -149,7 +149,7 @@ void DGUSRxHandler::ScreenChange(DGUS_VP &vp, void *data_ptr) { } if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -207,7 +207,7 @@ void DGUSRxHandler::PrintResume(DGUS_VP &vp, void *data_ptr) { } if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -364,7 +364,7 @@ void DGUSRxHandler::TempCool(DGUS_VP &vp, void *data_ptr) { #endif } - dgus_screen_handler.SetStatusMessagePGM(PSTR("Cooling...")); + dgus_screen_handler.SetStatusMessage(F("Cooling...")); dgus_screen_handler.TriggerFullUpdate(); } @@ -390,12 +390,12 @@ void DGUSRxHandler::ZOffset(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); if (!ExtUI::isAxisPositionKnown(ExtUI::Z)) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_HOMING_REQUIRED); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_HOMING_REQUIRED)); return; } if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -414,12 +414,12 @@ void DGUSRxHandler::ZOffsetStep(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); if (!ExtUI::isAxisPositionKnown(ExtUI::Z)) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_HOMING_REQUIRED); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_HOMING_REQUIRED)); return; } if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -456,12 +456,12 @@ void DGUSRxHandler::MoveToPoint(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); if (!ExtUI::isPositionKnown()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_HOMING_REQUIRED); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_HOMING_REQUIRED)); return; } if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -506,17 +506,17 @@ void DGUSRxHandler::Probe(DGUS_VP &vp, void *data_ptr) { UNUSED(data_ptr); #if ENABLED(MESH_BED_LEVELING) - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_ABL_REQUIRED); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_ABL_REQUIRED)); return; #endif if (!ExtUI::isPositionKnown()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_HOMING_REQUIRED); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_HOMING_REQUIRED)); return; } if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -535,7 +535,7 @@ void DGUSRxHandler::DisableABL(DGUS_VP &vp, void *data_ptr) { UNUSED(data_ptr); if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -576,7 +576,7 @@ void DGUSRxHandler::FilamentMove(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -600,7 +600,7 @@ void DGUSRxHandler::FilamentMove(DGUS_VP &vp, void *data_ptr) { } if (ExtUI::getActualTemp_celsius(extruder) < (float)EXTRUDE_MINTEMP) { - dgus_screen_handler.SetStatusMessagePGM(PSTR("Temperature too low")); + dgus_screen_handler.SetStatusMessage(F("Temperature too low")); return; } @@ -620,7 +620,7 @@ void DGUSRxHandler::Home(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -664,7 +664,7 @@ void DGUSRxHandler::Move(DGUS_VP &vp, void *data_ptr) { } if (!ExtUI::isAxisPositionKnown(axis)) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_HOMING_REQUIRED); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_HOMING_REQUIRED)); return; } @@ -720,7 +720,7 @@ void DGUSRxHandler::MoveStep(DGUS_VP &vp, void *data_ptr) { } if (!ExtUI::isAxisPositionKnown(axis)) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_HOMING_REQUIRED); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_HOMING_REQUIRED)); return; } @@ -757,7 +757,7 @@ void DGUSRxHandler::GcodeExecute(DGUS_VP &vp, void *data_ptr) { } if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -780,7 +780,7 @@ void DGUSRxHandler::ResetEEPROM(DGUS_VP &vp, void *data_ptr) { } if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -798,7 +798,7 @@ void DGUSRxHandler::SettingsExtra(DGUS_VP &vp, void *data_ptr) { case DGUS_Data::Extra::BUTTON1: #if ENABLED(BLTOUCH) if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -844,7 +844,7 @@ void DGUSRxHandler::PIDSetTemp(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -875,7 +875,7 @@ void DGUSRxHandler::PIDRun(DGUS_VP &vp, void *data_ptr) { UNUSED(data_ptr); if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -889,7 +889,7 @@ void DGUSRxHandler::PIDRun(DGUS_VP &vp, void *data_ptr) { heater = H_BED; break; #else - dgus_screen_handler.SetStatusMessagePGM(PSTR("Bed PID disabled")); + dgus_screen_handler.SetStatusMessage(F("Bed PID disabled")); return; #endif case DGUS_Data::Heater::H0: @@ -897,7 +897,7 @@ void DGUSRxHandler::PIDRun(DGUS_VP &vp, void *data_ptr) { heater = H_E0; break; #else - dgus_screen_handler.SetStatusMessagePGM(PSTR("PID disabled")); + dgus_screen_handler.SetStatusMessage(F("PID disabled")); return; #endif #if HOTENDS > 1 @@ -906,7 +906,7 @@ void DGUSRxHandler::PIDRun(DGUS_VP &vp, void *data_ptr) { heater = H_E1; break; #else - dgus_screen_handler.SetStatusMessagePGM(PSTR("PID disabled")); + dgus_screen_handler.SetStatusMessage(F("PID disabled")); return; #endif #endif @@ -936,7 +936,7 @@ void DGUSRxHandler::PIDRun(DGUS_VP &vp, void *data_ptr) { } if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } @@ -955,12 +955,12 @@ void DGUSRxHandler::PIDRun(DGUS_VP &vp, void *data_ptr) { } if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return; } if (!recovery.valid()) { - dgus_screen_handler.SetStatusMessagePGM(PSTR("Invalid recovery data")); + dgus_screen_handler.SetStatusMessage(F("Invalid recovery data")); return; } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp index 02cc3d6836..1489ed4bbe 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp @@ -135,20 +135,17 @@ void DGUSScreenHandler::Loop() { return; } - if (current_screen == DGUS_Screen::LEVELING_PROBING - && IsPrinterIdle()) { + if (current_screen == DGUS_Screen::LEVELING_PROBING && IsPrinterIdle()) { dgus_display.PlaySound(3); - SetStatusMessagePGM(ExtUI::getMeshValid() ? - PSTR("Probing successful") - : PSTR("Probing failed")); + SetStatusMessage(ExtUI::getMeshValid() ? F("Probing successful") : F("Probing failed")); MoveToScreen(DGUS_Screen::LEVELING_AUTOMATIC); return; } if (status_expire > 0 && ELAPSED(ms, status_expire)) { - SetStatusMessagePGM(NUL_STR, 0); + SetStatusMessage(FPSTR(NUL_STR), 0); return; } @@ -194,7 +191,7 @@ void DGUSScreenHandler::SettingsReset() { Ready(); } - SetStatusMessagePGM(PSTR("EEPROM reset")); + SetStatusMessage(F("EEPROM reset")); } void DGUSScreenHandler::StoreSettings(char *buff) { @@ -229,13 +226,13 @@ void DGUSScreenHandler::LoadSettings(const char *buff) { void DGUSScreenHandler::ConfigurationStoreWritten(bool success) { if (!success) { - SetStatusMessagePGM(PSTR("EEPROM write failed")); + SetStatusMessage(F("EEPROM write failed")); } } void DGUSScreenHandler::ConfigurationStoreRead(bool success) { if (!success) { - SetStatusMessagePGM(PSTR("EEPROM read failed")); + SetStatusMessage(F("EEPROM read failed")); } else if (!settings_ready) { settings_ready = true; @@ -324,7 +321,7 @@ void DGUSScreenHandler::FilamentRunout(const ExtUI::extruder_t extruder) { } void DGUSScreenHandler::SDCardError() { - SetStatusMessagePGM(GET_TEXT(MSG_MEDIA_READ_ERROR)); + SetStatusMessage(GET_TEXT_F(MSG_MEDIA_READ_ERROR)); if (current_screen == DGUS_Screen::PRINT) { TriggerScreenChange(DGUS_Screen::HOME); @@ -346,19 +343,19 @@ void DGUSScreenHandler::FilamentRunout(const ExtUI::extruder_t extruder) { void DGUSScreenHandler::PidTuning(const ExtUI::result_t rst) { switch (rst) { case ExtUI::PID_STARTED: - SetStatusMessagePGM(GET_TEXT(MSG_PID_AUTOTUNE)); + SetStatusMessage(GET_TEXT_F(MSG_PID_AUTOTUNE)); break; case ExtUI::PID_BAD_EXTRUDER_NUM: - SetStatusMessagePGM(GET_TEXT(MSG_PID_BAD_EXTRUDER_NUM)); + SetStatusMessage(GET_TEXT_F(MSG_PID_BAD_EXTRUDER_NUM)); break; case ExtUI::PID_TEMP_TOO_HIGH: - SetStatusMessagePGM(GET_TEXT(MSG_PID_TEMP_TOO_HIGH)); + SetStatusMessage(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH)); break; case ExtUI::PID_TUNING_TIMEOUT: - SetStatusMessagePGM(GET_TEXT(MSG_PID_TIMEOUT)); + SetStatusMessage(GET_TEXT_F(MSG_PID_TIMEOUT)); break; case ExtUI::PID_DONE: - SetStatusMessagePGM(GET_TEXT(MSG_PID_AUTOTUNE_DONE)); + SetStatusMessage(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE)); break; default: return; @@ -411,8 +408,8 @@ void DGUSScreenHandler::SetStatusMessage(const char* msg, const millis_t duratio status_expire = (duration > 0 ? ExtUI::safe_millis() + duration : 0); } -void DGUSScreenHandler::SetStatusMessagePGM(PGM_P msg, const millis_t duration) { - dgus_display.WriteStringPGM((uint16_t)DGUS_Addr::MESSAGE_Status, msg, DGUS_STATUS_LEN, false, true); +void DGUSScreenHandler::SetStatusMessage(FSTR_P const fmsg, const millis_t duration) { + dgus_display.WriteStringPGM((uint16_t)DGUS_Addr::MESSAGE_Status, FTOP(msg), DGUS_STATUS_LEN, false, true); status_expire = (duration > 0 ? ExtUI::safe_millis() + duration : 0); } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h index 0c5e066212..0cc885eb7f 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h @@ -73,7 +73,7 @@ public: static void SetMessageLinePGM(PGM_P msg, uint8_t line); static void SetStatusMessage(const char* msg, const millis_t duration = DGUS_STATUS_EXPIRATION_MS); - static void SetStatusMessagePGM(PGM_P msg, const millis_t duration = DGUS_STATUS_EXPIRATION_MS); + static void SetStatusMessage(FSTR_P const msg, const millis_t duration = DGUS_STATUS_EXPIRATION_MS); static void ShowWaitScreen(DGUS_Screen return_screen, bool has_continue = false); diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.cpp index d8395d0182..090d53c92e 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSSetupHandler.cpp @@ -68,7 +68,7 @@ bool DGUSSetupHandler::LevelingMenu() { ExtUI::setLevelingActive(dgus_screen_handler.leveling_active); if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return false; } @@ -99,7 +99,7 @@ bool DGUSSetupHandler::LevelingManual() { } if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return false; } @@ -118,7 +118,7 @@ bool DGUSSetupHandler::LevelingOffset() { dgus_screen_handler.offset_steps = DGUS_Data::StepSize::MMP1; if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return false; } @@ -175,7 +175,7 @@ bool DGUSSetupHandler::Move() { dgus_screen_handler.move_steps = DGUS_Data::StepSize::MM10; if (!dgus_screen_handler.IsPrinterIdle()) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_BUSY); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_BUSY)); return false; } @@ -186,7 +186,7 @@ bool DGUSSetupHandler::Gcode() { ZERO(dgus_screen_handler.gcode); if (dgus_display.gui_version < 0x30 || dgus_display.os_version < 0x21) { - dgus_screen_handler.SetStatusMessagePGM(DGUS_MSG_FW_OUTDATED); + dgus_screen_handler.SetStatusMessage(FPSTR(DGUS_MSG_FW_OUTDATED)); return false; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp index cdc303a89e..6e4668eb36 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp @@ -52,7 +52,7 @@ bool StatusScreen::jog_xy; bool StatusScreen::fine_motion; void StatusScreen::unlockMotors() { - injectCommands_P(PSTR("M84 XY")); + injectCommands(F("M84 XY")); jog_xy = false; } @@ -305,7 +305,7 @@ bool StatusScreen::onTouchEnd(uint8_t tag) { case 12: if (!jog_xy) { jog_xy = true; - injectCommands_P(PSTR("M17")); + injectCommands(F("M17")); } jog({ 0, 0, 0 }); break; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp index 3636b5da6c..5ea9eed037 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp @@ -81,7 +81,7 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) { case 2: BedMeshViewScreen::doProbe(); break; case 3: BedMeshViewScreen::show(); break; case 4: BedMeshEditScreen::show(); break; - case 5: injectCommands_P(PSTR("M280 P0 S60")); break; + case 5: injectCommands(F("M280 P0 S60")); break; case 6: SpinnerDialogBox::enqueueAndWait(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break; default: return false; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp index 3fe17b72d5..2d404aff6c 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp @@ -86,7 +86,7 @@ bool MainMenu::onTouchEnd(uint8_t tag) { case 6: GOTO_SCREEN(FeedratePercentScreen); break; case 7: GOTO_SCREEN(FlowPercentScreen); break; case 8: GOTO_SCREEN(AdvancedSettingsMenu); break; - case 9: injectCommands_P(PSTR("M84")); break; + case 9: injectCommands(F("M84")); break; #if HAS_LEVELING case 10: GOTO_SCREEN(LevelingMenu); break; #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.cpp index 424e0afa76..b5ce108106 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.cpp @@ -74,37 +74,37 @@ bool PreheatMenu::onTouchEnd(uint8_t tag) { case 1: GOTO_PREVIOUS(); break; case 2: #ifdef COCOA_PRESS_PREHEAT_DARK_CHOCOLATE_INT_SCRIPT - injectCommands_P(PSTR(COCOA_PRESS_PREHEAT_DARK_CHOCOLATE_INT_SCRIPT)); + injectCommands(F(COCOA_PRESS_PREHEAT_DARK_CHOCOLATE_INT_SCRIPT)); #endif GOTO_SCREEN(PreheatTimerScreen); break; case 3: #ifdef COCOA_PRESS_PREHEAT_MILK_CHOCOLATE_INT_SCRIPT - injectCommands_P(PSTR(COCOA_PRESS_PREHEAT_MILK_CHOCOLATE_INT_SCRIPT)); + injectCommands(F(COCOA_PRESS_PREHEAT_MILK_CHOCOLATE_INT_SCRIPT)); #endif GOTO_SCREEN(PreheatTimerScreen); break; case 4: #ifdef COCOA_PRESS_PREHEAT_WHITE_CHOCOLATE_INT_SCRIPT - injectCommands_P(PSTR(COCOA_PRESS_PREHEAT_WHITE_CHOCOLATE_INT_SCRIPT)); + injectCommands(F(COCOA_PRESS_PREHEAT_WHITE_CHOCOLATE_INT_SCRIPT)); #endif GOTO_SCREEN(PreheatTimerScreen); break; case 5: #ifdef COCOA_PRESS_PREHEAT_DARK_CHOCOLATE_EXT_SCRIPT - injectCommands_P(PSTR(COCOA_PRESS_PREHEAT_DARK_CHOCOLATE_EXT_SCRIPT)); + injectCommands(F(COCOA_PRESS_PREHEAT_DARK_CHOCOLATE_EXT_SCRIPT)); #endif GOTO_SCREEN(PreheatTimerScreen); break; case 6: #ifdef COCOA_PRESS_PREHEAT_MILK_CHOCOLATE_EXT_SCRIPT - injectCommands_P(PSTR(COCOA_PRESS_PREHEAT_MILK_CHOCOLATE_EXT_SCRIPT)); + injectCommands(F(COCOA_PRESS_PREHEAT_MILK_CHOCOLATE_EXT_SCRIPT)); #endif GOTO_SCREEN(PreheatTimerScreen); break; case 7: #ifdef COCOA_PRESS_PREHEAT_WHITE_CHOCOLATE_EXT_SCRIPT - injectCommands_P(PSTR(COCOA_PRESS_PREHEAT_WHITE_CHOCOLATE_EXT_SCRIPT)); + injectCommands(F(COCOA_PRESS_PREHEAT_WHITE_CHOCOLATE_EXT_SCRIPT)); #endif GOTO_SCREEN(PreheatTimerScreen); break; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp index c7d0cc3f73..37eb29a99d 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp @@ -174,11 +174,11 @@ bool BedMeshEditScreen::onTouchEnd(uint8_t tag) { case 1: // On Cancel, reload saved mesh, discarding changes GOTO_PREVIOUS(); - injectCommands_P(PSTR("G29 L1")); + injectCommands(F("G29 L1")); return true; case 2: saveAdjustedHighlightedValue(); - injectCommands_P(PSTR("G29 S1")); + injectCommands(F("G29 S1")); mydata.needSave = false; return true; case 3: diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp index 8db2d2ef70..7b4195ff5c 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp @@ -154,11 +154,11 @@ void BedMeshViewScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI void BedMeshViewScreen::doProbe() { GOTO_SCREEN(BedMeshViewScreen); mydata.count = 0; - injectCommands_P(PSTR(BED_LEVELING_COMMANDS)); + injectCommands(F(BED_LEVELING_COMMANDS)); } void BedMeshViewScreen::show() { - injectCommands_P(PSTR("G29 L1")); + injectCommands(F("G29 L1")); GOTO_SCREEN(BedMeshViewScreen); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_auto_calibration_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_auto_calibration_dialog_box.cpp index 748cc1d7ef..5c43ed34ea 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_auto_calibration_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/confirm_auto_calibration_dialog_box.cpp @@ -37,7 +37,7 @@ bool ConfirmAutoCalibrationDialogBox::onTouchEnd(uint8_t tag) { switch (tag) { case 1: GOTO_SCREEN(StatusScreen); - injectCommands_P(PSTR("G425")); + injectCommands(F("G425")); return true; default: return DialogBoxBaseClass::onTouchEnd(tag); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp index 8807480897..bcdcad17be 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp @@ -33,7 +33,7 @@ using namespace Theme; #define _USER_DESC(N) MAIN_MENU_ITEM_##N##_DESC #define _USER_GCODE(N) MAIN_MENU_ITEM_##N##_GCODE #define _USER_ITEM(N) .tag(_ITEM_TAG(N)).button(USER_ITEM_POS(N), _USER_DESC(N)) -#define _USER_ACTION(N) case _ITEM_TAG(N): injectCommands_P(PSTR(_USER_GCODE(N))); TERN_(USER_SCRIPT_RETURN, GOTO_SCREEN(StatusScreen)); break; +#define _USER_ACTION(N) case _ITEM_TAG(N): injectCommands(F(_USER_GCODE(N))); TERN_(USER_SCRIPT_RETURN, GOTO_SCREEN(StatusScreen)); break; void CustomUserMenus::onRedraw(draw_mode_t what) { if (what & BACKGROUND) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp index 05845a9755..11db21aca9 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp @@ -125,11 +125,11 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) { #if ENABLED(G26_MESH_VALIDATION) case 6: GOTO_SCREEN(StatusScreen); - injectCommands_P(PSTR("G28\nM117 Heating...\nG26 R X0 Y0\nG27")); + injectCommands(F("G28\nM117 Heating...\nG26 R X0 Y0\nG27")); break; #endif #if ENABLED(BLTOUCH) - case 7: injectCommands_P(PSTR("M280 P0 S60")); break; + case 7: injectCommands(F("M280 P0 S60")); break; case 8: SpinnerDialogBox::enqueueAndWait(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break; #endif default: return false; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.cpp index a6c39db796..6ccda405fc 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.cpp @@ -106,10 +106,10 @@ bool MainMenu::onTouchEnd(uint8_t tag) { case 1: SaveSettingsDialogBox::promptToSaveSettings(); break; case 2: SpinnerDialogBox::enqueueAndWait(F("G28")); break; #if ENABLED(NOZZLE_CLEAN_FEATURE) - case 3: injectCommands_P(PSTR("G12")); GOTO_SCREEN(StatusScreen); break; + case 3: injectCommands(F("G12")); GOTO_SCREEN(StatusScreen); break; #endif case 4: GOTO_SCREEN(MoveAxisScreen); break; - case 5: injectCommands_P(PSTR("M84")); break; + case 5: injectCommands(F("M84")); break; case 6: GOTO_SCREEN(TemperatureScreen); break; case 7: GOTO_SCREEN(ChangeFilamentScreen); break; case 8: GOTO_SCREEN(AdvancedSettingsMenu); break; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/restore_failsafe_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/restore_failsafe_dialog_box.cpp index 2dfd64fa5b..f82ba1d5c8 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/restore_failsafe_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/restore_failsafe_dialog_box.cpp @@ -35,7 +35,7 @@ void RestoreFailsafeDialogBox::onRedraw(draw_mode_t) { bool RestoreFailsafeDialogBox::onTouchEnd(uint8_t tag) { switch (tag) { case 1: - ExtUI::injectCommands_P(PSTR("M502")); + ExtUI::injectCommands(F("M502")); AlertDialogBox::show(GET_TEXT_F(MSG_EEPROM_RESET)); // Remove RestoreFailsafeDialogBox from the stack // so the alert box doesn't return to it. diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/save_settings_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/save_settings_dialog_box.cpp index 5d92052ace..496d004a20 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/save_settings_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/save_settings_dialog_box.cpp @@ -38,7 +38,7 @@ bool SaveSettingsDialogBox::onTouchEnd(uint8_t tag) { needs_save = false; switch (tag) { case 1: - injectCommands_P(PSTR("M500")); + injectCommands(F("M500")); AlertDialogBox::show(GET_TEXT_F(MSG_EEPROM_SAVED)); // Remove SaveSettingsDialogBox from the stack // so the alert box doesn't return to me. diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.cpp index 2493de795a..3928bf3297 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/spinner_dialog_box.cpp @@ -60,7 +60,7 @@ void SpinnerDialogBox::onRefresh() { void SpinnerDialogBox::onRedraw(draw_mode_t) { } -void SpinnerDialogBox::show(FSTR_P message) { +void SpinnerDialogBox::show(FSTR_P fstr) { CommandProcessor cmd; if (AT_SCREEN(SpinnerDialogBox)) cmd.stop().execute(); cmd.cmd(CMD_DLSTART) @@ -68,7 +68,7 @@ void SpinnerDialogBox::show(FSTR_P message) { .cmd(CLEAR(true,true,true)) .cmd(COLOR_RGB(bg_text_enabled)) .tag(0); - draw_text_box(cmd, BTN_POS(1,1), BTN_SIZE(2,3), message, OPT_CENTER, font_large); + draw_text_box(cmd, BTN_POS(1,1), BTN_SIZE(2,3), fstr, OPT_CENTER, font_large); DLCache dlcache(SPINNER_CACHE); if (!dlcache.store(SPINNER_DL_SIZE)) { SERIAL_ECHO_MSG("CachedScreen::storeBackground() failed: not enough DL cache space"); @@ -86,14 +86,14 @@ void SpinnerDialogBox::hide() { GOTO_PREVIOUS(); } -void SpinnerDialogBox::enqueueAndWait(FSTR_P message, FSTR_P commands) { - show(message); - ExtUI::injectCommands_P((const char*)commands); +void SpinnerDialogBox::enqueueAndWait(FSTR_P fstr, FSTR_P commands) { + show(fstr); + ExtUI::injectCommands(commands); mydata.auto_hide = true; } -void SpinnerDialogBox::enqueueAndWait(FSTR_P message, char *commands) { - show(message); +void SpinnerDialogBox::enqueueAndWait(FSTR_P fstr, char *commands) { + show(fstr); ExtUI::injectCommands(commands); mydata.auto_hide = true; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/stress_test_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/stress_test_screen.cpp index ab1f96a399..ea4b872303 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/stress_test_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/stress_test_screen.cpp @@ -84,7 +84,7 @@ void StressTestScreen::runTestOnBootup(bool enable) { // whether or not we need to re-run the test // at startup. LockScreen::set_hash(enable ? 0xDEAD : 0); - injectCommands_P(PSTR("M500")); + injectCommands(F("M500")); } void StressTestScreen::startupCheck() { @@ -122,7 +122,7 @@ void StressTestScreen::onIdle() { injectCommands_P(G28_STR); } else { - injectCommands_P(PSTR( + injectCommands(F( "G0 X100 Y100 Z100 F6000\n" "T0\nG4 S1" E_TERN_("\nT1\nG4 S1") diff --git a/Marlin/src/lcd/extui/nextion/FileNavigator.cpp b/Marlin/src/lcd/extui/nextion/FileNavigator.cpp index 07f1256ded..6730370a94 100644 --- a/Marlin/src/lcd/extui/nextion/FileNavigator.cpp +++ b/Marlin/src/lcd/extui/nextion/FileNavigator.cpp @@ -83,46 +83,46 @@ void FileNavigator::getFiles(uint16_t index) { #endif if (currentindex == 0 && folderdepth > 0) { // Add a link to go up a folder - nextion.SendtoTFT(PSTR("vis p0,1")); - nextion.SendtoTFT(PSTR("\xFF\xFF\xFF")); + nextion.SendtoTFT(F("vis p0,1")); + nextion.SendtoTFT(F("\xFF\xFF\xFF")); SEND_VAL("tmpUP", "0"); files--; } else { - nextion.SendtoTFT(PSTR("vis p0,0")); - nextion.SendtoTFT(PSTR("\xFF\xFF\xFF")); + nextion.SendtoTFT(F("vis p0,0")); + nextion.SendtoTFT(F("\xFF\xFF\xFF")); } for (uint16_t seek = currentindex; seek < currentindex + files; seek++) { if (filelist.seek(seek)) { - nextion.SendtoTFT(PSTR("s")); + nextion.SendtoTFT(F("s")); LCD_SERIAL.print(fcnt); - nextion.SendtoTFT(PSTR(".txt=\"")); + nextion.SendtoTFT(F(".txt=\"")); if (filelist.isDir()) { LCD_SERIAL.print(filelist.shortFilename()); - nextion.SendtoTFT(PSTR("/\"")); - nextion.SendtoTFT(PSTR("\xFF\xFF\xFF")); + nextion.SendtoTFT(F("/\"")); + nextion.SendtoTFT(F("\xFF\xFF\xFF")); - nextion.SendtoTFT(PSTR("l")); + nextion.SendtoTFT(F("l")); LCD_SERIAL.print(fcnt); - nextion.SendtoTFT(PSTR(".txt=\"")); + nextion.SendtoTFT(F(".txt=\"")); LCD_SERIAL.print(filelist.filename()); - nextion.SendtoTFT(PSTR("\"")); - nextion.SendtoTFT(PSTR("\xFF\xFF\xFF")); + nextion.SendtoTFT(F("\"")); + nextion.SendtoTFT(F("\xFF\xFF\xFF")); SEND_PCO2("l", fcnt, "1055"); } else { LCD_SERIAL.print(currentfoldername); LCD_SERIAL.print(filelist.shortFilename()); - nextion.SendtoTFT(PSTR("\"")); - nextion.SendtoTFT(PSTR("\xFF\xFF\xFF")); + nextion.SendtoTFT(F("\"")); + nextion.SendtoTFT(F("\xFF\xFF\xFF")); - nextion.SendtoTFT(PSTR("l")); + nextion.SendtoTFT(F("l")); LCD_SERIAL.print(fcnt); - nextion.SendtoTFT(PSTR(".txt=\"")); + nextion.SendtoTFT(F(".txt=\"")); LCD_SERIAL.print(filelist.longFilename()); - nextion.SendtoTFT(PSTR("\"")); - nextion.SendtoTFT(PSTR("\xFF\xFF\xFF")); + nextion.SendtoTFT(F("\"")); + nextion.SendtoTFT(F("\xFF\xFF\xFF")); } fcnt++; fseek = seek; diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp index c4e0e66a39..64e909779d 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp @@ -110,12 +110,12 @@ void NextionTFT::StatusChange(const char * const msg) { SEND_VALasTXT("tmppage.M117", msg); } -void NextionTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEM string to the panel +void NextionTFT::SendtoTFT(FSTR_P fstr) { // A helper to print PROGMEM string to the panel #if NEXDEBUG(N_SOME) - DEBUG_ECHOPGM_P(str); + DEBUG_ECHOF(fstr); #endif - while (const char c = pgm_read_byte(str++)) - LCD_SERIAL.write(c); + PGM_P str = FTOP(fstr); + while (const char c = pgm_read_byte(str++)) LCD_SERIAL.write(c); } bool NextionTFT::ReadTFTCommand() { @@ -522,7 +522,7 @@ void NextionTFT::PanelAction(uint8_t req) { case 66: // Refresh SD if (!isPrinting()) { - injectCommands_P(PSTR("M21")); + injectCommands(F("M21")); filenavigator.reset(); } break; @@ -546,8 +546,8 @@ void NextionTFT::PanelAction(uint8_t req) { #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) if (canMove(getActiveTool())) { switch (nextion_command[4]) { - case 'L': injectCommands_P(PSTR("M701")); break; - case 'U': injectCommands_P(PSTR("M702")); break; + case 'L': injectCommands(F("M701")); break; + case 'U': injectCommands(F("M702")); break; } } else { diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft.h b/Marlin/src/lcd/extui/nextion/nextion_tft.h index 4eb5fbe0b7..f32e5d4ef1 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft.h +++ b/Marlin/src/lcd/extui/nextion/nextion_tft.h @@ -43,9 +43,9 @@ class NextionTFT { static void Startup(); static void IdleLoop(); static void PrinterKilled(PGM_P, PGM_P); - static void ConfirmationRequest(const char * const ); - static void StatusChange(const char * const ); - static void SendtoTFT(PGM_P); + static void ConfirmationRequest(const char * const); + static void StatusChange(const char * const); + static void SendtoTFT(FSTR_P const); static void UpdateOnChange(); static void PrintFinished(); static void PanelInfo(uint8_t); diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft_defs.h b/Marlin/src/lcd/extui/nextion/nextion_tft_defs.h index 32d3ea3295..4570e9bba4 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft_defs.h +++ b/Marlin/src/lcd/extui/nextion/nextion_tft_defs.h @@ -54,10 +54,10 @@ // TFT panel commands #define msg_welcome MACHINE_NAME " Ready." -#define SEND_TEMP(x,y,t,z) (nextion.SendtoTFT(PSTR(x)), nextion.SendtoTFT(PSTR(".txt=\"")), LCD_SERIAL.print(y), nextion.SendtoTFT(PSTR(t)), LCD_SERIAL.print(z), nextion.SendtoTFT(PSTR("\"\xFF\xFF\xFF"))) -#define SEND_VAL(x,y) (nextion.SendtoTFT(PSTR(x)), nextion.SendtoTFT(PSTR(".val=")), LCD_SERIAL.print(y), nextion.SendtoTFT(PSTR("\xFF\xFF\xFF"))) -#define SEND_TXT(x,y) (nextion.SendtoTFT(PSTR(x)), nextion.SendtoTFT(PSTR(".txt=\"")), nextion.SendtoTFT(PSTR(y)), nextion.SendtoTFT(PSTR("\"\xFF\xFF\xFF"))) -#define SEND_TXT_P(x,y) (nextion.SendtoTFT(PSTR(x)), nextion.SendtoTFT(PSTR(".txt=\"")), nextion.SendtoTFT(y), nextion.SendtoTFT(PSTR("\"\xFF\xFF\xFF"))) -#define SEND_VALasTXT(x,y) (nextion.SendtoTFT(PSTR(x)), nextion.SendtoTFT(PSTR(".txt=\"")), LCD_SERIAL.print(y), nextion.SendtoTFT(PSTR("\"\xFF\xFF\xFF"))) -#define SEND_TXT_END(x) (nextion.SendtoTFT(PSTR(x)), nextion.SendtoTFT(PSTR("\xFF\xFF\xFF"))) -#define SEND_PCO2(x,y,z) (nextion.SendtoTFT(PSTR(x)), LCD_SERIAL.print(y), nextion.SendtoTFT(PSTR(".pco=")), nextion.SendtoTFT(PSTR(z)), nextion.SendtoTFT(PSTR("\xFF\xFF\xFF"))) +#define SEND_TEMP(x,y,t,z) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), LCD_SERIAL.print(y), nextion.SendtoTFT(F(t)), LCD_SERIAL.print(z), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) +#define SEND_VAL(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".val=")), LCD_SERIAL.print(y), nextion.SendtoTFT(F("\xFF\xFF\xFF"))) +#define SEND_TXT(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), nextion.SendtoTFT(F(y)), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) +#define SEND_TXT_P(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), nextion.SendtoTFT(y), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) +#define SEND_VALasTXT(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), LCD_SERIAL.print(y), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) +#define SEND_TXT_END(x) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F("\xFF\xFF\xFF"))) +#define SEND_PCO2(x,y,z) (nextion.SendtoTFT(F(x)), LCD_SERIAL.print(y), nextion.SendtoTFT(F(".pco=")), nextion.SendtoTFT(F(z)), nextion.SendtoTFT(F("\xFF\xFF\xFF"))) diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index d37b277110..afd762a470 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -1077,15 +1077,15 @@ namespace ExtUI { void resumePrint() { ui.resume_print(); } void stopPrint() { ui.abort_print(); } - void onUserConfirmRequired_P(PGM_P const pstr) { - char msg[strlen_P(pstr) + 1]; - strcpy_P(msg, pstr); + void onUserConfirmRequired(FSTR_P const fstr) { + char msg[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(msg, FTOP(fstr)); onUserConfirmRequired(msg); } - void onStatusChanged_P(PGM_P const pstr) { - char msg[strlen_P(pstr) + 1]; - strcpy_P(msg, pstr); + void onStatusChanged(FSTR_P const fstr) { + char msg[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(msg, FTOP(fstr)); onStatusChanged(msg); } diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 9e1ae3a9c0..4866c5b9d7 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -79,6 +79,7 @@ namespace ExtUI { bool canMove(const axis_t); bool canMove(const extruder_t); void injectCommands_P(PGM_P const); + inline void injectCommands(FSTR_P const fstr) { injectCommands_P(FTOP(fstr)); } void injectCommands(char * const); bool commandsInQueue(); @@ -400,9 +401,9 @@ namespace ExtUI { void onPrintFinished(); void onFilamentRunout(const extruder_t extruder); void onUserConfirmRequired(const char * const msg); - void onUserConfirmRequired_P(PGM_P const pstr); + void onUserConfirmRequired(FSTR_P const fstr); void onStatusChanged(const char * const msg); - void onStatusChanged_P(PGM_P const pstr); + void onStatusChanged(FSTR_P const fstr); void onHomingStart(); void onHomingComplete(); void onSteppersDisabled(); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 0401ae2794..5b77e53947 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1741,18 +1741,18 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; pause_mode = mode; ExtUI::pauseModeStatus = message; switch (message) { - case PAUSE_MESSAGE_PARKING: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_PAUSE_PRINT_PARKING)); break; - case PAUSE_MESSAGE_CHANGING: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_INIT)); break; - case PAUSE_MESSAGE_UNLOAD: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_UNLOAD)); break; - case PAUSE_MESSAGE_WAITING: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_ADVANCED_PAUSE_WAITING)); break; - case PAUSE_MESSAGE_INSERT: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_INSERT)); break; - case PAUSE_MESSAGE_LOAD: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_LOAD)); break; + case PAUSE_MESSAGE_PARKING: ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; + case PAUSE_MESSAGE_CHANGING: ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; + case PAUSE_MESSAGE_UNLOAD: ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; + case PAUSE_MESSAGE_WAITING: ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING)); break; + case PAUSE_MESSAGE_INSERT: ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT)); break; + case PAUSE_MESSAGE_LOAD: ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); break; case PAUSE_MESSAGE_PURGE: - ExtUI::onUserConfirmRequired_P(GET_TEXT(TERN(ADVANCED_PAUSE_CONTINUOUS_PURGE, MSG_FILAMENT_CHANGE_CONT_PURGE, MSG_FILAMENT_CHANGE_PURGE))); break; - case PAUSE_MESSAGE_RESUME: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_RESUME)); break; - case PAUSE_MESSAGE_HEAT: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_HEAT)); break; - case PAUSE_MESSAGE_HEATING: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_HEATING)); break; - case PAUSE_MESSAGE_OPTION: ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_OPTION_HEADER)); break; + ExtUI::onUserConfirmRequired(GET_TEXT_F(TERN(ADVANCED_PAUSE_CONTINUOUS_PURGE, MSG_FILAMENT_CHANGE_CONT_PURGE, MSG_FILAMENT_CHANGE_PURGE))); break; + case PAUSE_MESSAGE_RESUME: ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_RESUME)); break; + case PAUSE_MESSAGE_HEAT: ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT)); break; + case PAUSE_MESSAGE_HEATING: ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEATING)); break; + case PAUSE_MESSAGE_OPTION: ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_OPTION_HEADER)); break; case PAUSE_MESSAGE_STATUS: default: break; } diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index 0990ac504d..95103e9bf6 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -65,7 +65,7 @@ void _man_probe_pt(const xy_pos_t &xy) { _man_probe_pt(xy); ui.defer_status_screen(); TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("Delta Calibration in progress"), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Delta Calibration in progress"))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Delta Calibration in progress"))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); ui.goto_previous_screen_no_defer(); return current_position.z; diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 18e72f401c..f37d2aa03f 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -296,7 +296,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { SERIAL_ECHOLNF(ds_str); TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("Stow Probe"), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Stow Probe"))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Stow Probe"))); TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, PSTR("Stow Probe"), CONTINUE_STR)); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); ui.reset_status(); From 9cf1c3cf051f7fa946098e7a7873aa0a8797d62a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 25 Sep 2021 23:52:41 -0500 Subject: [PATCH 013/546] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20F()=20to=20UTF-8?= =?UTF-8?q?/MMU2=20string=20put?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/shared/progmem.h | 2 +- Marlin/src/feature/mmu/mmu2.cpp | 48 ++++++++++--------- Marlin/src/feature/mmu/mmu2.h | 8 ++-- Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp | 4 +- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 45 ++++++++--------- Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp | 4 +- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 42 ++++++++-------- Marlin/src/lcd/dogm/lcdprint_u8g.cpp | 4 +- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 10 ++-- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 14 +++--- .../lcd/dogm/status_screen_lite_ST7920.cpp | 12 ++--- .../src/lcd/dogm/status_screen_lite_ST7920.h | 2 +- .../src/lcd/e3v2/marlinui/lcdprint_dwin.cpp | 4 +- Marlin/src/lcd/e3v2/marlinui/ui_common.cpp | 4 +- Marlin/src/lcd/lcdprint.h | 23 ++++++--- Marlin/src/lcd/menu/game/game.cpp | 2 +- Marlin/src/lcd/menu/menu_bed_corners.cpp | 4 +- Marlin/src/lcd/menu/menu_mixer.cpp | 4 +- Marlin/src/lcd/menu/menu_tune.cpp | 4 +- Marlin/src/lcd/tft/ui_common.cpp | 4 +- 20 files changed, 129 insertions(+), 115 deletions(-) diff --git a/Marlin/src/HAL/shared/progmem.h b/Marlin/src/HAL/shared/progmem.h index a76b379bb8..4cd7663df9 100644 --- a/Marlin/src/HAL/shared/progmem.h +++ b/Marlin/src/HAL/shared/progmem.h @@ -111,7 +111,7 @@ class __FlashStringHelper; #define strrchr_P(str, c) strrchr((str), (c)) #endif #ifndef strsep_P -#define strsep_P(strp, delim) strsep((strp), (delim)) +#define strsep_P(pstr, delim) strsep((pstr), (delim)) #endif #ifndef strspn_P #define strspn_P(str, chrs) strspn((str), (chrs)) diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 363e4d5505..b2835dc3ce 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -54,7 +54,7 @@ MMU2 mmu2; #define MMU_CMD_TIMEOUT 45000UL // 45s timeout for mmu commands (except P0) #define MMU_P0_TIMEOUT 3000UL // Timeout for P0 command: 3seconds -#define MMU2_COMMAND(S) tx_str_P(PSTR(S "\n")) +#define MMU2_COMMAND(S) tx_str(F(S "\n")) #if ENABLED(MMU_EXTRUDER_SENSOR) uint8_t mmu_idl_sens = 0; @@ -229,17 +229,17 @@ void MMU2::mmu_loop() { if (cmd) { if (WITHIN(cmd, MMU_CMD_T0, MMU_CMD_T0 + EXTRUDERS - 1)) { // tool change - int filament = cmd - MMU_CMD_T0; + const int filament = cmd - MMU_CMD_T0; DEBUG_ECHOLNPGM("MMU <= T", filament); - tx_printf_P(PSTR("T%d\n"), filament); + tx_printf(F("T%d\n"), filament); TERN_(MMU_EXTRUDER_SENSOR, mmu_idl_sens = 1); // enable idler sensor, if any state = 3; // wait for response } else if (WITHIN(cmd, MMU_CMD_L0, MMU_CMD_L0 + EXTRUDERS - 1)) { // load - int filament = cmd - MMU_CMD_L0; + const int filament = cmd - MMU_CMD_L0; DEBUG_ECHOLNPGM("MMU <= L", filament); - tx_printf_P(PSTR("L%d\n"), filament); + tx_printf(F("L%d\n"), filament); state = 3; // wait for response } else if (cmd == MMU_CMD_C0) { @@ -257,9 +257,9 @@ void MMU2::mmu_loop() { } else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E0 + EXTRUDERS - 1)) { // eject filament - int filament = cmd - MMU_CMD_E0; + const int filament = cmd - MMU_CMD_E0; DEBUG_ECHOLNPGM("MMU <= E", filament); - tx_printf_P(PSTR("E%d\n"), filament); + tx_printf(F("E%d\n"), filament); state = 3; // wait for response } else if (cmd == MMU_CMD_R0) { @@ -270,9 +270,9 @@ void MMU2::mmu_loop() { } else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F0 + EXTRUDERS - 1)) { // filament type - int filament = cmd - MMU_CMD_F0; + const int filament = cmd - MMU_CMD_F0; DEBUG_ECHOLNPGM("MMU <= F", filament, " ", cmd_arg); - tx_printf_P(PSTR("F%d %d\n"), filament, cmd_arg); + tx_printf(F("F%d %d\n"), filament, cmd_arg); state = 3; // wait for response } @@ -356,13 +356,15 @@ void MMU2::mmu_loop() { */ bool MMU2::rx_start() { // check for start message - return rx_str_P(PSTR("start\n")); + return rx_str(F("start\n")); } /** * Check if the data received ends with the given string. */ -bool MMU2::rx_str_P(const char *str) { +bool MMU2::rx_str(FSTR_P fstr) { + PGM_P pstr = FTOP(fstr); + uint8_t i = strlen(rx_buffer); while (MMU2_SERIAL.available()) { @@ -375,14 +377,14 @@ bool MMU2::rx_str_P(const char *str) { } rx_buffer[i] = '\0'; - uint8_t len = strlen_P(str); + uint8_t len = strlen_P(pstr); if (i < len) return false; - str += len; + pstr += len; while (len--) { - char c0 = pgm_read_byte(str--), c1 = rx_buffer[i--]; + char c0 = pgm_read_byte(pstr--), c1 = rx_buffer[i--]; if (c0 == c1) continue; if (c0 == '\r' && c1 == '\n') continue; // match cr as lf if (c0 == '\n' && c1 == '\r') continue; // match lf as cr @@ -394,19 +396,19 @@ bool MMU2::rx_str_P(const char *str) { /** * Transfer data to MMU, no argument */ -void MMU2::tx_str_P(const char *str) { +void MMU2::tx_str(FSTR_P fstr) { clear_rx_buffer(); - uint8_t len = strlen_P(str); - LOOP_L_N(i, len) MMU2_SERIAL.write(pgm_read_byte(str++)); + PGM_P pstr = FTOP(fstr); + while (const char c = pgm_read_byte(pstr)) { MMU2_SERIAL.write(c); pstr++; } prev_request = millis(); } /** * Transfer data to MMU, single argument */ -void MMU2::tx_printf_P(const char *format, int argument = -1) { +void MMU2::tx_printf(FSTR_P format, int argument = -1) { clear_rx_buffer(); - uint8_t len = sprintf_P(tx_buffer, format, argument); + const uint8_t len = sprintf_P(tx_buffer, FTOP(format), argument); LOOP_L_N(i, len) MMU2_SERIAL.write(tx_buffer[i]); prev_request = millis(); } @@ -414,9 +416,9 @@ void MMU2::tx_printf_P(const char *format, int argument = -1) { /** * Transfer data to MMU, two arguments */ -void MMU2::tx_printf_P(const char *format, int argument1, int argument2) { +void MMU2::tx_printf(FSTR_P format, int argument1, int argument2) { clear_rx_buffer(); - uint8_t len = sprintf_P(tx_buffer, format, argument1, argument2); + const uint8_t len = sprintf_P(tx_buffer, FTOP(format), argument1, argument2); LOOP_L_N(i, len) MMU2_SERIAL.write(tx_buffer[i]); prev_request = millis(); } @@ -433,7 +435,7 @@ void MMU2::clear_rx_buffer() { * Check if we received 'ok' from MMU */ bool MMU2::rx_ok() { - if (rx_str_P(PSTR("ok\n"))) { + if (rx_str(F("ok\n"))) { prev_P0_request = millis(); return true; } @@ -853,7 +855,7 @@ void MMU2::filament_runout() { if (cmd == MMU_CMD_NONE && last_cmd == MMU_CMD_C0) { if (present && !mmu2s_triggered) { DEBUG_ECHOLNPGM("MMU <= 'A'"); - tx_str_P(PSTR("A\n")); + tx_str(F("A\n")); } // Slowly spin the extruder during C0 else { diff --git a/Marlin/src/feature/mmu/mmu2.h b/Marlin/src/feature/mmu/mmu2.h index 95338a5184..9574e2217f 100644 --- a/Marlin/src/feature/mmu/mmu2.h +++ b/Marlin/src/feature/mmu/mmu2.h @@ -57,10 +57,10 @@ public: static bool eject_filament(const uint8_t index, const bool recover); private: - static bool rx_str_P(const char *str); - static void tx_str_P(const char *str); - static void tx_printf_P(const char *format, const int argument); - static void tx_printf_P(const char *format, const int argument1, const int argument2); + static inline bool rx_str(FSTR_P fstr); + static inline void tx_str(FSTR_P fstr); + static inline void tx_printf(FSTR_P ffmt, const int argument); + static inline void tx_printf(FSTR_P ffmt, const int argument1, const int argument2); static void clear_rx_buffer(); static bool rx_ok(); diff --git a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp index 19e3814a6f..31b26aa5bb 100644 --- a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp +++ b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp @@ -1063,8 +1063,8 @@ 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(PGM_P utf8_str_P, pixel_len_t max_length) { - return lcd_put_u8str_max_cb(utf8_str_P, read_byte_rom, max_length); +int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { + return lcd_put_u8str_max_cb(utf8_pstr, read_byte_rom, max_length); } #if ENABLED(DEBUG_LCDPRINT) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index f4d765e2d3..b450c9c10f 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -409,15 +409,15 @@ void MarlinUI::clear_lcd() { lcd.clear(); } } // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line - void lcd_scroll(const lcd_uint_t col, const lcd_uint_t line, PGM_P const text, const uint8_t len, const int16_t time) { - uint8_t slen = utf8_strlen_P(text); + void lcd_scroll(const lcd_uint_t col, const lcd_uint_t line, FSTR_P const ftxt, const uint8_t len, const int16_t time) { + uint8_t slen = utf8_strlen_P(FTOP(ftxt)); if (slen < len) { - lcd_put_u8str_max_P(col, line, text, len); + lcd_put_u8str_max(col, line, ftxt, len); for (; slen < len; ++slen) lcd_put_wchar(' '); safe_delay(time); } else { - PGM_P p = text; + PGM_P p = FTOP(ftxt); int dly = time / _MAX(slen, 1); LOOP_LE_N(i, slen) { @@ -439,9 +439,9 @@ void MarlinUI::clear_lcd() { lcd.clear(); } static void logo_lines(PGM_P const extra) { int16_t indent = (LCD_WIDTH - 8 - utf8_strlen_P(extra)) / 2; - lcd_put_wchar(indent, 0, '\x00'); lcd_put_u8str_P(PSTR( "------" )); lcd_put_wchar('\x01'); - lcd_put_u8str_P(indent, 1, PSTR("|Marlin|")); lcd_put_u8str_P(extra); - lcd_put_wchar(indent, 2, '\x02'); lcd_put_u8str_P(PSTR( "------" )); lcd_put_wchar('\x03'); + lcd_put_wchar(indent, 0, '\x00'); lcd_put_u8str(F( "------" )); lcd_put_wchar('\x01'); + lcd_put_u8str(indent, 1, F("|Marlin|")); lcd_put_u8str_P(extra); + lcd_put_wchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_wchar('\x03'); } void MarlinUI::show_bootscreen() { @@ -450,15 +450,16 @@ void MarlinUI::clear_lcd() { lcd.clear(); } #define LCD_EXTRA_SPACE (LCD_WIDTH-8) - #define CENTER_OR_SCROLL(STRING,DELAY) \ + #define CENTER_OR_SCROLL(STRING,DELAY) { \ lcd_erase_line(3); \ - if (utf8_strlen(STRING) <= LCD_WIDTH) { \ - lcd_put_u8str_P((LCD_WIDTH - utf8_strlen_P(PSTR(STRING))) / 2, 3, PSTR(STRING)); \ + const int len = utf8_strlen(STRING); \ + if (len <= LCD_WIDTH) { \ + lcd_put_u8str((LCD_WIDTH - len) / 2, 3, F(STRING)); \ safe_delay(DELAY); \ } \ - else { \ - lcd_scroll(0, 3, PSTR(STRING), LCD_WIDTH, DELAY); \ - } + else \ + lcd_scroll(0, 3, F(STRING), LCD_WIDTH, DELAY); \ + } // // Show the Marlin logo with splash line 1 @@ -497,9 +498,9 @@ void MarlinUI::draw_kill_screen() { lcd_put_u8str(0, 0, status_message); lcd_uint_t y = 2; #if LCD_HEIGHT >= 4 - lcd_put_u8str_P(0, y++, GET_TEXT(MSG_HALTED)); + lcd_put_u8str(0, y++, GET_TEXT_F(MSG_HALTED)); #endif - lcd_put_u8str_P(0, y, GET_TEXT(MSG_PLEASE_RESET)); + lcd_put_u8str(0, y, GET_TEXT_F(MSG_PLEASE_RESET)); } // @@ -514,7 +515,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const else if (axis_should_home(axis)) while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?'); else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis)) - lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" ")); + lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" ")); else lcd_put_u8str(value); } @@ -613,11 +614,11 @@ FORCE_INLINE void _draw_bed_status(const bool blink) { FORCE_INLINE void _draw_print_progress() { const uint8_t progress = ui.get_progress_percent(); - lcd_put_u8str_P(PSTR(TERN(SDSUPPORT, "SD", "P:"))); + lcd_put_u8str(F(TERN(SDSUPPORT, "SD", "P:"))); if (progress) lcd_put_u8str(ui8tostr3rj(progress)); else - lcd_put_u8str_P(PSTR("---")); + lcd_put_u8str(F("---")); lcd_put_wchar('%'); } @@ -661,9 +662,9 @@ void MarlinUI::draw_status_message(const bool blink) { // Alternate Status message and Filament display if (ELAPSED(millis(), next_filament_display)) { - lcd_put_u8str_P(PSTR("Dia ")); + lcd_put_u8str(F("Dia ")); lcd_put_u8str(ftostr12ns(filwidth.measured_mm)); - lcd_put_u8str_P(PSTR(" V")); + lcd_put_u8str(F(" V")); lcd_put_u8str(i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled))); lcd_put_wchar('%'); return; @@ -1473,7 +1474,7 @@ void MarlinUI::draw_status_screen() { if (!isnan(ubl.z_values[x_plot][y_plot])) lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); else - lcd_put_u8str_P(PSTR(" -----")); + lcd_put_u8str(F(" -----")); #else // 16x4 or 20x4 display @@ -1492,7 +1493,7 @@ void MarlinUI::draw_status_screen() { if (!isnan(ubl.z_values[x_plot][y_plot])) lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); else - lcd_put_u8str_P(PSTR(" -----")); + lcd_put_u8str(F(" -----")); #endif // LCD_HEIGHT > 3 } diff --git a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp index dddab1f259..106ce76138 100644 --- a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp @@ -1061,8 +1061,8 @@ 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(PGM_P utf8_str_P, pixel_len_t max_length) { - return lcd_put_u8str_max_cb(utf8_str_P, read_byte_rom, max_length); +int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { + return lcd_put_u8str_max_cb(utf8_pstr, read_byte_rom, max_length); } #if ENABLED(DEBUG_LCDPRINT) diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 9617b3775d..420bd7cd66 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -399,9 +399,9 @@ static void center_text_P(PGM_P pstart, uint8_t y) { uint8_t indent = (LCD_WIDTH - 8) / 2; // symbols 217 (bottom right corner) and 218 (top left corner) are using for letters in some languages // and they should be moved to beginning ASCII table as special symbols - lcd.setCursor(indent, 0); lcd.write(TLC); lcd_put_u8str_P(PSTR("------")); lcd.write(TRC); - lcd.setCursor(indent, 1); lcd.write(LR); lcd_put_u8str_P(PSTR("Marlin")); lcd.write(LR); - lcd.setCursor(indent, 2); lcd.write(BLC); lcd_put_u8str_P(PSTR("------")); lcd.write(BRC); + lcd.setCursor(indent, 0); lcd.write(TLC); lcd_put_u8str(F("------")); lcd.write(TRC); + lcd.setCursor(indent, 1); lcd.write(LR); lcd_put_u8str(F("Marlin")); lcd.write(LR); + lcd.setCursor(indent, 2); lcd.write(BLC); lcd_put_u8str(F("------")); lcd.write(BRC); center_text_P(PSTR(SHORT_BUILD_VERSION), 3); center_text_P(PSTR(MARLIN_WEBSITE_URL), 4); picBits = ICON_LOGO; @@ -437,7 +437,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const else if (axis_should_home(axis)) while (const char c = *value++) lcd.write(c <= '.' ? c : '?'); else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis)) - lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" ")); + lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" ")); else lcd_put_u8str(value); } @@ -515,7 +515,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const FORCE_INLINE void _draw_cooler_status(const bool blink) { const celsius_t t2 = thermalManager.degTargetCooler(); - lcd.setCursor(0, 5); lcd_put_u8str_P(PSTR("COOL")); + lcd.setCursor(0, 5); lcd_put_u8str(F("COOL")); lcd.setCursor(1, 6); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler())); lcd.setCursor(1, 7); @@ -543,7 +543,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if ENABLED(LASER_COOLANT_FLOW_METER) FORCE_INLINE void _draw_flowmeter_status() { - lcd.setCursor(5, 5); lcd_put_u8str_P(PSTR("FLOW")); + lcd.setCursor(5, 5); lcd_put_u8str(F("FLOW")); lcd.setCursor(7, 6); lcd_put_wchar('L'); lcd.setCursor(6, 7); lcd_put_u8str(ftostr11ns(cooler.flowrate)); @@ -556,7 +556,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if ENABLED(I2C_AMMETER) FORCE_INLINE void _draw_ammeter_status() { - lcd.setCursor(10, 5); lcd_put_u8str_P(PSTR("ILAZ")); + lcd.setCursor(10, 5); lcd_put_u8str(F("ILAZ")); ammeter.read(); lcd.setCursor(11, 6); if (ammeter.current <= 0.999f) @@ -580,9 +580,9 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if HAS_CUTTER FORCE_INLINE void _draw_cutter_status() { - lcd.setCursor(15, 5); lcd_put_u8str_P(PSTR("CUTT")); + lcd.setCursor(15, 5); lcd_put_u8str(F("CUTT")); #if CUTTER_UNIT_IS(RPM) - lcd.setCursor(16, 6); lcd_put_u8str_P(PSTR("RPM")); + lcd.setCursor(16, 6); lcd_put_u8str(F("RPM")); lcd.setCursor(15, 7); lcd_put_u8str(ftostr31ns(float(cutter.unitPower) / 1000)); lcd_put_wchar('K'); #elif CUTTER_UNIT_IS(PERCENT) @@ -604,14 +604,14 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const if (!PanelDetected) return; const uint8_t progress = ui._get_progress(); #if ENABLED(SDSUPPORT) - lcd_put_u8str_P(PSTR("SD")); + lcd_put_u8str(F("SD")); #elif ENABLED(LCD_SET_PROGRESS_MANUALLY) - lcd_put_u8str_P(PSTR("P:")); + lcd_put_u8str(F("P:")); #endif if (progress) lcd.print(ui8tostr3rj(progress)); else - lcd_put_u8str_P(PSTR("---")); + lcd_put_u8str(F("---")); lcd.write('%'); } @@ -643,9 +643,9 @@ void MarlinUI::draw_status_message(const bool blink) { // Alternate Status message and Filament display if (ELAPSED(millis(), next_filament_display)) { - lcd_put_u8str_P(PSTR("Dia ")); + lcd_put_u8str(F("Dia ")); lcd.print(ftostr12ns(filament_width_meas)); - lcd_put_u8str_P(PSTR(" V")); + lcd_put_u8str(F(" V")); lcd.print(i16tostr3rj(100.0 * ( parser.volumetric_enabled ? planner.volumetric_area_nominal / planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] @@ -802,7 +802,7 @@ void MarlinUI::draw_status_screen() { // lcd.setCursor(0, 1); - lcd_put_u8str_P(PSTR("FR")); lcd.print(i16tostr3rj(feedrate_percentage)); lcd.write('%'); + lcd_put_u8str(F("FR")); lcd.print(i16tostr3rj(feedrate_percentage)); lcd.write('%'); #if BOTH(SDSUPPORT, HAS_PRINT_PROGRESS) lcd.setCursor(LCD_WIDTH / 2 - 3, 1); @@ -895,7 +895,7 @@ void MarlinUI::draw_status_screen() { #else #define FANX 17 #endif - lcd.setCursor(FANX, 5); lcd_put_u8str_P(PSTR("FAN")); + lcd.setCursor(FANX, 5); lcd_put_u8str(F("FAN")); lcd.setCursor(FANX + 1, 6); lcd.write('%'); lcd.setCursor(FANX, 7); lcd.print(i16tostr3rj(per)); @@ -931,7 +931,7 @@ void MarlinUI::draw_status_screen() { void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) { if (!PanelDetected) return; lcd.setCursor((LCD_WIDTH - 14) / 2, row + 1); - lcd.write(LCD_STR_THERMOMETER[0]); lcd_put_u8str_P(PSTR(" E")); lcd.write('1' + extruder); lcd.write(' '); + lcd.write(LCD_STR_THERMOMETER[0]); lcd_put_u8str(F(" E")); lcd.write('1' + extruder); lcd.write(' '); lcd.print(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); lcd.write(LCD_STR_DEGREE[0]); lcd.write('/'); lcd.print(i16tostr3rj(thermalManager.degTargetHotend(extruder))); lcd.write(LCD_STR_DEGREE[0]); lcd.print_line(); @@ -1064,18 +1064,18 @@ void MarlinUI::draw_status_screen() { *fb++ = ','; lcd.print(i16tostr3left(y_plot)); *fb = ')'; // Show all values - lcd.setCursor(_LCD_W_POS, 1); lcd_put_u8str_P(PSTR("X:")); + lcd.setCursor(_LCD_W_POS, 1); lcd_put_u8str(F("X:")); lcd.print(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot])))); - lcd.setCursor(_LCD_W_POS, 2); lcd_put_u8str_P(PSTR("Y:")); + lcd.setCursor(_LCD_W_POS, 2); lcd_put_u8str(F("Y:")); lcd.print(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot])))); // Show the location value - lcd.setCursor(_LCD_W_POS, 3); lcd_put_u8str_P(PSTR("Z:")); + lcd.setCursor(_LCD_W_POS, 3); lcd_put_u8str(F("Z:")); if (!isnan(ubl.z_values[x_plot][y_plot])) lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot])); else - lcd_put_u8str_P(PSTR(" -----")); + lcd_put_u8str(F(" -----")); center_text_P(GET_TEXT(MSG_UBL_FINE_TUNE_MESH), 8); diff --git a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp index a85dc9f979..f74a59a08c 100644 --- a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp +++ b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp @@ -46,9 +46,9 @@ int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) { return ret; } -int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) { +int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { u8g_uint_t x = u8g.getPrintCol(), y = u8g.getPrintRow(), - ret = uxg_DrawUtf8StrP(u8g.getU8g(), x, y, utf8_str_P, max_length); + ret = uxg_DrawUtf8StrP(u8g.getU8g(), x, y, utf8_pstr, max_length); u8g.setPrintPos(x + ret, y); return ret; } diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 4a7e26ae83..5d4c30bbb4 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -217,8 +217,8 @@ bool MarlinUI::detected() { return true; } auto _draw_bootscreen_bmp = [&](const uint8_t *bitmap) { u8g.drawBitmapP(offx, offy, START_BMP_BYTEWIDTH, START_BMPHEIGHT, bitmap); set_font(FONT_MENU); - if (!two_part || !line2) lcd_put_u8str_P(txt_offx_1, txt_base - (MENU_FONT_HEIGHT), PSTR(SHORT_BUILD_VERSION)); - if (!two_part || line2) lcd_put_u8str_P(txt_offx_2, txt_base, PSTR(MARLIN_WEBSITE_URL)); + if (!two_part || !line2) lcd_put_u8str(txt_offx_1, txt_base - (MENU_FONT_HEIGHT), F(SHORT_BUILD_VERSION)); + if (!two_part || line2) lcd_put_u8str(txt_offx_2, txt_base, F(MARLIN_WEBSITE_URL)); }; auto draw_bootscreen_bmp = [&](const uint8_t *bitmap) { @@ -331,8 +331,8 @@ void MarlinUI::draw_kill_screen() { do { set_font(FONT_MENU); lcd_put_u8str(0, h4 * 1, status_message); - lcd_put_u8str_P(0, h4 * 2, GET_TEXT(MSG_HALTED)); - lcd_put_u8str_P(0, h4 * 3, GET_TEXT(MSG_PLEASE_RESET)); + lcd_put_u8str(0, h4 * 2, GET_TEXT_F(MSG_HALTED)); + lcd_put_u8str(0, h4 * 3, GET_TEXT_F(MSG_PLEASE_RESET)); } while (u8g.nextPage()); } @@ -611,7 +611,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop if (!isnan(ubl.z_values[x_plot][y_plot])) lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); else - lcd_put_u8str_P(PSTR(" -----")); + lcd_put_u8str(F(" -----")); } } diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 8b707ba7c7..847c13d3ac 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -191,7 +191,7 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, const uint8_t ty) { if (temp < 0) - lcd_put_u8str(tx - 3 * (INFO_FONT_WIDTH) / 2 + 1, ty, "err"); + lcd_put_u8str(tx - 3 * (INFO_FONT_WIDTH) / 2 + 1, ty, F("err")); else { const char *str = i16tostr3rj(temp); const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1; @@ -436,7 +436,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const else if (axis_should_home(axis)) while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?'); else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis)) - lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" ")); + lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" ")); else lcd_put_u8str(value); } @@ -777,7 +777,7 @@ void MarlinUI::draw_status_screen() { } } else if (progress_state == 2 && estimation_string[0]) { - lcd_put_u8str_P(PROGRESS_BAR_X, EXTRAS_BASELINE, PSTR("R:")); + lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("R:")); lcd_put_u8str(estimation_x_pos, EXTRAS_BASELINE, estimation_string); } else if (elapsed_string[0]) { @@ -879,7 +879,7 @@ void MarlinUI::draw_status_screen() { if (show_e_total) { #if ENABLED(LCD_SHOW_E_TOTAL) _draw_axis_value(E_AXIS, xstring, true); - lcd_put_u8str_P(PSTR(" ")); + lcd_put_u8str(F(" ")); #endif } else { @@ -918,7 +918,7 @@ void MarlinUI::draw_status_screen() { lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring); lcd_put_wchar('%'); set_font(FONT_MENU); - lcd_put_wchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA)); + lcd_put_wchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str(F(LCD_STR_FILAM_DIA)); lcd_put_wchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]); #endif } @@ -932,10 +932,10 @@ void MarlinUI::draw_status_screen() { #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) // Alternate Status message and Filament display if (ELAPSED(millis(), next_filament_display)) { - lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA)); + lcd_put_u8str(F(LCD_STR_FILAM_DIA)); lcd_put_wchar(':'); lcd_put_u8str(wstring); - lcd_put_u8str_P(PSTR(" " LCD_STR_FILAM_MUL)); + lcd_put_u8str(F(" " LCD_STR_FILAM_MUL)); lcd_put_wchar(':'); lcd_put_u8str(mstring); lcd_put_wchar('%'); diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index be112c8d54..2e6d697488 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -99,9 +99,9 @@ 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(PGM_P const str) { - PGM_P p_str = (PGM_P)str; - while (char c = pgm_read_byte(p_str++)) write_byte(c); +void ST7920_Lite_Status_Screen::write_str(FSTR_P const fstr) { + PGM_P pstr = FTOP(fstr); + while (char c = pgm_read_byte(pstr++)) write_byte(c); } void ST7920_Lite_Status_Screen::write_number(const int16_t value, const uint8_t digits/*=3*/) { @@ -500,11 +500,11 @@ void ST7920_Lite_Status_Screen::draw_progress_bar(const uint8_t value) { // Draw centered if (value > 9) { write_number(value, 4); - write_str_P(PSTR("% ")); + write_str(F("% ")); } else { write_number(value, 3); - write_str_P(PSTR("% ")); + write_str(F("% ")); } } @@ -559,7 +559,7 @@ void ST7920_Lite_Status_Screen::draw_temps(uint8_t line, const int16_t temp, con }; if (targetStateChange) { - if (!showTarget) write_str_P(PSTR(" ")); + if (!showTarget) write_str(F(" ")); draw_degree_symbol(5, line, !showTarget); draw_degree_symbol(9, line, showTarget); } diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h index b217246484..7fe878356b 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h @@ -46,7 +46,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(PGM_P const str); + static void write_str(FSTR_P const fstr); static void write_number(const int16_t value, const uint8_t digits=3); static void _extended_function_set(const bool extended, const bool graphics); diff --git a/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp b/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp index 8892f1a004..44be749d41 100644 --- a/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp @@ -101,8 +101,8 @@ 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(PGM_P utf8_str_P, pixel_len_t max_length) { - return lcd_put_u8str_max_cb(utf8_str_P, read_byte_rom, max_length); +int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { + return lcd_put_u8str_max_cb(utf8_pstr, read_byte_rom, max_length); } lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const inStr/*=nullptr*/, const lcd_uint_t maxlen/*=LCD_WIDTH*/) { diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp index ca8e6c177f..126700185b 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp @@ -160,11 +160,11 @@ void MarlinUI::draw_kill_screen() { slen = utf8_strlen(S(GET_TEXT_F(MSG_HALTED))); lcd_moveto(cx - (slen / 2), cy); - lcd_put_u8str_P((const char*)GET_TEXT_F(MSG_HALTED)); + lcd_put_u8str(GET_TEXT_F(MSG_HALTED)); slen = utf8_strlen(S(GET_TEXT_F(MSG_HALTED))); lcd_moveto(cx - (slen / 2), cy + 1); - lcd_put_u8str_P((const char*)GET_TEXT_F(MSG_HALTED)); + lcd_put_u8str(GET_TEXT_F(MSG_HALTED)); } // diff --git a/Marlin/src/lcd/lcdprint.h b/Marlin/src/lcd/lcdprint.h index f6ac818ae5..c701a59568 100644 --- a/Marlin/src/lcd/lcdprint.h +++ b/Marlin/src/lcd/lcdprint.h @@ -152,17 +152,20 @@ void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row); /** * @brief Draw a ROM UTF-8 string * - * @param utf8_str_P : the ROM UTF-8 string + * @param utf8_pstr : the ROM UTF-8 string * @param max_length : the pixel length of the string allowed (or number of slots in HD44780) * * @return the pixel width * * Draw a ROM UTF-8 string */ -int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length); -inline int lcd_put_u8str_max_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P utf8_str_P, pixel_len_t max_length) { +int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length); +inline int lcd_put_u8str_max_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P utf8_pstr, pixel_len_t max_length) { lcd_moveto(col, row); - return lcd_put_u8str_max_P(utf8_str_P, max_length); + return lcd_put_u8str_max_P(utf8_pstr, max_length); +} +inline int lcd_put_u8str_max(const lcd_uint_t col, const lcd_uint_t row, FSTR_P const utf8_fstr, pixel_len_t max_length) { + return lcd_put_u8str_max_P(col, row, FTOP(utf8_fstr), max_length); } void lcd_put_int(const int i); @@ -177,14 +180,22 @@ inline int lcd_put_u8str_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P con return lcd_put_u8str_P(pstr); } +inline int lcd_put_u8str(FSTR_P const fstr) { return lcd_put_u8str_P(FTOP(fstr)); } +inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, FSTR_P const fstr) { + return lcd_put_u8str_P(col, row, FTOP(fstr)); +} + lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const inStr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH); inline lcd_uint_t lcd_put_u8str_ind_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P const pstr, const int8_t ind, PGM_P const inStr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH) { lcd_moveto(col, row); return lcd_put_u8str_ind_P(pstr, ind, inStr, maxlen); } +inline lcd_uint_t lcd_put_u8str_ind(const lcd_uint_t col, const lcd_uint_t row, FSTR_P const fstr, const int8_t ind, FSTR_P const inFstr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH) { + return lcd_put_u8str_ind_P(col, row, FTOP(fstr), ind, FTOP(inFstr), maxlen); +} -inline int lcd_put_u8str(const char *str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); } -inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, PGM_P const str) { +inline int lcd_put_u8str(const char * const str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); } +inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, const char * const str) { lcd_moveto(col, row); return lcd_put_u8str(str); } diff --git a/Marlin/src/lcd/menu/game/game.cpp b/Marlin/src/lcd/menu/game/game.cpp index c14bd2a68d..d465b00388 100644 --- a/Marlin/src/lcd/menu/game/game.cpp +++ b/Marlin/src/lcd/menu/game/game.cpp @@ -48,7 +48,7 @@ void MarlinGame::draw_game_over() { u8g.setColorIndex(0); u8g.drawBox(lx - 1, ly - gohigh - 1, gowide + 2, gohigh + 2); u8g.setColorIndex(1); - if (ui.get_blink()) lcd_put_u8str_P(lx, ly, PSTR("GAME OVER")); + if (ui.get_blink()) lcd_put_u8str(lx, ly, F("GAME OVER")); } } diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 1c7ab35e44..178d466478 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -179,7 +179,7 @@ static void _lcd_level_bed_corners_get_next_position() { // Display # of good points found vs total needed if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) { SETCURSOR(TERN(TFT_COLOR_UI, 2, 0), cy); - lcd_put_u8str_P(GET_TEXT(MSG_BED_TRAMMING_GOOD_POINTS)); + lcd_put_u8str_(GET_TEXT_F(MSG_BED_TRAMMING_GOOD_POINTS)); IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, cy)); lcd_put_u8str(GOOD_POINTS_TO_STR(good_points)); lcd_put_wchar('/'); @@ -192,7 +192,7 @@ static void _lcd_level_bed_corners_get_next_position() { // Display the Last Z value if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) { SETCURSOR(TERN(TFT_COLOR_UI, 2, 0), cy); - lcd_put_u8str_P(GET_TEXT(MSG_BED_TRAMMING_LAST_Z)); + lcd_put_u8str(GET_TEXT_F(MSG_BED_TRAMMING_LAST_Z)); IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, 2)); lcd_put_u8str(LAST_Z_TO_STR(last_z)); } diff --git a/Marlin/src/lcd/menu/menu_mixer.cpp b/Marlin/src/lcd/menu/menu_mixer.cpp index 694fd54813..be4363574b 100644 --- a/Marlin/src/lcd/menu/menu_mixer.cpp +++ b/Marlin/src/lcd/menu/menu_mixer.cpp @@ -57,7 +57,7 @@ if (ui.should_draw()) { char tmp[16]; SETCURSOR(1, (LCD_HEIGHT - 1) / 2); - lcd_put_u8str_P(isend ? GET_TEXT(MSG_END_Z) : GET_TEXT(MSG_START_Z)); + lcd_put_u8str(isend ? GET_TEXT_F(MSG_END_Z) : GET_TEXT_F(MSG_START_Z)); sprintf_P(tmp, PSTR("%4d.%d mm"), int(zvar), int(zvar * 10) % 10); SETCURSOR_RJ(9, (LCD_HEIGHT - 1) / 2); lcd_put_u8str(tmp); @@ -114,7 +114,7 @@ static uint8_t v_index; void _lcd_draw_mix(const uint8_t y) { char tmp[20]; // "100%_100%" sprintf_P(tmp, PSTR("%3d%% %3d%%"), int(mixer.mix[0]), int(mixer.mix[1])); - SETCURSOR(2, y); lcd_put_u8str_P(GET_TEXT(MSG_MIX)); + SETCURSOR(2, y); lcd_put_u8str(GET_TEXT_F(MSG_MIX)); SETCURSOR_RJ(10, y); lcd_put_u8str(tmp); } #endif diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index 37ffb679e9..b3f078d7a0 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -73,12 +73,12 @@ TERN_(HAS_MARLINUI_U8GLIB, ui.set_font(FONT_MENU)); #if ENABLED(TFT_COLOR_UI) lcd_moveto(4, 3); - lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL)); + lcd_put_u8str(GET_TEXT_F(MSG_BABYSTEP_TOTAL)); lcd_put_wchar(':'); lcd_moveto(10, 3); #else lcd_moveto(0, TERN(HAS_MARLINUI_U8GLIB, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT, LCD_HEIGHT - 1)); - lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL)); + lcd_put_u8str(GET_TEXT_F(MSG_BABYSTEP_TOTAL)); lcd_put_wchar(':'); #endif lcd_put_u8str(BABYSTEP_TO_STR(mps * babystep.axis_total[BS_TOTAL_IND(axis)])); diff --git a/Marlin/src/lcd/tft/ui_common.cpp b/Marlin/src/lcd/tft/ui_common.cpp index 41862b5ad8..e152ceab50 100644 --- a/Marlin/src/lcd/tft/ui_common.cpp +++ b/Marlin/src/lcd/tft/ui_common.cpp @@ -105,9 +105,9 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) { return tft_string.width(); } -int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) { +int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { if (max_length < 1) return 0; - tft_string.set(utf8_str_P); + tft_string.set(utf8_pstr); tft_string.trim(); tft_string.truncate(max_length); tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); From cabd538fdd03bec0b293cb290bbc3dc123da780a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Sep 2021 13:40:01 -0500 Subject: [PATCH 014/546] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20F()=20to=20G-cod?= =?UTF-8?q?e=20report=20header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/bedlevel/M420.cpp | 2 +- Marlin/src/gcode/calibrate/G34_M422.cpp | 2 +- Marlin/src/gcode/calibrate/M425.cpp | 2 +- Marlin/src/gcode/calibrate/M665.cpp | 6 +++--- Marlin/src/gcode/calibrate/M666.cpp | 4 ++-- Marlin/src/gcode/calibrate/M852.cpp | 2 +- Marlin/src/gcode/config/M200-M205.cpp | 10 +++++----- Marlin/src/gcode/config/M217.cpp | 2 +- Marlin/src/gcode/config/M218.cpp | 2 +- Marlin/src/gcode/config/M281.cpp | 2 +- Marlin/src/gcode/config/M301.cpp | 2 +- Marlin/src/gcode/config/M304.cpp | 2 +- Marlin/src/gcode/config/M309.cpp | 2 +- Marlin/src/gcode/config/M92.cpp | 2 +- Marlin/src/gcode/control/M211.cpp | 2 +- Marlin/src/gcode/feature/advance/M900.cpp | 2 +- Marlin/src/gcode/feature/controllerfan/M710.cpp | 2 +- Marlin/src/gcode/feature/digipot/M907-M910.cpp | 2 +- Marlin/src/gcode/feature/fwretract/M207-M209.cpp | 6 +++--- Marlin/src/gcode/feature/pause/M603.cpp | 2 +- Marlin/src/gcode/feature/powerloss/M413.cpp | 2 +- Marlin/src/gcode/feature/runout/M412.cpp | 2 +- Marlin/src/gcode/feature/trinamic/M569.cpp | 2 +- Marlin/src/gcode/feature/trinamic/M906.cpp | 2 +- Marlin/src/gcode/feature/trinamic/M911-M914.cpp | 4 ++-- Marlin/src/gcode/gcode.cpp | 6 +++--- Marlin/src/gcode/gcode.h | 6 +++--- Marlin/src/gcode/geometry/M206_M428.cpp | 2 +- Marlin/src/gcode/lcd/M145.cpp | 2 +- Marlin/src/gcode/lcd/M250.cpp | 2 +- Marlin/src/gcode/lcd/M256.cpp | 2 +- Marlin/src/gcode/lcd/M414.cpp | 2 +- Marlin/src/gcode/probe/M851.cpp | 2 +- Marlin/src/gcode/units/M149.cpp | 2 +- Marlin/src/module/settings.cpp | 2 +- Marlin/src/module/temperature.cpp | 2 +- 36 files changed, 50 insertions(+), 50 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/M420.cpp b/Marlin/src/gcode/bedlevel/M420.cpp index 1240b14fd2..5dcef961ee 100644 --- a/Marlin/src/gcode/bedlevel/M420.cpp +++ b/Marlin/src/gcode/bedlevel/M420.cpp @@ -243,7 +243,7 @@ void GcodeSuite::M420() { } void GcodeSuite::M420_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR( + report_heading_etc(forReplay, F( TERN(MESH_BED_LEVELING, "Mesh Bed Leveling", TERN(AUTO_BED_LEVELING_UBL, "Unified Bed Leveling", "Auto Bed Leveling")) )); SERIAL_ECHOF( diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 25855e6a4e..8f4eab2c97 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -538,7 +538,7 @@ void GcodeSuite::M422() { } void GcodeSuite::M422_report(const bool forReplay/*=true*/) { - report_heading(forReplay, PSTR(STR_Z_AUTO_ALIGN)); + report_heading(forReplay, F(STR_Z_AUTO_ALIGN)); LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) { report_echo_start(forReplay); SERIAL_ECHOLNPGM_P( diff --git a/Marlin/src/gcode/calibrate/M425.cpp b/Marlin/src/gcode/calibrate/M425.cpp index 1d314a37d3..190af0f71b 100644 --- a/Marlin/src/gcode/calibrate/M425.cpp +++ b/Marlin/src/gcode/calibrate/M425.cpp @@ -114,7 +114,7 @@ void GcodeSuite::M425() { } void GcodeSuite::M425_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_BACKLASH_COMPENSATION)); + report_heading_etc(forReplay, F(STR_BACKLASH_COMPENSATION)); SERIAL_ECHOLNPGM_P( PSTR(" M425 F"), backlash.get_correction() #ifdef BACKLASH_SMOOTHING_MM diff --git a/Marlin/src/gcode/calibrate/M665.cpp b/Marlin/src/gcode/calibrate/M665.cpp index 11de1ce434..aa21471b60 100644 --- a/Marlin/src/gcode/calibrate/M665.cpp +++ b/Marlin/src/gcode/calibrate/M665.cpp @@ -62,7 +62,7 @@ } void GcodeSuite::M665_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_DELTA_SETTINGS)); + report_heading_etc(forReplay, F(STR_DELTA_SETTINGS)); SERIAL_ECHOLNPGM_P( PSTR(" M665 L"), LINEAR_UNIT(delta_diagonal_rod) , PSTR(" R"), LINEAR_UNIT(delta_radius) @@ -132,7 +132,7 @@ } void GcodeSuite::M665_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_SCARA_SETTINGS " (" STR_S_SEG_PER_SEC TERN_(HAS_SCARA_OFFSET, " " STR_SCARA_P_T_Z) ")")); + report_heading_etc(forReplay, F(STR_SCARA_SETTINGS " (" STR_S_SEG_PER_SEC TERN_(HAS_SCARA_OFFSET, " " STR_SCARA_P_T_Z) ")")); SERIAL_ECHOLNPGM_P( PSTR(" M665 S"), segments_per_second #if HAS_SCARA_OFFSET @@ -162,7 +162,7 @@ } void GcodeSuite::M665_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_POLARGRAPH_SETTINGS " (" STR_S_SEG_PER_SEC ")")); + report_heading_etc(forReplay, F(STR_POLARGRAPH_SETTINGS " (" STR_S_SEG_PER_SEC ")")); SERIAL_ECHOLNPGM(" M665 S", segments_per_second); } diff --git a/Marlin/src/gcode/calibrate/M666.cpp b/Marlin/src/gcode/calibrate/M666.cpp index c4149c2352..15f8baf109 100644 --- a/Marlin/src/gcode/calibrate/M666.cpp +++ b/Marlin/src/gcode/calibrate/M666.cpp @@ -61,7 +61,7 @@ } void GcodeSuite::M666_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_ENDSTOP_ADJUSTMENT)); + report_heading_etc(forReplay, F(STR_ENDSTOP_ADJUSTMENT)); SERIAL_ECHOLNPGM_P( PSTR(" M666 X"), LINEAR_UNIT(delta_endstop_adj.a) , SP_Y_STR, LINEAR_UNIT(delta_endstop_adj.b) @@ -105,7 +105,7 @@ } void GcodeSuite::M666_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_ENDSTOP_ADJUSTMENT)); + report_heading_etc(forReplay, F(STR_ENDSTOP_ADJUSTMENT)); SERIAL_ECHOPGM(" M666"); #if ENABLED(X_DUAL_ENDSTOPS) SERIAL_ECHOLNPGM_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj)); diff --git a/Marlin/src/gcode/calibrate/M852.cpp b/Marlin/src/gcode/calibrate/M852.cpp index c4361b89f3..b24a449652 100644 --- a/Marlin/src/gcode/calibrate/M852.cpp +++ b/Marlin/src/gcode/calibrate/M852.cpp @@ -92,7 +92,7 @@ void GcodeSuite::M852() { } void GcodeSuite::M852_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_SKEW_FACTOR)); + report_heading_etc(forReplay, F(STR_SKEW_FACTOR)); SERIAL_ECHOPAIR_F(" M851 I", planner.skew_factor.xy, 6); #if ENABLED(SKEW_CORRECTION_FOR_Z) SERIAL_ECHOPAIR_F(" J", planner.skew_factor.xz, 6); diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp index 2880bd9943..7b7ce5e10d 100644 --- a/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin/src/gcode/config/M200-M205.cpp @@ -76,7 +76,7 @@ void GcodeSuite::M200_report(const bool forReplay/*=true*/) { if (!forReplay) { - report_heading(forReplay, PSTR(STR_FILAMENT_SETTINGS), false); + report_heading(forReplay, F(STR_FILAMENT_SETTINGS), false); if (!parser.volumetric_enabled) SERIAL_ECHOPGM(" (Disabled):"); SERIAL_EOL(); report_echo_start(forReplay); @@ -133,7 +133,7 @@ void GcodeSuite::M201() { } void GcodeSuite::M201_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_MAX_ACCELERATION)); + report_heading_etc(forReplay, F(STR_MAX_ACCELERATION)); SERIAL_ECHOLNPGM_P( LIST_N(DOUBLE(LINEAR_AXES), PSTR(" M201 X"), LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[X_AXIS]), @@ -178,7 +178,7 @@ void GcodeSuite::M203() { } void GcodeSuite::M203_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_MAX_FEEDRATES)); + report_heading_etc(forReplay, F(STR_MAX_FEEDRATES)); SERIAL_ECHOLNPGM_P( LIST_N(DOUBLE(LINEAR_AXES), PSTR(" M203 X"), LINEAR_UNIT(planner.settings.max_feedrate_mm_s[X_AXIS]), @@ -224,7 +224,7 @@ void GcodeSuite::M204() { } void GcodeSuite::M204_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_ACCELERATION_P_R_T)); + report_heading_etc(forReplay, F(STR_ACCELERATION_P_R_T)); SERIAL_ECHOLNPGM_P( PSTR(" M204 P"), LINEAR_UNIT(planner.settings.acceleration) , PSTR(" R"), LINEAR_UNIT(planner.settings.retract_acceleration) @@ -285,7 +285,7 @@ void GcodeSuite::M205() { } void GcodeSuite::M205_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR( + report_heading_etc(forReplay, F( "Advanced (B S T" TERN_(HAS_JUNCTION_DEVIATION, " J") TERN_(HAS_CLASSIC_JERK, " X Y Z") diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 1299259b53..7576272a48 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -131,7 +131,7 @@ void GcodeSuite::M217() { } void GcodeSuite::M217_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_TOOL_CHANGING)); + report_heading_etc(forReplay, F(STR_TOOL_CHANGING)); SERIAL_ECHOPGM(" M217"); diff --git a/Marlin/src/gcode/config/M218.cpp b/Marlin/src/gcode/config/M218.cpp index c95cd6c1b9..c39447a28d 100644 --- a/Marlin/src/gcode/config/M218.cpp +++ b/Marlin/src/gcode/config/M218.cpp @@ -57,7 +57,7 @@ void GcodeSuite::M218() { } void GcodeSuite::M218_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_HOTEND_OFFSETS)); + report_heading_etc(forReplay, F(STR_HOTEND_OFFSETS)); LOOP_S_L_N(e, 1, HOTENDS) { report_echo_start(forReplay); SERIAL_ECHOPGM_P( diff --git a/Marlin/src/gcode/config/M281.cpp b/Marlin/src/gcode/config/M281.cpp index ac91f08cb4..b90de6be30 100644 --- a/Marlin/src/gcode/config/M281.cpp +++ b/Marlin/src/gcode/config/M281.cpp @@ -55,7 +55,7 @@ void GcodeSuite::M281() { } void GcodeSuite::M281_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_SERVO_ANGLES)); + report_heading_etc(forReplay, F(STR_SERVO_ANGLES)); LOOP_L_N(i, NUM_SERVOS) { switch (i) { default: break; diff --git a/Marlin/src/gcode/config/M301.cpp b/Marlin/src/gcode/config/M301.cpp index db882b3b65..fc9f1883d6 100644 --- a/Marlin/src/gcode/config/M301.cpp +++ b/Marlin/src/gcode/config/M301.cpp @@ -79,7 +79,7 @@ void GcodeSuite::M301() { } void GcodeSuite::M301_report(const bool forReplay/*=true*/ E_OPTARG(const int8_t eindex/*=-1*/)) { - report_heading(forReplay, PSTR(STR_HOTEND_PID)); + report_heading(forReplay, F(STR_HOTEND_PID)); IF_DISABLED(HAS_MULTI_EXTRUDER, constexpr int8_t eindex = -1); HOTEND_LOOP() { if (e == eindex || eindex == -1) { diff --git a/Marlin/src/gcode/config/M304.cpp b/Marlin/src/gcode/config/M304.cpp index 05ee4bad80..4bd415db1e 100644 --- a/Marlin/src/gcode/config/M304.cpp +++ b/Marlin/src/gcode/config/M304.cpp @@ -42,7 +42,7 @@ void GcodeSuite::M304() { } void GcodeSuite::M304_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_BED_PID)); + report_heading_etc(forReplay, F(STR_BED_PID)); SERIAL_ECHO_MSG( " M304 P", thermalManager.temp_bed.pid.Kp , " I", unscalePID_i(thermalManager.temp_bed.pid.Ki) diff --git a/Marlin/src/gcode/config/M309.cpp b/Marlin/src/gcode/config/M309.cpp index 01c4e62347..577023292e 100644 --- a/Marlin/src/gcode/config/M309.cpp +++ b/Marlin/src/gcode/config/M309.cpp @@ -42,7 +42,7 @@ void GcodeSuite::M309() { } void GcodeSuite::M309_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_CHAMBER_PID)); + report_heading_etc(forReplay, F(STR_CHAMBER_PID)); SERIAL_ECHOLNPGM( " M309 P", thermalManager.temp_chamber.pid.Kp , " I", unscalePID_i(thermalManager.temp_chamber.pid.Ki) diff --git a/Marlin/src/gcode/config/M92.cpp b/Marlin/src/gcode/config/M92.cpp index ef11533114..54fe698f97 100644 --- a/Marlin/src/gcode/config/M92.cpp +++ b/Marlin/src/gcode/config/M92.cpp @@ -91,7 +91,7 @@ void GcodeSuite::M92() { } void GcodeSuite::M92_report(const bool forReplay/*=true*/, const int8_t e/*=-1*/) { - report_heading_etc(forReplay, PSTR(STR_STEPS_PER_UNIT)); + report_heading_etc(forReplay, F(STR_STEPS_PER_UNIT)); SERIAL_ECHOPGM_P(LIST_N(DOUBLE(LINEAR_AXES), PSTR(" M92 X"), LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]), SP_Y_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]), diff --git a/Marlin/src/gcode/control/M211.cpp b/Marlin/src/gcode/control/M211.cpp index d108070279..95ae052a7b 100644 --- a/Marlin/src/gcode/control/M211.cpp +++ b/Marlin/src/gcode/control/M211.cpp @@ -40,7 +40,7 @@ void GcodeSuite::M211() { } void GcodeSuite::M211_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_SOFT_ENDSTOPS)); + report_heading_etc(forReplay, F(STR_SOFT_ENDSTOPS)); SERIAL_ECHOPGM(" M211 S", AS_DIGIT(soft_endstop._enabled), " ; "); serialprintln_onoff(soft_endstop._enabled); diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index 4ed601bbe8..054ea3617f 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -145,7 +145,7 @@ void GcodeSuite::M900() { } void GcodeSuite::M900_report(const bool forReplay/*=true*/) { - report_heading(forReplay, PSTR(STR_LINEAR_ADVANCE)); + report_heading(forReplay, F(STR_LINEAR_ADVANCE)); #if EXTRUDERS < 2 report_echo_start(forReplay); SERIAL_ECHOLNPGM(" M900 K", planner.extruder_advance_K[0]); diff --git a/Marlin/src/gcode/feature/controllerfan/M710.cpp b/Marlin/src/gcode/feature/controllerfan/M710.cpp index eede16b5bd..b98d88845d 100644 --- a/Marlin/src/gcode/feature/controllerfan/M710.cpp +++ b/Marlin/src/gcode/feature/controllerfan/M710.cpp @@ -67,7 +67,7 @@ void GcodeSuite::M710() { } void GcodeSuite::M710_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_CONTROLLER_FAN)); + report_heading_etc(forReplay, F(STR_CONTROLLER_FAN)); SERIAL_ECHOLNPGM(" M710" " S", int(controllerFan.settings.active_speed), " I", int(controllerFan.settings.idle_speed), diff --git a/Marlin/src/gcode/feature/digipot/M907-M910.cpp b/Marlin/src/gcode/feature/digipot/M907-M910.cpp index a0b5c48e82..757cffd473 100644 --- a/Marlin/src/gcode/feature/digipot/M907-M910.cpp +++ b/Marlin/src/gcode/feature/digipot/M907-M910.cpp @@ -100,7 +100,7 @@ void GcodeSuite::M907() { #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM void GcodeSuite::M907_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_STEPPER_MOTOR_CURRENTS)); + report_heading_etc(forReplay, F(STR_STEPPER_MOTOR_CURRENTS)); #if HAS_MOTOR_CURRENT_PWM SERIAL_ECHOLNPGM_P( // PWM-based has 3 values: PSTR(" M907 X"), stepper.motor_current_setting[0] // X and Y diff --git a/Marlin/src/gcode/feature/fwretract/M207-M209.cpp b/Marlin/src/gcode/feature/fwretract/M207-M209.cpp index 040a09a8e0..173c2894dc 100644 --- a/Marlin/src/gcode/feature/fwretract/M207-M209.cpp +++ b/Marlin/src/gcode/feature/fwretract/M207-M209.cpp @@ -38,7 +38,7 @@ void GcodeSuite::M207() { fwretract.M207(); } void GcodeSuite::M207_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_RETRACT_S_F_Z)); + report_heading_etc(forReplay, F(STR_RETRACT_S_F_Z)); fwretract.M207_report(); } @@ -53,7 +53,7 @@ void GcodeSuite::M207_report(const bool forReplay/*=true*/) { void GcodeSuite::M208() { fwretract.M208(); } void GcodeSuite::M208_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_RECOVER_S_F)); + report_heading_etc(forReplay, F(STR_RECOVER_S_F)); fwretract.M208_report(); } @@ -68,7 +68,7 @@ void GcodeSuite::M208_report(const bool forReplay/*=true*/) { void GcodeSuite::M209() { fwretract.M209(); } void GcodeSuite::M209_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_AUTO_RETRACT_S)); + report_heading_etc(forReplay, F(STR_AUTO_RETRACT_S)); fwretract.M209_report(); } diff --git a/Marlin/src/gcode/feature/pause/M603.cpp b/Marlin/src/gcode/feature/pause/M603.cpp index ebb110d2e7..6689749cfb 100644 --- a/Marlin/src/gcode/feature/pause/M603.cpp +++ b/Marlin/src/gcode/feature/pause/M603.cpp @@ -65,7 +65,7 @@ void GcodeSuite::M603() { } void GcodeSuite::M603_report(const bool forReplay/*=true*/) { - report_heading(forReplay, PSTR(STR_FILAMENT_LOAD_UNLOAD)); + report_heading(forReplay, F(STR_FILAMENT_LOAD_UNLOAD)); #if EXTRUDERS == 1 report_echo_start(forReplay); diff --git a/Marlin/src/gcode/feature/powerloss/M413.cpp b/Marlin/src/gcode/feature/powerloss/M413.cpp index 9bf109559f..e02bd4bd95 100644 --- a/Marlin/src/gcode/feature/powerloss/M413.cpp +++ b/Marlin/src/gcode/feature/powerloss/M413.cpp @@ -57,7 +57,7 @@ void GcodeSuite::M413() { } void GcodeSuite::M413_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_POWER_LOSS_RECOVERY)); + report_heading_etc(forReplay, F(STR_POWER_LOSS_RECOVERY)); SERIAL_ECHOPGM(" M413 S", AS_DIGIT(recovery.enabled), " ; "); serialprintln_onoff(recovery.enabled); } diff --git a/Marlin/src/gcode/feature/runout/M412.cpp b/Marlin/src/gcode/feature/runout/M412.cpp index 9cbfbade66..bcf1e9f1b1 100644 --- a/Marlin/src/gcode/feature/runout/M412.cpp +++ b/Marlin/src/gcode/feature/runout/M412.cpp @@ -67,7 +67,7 @@ void GcodeSuite::M412() { } void GcodeSuite::M412_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_FILAMENT_RUNOUT_SENSOR)); + report_heading_etc(forReplay, F(STR_FILAMENT_RUNOUT_SENSOR)); SERIAL_ECHOPGM( " M412 S", runout.enabled #if HAS_FILAMENT_RUNOUT_DISTANCE diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index 00aadd4756..959fc16e67 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -139,7 +139,7 @@ void GcodeSuite::M569() { } void GcodeSuite::M569_report(const bool forReplay/*=true*/) { - report_heading(forReplay, PSTR(STR_DRIVER_STEPPING_MODE)); + report_heading(forReplay, F(STR_DRIVER_STEPPING_MODE)); auto say_M569 = [](const bool forReplay, const char * const etc=nullptr, const bool eol=false) { if (!forReplay) SERIAL_ECHO_START(); diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index c3e12a4f92..f28718c831 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -199,7 +199,7 @@ void GcodeSuite::M906() { } void GcodeSuite::M906_report(const bool forReplay/*=true*/) { - report_heading(forReplay, PSTR(STR_STEPPER_DRIVER_CURRENT)); + report_heading(forReplay, F(STR_STEPPER_DRIVER_CURRENT)); auto say_M906 = [](const bool forReplay) { report_echo_start(forReplay); diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index f15343484a..3f83558fd4 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -311,7 +311,7 @@ } void GcodeSuite::M913_report(const bool forReplay/*=true*/) { - report_heading(forReplay, PSTR(STR_HYBRID_THRESHOLD)); + report_heading(forReplay, F(STR_HYBRID_THRESHOLD)); auto say_M913 = [](const bool forReplay) { report_echo_start(forReplay); @@ -512,7 +512,7 @@ } void GcodeSuite::M914_report(const bool forReplay/*=true*/) { - report_heading(forReplay, PSTR(STR_STALLGUARD_THRESHOLD)); + report_heading(forReplay, F(STR_STALLGUARD_THRESHOLD)); auto say_M914 = [](const bool forReplay) { report_echo_start(forReplay); diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index e23315e9f5..e05a5f236a 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -103,12 +103,12 @@ axis_bits_t GcodeSuite::axis_relative = 0 LOGICAL_AXIS_GANG( #endif void GcodeSuite::report_echo_start(const bool forReplay) { if (!forReplay) SERIAL_ECHO_START(); } -void GcodeSuite::report_heading(const bool forReplay, PGM_P const pstr, const bool eol/*=true*/) { +void GcodeSuite::report_heading(const bool forReplay, FSTR_P const fstr, const bool eol/*=true*/) { if (forReplay) return; - if (pstr) { + if (fstr) { SERIAL_ECHO_START(); SERIAL_ECHOPGM("; "); - SERIAL_ECHOPGM_P(pstr); + SERIAL_ECHOF(fstr); } if (eol) { SERIAL_CHAR(':'); SERIAL_EOL(); } } diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 0106f002c2..5ad4750fe4 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -382,9 +382,9 @@ public: } static void report_echo_start(const bool forReplay); - static void report_heading(const bool forReplay, PGM_P const pstr, const bool eol=true); - static inline void report_heading_etc(const bool forReplay, PGM_P const pstr, const bool eol=true) { - report_heading(forReplay, pstr, eol); + static void report_heading(const bool forReplay, FSTR_P const fstr, const bool eol=true); + static inline void report_heading_etc(const bool forReplay, FSTR_P const fstr, const bool eol=true) { + report_heading(forReplay, fstr, eol); report_echo_start(forReplay); } static void say_units(); diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index 8dba238d09..131dbecf33 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -53,7 +53,7 @@ void GcodeSuite::M206() { } void GcodeSuite::M206_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_HOME_OFFSET)); + report_heading_etc(forReplay, F(STR_HOME_OFFSET)); SERIAL_ECHOLNPGM_P( #if IS_CARTESIAN LIST_N(DOUBLE(LINEAR_AXES), diff --git a/Marlin/src/gcode/lcd/M145.cpp b/Marlin/src/gcode/lcd/M145.cpp index 77fd425763..2dba238d3f 100644 --- a/Marlin/src/gcode/lcd/M145.cpp +++ b/Marlin/src/gcode/lcd/M145.cpp @@ -61,7 +61,7 @@ void GcodeSuite::M145() { } void GcodeSuite::M145_report(const bool forReplay/*=true*/) { - report_heading(forReplay, PSTR(STR_MATERIAL_HEATUP)); + report_heading(forReplay, F(STR_MATERIAL_HEATUP)); LOOP_L_N(i, PREHEAT_COUNT) { report_echo_start(forReplay); SERIAL_ECHOLNPGM_P( diff --git a/Marlin/src/gcode/lcd/M250.cpp b/Marlin/src/gcode/lcd/M250.cpp index 083fb37f65..25e4232788 100644 --- a/Marlin/src/gcode/lcd/M250.cpp +++ b/Marlin/src/gcode/lcd/M250.cpp @@ -38,7 +38,7 @@ void GcodeSuite::M250() { } void GcodeSuite::M250_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_LCD_CONTRAST)); + report_heading_etc(forReplay, F(STR_LCD_CONTRAST)); SERIAL_ECHOLNPGM(" M250 C", ui.contrast); } diff --git a/Marlin/src/gcode/lcd/M256.cpp b/Marlin/src/gcode/lcd/M256.cpp index ee187cc2e1..9842cc2583 100644 --- a/Marlin/src/gcode/lcd/M256.cpp +++ b/Marlin/src/gcode/lcd/M256.cpp @@ -37,7 +37,7 @@ void GcodeSuite::M256() { } void GcodeSuite::M256_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_LCD_BRIGHTNESS)); + report_heading_etc(forReplay, F(STR_LCD_BRIGHTNESS)); SERIAL_ECHOLNPGM(" M256 B", ui.brightness); } diff --git a/Marlin/src/gcode/lcd/M414.cpp b/Marlin/src/gcode/lcd/M414.cpp index 0eac980e0f..9aa49ea3c2 100644 --- a/Marlin/src/gcode/lcd/M414.cpp +++ b/Marlin/src/gcode/lcd/M414.cpp @@ -44,7 +44,7 @@ void GcodeSuite::M414() { } void GcodeSuite::M414_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_UI_LANGUAGE)); + report_heading_etc(forReplay, F(STR_UI_LANGUAGE)); SERIAL_ECHOLNPGM(" M414 S", ui.language); } diff --git a/Marlin/src/gcode/probe/M851.cpp b/Marlin/src/gcode/probe/M851.cpp index 7ec326730f..e66392acb4 100644 --- a/Marlin/src/gcode/probe/M851.cpp +++ b/Marlin/src/gcode/probe/M851.cpp @@ -84,7 +84,7 @@ void GcodeSuite::M851() { } void GcodeSuite::M851_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_Z_PROBE_OFFSET)); + report_heading_etc(forReplay, F(STR_Z_PROBE_OFFSET)); SERIAL_ECHOPGM_P( #if HAS_PROBE_XY_OFFSET PSTR(" M851 X"), LINEAR_UNIT(probe.offset_xy.x), diff --git a/Marlin/src/gcode/units/M149.cpp b/Marlin/src/gcode/units/M149.cpp index b1cfbb2511..3f1ea3654e 100644 --- a/Marlin/src/gcode/units/M149.cpp +++ b/Marlin/src/gcode/units/M149.cpp @@ -37,7 +37,7 @@ void GcodeSuite::M149() { } void GcodeSuite::M149_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, PSTR(STR_TEMPERATURE_UNITS)); + report_heading_etc(forReplay, F(STR_TEMPERATURE_UNITS)); SERIAL_ECHOPGM(" M149 ", AS_CHAR(parser.temp_units_code()), " ; Units in "); SERIAL_ECHOLNF(parser.temp_units_name()); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 4f15dceba8..6b7143e82a 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3037,7 +3037,7 @@ void MarlinSettings::reset() { #define CONFIG_ECHO_START() gcode.report_echo_start(forReplay) #define CONFIG_ECHO_MSG(V...) do{ CONFIG_ECHO_START(); SERIAL_ECHOLNPGM(V); }while(0) #define CONFIG_ECHO_MSG_P(V...) do{ CONFIG_ECHO_START(); SERIAL_ECHOLNPGM_P(V); }while(0) - #define CONFIG_ECHO_HEADING(STR) gcode.report_heading(forReplay, PSTR(STR)) + #define CONFIG_ECHO_HEADING(STR) gcode.report_heading(forReplay, F(STR)) void M92_report(const bool echo=true, const int8_t e=-1); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index aa81ea5d96..a3ada25118 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1727,7 +1727,7 @@ void Temperature::manage_heater() { } void Temperature::M305_report(const uint8_t t_index, const bool forReplay/*=true*/) { - gcode.report_heading_etc(forReplay, PSTR(STR_USER_THERMISTORS)); + gcode.report_heading_etc(forReplay, F(STR_USER_THERMISTORS)); SERIAL_ECHOPGM(" M305 P", AS_DIGIT(t_index)); const user_thermistor_t &t = user_thermistor[t_index]; From 24dbeceb45a72c0b96d42e46ba750f41ac1dd4e2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Sep 2021 13:46:42 -0500 Subject: [PATCH 015/546] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20F()=20to=20vario?= =?UTF-8?q?us=20reports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/shared/Delay.cpp | 36 +++++----- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 12 ++-- Marlin/src/feature/max7219.cpp | 41 ++++++----- Marlin/src/feature/max7219.h | 4 +- Marlin/src/feature/powerloss.cpp | 8 +-- Marlin/src/feature/powerloss.h | 4 +- Marlin/src/feature/stepper_driver_safety.cpp | 12 ++-- Marlin/src/feature/twibus.cpp | 46 ++++++------ Marlin/src/feature/twibus.h | 23 +++--- Marlin/src/gcode/bedlevel/M420.cpp | 2 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 30 ++++---- Marlin/src/gcode/calibrate/G28.cpp | 14 ++-- Marlin/src/gcode/calibrate/G33.cpp | 44 ++++++------ Marlin/src/gcode/calibrate/M100.cpp | 14 ++-- Marlin/src/gcode/config/M43.cpp | 6 +- .../src/gcode/feature/network/M552-M554.cpp | 10 +-- Marlin/src/gcode/feature/powerloss/M1000.cpp | 6 +- Marlin/src/gcode/feature/powerloss/M413.cpp | 2 +- Marlin/src/gcode/feature/trinamic/M569.cpp | 36 +++++----- Marlin/src/gcode/gcode.cpp | 4 +- Marlin/src/gcode/host/M115.cpp | 70 +++++++++---------- Marlin/src/gcode/host/M360.cpp | 62 ++++++++-------- Marlin/src/gcode/queue.cpp | 12 ++-- Marlin/src/gcode/queue.h | 2 +- Marlin/src/libs/stopwatch.cpp | 18 ++--- Marlin/src/libs/stopwatch.h | 11 ++- Marlin/src/libs/vector_3.cpp | 24 +++---- Marlin/src/libs/vector_3.h | 4 +- Marlin/src/module/endstops.cpp | 14 ++-- Marlin/src/pins/pinsDebug.h | 8 +-- 30 files changed, 288 insertions(+), 291 deletions(-) diff --git a/Marlin/src/HAL/shared/Delay.cpp b/Marlin/src/HAL/shared/Delay.cpp index 32543c6d0a..c64376d25d 100644 --- a/Marlin/src/HAL/shared/Delay.cpp +++ b/Marlin/src/HAL/shared/Delay.cpp @@ -108,13 +108,14 @@ #if ENABLED(MARLIN_DEV_MODE) void dump_delay_accuracy_check() { - auto report_call_time = [](PGM_P const name, PGM_P const unit, const uint32_t cycles, const uint32_t total, const bool do_flush=true) { + auto report_call_time = [](FSTR_P const name, FSTR_P const unit, const uint32_t cycles, const uint32_t total, const bool do_flush=true) { SERIAL_ECHOPGM("Calling "); - SERIAL_ECHOPGM_P(name); + SERIAL_ECHOF(name); SERIAL_ECHOLNPGM(" for ", cycles); - SERIAL_ECHOPGM_P(unit); + SERIAL_ECHOF(unit); SERIAL_ECHOLNPGM(" took: ", total); - SERIAL_ECHOPGM_P(unit); + SERIAL_CHAR(' '); + SERIAL_ECHOF(unit); if (do_flush) SERIAL_FLUSHTX(); }; @@ -126,41 +127,42 @@ constexpr uint32_t testValues[] = { 1, 5, 10, 20, 50, 100, 150, 200, 350, 500, 750, 1000 }; for (auto i : testValues) { s = micros(); DELAY_US(i); e = micros(); - report_call_time(PSTR("delay"), PSTR("us"), i, e - s); + report_call_time(F("delay"), F("us"), i, e - s); } if (HW_REG(_DWT_CTRL)) { + static FSTR_P cyc = F("cycles"); + static FSTR_P dcd = F("DELAY_CYCLES directly "); + for (auto i : testValues) { s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(i); e = HW_REG(_DWT_CYCCNT); - report_call_time(PSTR("runtime delay"), PSTR("cycles"), i, e - s); + report_call_time(F("runtime delay"), cyc, i, e - s); } // Measure the delay to call a real function compared to a function pointer s = HW_REG(_DWT_CYCCNT); delay_dwt(1); e = HW_REG(_DWT_CYCCNT); - report_call_time(PSTR("delay_dwt"), PSTR("cycles"), 1, e - s); - - static PGMSTR(dcd, "DELAY_CYCLES directly "); + report_call_time(F("delay_dwt"), cyc, 1, e - s); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 1); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, PSTR("cycles"), 1, e - s, false); + report_call_time(dcd, cyc, 1, e - s, false); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 5); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, PSTR("cycles"), 5, e - s, false); + report_call_time(dcd, cyc, 5, e - s, false); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(10); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, PSTR("cycles"), 10, e - s, false); + report_call_time(dcd, cyc, 10, e - s, false); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(20); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, PSTR("cycles"), 20, e - s, false); + report_call_time(dcd, cyc, 20, e - s, false); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(50); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, PSTR("cycles"), 50, e - s, false); + report_call_time(dcd, cyc, 50, e - s, false); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(100); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, PSTR("cycles"), 100, e - s, false); + report_call_time(dcd, cyc, 100, e - s, false); s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(200); e = HW_REG(_DWT_CYCCNT); - report_call_time(dcd, PSTR("cycles"), 200, e - s, false); + report_call_time(dcd, cyc, 200, e - s, false); } } #endif // MARLIN_DEV_MODE @@ -170,7 +172,7 @@ void calibrate_delay_loop() {} #if ENABLED(MARLIN_DEV_MODE) - void dump_delay_accuracy_check() { SERIAL_ECHOPGM_P(PSTR("N/A on this platform")); } + void dump_delay_accuracy_check() { SERIAL_ECHOPGM("N/A on this platform"); } #endif #endif diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 051cb6a4d6..d78a5e2578 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -1609,7 +1609,7 @@ void unified_bed_leveling::smart_fill_mesh() { } if (DEBUGGING(LEVELING)) { - rotation.debug(PSTR("rotation matrix:\n")); + rotation.debug(F("rotation matrix:\n")); DEBUG_ECHOPAIR_F("LSF Results A=", lsf_results.A, 7); DEBUG_ECHOPAIR_F(" B=", lsf_results.B, 7); DEBUG_ECHOLNPAIR_F(" D=", lsf_results.D, 7); @@ -1636,14 +1636,14 @@ void unified_bed_leveling::smart_fill_mesh() { auto normed = [&](const xy_pos_t &pos, const_float_t zadd) { return normal.x * pos.x + normal.y * pos.y + zadd; }; - auto debug_pt = [](PGM_P const pre, const xy_pos_t &pos, const_float_t zadd) { - d_from(); SERIAL_ECHOPGM_P(pre); + auto debug_pt = [](FSTR_P const pre, const xy_pos_t &pos, const_float_t zadd) { + d_from(); SERIAL_ECHOF(pre); DEBUG_ECHO_F(normed(pos, zadd), 6); DEBUG_ECHOLNPAIR_F(" Z error = ", zadd - get_z_correction(pos), 6); }; - debug_pt(PSTR("1st point: "), probe_pt[0], normal.z * z1); - debug_pt(PSTR("2nd point: "), probe_pt[1], normal.z * z2); - debug_pt(PSTR("3rd point: "), probe_pt[2], normal.z * z3); + debug_pt(F("1st point: "), probe_pt[0], normal.z * z1); + debug_pt(F("2nd point: "), probe_pt[1], normal.z * z2); + debug_pt(F("3rd point: "), probe_pt[2], normal.z * z3); d_from(); DEBUG_ECHOPGM("safe home with Z="); DEBUG_ECHOLNPAIR_F("0 : ", normed(safe_homing_xy, 0), 6); d_from(); DEBUG_ECHOPGM("safe home with Z="); diff --git a/Marlin/src/feature/max7219.cpp b/Marlin/src/feature/max7219.cpp index e13c6f5b97..474933aa19 100644 --- a/Marlin/src/feature/max7219.cpp +++ b/Marlin/src/feature/max7219.cpp @@ -124,11 +124,10 @@ uint8_t Max7219::suspended; // = 0; #define SIG_DELAY() DELAY_NS(250) #endif -void Max7219::error(const char * const func, const int32_t v1, const int32_t v2/*=-1*/) { +void Max7219::error(FSTR_P const func, const int32_t v1, const int32_t v2/*=-1*/) { #if ENABLED(MAX7219_ERRORS) SERIAL_ECHOPGM("??? Max7219::"); - SERIAL_ECHOPGM_P(func); - SERIAL_CHAR('('); + SERIAL_ECHOF(func, AS_CHAR('(')); SERIAL_ECHO(v1); if (v2 > 0) SERIAL_ECHOPGM(", ", v2); SERIAL_CHAR(')'); @@ -268,24 +267,24 @@ void Max7219::set(const uint8_t line, const uint8_t bits) { // Modify a single LED bit and send the changed line void Max7219::led_set(const uint8_t x, const uint8_t y, const bool on) { - if (x >= MAX7219_X_LEDS || y >= MAX7219_Y_LEDS) return error(PSTR("led_set"), x, y); + if (x >= MAX7219_X_LEDS || y >= MAX7219_Y_LEDS) return error(F("led_set"), x, y); if (BIT_7219(x, y) == on) return; XOR_7219(x, y); refresh_unit_line(LED_IND(x, y)); } void Max7219::led_on(const uint8_t x, const uint8_t y) { - if (x >= MAX7219_X_LEDS || y >= MAX7219_Y_LEDS) return error(PSTR("led_on"), x, y); + if (x >= MAX7219_X_LEDS || y >= MAX7219_Y_LEDS) return error(F("led_on"), x, y); led_set(x, y, true); } void Max7219::led_off(const uint8_t x, const uint8_t y) { - if (x >= MAX7219_X_LEDS || y >= MAX7219_Y_LEDS) return error(PSTR("led_off"), x, y); + if (x >= MAX7219_X_LEDS || y >= MAX7219_Y_LEDS) return error(F("led_off"), x, y); led_set(x, y, false); } void Max7219::led_toggle(const uint8_t x, const uint8_t y) { - if (x >= MAX7219_X_LEDS || y >= MAX7219_Y_LEDS) return error(PSTR("led_toggle"), x, y); + if (x >= MAX7219_X_LEDS || y >= MAX7219_Y_LEDS) return error(F("led_toggle"), x, y); led_set(x, y, !BIT_7219(x, y)); } @@ -328,13 +327,13 @@ void Max7219::fill() { } void Max7219::clear_row(const uint8_t row) { - if (row >= MAX7219_Y_LEDS) return error(PSTR("clear_row"), row); + if (row >= MAX7219_Y_LEDS) return error(F("clear_row"), row); LOOP_L_N(x, MAX7219_X_LEDS) CLR_7219(x, row); send_row(row); } void Max7219::clear_column(const uint8_t col) { - if (col >= MAX7219_X_LEDS) return error(PSTR("set_column"), col); + if (col >= MAX7219_X_LEDS) return error(F("set_column"), col); LOOP_L_N(y, MAX7219_Y_LEDS) CLR_7219(col, y); send_column(col); } @@ -345,7 +344,7 @@ void Max7219::clear_column(const uint8_t col) { * once with a single call to the function (if rotated 90° or 270°). */ void Max7219::set_row(const uint8_t row, const uint32_t val) { - if (row >= MAX7219_Y_LEDS) return error(PSTR("set_row"), row); + if (row >= MAX7219_Y_LEDS) return error(F("set_row"), row); uint32_t mask = _BV32(MAX7219_X_LEDS - 1); LOOP_L_N(x, MAX7219_X_LEDS) { if (val & mask) SET_7219(x, row); else CLR_7219(x, row); @@ -360,7 +359,7 @@ void Max7219::set_row(const uint8_t row, const uint32_t val) { * once with a single call to the function (if rotated 0° or 180°). */ void Max7219::set_column(const uint8_t col, const uint32_t val) { - if (col >= MAX7219_X_LEDS) return error(PSTR("set_column"), col); + if (col >= MAX7219_X_LEDS) return error(F("set_column"), col); uint32_t mask = _BV32(MAX7219_Y_LEDS - 1); LOOP_L_N(y, MAX7219_Y_LEDS) { if (val & mask) SET_7219(col, y); else CLR_7219(col, y); @@ -371,56 +370,56 @@ void Max7219::set_column(const uint8_t col, const uint32_t val) { void Max7219::set_rows_16bits(const uint8_t y, uint32_t val) { #if MAX7219_X_LEDS == 8 - if (y > MAX7219_Y_LEDS - 2) return error(PSTR("set_rows_16bits"), y, val); + if (y > MAX7219_Y_LEDS - 2) return error(F("set_rows_16bits"), y, val); set_row(y + 1, val); val >>= 8; set_row(y + 0, val); #else // at least 16 bits on each row - if (y > MAX7219_Y_LEDS - 1) return error(PSTR("set_rows_16bits"), y, val); + if (y > MAX7219_Y_LEDS - 1) return error(F("set_rows_16bits"), y, val); set_row(y, val); #endif } void Max7219::set_rows_32bits(const uint8_t y, uint32_t val) { #if MAX7219_X_LEDS == 8 - if (y > MAX7219_Y_LEDS - 4) return error(PSTR("set_rows_32bits"), y, val); + if (y > MAX7219_Y_LEDS - 4) return error(F("set_rows_32bits"), y, val); set_row(y + 3, val); val >>= 8; set_row(y + 2, val); val >>= 8; set_row(y + 1, val); val >>= 8; set_row(y + 0, val); #elif MAX7219_X_LEDS == 16 - if (y > MAX7219_Y_LEDS - 2) return error(PSTR("set_rows_32bits"), y, val); + if (y > MAX7219_Y_LEDS - 2) return error(F("set_rows_32bits"), y, val); set_row(y + 1, val); val >>= 16; set_row(y + 0, val); #else // at least 24 bits on each row. In the 3 matrix case, just display the low 24 bits - if (y > MAX7219_Y_LEDS - 1) return error(PSTR("set_rows_32bits"), y, val); + if (y > MAX7219_Y_LEDS - 1) return error(F("set_rows_32bits"), y, val); set_row(y, val); #endif } void Max7219::set_columns_16bits(const uint8_t x, uint32_t val) { #if MAX7219_Y_LEDS == 8 - if (x > MAX7219_X_LEDS - 2) return error(PSTR("set_columns_16bits"), x, val); + if (x > MAX7219_X_LEDS - 2) return error(F("set_columns_16bits"), x, val); set_column(x + 0, val); val >>= 8; set_column(x + 1, val); #else // at least 16 bits in each column - if (x > MAX7219_X_LEDS - 1) return error(PSTR("set_columns_16bits"), x, val); + if (x > MAX7219_X_LEDS - 1) return error(F("set_columns_16bits"), x, val); set_column(x, val); #endif } void Max7219::set_columns_32bits(const uint8_t x, uint32_t val) { #if MAX7219_Y_LEDS == 8 - if (x > MAX7219_X_LEDS - 4) return error(PSTR("set_rows_32bits"), x, val); + if (x > MAX7219_X_LEDS - 4) return error(F("set_rows_32bits"), x, val); set_column(x + 3, val); val >>= 8; set_column(x + 2, val); val >>= 8; set_column(x + 1, val); val >>= 8; set_column(x + 0, val); #elif MAX7219_Y_LEDS == 16 - if (x > MAX7219_X_LEDS - 2) return error(PSTR("set_rows_32bits"), x, val); + if (x > MAX7219_X_LEDS - 2) return error(F("set_rows_32bits"), x, val); set_column(x + 1, val); val >>= 16; set_column(x + 0, val); #else // at least 24 bits on each row. In the 3 matrix case, just display the low 24 bits - if (x > MAX7219_X_LEDS - 1) return error(PSTR("set_rows_32bits"), x, val); + if (x > MAX7219_X_LEDS - 1) return error(F("set_rows_32bits"), x, val); set_column(x, val); #endif } diff --git a/Marlin/src/feature/max7219.h b/Marlin/src/feature/max7219.h index 3e5b62db2f..c25fef1730 100644 --- a/Marlin/src/feature/max7219.h +++ b/Marlin/src/feature/max7219.h @@ -42,6 +42,8 @@ * a Max7219_Set_Row(). The opposite is true for rotations of 0 or 180 degrees. */ +#include "../inc/MarlinConfig.h" + #ifndef MAX7219_ROTATE #define MAX7219_ROTATE 0 #endif @@ -140,7 +142,7 @@ public: private: static uint8_t suspended; - static void error(const char * const func, const int32_t v1, const int32_t v2=-1); + static void error(FSTR_P const func, const int32_t v1, const int32_t v2=-1); static void noop(); static void set(const uint8_t line, const uint8_t bits); static void send_row(const uint8_t row); diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 9808113ecc..bc19c9b18e 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -130,7 +130,7 @@ void PrintJobRecovery::load() { (void)file.read(&info, sizeof(info)); close(); } - debug(PSTR("Load")); + debug(F("Load")); } /** @@ -311,7 +311,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW */ void PrintJobRecovery::write() { - debug(PSTR("Write")); + debug(F("Write")); open(false); file.seekSet(0); @@ -575,8 +575,8 @@ void PrintJobRecovery::resume() { #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) - void PrintJobRecovery::debug(PGM_P const prefix) { - DEBUG_ECHOPGM_P(prefix); + void PrintJobRecovery::debug(FSTR_P const prefix) { + DEBUG_ECHOF(prefix); DEBUG_ECHOLNPGM(" Job Recovery Info...\nvalid_head:", info.valid_head, " valid_foot:", info.valid_foot); if (info.valid_head) { if (info.valid_head == info.valid_foot) { diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 6a13c92df7..76cb398af2 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -204,9 +204,9 @@ class PrintJobRecovery { static inline bool valid() { return info.valid() && interrupted_file_exists(); } #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) - static void debug(PGM_P const prefix); + static void debug(FSTR_P const prefix); #else - static inline void debug(PGM_P const) {} + static inline void debug(FSTR_P const) {} #endif private: diff --git a/Marlin/src/feature/stepper_driver_safety.cpp b/Marlin/src/feature/stepper_driver_safety.cpp index 8ba0968cd2..11b90954b4 100644 --- a/Marlin/src/feature/stepper_driver_safety.cpp +++ b/Marlin/src/feature/stepper_driver_safety.cpp @@ -28,11 +28,11 @@ static uint32_t axis_plug_backward = 0; -void stepper_driver_backward_error(PGM_P str) { +void stepper_driver_backward_error(FSTR_P const fstr) { SERIAL_ERROR_START(); - SERIAL_ECHOPGM_P(str); + SERIAL_ECHOF(fstr); SERIAL_ECHOLNPGM(" driver is backward!"); - ui.status_printf(2, F(S_FMT S_FMT), str, GET_TEXT(MSG_DRIVER_BACKWARD)); + ui.status_printf(2, F(S_FMT S_FMT), FTOP(fstr), GET_TEXT(MSG_DRIVER_BACKWARD)); } void stepper_driver_backward_check() { @@ -45,7 +45,7 @@ void stepper_driver_backward_check() { delay(20); \ if (READ(AXIS##_ENABLE_PIN) == false) { \ SBI(axis_plug_backward, BIT); \ - stepper_driver_backward_error(PSTR(STRINGIFY(AXIS))); \ + stepper_driver_backward_error(F(STRINGIFY(AXIS))); \ } \ }while(0) @@ -82,12 +82,12 @@ void stepper_driver_backward_check() { void stepper_driver_backward_report() { if (!axis_plug_backward) return; - auto _report_if_backward = [](PGM_P axis, uint8_t bit) { + auto _report_if_backward = [](FSTR_P const axis, uint8_t bit) { if (TEST(axis_plug_backward, bit)) stepper_driver_backward_error(axis); }; - #define REPORT_BACKWARD(axis, bit) TERN_(HAS_##axis##_ENABLE, _report_if_backward(PSTR(STRINGIFY(axis)), bit)) + #define REPORT_BACKWARD(axis, bit) TERN_(HAS_##axis##_ENABLE, _report_if_backward(F(STRINGIFY(axis)), bit)) REPORT_BACKWARD(X, 0); REPORT_BACKWARD(X2, 1); diff --git a/Marlin/src/feature/twibus.cpp b/Marlin/src/feature/twibus.cpp index 5f5209cdd4..55e4da75cf 100644 --- a/Marlin/src/feature/twibus.cpp +++ b/Marlin/src/feature/twibus.cpp @@ -51,27 +51,27 @@ void TWIBus::address(const uint8_t adr) { addr = adr; - debug(PSTR("address"), adr); + debug(F("address"), adr); } void TWIBus::addbyte(const char c) { if (buffer_s >= COUNT(buffer)) return; buffer[buffer_s++] = c; - debug(PSTR("addbyte"), c); + debug(F("addbyte"), c); } void TWIBus::addbytes(char src[], uint8_t bytes) { - debug(PSTR("addbytes"), bytes); + debug(F("addbytes"), bytes); while (bytes--) addbyte(*src++); } void TWIBus::addstring(char str[]) { - debug(PSTR("addstring"), str); + debug(F("addstring"), str); while (char c = *str++) addbyte(c); } void TWIBus::send() { - debug(PSTR("send"), addr); + debug(F("send"), addr); Wire.beginTransmission(I2C_ADDRESS(addr)); Wire.write(buffer, buffer_s); @@ -81,20 +81,20 @@ void TWIBus::send() { } // static -void TWIBus::echoprefix(uint8_t bytes, const char pref[], uint8_t adr) { +void TWIBus::echoprefix(uint8_t bytes, FSTR_P const pref, uint8_t adr) { SERIAL_ECHO_START(); - SERIAL_ECHOPGM_P(pref); + SERIAL_ECHOF(pref); SERIAL_ECHOPGM(": from:", adr, " bytes:", bytes, " data:"); } // static -void TWIBus::echodata(uint8_t bytes, const char pref[], uint8_t adr) { +void TWIBus::echodata(uint8_t bytes, FSTR_P const pref, uint8_t adr) { echoprefix(bytes, pref, adr); while (bytes-- && Wire.available()) SERIAL_CHAR(Wire.read()); SERIAL_EOL(); } -void TWIBus::echobuffer(const char pref[], uint8_t adr) { +void TWIBus::echobuffer(FSTR_P const pref, uint8_t adr) { echoprefix(buffer_s, pref, adr); LOOP_L_N(i, buffer_s) SERIAL_CHAR(buffer[i]); SERIAL_EOL(); @@ -103,11 +103,11 @@ void TWIBus::echobuffer(const char pref[], uint8_t adr) { bool TWIBus::request(const uint8_t bytes) { if (!addr) return false; - debug(PSTR("request"), bytes); + debug(F("request"), bytes); // requestFrom() is a blocking function if (Wire.requestFrom(I2C_ADDRESS(addr), bytes) == 0) { - debug("request fail", I2C_ADDRESS(addr)); + debug(F("request fail"), I2C_ADDRESS(addr)); return false; } @@ -115,10 +115,10 @@ bool TWIBus::request(const uint8_t bytes) { } void TWIBus::relay(const uint8_t bytes) { - debug(PSTR("relay"), bytes); + debug(F("relay"), bytes); if (request(bytes)) - echodata(bytes, PSTR("i2c-reply"), addr); + echodata(bytes, F("i2c-reply"), addr); } uint8_t TWIBus::capture(char *dst, const uint8_t bytes) { @@ -127,7 +127,7 @@ uint8_t TWIBus::capture(char *dst, const uint8_t bytes) { while (count < bytes && Wire.available()) dst[count++] = Wire.read(); - debug(PSTR("capture"), count); + debug(F("capture"), count); return count; } @@ -140,12 +140,12 @@ void TWIBus::flush() { #if I2C_SLAVE_ADDRESS > 0 void TWIBus::receive(uint8_t bytes) { - debug(PSTR("receive"), bytes); - echodata(bytes, PSTR("i2c-receive"), 0); + debug(F("receive"), bytes); + echodata(bytes, F("i2c-receive"), 0); } void TWIBus::reply(char str[]/*=nullptr*/) { - debug(PSTR("reply"), str); + debug(F("reply"), str); if (str) { reset(); @@ -170,18 +170,16 @@ void TWIBus::flush() { #if ENABLED(DEBUG_TWIBUS) // static - void TWIBus::prefix(const char func[]) { - SERIAL_ECHOPGM("TWIBus::"); - SERIAL_ECHOPGM_P(func); - SERIAL_ECHOPGM(": "); + void TWIBus::prefix(FSTR_P const func) { + SERIAL_ECHOPGM("TWIBus::", func, ": "); } - void TWIBus::debug(const char func[], uint32_t adr) { + void TWIBus::debug(FSTR_P const func, uint32_t adr) { if (DEBUGGING(INFO)) { prefix(func); SERIAL_ECHOLN(adr); } } - void TWIBus::debug(const char func[], char c) { + void TWIBus::debug(FSTR_P const func, char c) { if (DEBUGGING(INFO)) { prefix(func); SERIAL_ECHOLN(c); } } - void TWIBus::debug(const char func[], char str[]) { + void TWIBus::debug(FSTR_P const func, char str[]) { if (DEBUGGING(INFO)) { prefix(func); SERIAL_ECHOLN(str); } } diff --git a/Marlin/src/feature/twibus.h b/Marlin/src/feature/twibus.h index 5939153482..2a8a7fef6a 100644 --- a/Marlin/src/feature/twibus.h +++ b/Marlin/src/feature/twibus.h @@ -142,7 +142,7 @@ class TWIBus { * * @param bytes the number of bytes to request */ - static void echoprefix(uint8_t bytes, const char prefix[], uint8_t adr); + static void echoprefix(uint8_t bytes, FSTR_P prefix, uint8_t adr); /** * @brief Echo data on the bus to serial @@ -151,7 +151,7 @@ class TWIBus { * * @param bytes the number of bytes to request */ - static void echodata(uint8_t bytes, const char prefix[], uint8_t adr); + static void echodata(uint8_t bytes, FSTR_P prefix, uint8_t adr); /** * @brief Echo data in the buffer to serial @@ -160,7 +160,7 @@ class TWIBus { * * @param bytes the number of bytes to request */ - void echobuffer(const char prefix[], uint8_t adr); + void echobuffer(FSTR_P prefix, uint8_t adr); /** * @brief Request data from the slave device and wait. @@ -237,17 +237,16 @@ class TWIBus { * @brief Prints a debug message * @details Prints a simple debug message "TWIBus::function: value" */ - static void prefix(const char func[]); - static void debug(const char func[], uint32_t adr); - static void debug(const char func[], char c); - static void debug(const char func[], char adr[]); - static inline void debug(const char func[], uint8_t v) { debug(func, (uint32_t)v); } + static void prefix(FSTR_P const func); + static void debug(FSTR_P const func, uint32_t adr); + static void debug(FSTR_P const func, char c); + static void debug(FSTR_P const func, char adr[]); #else - static inline void debug(const char[], uint32_t) {} - static inline void debug(const char[], char) {} - static inline void debug(const char[], char[]) {} - static inline void debug(const char[], uint8_t) {} + static inline void debug(FSTR_P const, uint32_t) {} + static inline void debug(FSTR_P const, char) {} + static inline void debug(FSTR_P const, char[]) {} #endif + static inline void debug(FSTR_P const func, uint8_t v) { debug(func, (uint32_t)v); } }; extern TWIBus i2c; diff --git a/Marlin/src/gcode/bedlevel/M420.cpp b/Marlin/src/gcode/bedlevel/M420.cpp index 5dcef961ee..3c23e85a1d 100644 --- a/Marlin/src/gcode/bedlevel/M420.cpp +++ b/Marlin/src/gcode/bedlevel/M420.cpp @@ -195,7 +195,7 @@ void GcodeSuite::M420() { // V to print the matrix or mesh if (seenV) { #if ABL_PLANAR - planner.bed_level_matrix.debug(PSTR("Bed Level Correction Matrix:")); + planner.bed_level_matrix.debug(F("Bed Level Correction Matrix:")); #else if (leveling_is_valid()) { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 07aefe8aed..f7afd93c81 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -783,8 +783,8 @@ G29_TYPE GcodeSuite::G29() { float min_diff = 999; - auto print_topo_map = [&](PGM_P const title, const bool get_min) { - SERIAL_ECHOPGM_P(title); + auto print_topo_map = [&](FSTR_P const title, const bool get_min) { + SERIAL_ECHOF(title); for (int8_t yy = abl.grid_points.y - 1; yy >= 0; yy--) { LOOP_L_N(xx, abl.grid_points.x) { const int ind = abl.indexIntoAB[xx][yy]; @@ -802,19 +802,19 @@ G29_TYPE GcodeSuite::G29() { SERIAL_EOL(); }; - print_topo_map(PSTR("\nBed Height Topography:\n" - " +--- BACK --+\n" - " | |\n" - " L | (+) | R\n" - " E | | I\n" - " F | (-) N (+) | G\n" - " T | | H\n" - " | (-) | T\n" - " | |\n" - " O-- FRONT --+\n" - " (0,0)\n"), true); + print_topo_map(F("\nBed Height Topography:\n" + " +--- BACK --+\n" + " | |\n" + " L | (+) | R\n" + " E | | I\n" + " F | (-) N (+) | G\n" + " T | | H\n" + " | (-) | T\n" + " | |\n" + " O-- FRONT --+\n" + " (0,0)\n"), true); if (abl.verbose_level > 3) - print_topo_map(PSTR("\nCorrected Bed Height vs. Bed Topology:\n"), false); + print_topo_map(F("\nCorrected Bed Height vs. Bed Topology:\n"), false); } // abl.topography_map @@ -825,7 +825,7 @@ G29_TYPE GcodeSuite::G29() { // For LINEAR and 3POINT leveling correct the current position if (abl.verbose_level > 0) - planner.bed_level_matrix.debug(PSTR("\n\nBed Level Correction Matrix:")); + planner.bed_level_matrix.debug(F("\n\nBed Level Correction Matrix:")); if (!abl.dryrun) { // diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 1c7e839f45..26474e333b 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -269,28 +269,28 @@ void GcodeSuite::G28() { #endif #if HAS_HOMING_CURRENT - auto debug_current = [](PGM_P const s, const int16_t a, const int16_t b) { - DEBUG_ECHOPGM_P(s); DEBUG_ECHOLNPGM(" current: ", a, " -> ", b); + auto debug_current = [](FSTR_P const s, const int16_t a, const int16_t b) { + DEBUG_ECHOF(s); DEBUG_ECHOLNPGM(" current: ", a, " -> ", b); }; #if HAS_CURRENT_HOME(X) const int16_t tmc_save_current_X = stepperX.getMilliamps(); stepperX.rms_current(X_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(PSTR("X"), tmc_save_current_X, X_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F("X"), tmc_save_current_X, X_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(X2) const int16_t tmc_save_current_X2 = stepperX2.getMilliamps(); stepperX2.rms_current(X2_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(PSTR("X2"), tmc_save_current_X2, X2_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F("X2"), tmc_save_current_X2, X2_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(Y) const int16_t tmc_save_current_Y = stepperY.getMilliamps(); stepperY.rms_current(Y_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(PSTR("Y"), tmc_save_current_Y, Y_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F("Y"), tmc_save_current_Y, Y_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(Y2) const int16_t tmc_save_current_Y2 = stepperY2.getMilliamps(); stepperY2.rms_current(Y2_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(PSTR("Y2"), tmc_save_current_Y2, Y2_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F("Y2"), tmc_save_current_Y2, Y2_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(I) const int16_t tmc_save_current_I = stepperI.getMilliamps(); @@ -310,7 +310,7 @@ void GcodeSuite::G28() { #if HAS_CURRENT_HOME(Z) && ENABLED(DELTA) const int16_t tmc_save_current_Z = stepperZ.getMilliamps(); stepperZ.rms_current(Z_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(PSTR("Z"), tmc_save_current_Z, Z_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F("Z"), tmc_save_current_Z, Z_CURRENT_HOME); #endif #endif diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 4ac25c2cf1..779ae99d0a 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -97,10 +97,9 @@ void ac_cleanup(TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index)) { TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index, true)); } -void print_signed_float(PGM_P const prefix, const_float_t f) { +void print_signed_float(FSTR_P const prefix, const_float_t f) { SERIAL_ECHOPGM(" "); - SERIAL_ECHOPGM_P(prefix); - SERIAL_CHAR(':'); + SERIAL_ECHOF(prefix, AS_CHAR(':')); if (f >= 0) SERIAL_CHAR('+'); SERIAL_ECHO_F(f, 2); } @@ -111,24 +110,23 @@ void print_signed_float(PGM_P const prefix, const_float_t f) { static void print_calibration_settings(const bool end_stops, const bool tower_angles) { SERIAL_ECHOPGM(".Height:", delta_height); if (end_stops) { - print_signed_float(PSTR("Ex"), delta_endstop_adj.a); - print_signed_float(PSTR("Ey"), delta_endstop_adj.b); - print_signed_float(PSTR("Ez"), delta_endstop_adj.c); + print_signed_float(F("Ex"), delta_endstop_adj.a); + print_signed_float(F("Ey"), delta_endstop_adj.b); + print_signed_float(F("Ez"), delta_endstop_adj.c); } if (end_stops && tower_angles) { - SERIAL_ECHOPGM(" Radius:", delta_radius); - SERIAL_EOL(); + SERIAL_ECHOLNPGM(" Radius:", delta_radius); SERIAL_CHAR('.'); SERIAL_ECHO_SP(13); } if (tower_angles) { - print_signed_float(PSTR("Tx"), delta_tower_angle_trim.a); - print_signed_float(PSTR("Ty"), delta_tower_angle_trim.b); - print_signed_float(PSTR("Tz"), delta_tower_angle_trim.c); + print_signed_float(F("Tx"), delta_tower_angle_trim.a); + print_signed_float(F("Ty"), delta_tower_angle_trim.b); + print_signed_float(F("Tz"), delta_tower_angle_trim.c); } - if ((!end_stops && tower_angles) || (end_stops && !tower_angles)) { // XOR + if (end_stops != tower_angles) SERIAL_ECHOPGM(" Radius:", delta_radius); - } + SERIAL_EOL(); } @@ -137,11 +135,11 @@ static void print_calibration_settings(const bool end_stops, const bool tower_an */ static void print_calibration_results(const float z_pt[NPP + 1], const bool tower_points, const bool opposite_points) { SERIAL_ECHOPGM(". "); - print_signed_float(PSTR("c"), z_pt[CEN]); + print_signed_float(F("c"), z_pt[CEN]); if (tower_points) { - print_signed_float(PSTR(" x"), z_pt[__A]); - print_signed_float(PSTR(" y"), z_pt[__B]); - print_signed_float(PSTR(" z"), z_pt[__C]); + print_signed_float(F(" x"), z_pt[__A]); + print_signed_float(F(" y"), z_pt[__B]); + print_signed_float(F(" z"), z_pt[__C]); } if (tower_points && opposite_points) { SERIAL_EOL(); @@ -149,9 +147,9 @@ static void print_calibration_results(const float z_pt[NPP + 1], const bool towe SERIAL_ECHO_SP(13); } if (opposite_points) { - print_signed_float(PSTR("yz"), z_pt[_BC]); - print_signed_float(PSTR("zx"), z_pt[_CA]); - print_signed_float(PSTR("xy"), z_pt[_AB]); + print_signed_float(F("yz"), z_pt[_BC]); + print_signed_float(F("zx"), z_pt[_CA]); + print_signed_float(F("xy"), z_pt[_AB]); } SERIAL_EOL(); } @@ -653,13 +651,13 @@ void GcodeSuite::G33() { } } else { // dry run - PGM_P const enddryrun = PSTR("End DRY-RUN"); - SERIAL_ECHOPGM_P(enddryrun); + FSTR_P const enddryrun = F("End DRY-RUN"); + SERIAL_ECHOF(enddryrun); SERIAL_ECHO_SP(35); SERIAL_ECHOLNPAIR_F("std dev:", zero_std_dev, 3); char mess[21]; - strcpy_P(mess, enddryrun); + strcpy_P(mess, FTOP(enddryrun)); strcpy_P(&mess[11], PSTR(" sd:")); if (zero_std_dev < 1) sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev * 1000.0f)); diff --git a/Marlin/src/gcode/calibrate/M100.cpp b/Marlin/src/gcode/calibrate/M100.cpp index 0e2d42907a..338392b597 100644 --- a/Marlin/src/gcode/calibrate/M100.cpp +++ b/Marlin/src/gcode/calibrate/M100.cpp @@ -51,7 +51,7 @@ * Also, there are two support functions that can be called from a developer's C code. * * uint16_t check_for_free_memory_corruption(PGM_P const free_memory_start); - * void M100_dump_routine(PGM_P const title, const char * const start, const uintptr_t size); + * void M100_dump_routine(FSTR_P const title, const char * const start, const uintptr_t size); * * Initial version by Roxy-3D */ @@ -182,8 +182,8 @@ inline int32_t count_test_bytes(const char * const start_free_memory) { } } - void M100_dump_routine(PGM_P const title, const char * const start, const uintptr_t size) { - SERIAL_ECHOLNPGM_P(title); + void M100_dump_routine(FSTR_P const title, const char * const start, const uintptr_t size) { + SERIAL_ECHOLNF(title); // // Round the start and end locations to produce full lines of output // @@ -196,8 +196,8 @@ inline int32_t count_test_bytes(const char * const start_free_memory) { #endif // M100_FREE_MEMORY_DUMPER -inline int check_for_free_memory_corruption(PGM_P const title) { - SERIAL_ECHOPGM_P(title); +inline int check_for_free_memory_corruption(FSTR_P const title) { + SERIAL_ECHOF(title); char *start_free_memory = free_memory_start, *end_free_memory = free_memory_end; int n = end_free_memory - start_free_memory; @@ -217,7 +217,7 @@ inline int check_for_free_memory_corruption(PGM_P const title) { // idle(); serial_delay(20); #if ENABLED(M100_FREE_MEMORY_DUMPER) - M100_dump_routine(PSTR(" Memory corruption detected with end_free_memory, M532 X L) - cap_line(PSTR("PROGRESS")); + cap_line(F("PROGRESS")); // Print Job timer M75, M76, M77 - cap_line(PSTR("PRINT_JOB"), true); + cap_line(F("PRINT_JOB"), true); // AUTOLEVEL (G29) - cap_line(PSTR("AUTOLEVEL"), ENABLED(HAS_AUTOLEVEL)); + cap_line(F("AUTOLEVEL"), ENABLED(HAS_AUTOLEVEL)); // RUNOUT (M412, M600) - cap_line(PSTR("RUNOUT"), ENABLED(FILAMENT_RUNOUT_SENSOR)); + cap_line(F("RUNOUT"), ENABLED(FILAMENT_RUNOUT_SENSOR)); // Z_PROBE (G30) - cap_line(PSTR("Z_PROBE"), ENABLED(HAS_BED_PROBE)); + cap_line(F("Z_PROBE"), ENABLED(HAS_BED_PROBE)); // MESH_REPORT (M420 V) - cap_line(PSTR("LEVELING_DATA"), ENABLED(HAS_LEVELING)); + cap_line(F("LEVELING_DATA"), ENABLED(HAS_LEVELING)); // BUILD_PERCENT (M73) - cap_line(PSTR("BUILD_PERCENT"), ENABLED(LCD_SET_PROGRESS_MANUALLY)); + cap_line(F("BUILD_PERCENT"), ENABLED(LCD_SET_PROGRESS_MANUALLY)); // SOFTWARE_POWER (M80, M81) - cap_line(PSTR("SOFTWARE_POWER"), ENABLED(PSU_CONTROL)); + cap_line(F("SOFTWARE_POWER"), ENABLED(PSU_CONTROL)); // TOGGLE_LIGHTS (M355) - cap_line(PSTR("TOGGLE_LIGHTS"), ENABLED(CASE_LIGHT_ENABLE)); - cap_line(PSTR("CASE_LIGHT_BRIGHTNESS"), TERN0(CASE_LIGHT_ENABLE, caselight.has_brightness())); + cap_line(F("TOGGLE_LIGHTS"), ENABLED(CASE_LIGHT_ENABLE)); + cap_line(F("CASE_LIGHT_BRIGHTNESS"), TERN0(CASE_LIGHT_ENABLE, caselight.has_brightness())); // EMERGENCY_PARSER (M108, M112, M410, M876) - cap_line(PSTR("EMERGENCY_PARSER"), ENABLED(EMERGENCY_PARSER)); + cap_line(F("EMERGENCY_PARSER"), ENABLED(EMERGENCY_PARSER)); // HOST ACTION COMMANDS (paused, resume, resumed, cancel, etc.) - cap_line(PSTR("HOST_ACTION_COMMANDS"), ENABLED(HOST_ACTION_COMMANDS)); + cap_line(F("HOST_ACTION_COMMANDS"), ENABLED(HOST_ACTION_COMMANDS)); // PROMPT SUPPORT (M876) - cap_line(PSTR("PROMPT_SUPPORT"), ENABLED(HOST_PROMPT_SUPPORT)); + cap_line(F("PROMPT_SUPPORT"), ENABLED(HOST_PROMPT_SUPPORT)); // SDCARD (M20, M23, M24, etc.) - cap_line(PSTR("SDCARD"), ENABLED(SDSUPPORT)); + cap_line(F("SDCARD"), ENABLED(SDSUPPORT)); // REPEAT (M808) - cap_line(PSTR("REPEAT"), ENABLED(GCODE_REPEAT_MARKERS)); + cap_line(F("REPEAT"), ENABLED(GCODE_REPEAT_MARKERS)); // SD_WRITE (M928, M28, M29) - cap_line(PSTR("SD_WRITE"), ENABLED(SDSUPPORT) && DISABLED(SDCARD_READONLY)); + cap_line(F("SD_WRITE"), ENABLED(SDSUPPORT) && DISABLED(SDCARD_READONLY)); // AUTOREPORT_SD_STATUS (M27 extension) - cap_line(PSTR("AUTOREPORT_SD_STATUS"), ENABLED(AUTO_REPORT_SD_STATUS)); + cap_line(F("AUTOREPORT_SD_STATUS"), ENABLED(AUTO_REPORT_SD_STATUS)); // LONG_FILENAME_HOST_SUPPORT (M33) - cap_line(PSTR("LONG_FILENAME"), ENABLED(LONG_FILENAME_HOST_SUPPORT)); + cap_line(F("LONG_FILENAME"), ENABLED(LONG_FILENAME_HOST_SUPPORT)); // THERMAL_PROTECTION - cap_line(PSTR("THERMAL_PROTECTION"), ENABLED(THERMALLY_SAFE)); + cap_line(F("THERMAL_PROTECTION"), ENABLED(THERMALLY_SAFE)); // MOTION_MODES (M80-M89) - cap_line(PSTR("MOTION_MODES"), ENABLED(GCODE_MOTION_MODES)); + cap_line(F("MOTION_MODES"), ENABLED(GCODE_MOTION_MODES)); // ARC_SUPPORT (G2-G3) - cap_line(PSTR("ARCS"), ENABLED(ARC_SUPPORT)); + cap_line(F("ARCS"), ENABLED(ARC_SUPPORT)); // BABYSTEPPING (M290) - cap_line(PSTR("BABYSTEPPING"), ENABLED(BABYSTEPPING)); + cap_line(F("BABYSTEPPING"), ENABLED(BABYSTEPPING)); // CHAMBER_TEMPERATURE (M141, M191) - cap_line(PSTR("CHAMBER_TEMPERATURE"), ENABLED(HAS_HEATED_CHAMBER)); + cap_line(F("CHAMBER_TEMPERATURE"), ENABLED(HAS_HEATED_CHAMBER)); // COOLER_TEMPERATURE (M143, M193) - cap_line(PSTR("COOLER_TEMPERATURE"), ENABLED(HAS_COOLER)); + cap_line(F("COOLER_TEMPERATURE"), ENABLED(HAS_COOLER)); // MEATPACK Compression - cap_line(PSTR("MEATPACK"), SERIAL_IMPL.has_feature(port, SerialFeature::MeatPack)); + cap_line(F("MEATPACK"), SERIAL_IMPL.has_feature(port, SerialFeature::MeatPack)); // Machine Geometry #if ENABLED(M115_GEOMETRY_REPORT) diff --git a/Marlin/src/gcode/host/M360.cpp b/Marlin/src/gcode/host/M360.cpp index 1830dea3bf..29b7ae602b 100644 --- a/Marlin/src/gcode/host/M360.cpp +++ b/Marlin/src/gcode/host/M360.cpp @@ -43,9 +43,15 @@ static void config_line(PGM_P const name, const float val, PGM_P const pref=null config_prefix(name, pref, ind); SERIAL_ECHOLN(val); } +static void config_line(FSTR_P const name, const float val, FSTR_P const pref=nullptr, const int8_t ind=-1) { + config_line(FTOP(name), val, FTOP(pref) , ind); +} static void config_line_e(const int8_t e, PGM_P const name, const float val) { config_line(name, val, PSTR("Extr."), e + 1); } +static void config_line_e(const int8_t e, FSTR_P const name, const float val) { + config_line_e(e, FTOP(name), val); +} /** * M360: Report Firmware configuration @@ -60,19 +66,19 @@ void GcodeSuite::M360() { // // Basics and Enabled items // - config_line(PSTR("Baudrate"), BAUDRATE); - config_line(PSTR("InputBuffer"), MAX_CMD_SIZE); - config_line(PSTR("PrintlineCache"), BUFSIZE); - config_line(PSTR("MixingExtruder"), ENABLED(MIXING_EXTRUDER)); - config_line(PSTR("SDCard"), ENABLED(SDSUPPORT)); - config_line(PSTR("Fan"), ENABLED(HAS_FAN)); - config_line(PSTR("LCD"), ENABLED(HAS_DISPLAY)); - config_line(PSTR("SoftwarePowerSwitch"), 1); - config_line(PSTR("SupportLocalFilamentchange"), ENABLED(ADVANCED_PAUSE_FEATURE)); - config_line(PSTR("CaseLights"), ENABLED(CASE_LIGHT_ENABLE)); - config_line(PSTR("ZProbe"), ENABLED(HAS_BED_PROBE)); - config_line(PSTR("Autolevel"), ENABLED(HAS_LEVELING)); - config_line(PSTR("EEPROM"), ENABLED(EEPROM_SETTINGS)); + config_line(F("Baudrate"), BAUDRATE); + config_line(F("InputBuffer"), MAX_CMD_SIZE); + config_line(F("PrintlineCache"), BUFSIZE); + config_line(F("MixingExtruder"), ENABLED(MIXING_EXTRUDER)); + config_line(F("SDCard"), ENABLED(SDSUPPORT)); + config_line(F("Fan"), ENABLED(HAS_FAN)); + config_line(F("LCD"), ENABLED(HAS_DISPLAY)); + config_line(F("SoftwarePowerSwitch"), 1); + config_line(F("SupportLocalFilamentchange"), ENABLED(ADVANCED_PAUSE_FEATURE)); + config_line(F("CaseLights"), ENABLED(CASE_LIGHT_ENABLE)); + config_line(F("ZProbe"), ENABLED(HAS_BED_PROBE)); + config_line(F("Autolevel"), ENABLED(HAS_LEVELING)); + config_line(F("EEPROM"), ENABLED(EEPROM_SETTINGS)); // // Homing Directions @@ -87,7 +93,7 @@ void GcodeSuite::M360() { // #if HAS_CLASSIC_JERK if (planner.max_jerk.x == planner.max_jerk.y) - config_line(PSTR("XY"), planner.max_jerk.x, JERK_STR); + config_line(F("XY"), planner.max_jerk.x, JERK_STR); else { config_line(X_STR, planner.max_jerk.x, JERK_STR); config_line(Y_STR, planner.max_jerk.y, JERK_STR); @@ -98,21 +104,21 @@ void GcodeSuite::M360() { // // Firmware Retraction // - config_line(PSTR("SupportG10G11"), ENABLED(FWRETRACT)); + config_line(F("SupportG10G11"), ENABLED(FWRETRACT)); #if ENABLED(FWRETRACT) PGMSTR(RET_STR, "Retraction"); PGMSTR(UNRET_STR, "RetractionUndo"); PGMSTR(SPEED_STR, "Speed"); // M10 Retract with swap (long) moves - config_line(PSTR("Length"), fwretract.settings.retract_length, RET_STR); + config_line(F("Length"), fwretract.settings.retract_length, RET_STR); config_line(SPEED_STR, fwretract.settings.retract_feedrate_mm_s, RET_STR); - config_line(PSTR("ZLift"), fwretract.settings.retract_zraise, RET_STR); - config_line(PSTR("LongLength"), fwretract.settings.swap_retract_length, RET_STR); + config_line(F("ZLift"), fwretract.settings.retract_zraise, RET_STR); + config_line(F("LongLength"), fwretract.settings.swap_retract_length, RET_STR); // M11 Recover (undo) with swap (long) moves config_line(SPEED_STR, fwretract.settings.retract_recover_feedrate_mm_s, UNRET_STR); - config_line(PSTR("ExtraLength"), fwretract.settings.retract_recover_extra, UNRET_STR); - config_line(PSTR("ExtraLongLength"), fwretract.settings.swap_retract_recover_extra, UNRET_STR); - config_line(PSTR("LongSpeed"), fwretract.settings.swap_retract_recover_feedrate_mm_s, UNRET_STR); + config_line(F("ExtraLength"), fwretract.settings.retract_recover_extra, UNRET_STR); + config_line(F("ExtraLongLength"), fwretract.settings.swap_retract_recover_extra, UNRET_STR); + config_line(F("LongSpeed"), fwretract.settings.swap_retract_recover_feedrate_mm_s, UNRET_STR); #endif // @@ -163,22 +169,22 @@ void GcodeSuite::M360() { // // Heated Bed // - config_line(PSTR("HeatedBed"), ENABLED(HAS_HEATED_BED)); + config_line(F("HeatedBed"), ENABLED(HAS_HEATED_BED)); #if HAS_HEATED_BED - config_line(PSTR("MaxBedTemp"), BED_MAX_TARGET); + config_line(F("MaxBedTemp"), BED_MAX_TARGET); #endif // // Per-Extruder settings // - config_line(PSTR("NumExtruder"), EXTRUDERS); + config_line(F("NumExtruder"), EXTRUDERS); #if HAS_EXTRUDERS LOOP_L_N(e, EXTRUDERS) { config_line_e(e, JERK_STR, TERN(HAS_LINEAR_E_JERK, planner.max_e_jerk[E_INDEX_N(e)], TERN(HAS_CLASSIC_JERK, planner.max_jerk.e, DEFAULT_EJERK))); - config_line_e(e, PSTR("MaxSpeed"), planner.settings.max_feedrate_mm_s[E_AXIS_N(e)]); - config_line_e(e, PSTR("Acceleration"), planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(e)]); - config_line_e(e, PSTR("Diameter"), TERN(NO_VOLUMETRICS, DEFAULT_NOMINAL_FILAMENT_DIA, planner.filament_size[e])); - config_line_e(e, PSTR("MaxTemp"), thermalManager.hotend_maxtemp[e]); + config_line_e(e, F("MaxSpeed"), planner.settings.max_feedrate_mm_s[E_AXIS_N(e)]); + config_line_e(e, F("Acceleration"), planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(e)]); + config_line_e(e, F("Diameter"), TERN(NO_VOLUMETRICS, DEFAULT_NOMINAL_FILAMENT_DIA, planner.filament_size[e])); + config_line_e(e, F("MaxTemp"), thermalManager.hotend_maxtemp[e]); } #endif } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 983833c025..ee4f5b9d3b 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -302,10 +302,10 @@ static bool serial_data_available(serial_index_t index) { inline int read_serial(const serial_index_t index) { return SERIAL_IMPL.read(index); } -void GCodeQueue::gcode_line_error(PGM_P const err, const serial_index_t serial_ind) { +void GCodeQueue::gcode_line_error(FSTR_P const ferr, const serial_index_t serial_ind) { PORT_REDIRECT(SERIAL_PORTMASK(serial_ind)); // Reply to the serial port that sent the command SERIAL_ERROR_START(); - SERIAL_ECHOLNPGM_P(err, serial_state[serial_ind.index].last_N); + SERIAL_ECHOLNF(ferr, serial_state[serial_ind.index].last_N); while (read_serial(serial_ind) != -1) { /* nada */ } // Clear out the RX buffer. Why don't use flush here ? flush_and_request_resend(serial_ind); serial_state[serial_ind.index].count = 0; @@ -470,7 +470,7 @@ void GCodeQueue::get_serial_commands() { if (gcode_N != serial.last_N + 1 && !M110) { // In case of error on a serial port, don't prevent other serial port from making progress - gcode_line_error(PSTR(STR_ERR_LINE_NO), p); + gcode_line_error(F(STR_ERR_LINE_NO), p); break; } @@ -480,13 +480,13 @@ void GCodeQueue::get_serial_commands() { while (count) checksum ^= command[--count]; if (strtol(apos + 1, nullptr, 10) != checksum) { // In case of error on a serial port, don't prevent other serial port from making progress - gcode_line_error(PSTR(STR_ERR_CHECKSUM_MISMATCH), p); + gcode_line_error(F(STR_ERR_CHECKSUM_MISMATCH), p); break; } } else { // In case of error on a serial port, don't prevent other serial port from making progress - gcode_line_error(PSTR(STR_ERR_NO_CHECKSUM), p); + gcode_line_error(F(STR_ERR_NO_CHECKSUM), p); break; } @@ -495,7 +495,7 @@ void GCodeQueue::get_serial_commands() { #if ENABLED(SDSUPPORT) // Pronterface "M29" and "M29 " has no line number else if (card.flag.saving && !is_M29(command)) { - gcode_line_error(PSTR(STR_ERR_NO_CHECKSUM), p); + gcode_line_error(F(STR_ERR_NO_CHECKSUM), p); break; } #endif diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 71a710b8cb..c5562da3aa 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -259,7 +259,7 @@ private: */ static bool enqueue_one(const char *cmd); - static void gcode_line_error(PGM_P const err, const serial_index_t serial_ind); + static void gcode_line_error(FSTR_P const ferr, const serial_index_t serial_ind); friend class GcodeSuite; }; diff --git a/Marlin/src/libs/stopwatch.cpp b/Marlin/src/libs/stopwatch.cpp index adfaa3b043..4178807951 100644 --- a/Marlin/src/libs/stopwatch.cpp +++ b/Marlin/src/libs/stopwatch.cpp @@ -34,7 +34,7 @@ millis_t Stopwatch::startTimestamp; millis_t Stopwatch::stopTimestamp; bool Stopwatch::stop() { - Stopwatch::debug(PSTR("stop")); + debug(F("stop")); if (isRunning() || isPaused()) { TERN_(EXTENSIBLE_UI, ExtUI::onPrintTimerStopped()); @@ -46,7 +46,7 @@ bool Stopwatch::stop() { } bool Stopwatch::pause() { - Stopwatch::debug(PSTR("pause")); + debug(F("pause")); if (isRunning()) { TERN_(EXTENSIBLE_UI, ExtUI::onPrintTimerPaused()); @@ -58,7 +58,7 @@ bool Stopwatch::pause() { } bool Stopwatch::start() { - Stopwatch::debug(PSTR("start")); + debug(F("start")); TERN_(EXTENSIBLE_UI, ExtUI::onPrintTimerStarted()); @@ -74,14 +74,14 @@ bool Stopwatch::start() { } void Stopwatch::resume(const millis_t with_time) { - Stopwatch::debug(PSTR("resume")); + debug(F("resume")); reset(); if ((accumulator = with_time)) state = RUNNING; } void Stopwatch::reset() { - Stopwatch::debug(PSTR("reset")); + debug(F("reset")); state = STOPPED; startTimestamp = 0; @@ -95,12 +95,8 @@ millis_t Stopwatch::duration() { #if ENABLED(DEBUG_STOPWATCH) - void Stopwatch::debug(const char func[]) { - if (DEBUGGING(INFO)) { - SERIAL_ECHOPGM("Stopwatch::"); - SERIAL_ECHOPGM_P(func); - SERIAL_ECHOLNPGM("()"); - } + void Stopwatch::debug(FSTR_P const func) { + if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::", func, "()"); } #endif diff --git a/Marlin/src/libs/stopwatch.h b/Marlin/src/libs/stopwatch.h index b64a36a90e..fe5101a5be 100644 --- a/Marlin/src/libs/stopwatch.h +++ b/Marlin/src/libs/stopwatch.h @@ -21,14 +21,11 @@ */ #pragma once +#include "../inc/MarlinConfig.h" + // Print debug messages with M111 S2 (Uses 156 bytes of PROGMEM) //#define DEBUG_STOPWATCH -#include "../core/macros.h" // for FORCE_INLINE - -#include -typedef uint32_t millis_t; - /** * @brief Stopwatch class * @details This class acts as a timer proving stopwatch functionality including @@ -113,11 +110,11 @@ class Stopwatch { * @brief Print a debug message * @details Print a simple debug message "Stopwatch::function" */ - static void debug(const char func[]); + static void debug(FSTR_P const); #else - static inline void debug(const char[]) {} + static inline void debug(FSTR_P const) {} #endif }; diff --git a/Marlin/src/libs/vector_3.cpp b/Marlin/src/libs/vector_3.cpp index 4db8fb5f2e..614d2121b8 100644 --- a/Marlin/src/libs/vector_3.cpp +++ b/Marlin/src/libs/vector_3.cpp @@ -75,8 +75,8 @@ void vector_3::apply_rotation(const matrix_3x3 &matrix) { matrix.vectors[0].z * _x + matrix.vectors[1].z * _y + matrix.vectors[2].z * _z }; } -void vector_3::debug(PGM_P const title) { - SERIAL_ECHOPGM_P(title); +void vector_3::debug(FSTR_P const title) { + SERIAL_ECHOF(title); SERIAL_ECHOPAIR_F_P(SP_X_STR, x, 6); SERIAL_ECHOPAIR_F_P(SP_Y_STR, y, 6); SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z, 6); @@ -100,14 +100,14 @@ void matrix_3x3::set_to_identity() { // Create a matrix from 3 vector_3 inputs matrix_3x3 matrix_3x3::create_from_rows(const vector_3 &row_0, const vector_3 &row_1, const vector_3 &row_2) { - //row_0.debug(PSTR("row_0")); - //row_1.debug(PSTR("row_1")); - //row_2.debug(PSTR("row_2")); + //row_0.debug(F("row_0")); + //row_1.debug(F("row_1")); + //row_2.debug(F("row_2")); matrix_3x3 new_matrix; new_matrix.vectors[0] = row_0; new_matrix.vectors[1] = row_1; new_matrix.vectors[2] = row_2; - //new_matrix.debug(PSTR("new_matrix")); + //new_matrix.debug(F("new_matrix")); return new_matrix; } @@ -117,14 +117,14 @@ matrix_3x3 matrix_3x3::create_look_at(const vector_3 &target) { x_row = vector_3(1, 0, -target.x / target.z).get_normal(), y_row = vector_3::cross(z_row, x_row).get_normal(); - // x_row.debug(PSTR("x_row")); - // y_row.debug(PSTR("y_row")); - // z_row.debug(PSTR("z_row")); + // x_row.debug(F("x_row")); + // y_row.debug(F("y_row")); + // z_row.debug(F("z_row")); // create the matrix already correctly transposed matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row); - // rot.debug(PSTR("rot")); + // rot.debug(F("rot")); return rot; } @@ -137,8 +137,8 @@ matrix_3x3 matrix_3x3::transpose(const matrix_3x3 &original) { return new_matrix; } -void matrix_3x3::debug(PGM_P const title) { - if (title) SERIAL_ECHOLNPGM_P(title); +void matrix_3x3::debug(FSTR_P const title) { + if (title) SERIAL_ECHOLNF(title); LOOP_L_N(i, 3) { LOOP_L_N(j, 3) { if (vectors[i][j] >= 0.0) SERIAL_CHAR('+'); diff --git a/Marlin/src/libs/vector_3.h b/Marlin/src/libs/vector_3.h index 5d99fcec20..f515333cc7 100644 --- a/Marlin/src/libs/vector_3.h +++ b/Marlin/src/libs/vector_3.h @@ -78,7 +78,7 @@ struct vector_3 { operator xy_float_t() { return xy_float_t({ x, y }); } operator xyz_float_t() { return xyz_float_t({ x, y, z }); } - void debug(PGM_P const title); + void debug(FSTR_P const title); }; struct matrix_3x3 { @@ -91,7 +91,7 @@ struct matrix_3x3 { void set_to_identity(); - void debug(PGM_P const title); + void debug(FSTR_P const title); void apply_rotation_xyz(float &x, float &y, float &z); }; diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index b5f270ee63..80e20a0778 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -483,10 +483,10 @@ void Endstops::event_handler() { #pragma GCC diagnostic ignored "-Wunused-function" #endif -static void print_es_state(const bool is_hit, PGM_P const label=nullptr) { - if (label) SERIAL_ECHOPGM_P(label); +static void print_es_state(const bool is_hit, FSTR_P const flabel=nullptr) { + if (flabel) SERIAL_ECHOF(flabel); SERIAL_ECHOPGM(": "); - SERIAL_ECHOLNPGM_P(is_hit ? PSTR(STR_ENDSTOP_HIT) : PSTR(STR_ENDSTOP_OPEN)); + SERIAL_ECHOLNF(is_hit ? F(STR_ENDSTOP_HIT) : F(STR_ENDSTOP_OPEN)); } #if GCC_VERSION <= 50000 @@ -496,7 +496,7 @@ static void print_es_state(const bool is_hit, PGM_P const label=nullptr) { void _O2 Endstops::report_states() { TERN_(BLTOUCH, bltouch._set_SW_mode()); SERIAL_ECHOLNPGM(STR_M119_REPORT); - #define ES_REPORT(S) print_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING, PSTR(STR_##S)) + #define ES_REPORT(S) print_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING, F(STR_##S)) #if HAS_X_MIN ES_REPORT(X_MIN); #endif @@ -564,10 +564,10 @@ void _O2 Endstops::report_states() { ES_REPORT(K_MAX); #endif #if BOTH(MARLIN_DEV_MODE, PROBE_ACTIVATION_SWITCH) - print_es_state(probe_switch_activated(), PSTR(STR_PROBE_EN)); + print_es_state(probe_switch_activated(), F(STR_PROBE_EN)); #endif #if USES_Z_MIN_PROBE_PIN - print_es_state(PROBE_TRIGGERED(), PSTR(STR_Z_PROBE)); + print_es_state(PROBE_TRIGGERED(), F(STR_Z_PROBE)); #endif #if MULTI_FILAMENT_SENSOR #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; state = FIL_RUNOUT##N##_STATE; break; @@ -584,7 +584,7 @@ void _O2 Endstops::report_states() { } #undef _CASE_RUNOUT #elif HAS_FILAMENT_SENSOR - print_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE, PSTR(STR_FILAMENT)); + print_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE, F(STR_FILAMENT)); #endif TERN_(BLTOUCH, bltouch._reset_SW_mode()); diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index b384342335..e5db7f7b54 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -178,7 +178,7 @@ static void print_input_or_output(const bool isout) { } // pretty report with PWM info -inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool extended=false, PGM_P const start_string=nullptr) { +inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool extended=false, FSTR_P const start_string=nullptr) { char buffer[MAX_NAME_LENGTH + 1]; // for the sprintf statements bool found = false, multi_name_pin = false; @@ -202,7 +202,7 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e LOOP_L_N(x, COUNT(pin_array)) { // scan entire array and report all instances of this pin if (GET_ARRAY_PIN(x) == pin) { if (!found) { // report digital and analog pin number only on the first time through - if (start_string) SERIAL_ECHOPGM_P(start_string); + if (start_string) SERIAL_ECHOF(start_string); SERIAL_ECHOPGM("PIN: "); PRINT_PIN(pin); PRINT_PORT(pin); @@ -211,7 +211,7 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e } else { SERIAL_CHAR('.'); - SERIAL_ECHO_SP(MULTI_NAME_PAD + (start_string ? strlen_P(start_string) : 0)); // add padding if not the first instance found + SERIAL_ECHO_SP(MULTI_NAME_PAD + (start_string ? strlen_P(FTOP(start_string)) : 0)); // add padding if not the first instance found } PRINT_ARRAY_NAME(x); if (extended) { @@ -250,7 +250,7 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e } // end of for loop if (!found) { - if (start_string) SERIAL_ECHOPGM_P(start_string); + if (start_string) SERIAL_ECHOF(start_string); SERIAL_ECHOPGM("PIN: "); PRINT_PIN(pin); PRINT_PORT(pin); From 492d70424d3819762ece7ecb4913e94e3cebf232 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 28 Sep 2021 19:28:29 -0500 Subject: [PATCH 016/546] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20F()=20to=20MKS?= =?UTF-8?q?=20UI=20errors,=20assets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lcd/extui/mks_ui/draw_error_message.cpp | 9 +- .../src/lcd/extui/mks_ui/draw_error_message.h | 2 +- Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp | 28 +- Marlin/src/lcd/extui/mks_ui/mks_hardware.h | 5 +- Marlin/src/lcd/extui/mks_ui/pic_manager.cpp | 268 +++++++++--------- 5 files changed, 159 insertions(+), 153 deletions(-) diff --git a/Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp b/Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp index 6955e1803d..bc15100153 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp @@ -33,11 +33,12 @@ static lv_obj_t *scr; -void lv_draw_error_message(PGM_P const msg) { +void lv_draw_error_message(FSTR_P const fmsg) { + FSTR_P fhalted = F("PRINTER HALTED"), fplease = F("Please Reset"); SPI_TFT.LCD_clear(0x0000); - if (msg) disp_string((TFT_WIDTH - strlen(msg) * 16) / 2, 100, msg, 0xFFFF, 0x0000); - disp_string((TFT_WIDTH - strlen("PRINTER HALTED") * 16) / 2, 140, "PRINTER HALTED", 0xFFFF, 0x0000); - disp_string((TFT_WIDTH - strlen("Please Reset") * 16) / 2, 180, "Please Reset", 0xFFFF, 0x0000); + if (fmsg) disp_string((TFT_WIDTH - strlen_P(FTOP(fmsg)) * 16) / 2, 100, fmsg, 0xFFFF, 0x0000); + disp_string((TFT_WIDTH - strlen_P(FTOP(fhalted)) * 16) / 2, 140, fhalted, 0xFFFF, 0x0000); + disp_string((TFT_WIDTH - strlen_P(FTOP(fplease)) * 16) / 2, 180, fplease, 0xFFFF, 0x0000); } void lv_clear_error_message() { lv_obj_del(scr); } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_error_message.h b/Marlin/src/lcd/extui/mks_ui/draw_error_message.h index 6999ecf5e4..8963e7f477 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_error_message.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_error_message.h @@ -29,7 +29,7 @@ #define PGM_P const char * #endif -void lv_draw_error_message(PGM_P const msg); +void lv_draw_error_message(FSTR_P const fmsg); void lv_clear_error_message(); #ifdef __cplusplus diff --git a/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp index 3bd04563ba..4305462162 100644 --- a/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp +++ b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp @@ -697,24 +697,28 @@ void disp_char_1624(uint16_t x, uint16_t y, uint8_t c, uint16_t charColor, uint1 } } -void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor, uint16_t bkColor) { - while (*string != '\0') { - disp_char_1624(x, y, *string, charColor, bkColor); - string++; - x += 16; - } +void disp_string(uint16_t x, uint16_t y, const char * cstr, uint16_t charColor, uint16_t bkColor) { + for (char c; (c = *cstr); cstr++, x += 16) + disp_char_1624(x, y, c, charColor, bkColor); +} + +void disp_string(uint16_t x, uint16_t y, FSTR_P const fstr, uint16_t charColor, uint16_t bkColor) { + PGM_P pstr = FTOP(fstr); + for (char c; (c = pgm_read_byte(pstr)); pstr++, x += 16) + disp_char_1624(x, y, c, charColor, bkColor); } void disp_assets_update() { SPI_TFT.LCD_clear(0x0000); - disp_string(100, 140, "Assets Updating...", 0xFFFF, 0x0000); + disp_string(100, 140, F("Assets Updating..."), 0xFFFF, 0x0000); } -void disp_assets_update_progress(const char *msg) { - char buf[30]; - memset(buf, ' ', COUNT(buf)); - strncpy(buf, msg, strlen(msg)); - buf[COUNT(buf) - 1] = '\0'; +void disp_assets_update_progress(FSTR_P const fmsg) { + static constexpr int buflen = 30; + char buf[buflen]; + memset(buf, ' ', buflen); + strncpy_P(buf, FTOP(fmsg), buflen - 1); + buf[buflen - 1] = '\0'; disp_string(100, 165, buf, 0xFFFF, 0x0000); } diff --git a/Marlin/src/lcd/extui/mks_ui/mks_hardware.h b/Marlin/src/lcd/extui/mks_ui/mks_hardware.h index 5313265662..c0cdacd963 100644 --- a/Marlin/src/lcd/extui/mks_ui/mks_hardware.h +++ b/Marlin/src/lcd/extui/mks_ui/mks_hardware.h @@ -36,6 +36,7 @@ #endif // String display and assets -void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor, uint16_t bkColor); +void disp_string(uint16_t x, uint16_t y, const char * cstr, uint16_t charColor, uint16_t bkColor); +void disp_string(uint16_t x, uint16_t y, FSTR_P const fstr, uint16_t charColor, uint16_t bkColor); void disp_assets_update(); -void disp_assets_update_progress(const char *msg); +void disp_assets_update_progress(FSTR_P const msg); diff --git a/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp b/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp index 8333709074..ba2df10ecb 100644 --- a/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp +++ b/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp @@ -40,186 +40,186 @@ extern uint16_t DeviceCode; extern char *createFilename(char * const buffer, const dir_t &p); #endif -static const char assets[][LONG_FILENAME_LENGTH] = { +static FSTR_P const assets[] = { // Homing screen - "bmp_zeroAll.bin", - "bmp_zero.bin", - "bmp_zeroX.bin", - "bmp_zeroY.bin", - "bmp_zeroZ.bin", - "bmp_manual_off.bin", + F("bmp_zeroAll.bin"), + F("bmp_zero.bin"), + F("bmp_zeroX.bin"), + F("bmp_zeroY.bin"), + F("bmp_zeroZ.bin"), + F("bmp_manual_off.bin"), // Tool screen - "bmp_preHeat.bin", - "bmp_extruct.bin", - "bmp_mov.bin", - "bmp_leveling.bin", - "bmp_filamentchange.bin", - "bmp_more.bin", + F("bmp_preHeat.bin"), + F("bmp_extruct.bin"), + F("bmp_mov.bin"), + F("bmp_leveling.bin"), + F("bmp_filamentchange.bin"), + F("bmp_more.bin"), // Fan screen - "bmp_Add.bin", - "bmp_Dec.bin", - "bmp_speed255.bin", - "bmp_speed127.bin", - "bmp_speed0.bin", + F("bmp_Add.bin"), + F("bmp_Dec.bin"), + F("bmp_speed255.bin"), + F("bmp_speed127.bin"), + F("bmp_speed0.bin"), - "bmp_bed.bin", - "bmp_step1_degree.bin", - "bmp_step5_degree.bin", - "bmp_step10_degree.bin", + F("bmp_bed.bin"), + F("bmp_step1_degree.bin"), + F("bmp_step5_degree.bin"), + F("bmp_step10_degree.bin"), // Extrusion screen - "bmp_in.bin", - "bmp_out.bin", - "bmp_extru1.bin", + F("bmp_in.bin"), + F("bmp_out.bin"), + F("bmp_extru1.bin"), #if HAS_MULTI_EXTRUDER - "bmp_extru2.bin", + F("bmp_extru2.bin"), #endif - "bmp_speed_high.bin", - "bmp_speed_slow.bin", - "bmp_speed_normal.bin", - "bmp_step1_mm.bin", - "bmp_step5_mm.bin", - "bmp_step10_mm.bin", + F("bmp_speed_high.bin"), + F("bmp_speed_slow.bin"), + F("bmp_speed_normal.bin"), + F("bmp_step1_mm.bin"), + F("bmp_step5_mm.bin"), + F("bmp_step10_mm.bin"), // Select file screen - "bmp_pageUp.bin", - "bmp_pageDown.bin", - "bmp_back.bin", //TODO: why two back buttons? Why not just one? (return / back) - "bmp_dir.bin", - "bmp_file.bin", + F("bmp_pageUp.bin"), + F("bmp_pageDown.bin"), + F("bmp_back.bin"), // TODO: why two back buttons? Why not just one? (return / back) + F("bmp_dir.bin"), + F("bmp_file.bin"), // Move motor screen // TODO: 6 equal icons, just in diffenct rotation... it may be optimized too - "bmp_xAdd.bin", - "bmp_xDec.bin", - "bmp_yAdd.bin", - "bmp_yDec.bin", - "bmp_zAdd.bin", - "bmp_zDec.bin", - "bmp_step_move0_1.bin", - "bmp_step_move1.bin", - "bmp_step_move10.bin", + F("bmp_xAdd.bin"), + F("bmp_xDec.bin"), + F("bmp_yAdd.bin"), + F("bmp_yDec.bin"), + F("bmp_zAdd.bin"), + F("bmp_zDec.bin"), + F("bmp_step_move0_1.bin"), + F("bmp_step_move1.bin"), + F("bmp_step_move10.bin"), // Operation screen - "bmp_auto_off.bin", - "bmp_speed.bin", - "bmp_fan.bin", - "bmp_temp.bin", - "bmp_extrude_opr.bin", - "bmp_move_opr.bin", + F("bmp_auto_off.bin"), + F("bmp_speed.bin"), + F("bmp_fan.bin"), + F("bmp_temp.bin"), + F("bmp_extrude_opr.bin"), + F("bmp_move_opr.bin"), // Change speed screen - "bmp_step1_percent.bin", - "bmp_step5_percent.bin", - "bmp_step10_percent.bin", - "bmp_extruct_sel.bin", - "bmp_mov_changespeed.bin", - "bmp_mov_sel.bin", - "bmp_speed_extruct.bin", + F("bmp_step1_percent.bin"), + F("bmp_step5_percent.bin"), + F("bmp_step10_percent.bin"), + F("bmp_extruct_sel.bin"), + F("bmp_mov_changespeed.bin"), + F("bmp_mov_sel.bin"), + F("bmp_speed_extruct.bin"), // Printing screen - "bmp_pause.bin", - "bmp_resume.bin", - "bmp_stop.bin", - "bmp_ext1_state.bin", + F("bmp_pause.bin"), + F("bmp_resume.bin"), + F("bmp_stop.bin"), + F("bmp_ext1_state.bin"), #if HAS_MULTI_EXTRUDER - "bmp_ext2_state.bin", + F("bmp_ext2_state.bin"), #endif - "bmp_bed_state.bin", - "bmp_fan_state.bin", - "bmp_time_state.bin", - "bmp_zpos_state.bin", - "bmp_operate.bin", + F("bmp_bed_state.bin"), + F("bmp_fan_state.bin"), + F("bmp_time_state.bin"), + F("bmp_zpos_state.bin"), + F("bmp_operate.bin"), // Manual Level screen (only if auto level is disabled) #if DISABLED(AUTO_BED_LEVELING_BILINEAR) - "bmp_leveling1.bin", - "bmp_leveling2.bin", - "bmp_leveling3.bin", - "bmp_leveling4.bin", - "bmp_leveling5.bin", + F("bmp_leveling1.bin"), + F("bmp_leveling2.bin"), + F("bmp_leveling3.bin"), + F("bmp_leveling4.bin"), + F("bmp_leveling5.bin"), #endif // Language Select screen #if HAS_LANG_SELECT_SCREEN - "bmp_language.bin", - "bmp_simplified_cn.bin", - "bmp_simplified_cn_sel.bin", - "bmp_traditional_cn.bin", - "bmp_traditional_cn_sel.bin", - "bmp_english.bin", - "bmp_english_sel.bin", - "bmp_russian.bin", - "bmp_russian_sel.bin", - "bmp_spanish.bin", - "bmp_spanish_sel.bin", - "bmp_french.bin", - "bmp_french_sel.bin", - "bmp_italy.bin", - "bmp_italy_sel.bin", + F("bmp_language.bin"), + F("bmp_simplified_cn.bin"), + F("bmp_simplified_cn_sel.bin"), + F("bmp_traditional_cn.bin"), + F("bmp_traditional_cn_sel.bin"), + F("bmp_english.bin"), + F("bmp_english_sel.bin"), + F("bmp_russian.bin"), + F("bmp_russian_sel.bin"), + F("bmp_spanish.bin"), + F("bmp_spanish_sel.bin"), + F("bmp_french.bin"), + F("bmp_french_sel.bin"), + F("bmp_italy.bin"), + F("bmp_italy_sel.bin"), #endif // HAS_LANG_SELECT_SCREEN // G-code preview #if HAS_GCODE_DEFAULT_VIEW_IN_FLASH - "bmp_preview.bin", + F("bmp_preview.bin"), #endif #if HAS_LOGO_IN_FLASH - "bmp_logo.bin", + F("bmp_logo.bin"), #endif // Settings screen - "bmp_about.bin", - "bmp_eeprom_settings.bin", - "bmp_machine_para.bin", - "bmp_function1.bin", + F("bmp_about.bin"), + F("bmp_eeprom_settings.bin"), + F("bmp_machine_para.bin"), + F("bmp_function1.bin"), // Start screen - "bmp_printing.bin", - "bmp_set.bin", - "bmp_tool.bin", + F("bmp_printing.bin"), + F("bmp_set.bin"), + F("bmp_tool.bin"), // Base icons - "bmp_arrow.bin", - "bmp_back70x40.bin", - "bmp_value_blank.bin", - "bmp_blank_sel.bin", - "bmp_disable.bin", - "bmp_enable.bin", - "bmp_return.bin", + F("bmp_arrow.bin"), + F("bmp_back70x40.bin"), + F("bmp_value_blank.bin"), + F("bmp_blank_sel.bin"), + F("bmp_disable.bin"), + F("bmp_enable.bin"), + F("bmp_return.bin"), #if ENABLED(MKS_WIFI_MODULE) // Wifi screen - "bmp_wifi.bin", - "bmp_cloud.bin", + F("bmp_wifi.bin"), + F("bmp_cloud.bin"), #endif #if ENABLED(MULTI_VOLUME) - "bmp_usb_disk.bin", - // "bmp_usb_disk_sel.bin", - "bmp_sd.bin", - // "bmp_sd_sel.bin", + F("bmp_usb_disk.bin"), + //F("bmp_usb_disk_sel.bin"), + F("bmp_sd.bin"), + //F("bmp_sd_sel.bin"), #endif // Babystep screen - "bmp_baby_move0_01.bin", - "bmp_baby_move0_05.bin", - "bmp_baby_move0_1.bin", + F("bmp_baby_move0_01.bin"), + F("bmp_baby_move0_05.bin"), + F("bmp_baby_move0_1.bin"), // More screen - "bmp_custom1.bin", - "bmp_custom2.bin", - "bmp_custom3.bin", - "bmp_custom4.bin", - "bmp_custom5.bin", - "bmp_custom6.bin", - "bmp_custom7.bin" + F("bmp_custom1.bin"), + F("bmp_custom2.bin"), + F("bmp_custom3.bin"), + F("bmp_custom4.bin"), + F("bmp_custom5.bin"), + F("bmp_custom6.bin"), + F("bmp_custom7.bin") }; #if HAS_SPI_FLASH_FONT - static char fonts[][LONG_FILENAME_LENGTH] = { "FontUNIGBK.bin" }; + static FSTR_P const fonts[] = { F("FontUNIGBK.bin") }; #endif uint8_t currentFlashPage = 0; @@ -386,9 +386,9 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { longName[j] = '\0'; } - static int8_t arrayFindStr(const char arr[][LONG_FILENAME_LENGTH], uint8_t arraySize, const char *str) { + static int8_t arrayFindStr(FSTR_P const arr[], uint8_t arraySize, const char *str) { for (uint8_t a = 0; a < arraySize; a++) { - if (strcasecmp(arr[a], str) == 0) + if (strcasecmp(FTOP(arr[a]), str) == 0) return a; } return -1; @@ -403,7 +403,7 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { #define ASSET_TYPE_TITLE_LOGO 2 #define ASSET_TYPE_G_PREVIEW 3 #define ASSET_TYPE_FONT 4 - static void loadAsset(SdFile &dir, dir_t& entry, const char *fn, int8_t assetType) { + static void loadAsset(SdFile &dir, dir_t& entry, FSTR_P const fn, int8_t assetType) { SdFile file; char dosFilename[FILENAME_LENGTH]; createFilename(dosFilename, entry); @@ -429,14 +429,14 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { do { watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); - Pic_Logo_Write((uint8_t *)fn, public_buf, pbr); + Pic_Logo_Write((uint8_t*)fn, public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); } else if (assetType == ASSET_TYPE_TITLE_LOGO) { do { watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); - Pic_TitleLogo_Write((uint8_t *)fn, public_buf, pbr); + Pic_TitleLogo_Write((uint8_t*)fn, public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); } else if (assetType == ASSET_TYPE_G_PREVIEW) { @@ -447,7 +447,7 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { } while (pbr >= BMP_WRITE_BUF_LEN); } else if (assetType == ASSET_TYPE_ICON) { - Pic_Write_Addr = Pic_Info_Write((uint8_t *)fn, pfileSize); + Pic_Write_Addr = Pic_Info_Write((uint8_t*)fn, pfileSize); SPIFlash.beginWrite(Pic_Write_Addr); #if HAS_SPI_FLASH_COMPRESSION do { @@ -492,16 +492,16 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { if (dir.open(&root, assetsPath, O_RDONLY)) { disp_assets_update(); - disp_assets_update_progress("Erasing pics..."); + disp_assets_update_progress(F("Erasing pics...")); watchdog_refresh(); spiFlashErase_PIC(); #if HAS_SPI_FLASH_FONT - disp_assets_update_progress("Erasing fonts..."); + disp_assets_update_progress(F("Erasing fonts...")); watchdog_refresh(); spiFlashErase_FONT(); #endif - disp_assets_update_progress("Reading files..."); + disp_assets_update_progress(F("Reading files...")); dir_t d; while (dir.readDir(&d, card.longFilename) > 0) { // If we don't get a long name, but gets a short one, try it @@ -513,11 +513,11 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { int8_t a = arrayFindStr(assets, COUNT(assets), card.longFilename); if (a >= 0 && a < (int8_t)COUNT(assets)) { uint8_t assetType = ASSET_TYPE_ICON; - if (strstr(assets[a], "_logo")) + if (strstr_P(FTOP(assets[a]), PSTR("_logo"))) assetType = ASSET_TYPE_LOGO; - else if (strstr(assets[a], "_titlelogo")) + else if (strstr_P(FTOP(assets[a]), PSTR("_titlelogo"))) assetType = ASSET_TYPE_TITLE_LOGO; - else if (strstr(assets[a], "_preview")) + else if (strstr_P(FTOP(assets[a]), PSTR("_preview"))) assetType = ASSET_TYPE_G_PREVIEW; loadAsset(dir, d, assets[a], assetType); From 3d102a77ca475c2dc6461152ecc445247b9bfd26 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 28 Sep 2021 20:15:52 -0500 Subject: [PATCH 017/546] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20F()=20to=20kill?= =?UTF-8?q?=20/=20sendinfoscreen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 6 +-- Marlin/src/MarlinCore.h | 2 +- Marlin/src/feature/direct_stepping.cpp | 2 +- Marlin/src/feature/encoder_i2c.cpp | 2 +- Marlin/src/feature/mmu/mmu2.cpp | 2 +- Marlin/src/feature/pause.cpp | 2 +- Marlin/src/feature/powerloss.cpp | 2 +- Marlin/src/feature/tmc_util.cpp | 2 +- Marlin/src/gcode/control/M108_M112_M410.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/gcode_d.cpp | 2 +- Marlin/src/gcode/host/M16.cpp | 2 +- Marlin/src/gcode/lcd/M0_M1.cpp | 2 +- Marlin/src/gcode/queue.cpp | 2 +- Marlin/src/lcd/e3v2/enhanced/dwin.cpp | 2 +- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 2 +- .../extui/anycubic_chiron/chiron_extui.cpp | 4 +- .../lcd/extui/anycubic_chiron/chiron_tft.cpp | 2 +- .../lcd/extui/anycubic_chiron/chiron_tft.h | 2 +- .../extui/anycubic_i3mega/anycubic_extui.cpp | 2 +- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 2 +- .../src/lcd/extui/dgus/DGUSScreenHandler.cpp | 4 +- Marlin/src/lcd/extui/dgus/dgus_extui.cpp | 6 +-- .../lcd/extui/dgus/fysetc/DGUSScreenHandler.h | 6 +++ .../extui/dgus/hiprecy/DGUSScreenHandler.h | 6 +++ .../lcd/extui/dgus/mks/DGUSScreenHandler.cpp | 4 +- .../lcd/extui/dgus/mks/DGUSScreenHandler.h | 6 +++ .../lcd/extui/dgus/origin/DGUSScreenHandler.h | 6 +++ .../extui/dgus_reloaded/DGUSScreenHandler.cpp | 6 +-- .../extui/dgus_reloaded/DGUSScreenHandler.h | 2 +- .../dgus_reloaded/dgus_reloaded_extui.cpp | 2 +- Marlin/src/lcd/extui/example/example.cpp | 2 +- .../ftdi_eve_touch_ui/ftdi_eve_extui.cpp | 6 +-- Marlin/src/lcd/extui/malyan/malyan.cpp | 41 ++++++++------- Marlin/src/lcd/extui/malyan/malyan.h | 6 +-- Marlin/src/lcd/extui/malyan/malyan_extui.cpp | 24 ++++----- Marlin/src/lcd/extui/mks_ui/wifi_module.cpp | 2 +- .../src/lcd/extui/nextion/nextion_extui.cpp | 2 +- Marlin/src/lcd/extui/nextion/nextion_tft.cpp | 10 ++-- .../src/lcd/extui/nextion/nextion_tft_defs.h | 4 +- Marlin/src/lcd/extui/ui_api.cpp | 3 +- Marlin/src/lcd/extui/ui_api.h | 2 +- Marlin/src/lcd/marlinui.cpp | 4 +- Marlin/src/lcd/marlinui.h | 4 +- Marlin/src/module/endstops.cpp | 2 +- Marlin/src/module/motion.cpp | 2 +- Marlin/src/module/planner.cpp | 2 +- Marlin/src/module/probe.cpp | 2 +- Marlin/src/module/temperature.cpp | 52 +++++++++---------- Marlin/src/module/temperature.h | 2 +- Marlin/src/module/tool_change.cpp | 2 +- Marlin/src/sd/cardreader.cpp | 2 +- 52 files changed, 149 insertions(+), 123 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 8a15c45f83..346c5f8f2c 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -852,16 +852,16 @@ void idle(bool no_stepper_sleep/*=false*/) { * Kill all activity and lock the machine. * After this the machine will need to be reset. */ -void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) { +void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) { thermalManager.disable_all_heaters(); TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control // Echo the LCD message to serial for extra context - if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNPGM_P(lcd_error); } + if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNF(lcd_error); } #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) - ui.kill_screen(lcd_error ?: GET_TEXT(MSG_KILLED), lcd_component ?: NUL_STR); + ui.kill_screen(lcd_error ?: GET_TEXT_F(MSG_KILLED), lcd_component ?: FPSTR(NUL_STR)); #else UNUSED(lcd_error); UNUSED(lcd_component); #endif diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index c3698d616d..7063c7e2de 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -38,7 +38,7 @@ inline void idle_no_sleep() { idle(true); } extern bool G38_did_trigger; // Flag from the ISR to indicate the endstop changed #endif -void kill(PGM_P const lcd_error=nullptr, PGM_P const lcd_component=nullptr, const bool steppers_off=false); +void kill(FSTR_P const lcd_error=nullptr, FSTR_P const lcd_component=nullptr, const bool steppers_off=false); void minkill(const bool steppers_off=false); // Global State of the firmware diff --git a/Marlin/src/feature/direct_stepping.cpp b/Marlin/src/feature/direct_stepping.cpp index ce979145a1..b8ef04fcd9 100644 --- a/Marlin/src/feature/direct_stepping.cpp +++ b/Marlin/src/feature/direct_stepping.cpp @@ -174,7 +174,7 @@ namespace DirectStepping { template void SerialPageManager::write_responses() { if (fatal_error) { - kill(GET_TEXT(MSG_BAD_PAGE)); + kill(GET_TEXT_F(MSG_BAD_PAGE)); return; } diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index f843011b5d..87e611f86c 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -153,7 +153,7 @@ void I2CPositionEncoder::update() { #ifdef I2CPE_ERR_THRESH_ABORT if (ABS(error) > I2CPE_ERR_THRESH_ABORT * planner.settings.axis_steps_per_mm[encoderAxis]) { - //kill(PSTR("Significant Error")); + //kill(F("Significant Error")); SERIAL_ECHOLNPGM("Axis error over threshold, aborting!", error); safe_delay(5000); } diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index b2835dc3ce..56e6e6150b 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -448,7 +448,7 @@ bool MMU2::rx_ok() { void MMU2::check_version() { if (buildnr < MMU_REQUIRED_FW_BUILDNR) { SERIAL_ERROR_MSG("Invalid MMU2 firmware. Version >= " STRINGIFY(MMU_REQUIRED_FW_BUILDNR) " required."); - kill(GET_TEXT(MSG_KILL_MMU2_FIRMWARE)); + kill(GET_TEXT_F(MSG_KILL_MMU2_FIRMWARE)); } } diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 8a35a87eeb..643c4ef9fc 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -254,7 +254,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE))); TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE), FPSTR(CONTINUE_STR))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT(MSG_FILAMENT_CHANGE_PURGE), CONTINUE_STR)); + TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE), FPSTR(CONTINUE_STR))); wait_for_user = true; // A click or M108 breaks the purge_length loop for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count) unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE); diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index bc19c9b18e..723ec1903b 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -301,7 +301,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW retract_and_lift(zraise); #endif - kill(GET_TEXT(MSG_OUTAGE_RECOVERY)); + kill(GET_TEXT_F(MSG_OUTAGE_RECOVERY)); } #endif diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index c11d2e5f6d..82c10e6e8e 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -212,7 +212,7 @@ if (data.is_ot) SERIAL_ECHOLNPGM("overtemperature"); if (data.is_s2g) SERIAL_ECHOLNPGM("coil short circuit"); TERN_(TMC_DEBUG, tmc_report_all()); - kill(PSTR("Driver error")); + kill(F("Driver error")); } #endif diff --git a/Marlin/src/gcode/control/M108_M112_M410.cpp b/Marlin/src/gcode/control/M108_M112_M410.cpp index 309c806c8f..39f9c04e19 100644 --- a/Marlin/src/gcode/control/M108_M112_M410.cpp +++ b/Marlin/src/gcode/control/M108_M112_M410.cpp @@ -40,7 +40,7 @@ void GcodeSuite::M108() { * M112: Full Shutdown */ void GcodeSuite::M112() { - kill(M112_KILL_STR, nullptr, true); + kill(FPSTR(M112_KILL_STR), nullptr, true); } /** diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 79f53a8e77..40c21a19f3 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -262,7 +262,7 @@ void GcodeSuite::dwell(millis_t time) { #ifdef ACTION_ON_CANCEL host_action_cancel(); #endif - kill(GET_TEXT(MSG_LCD_PROBING_FAILED)); + kill(GET_TEXT_F(MSG_LCD_PROBING_FAILED)); #endif } diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 83646ef67c..204455e65e 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -58,7 +58,7 @@ void GcodeSuite::D(const int16_t dcode) { break; case 10: - kill(PSTR("D10"), PSTR("KILL TEST"), parser.seen_test('P')); + kill(F("D10"), F("KILL TEST"), parser.seen_test('P')); break; case 1: { diff --git a/Marlin/src/gcode/host/M16.cpp b/Marlin/src/gcode/host/M16.cpp index 1ac8580396..03e734daaa 100644 --- a/Marlin/src/gcode/host/M16.cpp +++ b/Marlin/src/gcode/host/M16.cpp @@ -33,7 +33,7 @@ void GcodeSuite::M16() { if (strcmp_P(parser.string_arg, PSTR(MACHINE_NAME))) - kill(GET_TEXT(MSG_KILL_EXPECTED_PRINTER)); + kill(GET_TEXT_F(MSG_KILL_EXPECTED_PRINTER)); } diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 17481f0198..239366fec8 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -67,7 +67,7 @@ void GcodeSuite::M0_M1() { #elif ENABLED(EXTENSIBLE_UI) if (parser.string_arg) - ExtUI::onUserConfirmRequired(parser.string_arg); // Can this take an SRAM string?? + ExtUI::onUserConfirmRequired(parser.string_arg); // String in an SRAM buffer else ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_USERWAIT)); #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index ee4f5b9d3b..b36205d622 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -523,7 +523,7 @@ void GCodeQueue::get_serial_commands() { // Process critical commands early if (command[0] == 'M') switch (command[3]) { case '8': if (command[2] == '0' && command[1] == '1') { wait_for_heatup = false; TERN_(HAS_LCD_MENU, wait_for_user = false); } break; - case '2': if (command[2] == '1' && command[1] == '1') kill(M112_KILL_STR, nullptr, true); break; + case '2': if (command[2] == '1' && command[1] == '1') kill(FPSTR(M112_KILL_STR), nullptr, true); break; case '0': if (command[1] == '4' && command[2] == '1') quickstop_stepper(); break; } #endif diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp b/Marlin/src/lcd/e3v2/enhanced/dwin.cpp index 064ebbd47d..b13a5abfda 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp +++ b/Marlin/src/lcd/e3v2/enhanced/dwin.cpp @@ -1852,7 +1852,7 @@ void DWIN_LoadSettings(const char *buff) { feedrate_percentage = 100; } -void MarlinUI::kill_screen(PGM_P lcd_error, PGM_P lcd_component) { +void MarlinUI::kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component) { DWIN_Draw_Popup(ICON_BLTouch, lcd_error, lcd_component); DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index ddf7b6dcd4..754f8bafaf 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -949,7 +949,7 @@ void CrealityDWINClass::Draw_Popup(FSTR_P const line1, FSTR_P const line2, FSTR_ } } -void MarlinUI::kill_screen(PGM_P const error, PGM_P const component) { +void MarlinUI::kill_screen(FSTR_P const error, FSTR_P const) { CrealityDWIN.Draw_Popup(F("Printer Kill Reason:"), error, F("Restart Required"), Wait, ICON_BLTouch); } diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp index 5cd0922800..7a58963c11 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp @@ -41,8 +41,8 @@ namespace ExtUI { void onIdle() { Chiron.IdleLoop(); } - void onPrinterKilled(PGM_P const error, PGM_P const component) { - Chiron.PrinterKilled(error,component); + void onPrinterKilled(FSTR_P const error, FSTR_P const component) { + Chiron.PrinterKilled(error, component); } void onMediaInserted() { Chiron.MediaEvent(AC_media_inserted); } diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index 483da200e8..c3fc6aa96e 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -126,7 +126,7 @@ void ChironTFT::IdleLoop() { CheckHeaters(); } -void ChironTFT::PrinterKilled(PGM_P error,PGM_P component) { +void ChironTFT::PrinterKilled(FSTR_P const error, FSTR_P const component) { SendtoTFTLN(AC_msg_kill_lcd); #if ACDEBUG(AC_MARLIN) SERIAL_ECHOLNPGM("PrinterKilled()\nerror: ", error , "\ncomponent: ", component); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h index a80763e372..44ba02dc5d 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h @@ -59,7 +59,7 @@ class ChironTFT { public: static void Startup(); static void IdleLoop(); - static void PrinterKilled(PGM_P, PGM_P); + static void PrinterKilled(FSTR_P, FSTR_P); static void MediaEvent(media_event_t); static void TimerEvent(timer_event_t); static void FilamentRunout(); diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp index 33e7e84a81..c0e1b44578 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp @@ -37,7 +37,7 @@ namespace ExtUI { void onStartup() { AnycubicTFT.OnSetup(); } void onIdle() { AnycubicTFT.OnCommandScan(); } - void onPrinterKilled(PGM_P const error, PGM_P const component) { AnycubicTFT.OnKillTFT(); } + void onPrinterKilled(FSTR_P const error, FSTR_P const component) { AnycubicTFT.OnKillTFT(); } void onMediaInserted() { AnycubicTFT.OnSDCardStateChange(true); } void onMediaError() { AnycubicTFT.OnSDCardError(); } void onMediaRemoved() { AnycubicTFT.OnSDCardStateChange(false); } diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp index 5bbcfd0b5e..98534ba65f 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -654,7 +654,7 @@ void AnycubicTFTClass::GetCommandFromTFT() { break; case 12: // A12 kill - kill(PSTR(STR_ERR_KILLED)); + kill(F(STR_ERR_KILLED)); break; case 13: // A13 SELECTION FILE diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp index 06b350ff77..c9e7268f04 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp @@ -340,7 +340,7 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) void DGUSScreenHandler::SDCardError() { DGUSScreenHandler::SDCardRemoved(); - sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("SD card error"), nullptr, true, true, true, true); + sendinfoscreen(F("NOTICE"), nullptr, F("SD card error"), nullptr, true, true, true, true); SetupConfirmAction(nullptr); GotoScreen(DGUSLCD_SCREEN_POPUP); } @@ -567,7 +567,7 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo if (buf[0]) queue.enqueue_one_now(buf); #if ENABLED(DGUS_UI_WAITING) - sendinfoscreen(PSTR("PID is autotuning"), PSTR("please wait"), NUL_STR, NUL_STR, true, true, true, true); + sendinfoscreen(F("PID is autotuning"), F("please wait"), NUL_STR, NUL_STR, true, true, true, true); GotoScreen(DGUSLCD_SCREEN_WAITING); #endif } diff --git a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp index 4f15827a49..04ba6b95c2 100644 --- a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp +++ b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp @@ -42,8 +42,8 @@ namespace ExtUI { void onIdle() { ScreenHandler.loop(); } - void onPrinterKilled(PGM_P const error, PGM_P const component) { - ScreenHandler.sendinfoscreen(GET_TEXT(MSG_HALTED), error, NUL_STR, GET_TEXT(MSG_PLEASE_RESET), true, true, true, true); + void onPrinterKilled(FSTR_P const error, FSTR_P const) { + ScreenHandler.sendinfoscreen(GET_TEXT_F(MSG_HALTED), error, FPSTR(NUL_STR), GET_TEXT_F(MSG_PLEASE_RESET), true, true, true, true); ScreenHandler.GotoScreen(DGUSLCD_SCREEN_KILL); while (!ScreenHandler.loop()); // Wait while anything is left to be sent } @@ -60,7 +60,7 @@ namespace ExtUI { void onUserConfirmRequired(const char * const msg) { if (msg) { - ScreenHandler.sendinfoscreen(PSTR("Please confirm."), nullptr, msg, nullptr, true, true, false, true); + ScreenHandler.sendinfoscreen(F("Please confirm."), nullptr, msg, nullptr, true, true, false, true); ScreenHandler.SetupConfirmAction(setUserConfirmed); ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP); } diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h index ee0af013a8..bb0bd2bd3b 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h @@ -38,6 +38,12 @@ public: // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifying whether the strings are in RAM or FLASH. static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); + } + static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); + } static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h index ee0af013a8..bb0bd2bd3b 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h @@ -38,6 +38,12 @@ public: // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifying whether the strings are in RAM or FLASH. static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); + } + static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); + } static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 0dc1e2245e..0e2a971fd1 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -1233,7 +1233,7 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ #if BOTH(HAS_HOTEND, PREVENT_COLD_EXTRUSION) if (hotend_too_cold) { if (thermalManager.targetTooColdToExtrude(hotend_too_cold - 1)) thermalManager.setTargetHotend(thermalManager.extrude_min_temp, hotend_too_cold - 1); - sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); + sendinfoscreen(F("NOTICE"), nullptr, F("Please wait."), F("Nozzle heating!"), true, true, true, true); SetupConfirmAction(nullptr); GotoScreen(DGUSLCD_SCREEN_POPUP); } @@ -1489,7 +1489,7 @@ void DGUSScreenHandler::DGUS_Runout_Idle(void) { queue.inject(F("M25")); GotoScreen(MKSLCD_SCREEN_PAUSE); - sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please change filament!"), nullptr, true, true, true, true); + sendinfoscreen(F("NOTICE"), nullptr, F("Please change filament!"), nullptr, true, true, true, true); //SetupConfirmAction(nullptr); GotoScreen(DGUSLCD_SCREEN_POPUP); break; diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h index 8d5d9066f4..0c80cd260e 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h @@ -38,6 +38,12 @@ public: // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifying whether the strings are in RAM or FLASH. static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); + } + static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); + } static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h index ee0af013a8..bb0bd2bd3b 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h @@ -38,6 +38,12 @@ public: // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifying whether the strings are in RAM or FLASH. static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); + } + static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); + } static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp index 1489ed4bbe..9bae2b95d3 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp @@ -159,9 +159,9 @@ void DGUSScreenHandler::Loop() { dgus_display.Loop(); } -void DGUSScreenHandler::PrinterKilled(PGM_P error, PGM_P component) { - SetMessageLinePGM(error, 1); - SetMessageLinePGM(component, 2); +void DGUSScreenHandler::PrinterKilled(FSTR_P const error, FSTR_P const component) { + SetMessageLinePGM(FTOP(error), 1); + SetMessageLinePGM(FTOP(component), 2); SetMessageLinePGM(NUL_STR, 3); SetMessageLinePGM(GET_TEXT(MSG_PLEASE_RESET), 4); diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h index 0cc885eb7f..509d599200 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h @@ -37,7 +37,7 @@ public: static void Ready(); static void Loop(); - static void PrinterKilled(PGM_P error, PGM_P component); + static void PrinterKilled(FSTR_P const error, FSTR_P const component); static void UserConfirmRequired(const char * const msg); static void SettingsReset(); static void StoreSettings(char *buff); diff --git a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp index 26f2dcbde9..61b072a3f7 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp @@ -46,7 +46,7 @@ namespace ExtUI { } } - void onPrinterKilled(PGM_P error, PGM_P component) { + void onPrinterKilled(FSTR_P const error, FSTR_P const component) { dgus_screen_handler.PrinterKilled(error, component); } diff --git a/Marlin/src/lcd/extui/example/example.cpp b/Marlin/src/lcd/extui/example/example.cpp index f74cbee91c..8f38d2aba6 100644 --- a/Marlin/src/lcd/extui/example/example.cpp +++ b/Marlin/src/lcd/extui/example/example.cpp @@ -46,7 +46,7 @@ namespace ExtUI { */ } void onIdle() {} - void onPrinterKilled(PGM_P const error, PGM_P const component) {} + void onPrinterKilled(FSTR_P const error, FSTR_P const component) {} void onMediaInserted() {} void onMediaError() {} void onMediaRemoved() {} diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp index 59833b06a0..109814abf2 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp @@ -38,9 +38,9 @@ namespace ExtUI { void onIdle() { EventLoop::loop(); } - void onPrinterKilled(PGM_P const error, PGM_P const component) { - char str[strlen_P(error) + strlen_P(component) + 3]; - sprintf_P(str, PSTR(S_FMT ": " S_FMT), error, component); + void onPrinterKilled(FSTR_P const error, FSTR_P const component) { + char str[strlen_P(FTOP(error)) + strlen_P(FTOP(component)) + 3]; + sprintf_P(str, PSTR(S_FMT ": " S_FMT), FTOP(error), FTOP(component)); KillScreen::show(str); } diff --git a/Marlin/src/lcd/extui/malyan/malyan.cpp b/Marlin/src/lcd/extui/malyan/malyan.cpp index 8c9bfc32e5..df7f305df2 100644 --- a/Marlin/src/lcd/extui/malyan/malyan.cpp +++ b/Marlin/src/lcd/extui/malyan/malyan.cpp @@ -74,35 +74,36 @@ uint16_t inbound_count; bool last_printing_status = false; // Everything written needs the high bit set. -void write_to_lcd_P(PGM_P const message) { +void write_to_lcd(FSTR_P const fmsg) { + PGM_P pmsg = FTOP(fmsg); char encoded_message[MAX_CURLY_COMMAND]; - uint8_t message_length = _MIN(strlen_P(message), sizeof(encoded_message)); + uint8_t message_length = _MIN(strlen_P(pmsg), sizeof(encoded_message)); LOOP_L_N(i, message_length) - encoded_message[i] = pgm_read_byte(&message[i]) | 0x80; + encoded_message[i] = pgm_read_byte(&pmsg[i]) | 0x80; LCD_SERIAL.Print::write(encoded_message, message_length); } -void write_to_lcd(const char * const message) { +void write_to_lcd(const char * const cmsg) { char encoded_message[MAX_CURLY_COMMAND]; - const uint8_t message_length = _MIN(strlen(message), sizeof(encoded_message)); + const uint8_t message_length = _MIN(strlen(cmsg), sizeof(encoded_message)); LOOP_L_N(i, message_length) - encoded_message[i] = message[i] | 0x80; + encoded_message[i] = cmsg[i] | 0x80; LCD_SERIAL.Print::write(encoded_message, message_length); } // {E:} is for error states. -void set_lcd_error_P(PGM_P const error, PGM_P const component/*=nullptr*/) { - write_to_lcd_P(PSTR("{E:")); - write_to_lcd_P(error); +void set_lcd_error(FSTR_P const error, FSTR_P const component/*=nullptr*/) { + write_to_lcd(F("{E:")); + write_to_lcd(error); if (component) { - write_to_lcd_P(PSTR(" ")); - write_to_lcd_P(component); + write_to_lcd(F(" ")); + write_to_lcd(component); } - write_to_lcd_P(PSTR("}")); + write_to_lcd(F("}")); } @@ -243,16 +244,16 @@ void process_lcd_p_command(const char *command) { switch (command[0]) { case 'P': ExtUI::pausePrint(); - write_to_lcd_P(PSTR("{SYS:PAUSED}")); + write_to_lcd(F("{SYS:PAUSED}")); break; case 'R': ExtUI::resumePrint(); - write_to_lcd_P(PSTR("{SYS:RESUMED}")); + write_to_lcd(F("{SYS:RESUMED}")); break; case 'X': - write_to_lcd_P(PSTR("{SYS:CANCELING}")); + write_to_lcd(F("{SYS:CANCELING}")); ExtUI::stopPrint(); - write_to_lcd_P(PSTR("{SYS:STARTED}")); + write_to_lcd(F("{SYS:STARTED}")); break; case 'H': queue.enqueue_now_P(G28_STR); break; // Home all axes default: { @@ -271,13 +272,13 @@ void process_lcd_p_command(const char *command) { // but the V2 LCD switches to "print" mode on {SYS:DIR} response. if (card.flag.filenameIsDir) { card.cd(card.filename); - write_to_lcd_P(PSTR("{SYS:DIR}")); + write_to_lcd(F("{SYS:DIR}")); } else { char message_buffer[MAX_CURLY_COMMAND]; sprintf_P(message_buffer, PSTR("{PRINTFILE:%s}"), card.longest_filename()); write_to_lcd(message_buffer); - write_to_lcd_P(PSTR("{SYS:BUILD}")); + write_to_lcd(F("{SYS:BUILD}")); card.openAndPrintFile(card.filename); } #endif @@ -332,7 +333,7 @@ void process_lcd_s_command(const char *command) { write_to_lcd(message_buffer); } - write_to_lcd_P(PSTR("{SYS:OK}")); + write_to_lcd(F("{SYS:OK}")); #endif } break; @@ -413,7 +414,7 @@ void update_usb_status(const bool forceUpdate) { // This is more logical. if (last_usb_connected_status != MYSERIAL1.connected() || forceUpdate) { last_usb_connected_status = MYSERIAL1.connected(); - write_to_lcd_P(last_usb_connected_status ? PSTR("{R:UC}\r\n") : PSTR("{R:UD}\r\n")); + write_to_lcd(last_usb_connected_status ? F("{R:UC}\r\n") : F("{R:UD}\r\n")); } } diff --git a/Marlin/src/lcd/extui/malyan/malyan.h b/Marlin/src/lcd/extui/malyan/malyan.h index e8afbd4a59..1d0e911ccd 100644 --- a/Marlin/src/lcd/extui/malyan/malyan.h +++ b/Marlin/src/lcd/extui/malyan/malyan.h @@ -33,10 +33,10 @@ extern uint16_t inbound_count; // For sending print completion messages extern bool last_printing_status; -void write_to_lcd_P(PGM_P const message); -void write_to_lcd(const char * const message); +void write_to_lcd(FSTR_P const fmsg); +void write_to_lcd(const char * const cmsg); -void set_lcd_error_P(PGM_P const error, PGM_P const component=nullptr); +void set_lcd_error(FSTR_P const error, FSTR_P const component=nullptr); void process_lcd_c_command(const char *command); void process_lcd_eb_command(const char *command); diff --git a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp index cae534de3b..f323728e27 100644 --- a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp +++ b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp @@ -55,13 +55,13 @@ namespace ExtUI { LCD_SERIAL.begin(LCD_BAUDRATE); // Signal init - write_to_lcd_P(PSTR("{SYS:STARTED}\r\n")); + write_to_lcd(F("{SYS:STARTED}\r\n")); // send a version that says "unsupported" - write_to_lcd_P(PSTR("{VER:99}\r\n")); + write_to_lcd(F("{VER:99}\r\n")); // No idea why it does this twice. - write_to_lcd_P(PSTR("{SYS:STARTED}\r\n")); + write_to_lcd(F("{SYS:STARTED}\r\n")); update_usb_status(true); } @@ -98,8 +98,8 @@ namespace ExtUI { #endif } - void onPrinterKilled(PGM_P const error, PGM_P const component) { - set_lcd_error_P(error, component); + void onPrinterKilled(FSTR_P const error, FSTR_P const component) { + set_lcd_error(error, component); } #if HAS_PID_HEATING @@ -109,28 +109,28 @@ namespace ExtUI { //SERIAL_ECHOLNPGM("OnPidTuning:", rst); switch (rst) { case PID_STARTED: - set_lcd_error_P(GET_TEXT(MSG_PID_AUTOTUNE)); + set_lcd_error(GET_TEXT_F(MSG_PID_AUTOTUNE)); break; case PID_BAD_EXTRUDER_NUM: - set_lcd_error_P(GET_TEXT(MSG_PID_BAD_EXTRUDER_NUM)); + set_lcd_error(GET_TEXT_F(MSG_PID_BAD_EXTRUDER_NUM)); break; case PID_TEMP_TOO_HIGH: - set_lcd_error_P(GET_TEXT(MSG_PID_TEMP_TOO_HIGH)); + set_lcd_error(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH)); break; case PID_TUNING_TIMEOUT: - set_lcd_error_P(GET_TEXT(MSG_PID_TIMEOUT)); + set_lcd_error(GET_TEXT_F(MSG_PID_TIMEOUT)); break; case PID_DONE: - set_lcd_error_P(GET_TEXT(MSG_PID_AUTOTUNE_DONE)); + set_lcd_error(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE)); break; } } #endif - void onPrintTimerStarted() { write_to_lcd_P(PSTR("{SYS:BUILD}")); } + void onPrintTimerStarted() { write_to_lcd(F("{SYS:BUILD}")); } void onPrintTimerPaused() {} - void onPrintTimerStopped() { write_to_lcd_P(PSTR("{TQ:100}")); } + void onPrintTimerStopped() { write_to_lcd(F("{TQ:100}")); } // Not needed for Malyan LCD void onStatusChanged(const char * const) {} diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index 96b0f2a086..20d4720d00 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -2030,7 +2030,7 @@ void get_wifi_commands() { wait_for_heatup = false; TERN_(HAS_LCD_MENU, wait_for_user = false); } - if (strcmp(command, "M112") == 0) kill(M112_KILL_STR, nullptr, true); + if (strcmp(command, "M112") == 0) kill(FPSTR(M112_KILL_STR), nullptr, true); if (strcmp(command, "M410") == 0) quickstop_stepper(); #endif diff --git a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp index a825bd502f..c19d3aee46 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp @@ -37,7 +37,7 @@ namespace ExtUI { void onStartup() { nextion.Startup(); } void onIdle() { nextion.IdleLoop(); } - void onPrinterKilled(PGM_P const error, PGM_P const component) { nextion.PrinterKilled(error,component); } + void onPrinterKilled(FSTR_P const error, FSTR_P const component) { nextion.PrinterKilled(error, component); } void onMediaInserted() {} void onMediaError() {} void onMediaRemoved() {} diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp index 64e909779d..810848469c 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp @@ -84,12 +84,12 @@ void NextionTFT::IdleLoop() { UpdateOnChange(); } -void NextionTFT::PrinterKilled(PGM_P error, PGM_P component) { +void NextionTFT::PrinterKilled(FSTR_P const error, FSTR_P const component) { SEND_TXT_END("page error"); - SEND_TXT("t3", "Error"); - SEND_TXT_P("t4", component); - SEND_TXT_P("t5", error); - SEND_TXT("t6", "Need reset"); + SEND_TXT_F("t3", F("Error")); + SEND_TXT_F("t4", component); + SEND_TXT_F("t5", error); + SEND_TXT_F("t6", F("Need reset")); } void NextionTFT::PrintFinished() { diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft_defs.h b/Marlin/src/lcd/extui/nextion/nextion_tft_defs.h index 4570e9bba4..cdd91bf2a3 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft_defs.h +++ b/Marlin/src/lcd/extui/nextion/nextion_tft_defs.h @@ -56,8 +56,8 @@ #define SEND_TEMP(x,y,t,z) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), LCD_SERIAL.print(y), nextion.SendtoTFT(F(t)), LCD_SERIAL.print(z), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) #define SEND_VAL(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".val=")), LCD_SERIAL.print(y), nextion.SendtoTFT(F("\xFF\xFF\xFF"))) -#define SEND_TXT(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), nextion.SendtoTFT(F(y)), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) -#define SEND_TXT_P(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), nextion.SendtoTFT(y), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) +#define SEND_TXT(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), nextion.SendtoTFT(F(y)), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) +#define SEND_TXT_F(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), nextion.SendtoTFT(y), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) #define SEND_VALasTXT(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), LCD_SERIAL.print(y), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) #define SEND_TXT_END(x) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F("\xFF\xFF\xFF"))) #define SEND_PCO2(x,y,z) (nextion.SendtoTFT(F(x)), LCD_SERIAL.print(y), nextion.SendtoTFT(F(".pco=")), nextion.SendtoTFT(F(z)), nextion.SendtoTFT(F("\xFF\xFF\xFF"))) diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index afd762a470..8e588ef8c2 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -1077,6 +1077,7 @@ namespace ExtUI { void resumePrint() { ui.resume_print(); } void stopPrint() { ui.abort_print(); } + // Simplest approach is to make an SRAM copy void onUserConfirmRequired(FSTR_P const fstr) { char msg[strlen_P(FTOP(fstr)) + 1]; strcpy_P(msg, FTOP(fstr)); @@ -1153,7 +1154,7 @@ void MarlinUI::init() { ExtUI::onStartup(); } void MarlinUI::update() { ExtUI::onIdle(); } -void MarlinUI::kill_screen(PGM_P const error, PGM_P const component) { +void MarlinUI::kill_screen(FSTR_P const error, FSTR_P const component) { using namespace ExtUI; if (!flags.printer_killed) { flags.printer_killed = true; diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 4866c5b9d7..7e899221ad 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -394,7 +394,7 @@ namespace ExtUI { void onMediaError(); void onMediaRemoved(); void onPlayTone(const uint16_t frequency, const uint16_t duration); - void onPrinterKilled(PGM_P const error, PGM_P const component); + void onPrinterKilled(FSTR_P const error, FSTR_P const component); void onPrintTimerStarted(); void onPrintTimerPaused(); void onPrintTimerStopped(); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 5b77e53947..aff7bb085f 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -663,9 +663,9 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; draw_status_screen(); } - void MarlinUI::kill_screen(PGM_P lcd_error, PGM_P lcd_component) { + void MarlinUI::kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component) { init(); - status_printf(1, F(S_FMT ": " S_FMT), lcd_error, lcd_component); + status_printf(1, F(S_FMT ": " S_FMT), FTOP(lcd_error), FTOP(lcd_component)); TERN_(HAS_LCD_MENU, return_to_status()); // RED ALERT. RED ALERT. diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index bc8442c576..883850d6e0 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -356,9 +356,9 @@ public: static void status_printf(const uint8_t level, FSTR_P const fmt, ...); #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) - static void kill_screen(PGM_P const lcd_error, PGM_P const lcd_component); + static void kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component); #else - static inline void kill_screen(PGM_P const, PGM_P const) {} + static inline void kill_screen(FSTR_P const, FSTR_P const) {} #endif #if HAS_DISPLAY diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 80e20a0778..da5a0073cf 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -384,7 +384,7 @@ void Endstops::not_homing() { // If the last move failed to trigger an endstop, call kill void Endstops::validate_homing_move() { if (trigger_state()) hit_on_purpose(); - else kill(GET_TEXT(MSG_KILL_HOMING_FAILED)); + else kill(GET_TEXT_F(MSG_KILL_HOMING_FAILED)); } #endif diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index c820ce3599..f5dd5d34c9 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1832,7 +1832,7 @@ void prepare_line_to_destination() { } if (TEST(endstops.state(), es)) { SERIAL_ECHO_MSG("Bad ", AS_CHAR(AXIS_CHAR(axis)), " Endstop?"); - kill(GET_TEXT(MSG_KILL_HOMING_FAILED)); + kill(GET_TEXT_F(MSG_KILL_HOMING_FAILED)); } #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index c6edfb835e..e62a9ab5ee 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -3036,7 +3036,7 @@ bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, cons void Planner::buffer_page(const page_idx_t page_idx, const uint8_t extruder, const uint16_t num_steps) { if (!last_page_step_rate) { - kill(GET_TEXT(MSG_BAD_PAGE_SPEED)); + kill(GET_TEXT_F(MSG_BAD_PAGE_SPEED)); return; } diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index f37d2aa03f..4078effe76 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -297,7 +297,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("Stow Probe"), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Stow Probe"))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, PSTR("Stow Probe"), CONTINUE_STR)); + TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, F("Stow Probe"), FPSTR(CONTINUE_STR))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); ui.reset_status(); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index a3ada25118..47941dffda 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -187,8 +187,8 @@ Temperature thermalManager; -const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, - str_t_heating_failed[] PROGMEM = STR_T_HEATING_FAILED; +PGMSTR(str_t_thermal_runaway, STR_T_THERMAL_RUNAWAY); +PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); /** * Macros to include the heater id in temp errors. The compiler's dead-code @@ -196,22 +196,22 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, */ #if HAS_HEATED_BED - #define _BED_PSTR(h) (h) == H_BED ? GET_TEXT(MSG_BED) : + #define _BED_FSTR(h) (h) == H_BED ? GET_TEXT_F(MSG_BED) : #else - #define _BED_PSTR(h) + #define _BED_FSTR(h) #endif #if HAS_HEATED_CHAMBER - #define _CHAMBER_PSTR(h) (h) == H_CHAMBER ? GET_TEXT(MSG_CHAMBER) : + #define _CHAMBER_FSTR(h) (h) == H_CHAMBER ? GET_TEXT_F(MSG_CHAMBER) : #else - #define _CHAMBER_PSTR(h) + #define _CHAMBER_FSTR(h) #endif #if HAS_COOLER - #define _COOLER_PSTR(h) (h) == H_COOLER ? GET_TEXT(MSG_COOLER) : + #define _COOLER_FSTR(h) (h) == H_COOLER ? GET_TEXT_F(MSG_COOLER) : #else - #define _COOLER_PSTR(h) + #define _COOLER_FSTR(h) #endif -#define _E_PSTR(h,N) ((HOTENDS) > N && (h) == N) ? PSTR(LCD_STR_E##N) : -#define HEATER_PSTR(h) _BED_PSTR(h) _CHAMBER_PSTR(h) _COOLER_PSTR(h) _E_PSTR(h,1) _E_PSTR(h,2) _E_PSTR(h,3) _E_PSTR(h,4) _E_PSTR(h,5) PSTR(LCD_STR_E0) +#define _E_FSTR(h,N) ((HOTENDS) > N && (h) == N) ? F(LCD_STR_E##N) : +#define HEATER_FSTR(h) _BED_FSTR(h) _CHAMBER_FSTR(h) _COOLER_FSTR(h) _E_FSTR(h,1) _E_FSTR(h,2) _E_FSTR(h,3) _E_FSTR(h,4) _E_FSTR(h,5) F(LCD_STR_E0) // // Initialize MAX TC objects/SPI @@ -731,10 +731,10 @@ volatile bool Temperature::raw_temps_ready = false; if (current_temp > watch_temp_target) heated = true; // - Flag if target temperature reached } else if (ELAPSED(ms, temp_change_ms)) // Watch timer expired - _temp_error(heater_id, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); + _temp_error(heater_id, FPSTR(str_t_heating_failed), GET_TEXT_F(MSG_HEATING_FAILED_LCD)); } else if (current_temp < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far? - _temp_error(heater_id, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY)); + _temp_error(heater_id, FPSTR(str_t_thermal_runaway), GET_TEXT_F(MSG_THERMAL_RUNAWAY)); } #endif } // every 2 seconds @@ -951,7 +951,7 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { // Temperature Error Handlers // -inline void loud_kill(PGM_P const lcd_msg, const heater_id_t heater_id) { +inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) { marlin_state = MF_KILLED; thermalManager.disable_all_heaters(); #if USE_BEEPER @@ -967,16 +967,16 @@ inline void loud_kill(PGM_P const lcd_msg, const heater_id_t heater_id) { } WRITE(BEEPER_PIN, HIGH); #endif - kill(lcd_msg, HEATER_PSTR(heater_id)); + kill(lcd_msg, HEATER_FSTR(heater_id)); } -void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_msg, PGM_P const lcd_msg) { +void Temperature::_temp_error(const heater_id_t heater_id, FSTR_P const serial_msg, FSTR_P const lcd_msg) { static uint8_t killed = 0; if (IsRunning() && TERN1(BOGUS_TEMPERATURE_GRACE_PERIOD, killed == 2)) { SERIAL_ERROR_START(); - SERIAL_ECHOPGM_P(serial_msg); + SERIAL_ECHOF(serial_msg); SERIAL_ECHOPGM(STR_STOPPED_HEATER); heater_id_t real_heater_id = heater_id; @@ -1031,14 +1031,14 @@ void Temperature::max_temp_error(const heater_id_t heater_id) { #if HAS_DWIN_E3V2_BASIC && (HAS_HOTEND || HAS_HEATED_BED) DWIN_Popup_Temperature(1); #endif - _temp_error(heater_id, PSTR(STR_T_MAXTEMP), GET_TEXT(MSG_ERR_MAXTEMP)); + _temp_error(heater_id, F(STR_T_MAXTEMP), GET_TEXT_F(MSG_ERR_MAXTEMP)); } void Temperature::min_temp_error(const heater_id_t heater_id) { #if HAS_DWIN_E3V2_BASIC && (HAS_HOTEND || HAS_HEATED_BED) DWIN_Popup_Temperature(0); #endif - _temp_error(heater_id, PSTR(STR_T_MINTEMP), GET_TEXT(MSG_ERR_MINTEMP)); + _temp_error(heater_id, F(STR_T_MINTEMP), GET_TEXT_F(MSG_ERR_MINTEMP)); } #if ANY(PID_DEBUG, PID_BED_DEBUG, PID_CHAMBER_DEBUG) @@ -1294,7 +1294,7 @@ void Temperature::manage_heater() { REMEMBER(mh, no_reentry, true); #if ENABLED(EMERGENCY_PARSER) - if (emergency_parser.killed_by_M112) kill(M112_KILL_STR, nullptr, true); + if (emergency_parser.killed_by_M112) kill(FPSTR(M112_KILL_STR), nullptr, true); if (emergency_parser.quickstop_by_M410) { emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! @@ -1344,7 +1344,7 @@ void Temperature::manage_heater() { start_watching_hotend(e); // If temp reached, turn off elapsed check else { TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); - _temp_error((heater_id_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); + _temp_error((heater_id_t)e, FPSTR(str_t_heating_failed), GET_TEXT_F(MSG_HEATING_FAILED_LCD)); } } #endif @@ -1356,7 +1356,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_REDUNDANT // Make sure measured temperatures are close together if (ABS(degRedundantTarget() - degRedundant()) > TEMP_SENSOR_REDUNDANT_MAX_DIFF) - _temp_error((heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET), PSTR(STR_REDUNDANCY), GET_TEXT(MSG_ERR_REDUNDANT_TEMP)); + _temp_error((heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET), F(STR_REDUNDANCY), GET_TEXT_F(MSG_ERR_REDUNDANT_TEMP)); #endif #if HAS_AUTO_FAN @@ -1387,7 +1387,7 @@ void Temperature::manage_heater() { start_watching_bed(); // If temp reached, turn off elapsed check else { TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); - _temp_error(H_BED, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); + _temp_error(H_BED, FPSTR(str_t_heating_failed), GET_TEXT_F(MSG_HEATING_FAILED_LCD)); } } #endif // WATCH_BED @@ -1467,7 +1467,7 @@ void Temperature::manage_heater() { if (watch_chamber.check(degChamber())) // Increased enough? Error below. start_watching_chamber(); // If temp reached, turn off elapsed check. else - _temp_error(H_CHAMBER, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); + _temp_error(H_CHAMBER, FPSTR(str_t_heating_failed), GET_TEXT_F(MSG_HEATING_FAILED_LCD)); } #endif @@ -1589,7 +1589,7 @@ void Temperature::manage_heater() { // Make sure temperature is decreasing if (watch_cooler.elapsed(ms)) { // Time to check the cooler? if (degCooler() > watch_cooler.target) // Failed to decrease enough? - _temp_error(H_COOLER, GET_TEXT(MSG_COOLING_FAILED), GET_TEXT(MSG_COOLING_FAILED)); + _temp_error(H_COOLER, GET_TEXT_F(MSG_COOLING_FAILED), GET_TEXT_F(MSG_COOLING_FAILED)); else start_watching_cooler(); // Start again if the target is still far off } @@ -2597,7 +2597,7 @@ void Temperature::init() { case TRRunaway: TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); - _temp_error(heater_id, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY)); + _temp_error(heater_id, FPSTR(str_t_thermal_runaway), GET_TEXT_F(MSG_THERMAL_RUNAWAY)); } } @@ -3896,7 +3896,7 @@ void Temperature::isr() { const bool wants_to_cool = isProbeAboveTemp(target_temp), will_wait = !(wants_to_cool && no_wait_for_cooling); if (will_wait) - SERIAL_ECHOLNPGM("Waiting for probe to ", (wants_to_cool ? PSTR("cool down") : PSTR("heat up")), " to ", target_temp, " degrees."); + SERIAL_ECHOLNPGM("Waiting for probe to ", wants_to_cool ? F("cool down") : F("heat up"), " to ", target_temp, " degrees."); #if DISABLED(BUSY_WHILE_HEATING) && ENABLED(HOST_KEEPALIVE_FEATURE) KEEPALIVE_STATE(NOT_BUSY); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 1675507f86..5579f71172 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -961,7 +961,7 @@ class Temperature { static float get_pid_output_chamber(); #endif - static void _temp_error(const heater_id_t e, PGM_P const serial_msg, PGM_P const lcd_msg); + static void _temp_error(const heater_id_t e, FSTR_P const serial_msg, FSTR_P const lcd_msg); static void min_temp_error(const heater_id_t e); static void max_temp_error(const heater_id_t e); diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 2f387abad4..285b4cba84 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -432,7 +432,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. } else if (kill_on_error && (!tool_sensor_disabled || disable)) { sensor_tries++; - if (sensor_tries > 10) kill(PSTR("Tool Sensor error")); + if (sensor_tries > 10) kill(F("Tool Sensor error")); safe_delay(5); } else { diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 6b8d2338c1..1ab6dcc7c6 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -646,7 +646,7 @@ void CardReader::openFileRead(const char * const path, const uint8_t subcall_typ // Too deep? The firmware has to bail. if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) { SERIAL_ERROR_MSG("Exceeded max SUBROUTINE depth:", SD_PROCEDURE_DEPTH); - kill(GET_TEXT(MSG_KILL_SUBCALL_OVERFLOW)); + kill(GET_TEXT_F(MSG_KILL_SUBCALL_OVERFLOW)); return; } From d9f7de7a24071fecb9bcae3400e3b4ec56c68a8d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 4 Oct 2021 19:50:14 -0500 Subject: [PATCH 018/546] =?UTF-8?q?=F0=9F=90=9B=20ExtUI=20F()=20followups?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to 12b5d997a2 --- Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp | 4 ++-- Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h | 4 ++-- Marlin/src/lcd/extui/nextion/nextion_tft.cpp | 2 +- Marlin/src/lcd/extui/nextion/nextion_tft.h | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index c3fc6aa96e..9f558e3a98 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -315,7 +315,7 @@ void ChironTFT::PrintComplete() { setSoftEndstopState(true); // enable endstops } -void ChironTFT::SendtoTFT(FSTR_P const fstr) { // A helper to print PROGMEM string to the panel +void ChironTFT::SendtoTFT(FSTR_P const fstr/*=nullptr*/) { // A helper to print PROGMEM string to the panel #if ACDEBUG(AC_SOME) SERIAL_ECHOF(fstr); #endif @@ -323,7 +323,7 @@ void ChironTFT::SendtoTFT(FSTR_P const fstr) { // A helper to print PROGMEM str while (const char c = pgm_read_byte(str++)) TFTSer.write(c); } -void ChironTFT::SendtoTFTLN(FSTR_P const fstr) { +void ChironTFT::SendtoTFTLN(FSTR_P const fstr/*=nullptr*/) { if (fstr) { #if ACDEBUG(AC_SOME) SERIAL_ECHOPGM("> "); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h index 44ba02dc5d..c9a32e584d 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h @@ -67,8 +67,8 @@ class ChironTFT { static void StatusChange(const char * const); static void PowerLossRecovery(); static void PrintComplete(); - static void SendtoTFT(FSTR_P const); - static void SendtoTFTLN(FSTR_P const); + static void SendtoTFT(FSTR_P const=nullptr); + static void SendtoTFTLN(FSTR_P const=nullptr); private: static void DetectPanelType(); static bool ReadTFTCommand(); diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp index 810848469c..99211a220c 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp @@ -110,7 +110,7 @@ void NextionTFT::StatusChange(const char * const msg) { SEND_VALasTXT("tmppage.M117", msg); } -void NextionTFT::SendtoTFT(FSTR_P fstr) { // A helper to print PROGMEM string to the panel +void NextionTFT::SendtoTFT(FSTR_P const fstr/*=nullptr*/) { // A helper to print PROGMEM string to the panel #if NEXDEBUG(N_SOME) DEBUG_ECHOF(fstr); #endif diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft.h b/Marlin/src/lcd/extui/nextion/nextion_tft.h index f32e5d4ef1..806630485c 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft.h +++ b/Marlin/src/lcd/extui/nextion/nextion_tft.h @@ -42,10 +42,11 @@ class NextionTFT { NextionTFT(); static void Startup(); static void IdleLoop(); - static void PrinterKilled(PGM_P, PGM_P); + static void PrinterKilled(FSTR_P const, FSTR_P const); static void ConfirmationRequest(const char * const); static void StatusChange(const char * const); - static void SendtoTFT(FSTR_P const); + static void SendtoTFT(FSTR_P const=nullptr); + //static void SendtoTFTLN(FSTR_P const=nullptr); static void UpdateOnChange(); static void PrintFinished(); static void PanelInfo(uint8_t); From d48cb1153785178fba59c0f11da75720585baafb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Oct 2021 21:19:28 -0500 Subject: [PATCH 019/546] =?UTF-8?q?=F0=9F=90=9B=20Followup=20to=20F()=20in?= =?UTF-8?q?=20config=5Fline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to 1dafd1887e --- Marlin/src/gcode/host/M360.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Marlin/src/gcode/host/M360.cpp b/Marlin/src/gcode/host/M360.cpp index 29b7ae602b..b1b558b033 100644 --- a/Marlin/src/gcode/host/M360.cpp +++ b/Marlin/src/gcode/host/M360.cpp @@ -93,7 +93,7 @@ void GcodeSuite::M360() { // #if HAS_CLASSIC_JERK if (planner.max_jerk.x == planner.max_jerk.y) - config_line(F("XY"), planner.max_jerk.x, JERK_STR); + config_line(F("XY"), planner.max_jerk.x, FPSTR(JERK_STR)); else { config_line(X_STR, planner.max_jerk.x, JERK_STR); config_line(Y_STR, planner.max_jerk.y, JERK_STR); @@ -110,15 +110,15 @@ void GcodeSuite::M360() { PGMSTR(UNRET_STR, "RetractionUndo"); PGMSTR(SPEED_STR, "Speed"); // M10 Retract with swap (long) moves - config_line(F("Length"), fwretract.settings.retract_length, RET_STR); - config_line(SPEED_STR, fwretract.settings.retract_feedrate_mm_s, RET_STR); - config_line(F("ZLift"), fwretract.settings.retract_zraise, RET_STR); - config_line(F("LongLength"), fwretract.settings.swap_retract_length, RET_STR); + config_line(F("Length"), fwretract.settings.retract_length, FPSTR(RET_STR)); + config_line(SPEED_STR, fwretract.settings.retract_feedrate_mm_s, RET_STR); + config_line(F("ZLift"), fwretract.settings.retract_zraise, FPSTR(RET_STR)); + config_line(F("LongLength"), fwretract.settings.swap_retract_length, FPSTR(RET_STR)); // M11 Recover (undo) with swap (long) moves - config_line(SPEED_STR, fwretract.settings.retract_recover_feedrate_mm_s, UNRET_STR); - config_line(F("ExtraLength"), fwretract.settings.retract_recover_extra, UNRET_STR); - config_line(F("ExtraLongLength"), fwretract.settings.swap_retract_recover_extra, UNRET_STR); - config_line(F("LongSpeed"), fwretract.settings.swap_retract_recover_feedrate_mm_s, UNRET_STR); + config_line(SPEED_STR, fwretract.settings.retract_recover_feedrate_mm_s, UNRET_STR); + config_line(F("ExtraLength"), fwretract.settings.retract_recover_extra, FPSTR(UNRET_STR)); + config_line(F("ExtraLongLength"), fwretract.settings.swap_retract_recover_extra, FPSTR(UNRET_STR)); + config_line(F("LongSpeed"), fwretract.settings.swap_retract_recover_feedrate_mm_s, FPSTR(UNRET_STR)); #endif // From 0018c94a7992a6bd0e13219504e664dc4703687d Mon Sep 17 00:00:00 2001 From: Pyro-Fox <36782094+Pyro-Fox@users.noreply.github.com> Date: Sat, 9 Oct 2021 15:09:50 -0700 Subject: [PATCH 020/546] =?UTF-8?q?=F0=9F=90=9B=20LCD=20string=20followup?= =?UTF-8?q?=20(#22892)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu_bed_corners.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 178d466478..79193fbef3 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -179,7 +179,7 @@ static void _lcd_level_bed_corners_get_next_position() { // Display # of good points found vs total needed if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) { SETCURSOR(TERN(TFT_COLOR_UI, 2, 0), cy); - lcd_put_u8str_(GET_TEXT_F(MSG_BED_TRAMMING_GOOD_POINTS)); + lcd_put_u8str(GET_TEXT_F(MSG_BED_TRAMMING_GOOD_POINTS)); IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, cy)); lcd_put_u8str(GOOD_POINTS_TO_STR(good_points)); lcd_put_wchar('/'); From 64128a5bcb46d9428ff9acc4f45fc79381c90322 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 10 Oct 2021 01:05:24 +0200 Subject: [PATCH 021/546] =?UTF-8?q?=F0=9F=90=9B=20Queue=20string=20followu?= =?UTF-8?q?p=20(#22900)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/queue.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index c5562da3aa..2e3e26d179 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -148,6 +148,12 @@ public: */ static bool enqueue_one(FSTR_P const fgcode); + /** + * Enqueue with Serial Echo + * Return true on success + */ + static bool enqueue_one(const char *cmd); + /** * Enqueue from program memory and return only when commands are actually enqueued */ @@ -253,12 +259,6 @@ private: // Process the next "immediate" command (SRAM) static bool process_injected_command(); - /** - * Enqueue with Serial Echo - * Return true on success - */ - static bool enqueue_one(const char *cmd); - static void gcode_line_error(FSTR_P const ferr, const serial_index_t serial_ind); friend class GcodeSuite; From f3be03da20708c8dfc990e6e293c4e25a3605e52 Mon Sep 17 00:00:00 2001 From: Stuart Pittaway <1201909+stuartpittaway@users.noreply.github.com> Date: Mon, 11 Oct 2021 23:42:29 +0100 Subject: [PATCH 022/546] =?UTF-8?q?=E2=9C=A8=20M261=20S=20I2C=20output=20f?= =?UTF-8?q?ormat=20(#22890)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/feature/twibus.cpp | 61 +++++++++++++++++++--- Marlin/src/feature/twibus.h | 10 ++-- Marlin/src/gcode/feature/i2c/M260_M261.cpp | 7 +-- Marlin/src/libs/hex_print.h | 2 +- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/Marlin/src/feature/twibus.cpp b/Marlin/src/feature/twibus.cpp index 55e4da75cf..0e23b48a40 100644 --- a/Marlin/src/feature/twibus.cpp +++ b/Marlin/src/feature/twibus.cpp @@ -28,11 +28,17 @@ #include +#include "../libs/hex_print.h" + TWIBus i2c; TWIBus::TWIBus() { #if I2C_SLAVE_ADDRESS == 0 - Wire.begin(); // No address joins the BUS as the master + Wire.begin( // No address joins the BUS as the master + #if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM) + pin_t(I2C_SDA_PIN), pin_t(I2C_SCL_PIN) + #endif + ); #else Wire.begin(I2C_SLAVE_ADDRESS); // Join the bus as a slave #endif @@ -88,14 +94,53 @@ void TWIBus::echoprefix(uint8_t bytes, FSTR_P const pref, uint8_t adr) { } // static -void TWIBus::echodata(uint8_t bytes, FSTR_P const pref, uint8_t adr) { - echoprefix(bytes, pref, adr); - while (bytes-- && Wire.available()) SERIAL_CHAR(Wire.read()); +void TWIBus::echodata(uint8_t bytes, FSTR_P const pref, uint8_t adr, const uint8_t style/*=0*/) { + union TwoBytesToInt16 { uint8_t bytes[2]; int16_t integervalue; }; + TwoBytesToInt16 ConversionUnion; + + echoprefix(bytes, pref, adr); + + while (bytes-- && Wire.available()) { + int value = Wire.read(); + switch (style) { + + // Style 1, HEX DUMP + case 1: + SERIAL_CHAR(hex_nybble((value & 0xF0) >> 4)); + SERIAL_CHAR(hex_nybble(value & 0x0F)); + if (bytes) SERIAL_CHAR(' '); + break; + + // Style 2, signed two byte integer (int16) + case 2: + if (bytes == 1) + ConversionUnion.bytes[1] = (uint8_t)value; + else if (bytes == 0) { + ConversionUnion.bytes[0] = (uint8_t)value; + // Output value in base 10 (standard decimal) + SERIAL_ECHO(ConversionUnion.integervalue); + } + break; + + // Style 3, unsigned byte, base 10 (uint8) + case 3: + SERIAL_ECHO(value); + if (bytes) SERIAL_CHAR(' '); + break; + + // Default style (zero), raw serial output + default: + // This can cause issues with some serial consoles, Pronterface is an example where things go wrong + SERIAL_CHAR(value); + break; + } + } + SERIAL_EOL(); } -void TWIBus::echobuffer(FSTR_P const pref, uint8_t adr) { - echoprefix(buffer_s, pref, adr); +void TWIBus::echobuffer(FSTR_P const prefix, uint8_t adr) { + echoprefix(buffer_s, prefix, adr); LOOP_L_N(i, buffer_s) SERIAL_CHAR(buffer[i]); SERIAL_EOL(); } @@ -114,11 +159,11 @@ bool TWIBus::request(const uint8_t bytes) { return true; } -void TWIBus::relay(const uint8_t bytes) { +void TWIBus::relay(const uint8_t bytes, const uint8_t style/*=0*/) { debug(F("relay"), bytes); if (request(bytes)) - echodata(bytes, F("i2c-reply"), addr); + echodata(bytes, F("i2c-reply"), addr, style); } uint8_t TWIBus::capture(char *dst, const uint8_t bytes) { diff --git a/Marlin/src/feature/twibus.h b/Marlin/src/feature/twibus.h index 2a8a7fef6a..d2c7270303 100644 --- a/Marlin/src/feature/twibus.h +++ b/Marlin/src/feature/twibus.h @@ -142,7 +142,7 @@ class TWIBus { * * @param bytes the number of bytes to request */ - static void echoprefix(uint8_t bytes, FSTR_P prefix, uint8_t adr); + static void echoprefix(uint8_t bytes, FSTR_P const prefix, uint8_t adr); /** * @brief Echo data on the bus to serial @@ -150,8 +150,9 @@ class TWIBus { * to serial in a parser-friendly format. * * @param bytes the number of bytes to request + * @param style Output format for the bytes, 0 = Raw byte [default], 1 = Hex characters, 2 = uint16_t */ - static void echodata(uint8_t bytes, FSTR_P prefix, uint8_t adr); + static void echodata(uint8_t bytes, FSTR_P const prefix, uint8_t adr, const uint8_t style=0); /** * @brief Echo data in the buffer to serial @@ -160,7 +161,7 @@ class TWIBus { * * @param bytes the number of bytes to request */ - void echobuffer(FSTR_P prefix, uint8_t adr); + void echobuffer(FSTR_P const prefix, uint8_t adr); /** * @brief Request data from the slave device and wait. @@ -192,10 +193,11 @@ class TWIBus { * @brief Request data from the slave device, echo to serial. * @details Request a number of bytes from a slave device and output * the returned data to serial in a parser-friendly format. + * @style Output format for the bytes, 0 = raw byte [default], 1 = Hex characters, 2 = uint16_t * * @param bytes the number of bytes to request */ - void relay(const uint8_t bytes); + void relay(const uint8_t bytes, const uint8_t style=0); #if I2C_SLAVE_ADDRESS > 0 diff --git a/Marlin/src/gcode/feature/i2c/M260_M261.cpp b/Marlin/src/gcode/feature/i2c/M260_M261.cpp index 438d1527f5..e978fb5048 100644 --- a/Marlin/src/gcode/feature/i2c/M260_M261.cpp +++ b/Marlin/src/gcode/feature/i2c/M260_M261.cpp @@ -60,15 +60,16 @@ void GcodeSuite::M260() { /** * M261: Request X bytes from I2C slave device * - * Usage: M261 A B + * Usage: M261 A B S