Browse Source

🎨 Apply F() to UTF-8/MMU2 string put

vanilla_fb_2.0.x
Scott Lahteine 3 years ago
parent
commit
9cf1c3cf05
  1. 2
      Marlin/src/HAL/shared/progmem.h
  2. 48
      Marlin/src/feature/mmu/mmu2.cpp
  3. 8
      Marlin/src/feature/mmu/mmu2.h
  4. 4
      Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp
  5. 45
      Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
  6. 4
      Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp
  7. 42
      Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
  8. 4
      Marlin/src/lcd/dogm/lcdprint_u8g.cpp
  9. 10
      Marlin/src/lcd/dogm/marlinui_DOGM.cpp
  10. 14
      Marlin/src/lcd/dogm/status_screen_DOGM.cpp
  11. 12
      Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp
  12. 2
      Marlin/src/lcd/dogm/status_screen_lite_ST7920.h
  13. 4
      Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp
  14. 4
      Marlin/src/lcd/e3v2/marlinui/ui_common.cpp
  15. 23
      Marlin/src/lcd/lcdprint.h
  16. 2
      Marlin/src/lcd/menu/game/game.cpp
  17. 4
      Marlin/src/lcd/menu/menu_bed_corners.cpp
  18. 4
      Marlin/src/lcd/menu/menu_mixer.cpp
  19. 4
      Marlin/src/lcd/menu/menu_tune.cpp
  20. 4
      Marlin/src/lcd/tft/ui_common.cpp

2
Marlin/src/HAL/shared/progmem.h

@ -111,7 +111,7 @@ class __FlashStringHelper;
#define strrchr_P(str, c) strrchr((str), (c)) #define strrchr_P(str, c) strrchr((str), (c))
#endif #endif
#ifndef strsep_P #ifndef strsep_P
#define strsep_P(strp, delim) strsep((strp), (delim)) #define strsep_P(pstr, delim) strsep((pstr), (delim))
#endif #endif
#ifndef strspn_P #ifndef strspn_P
#define strspn_P(str, chrs) strspn((str), (chrs)) #define strspn_P(str, chrs) strspn((str), (chrs))

48
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_CMD_TIMEOUT 45000UL // 45s timeout for mmu commands (except P0)
#define MMU_P0_TIMEOUT 3000UL // Timeout for P0 command: 3seconds #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) #if ENABLED(MMU_EXTRUDER_SENSOR)
uint8_t mmu_idl_sens = 0; uint8_t mmu_idl_sens = 0;
@ -229,17 +229,17 @@ void MMU2::mmu_loop() {
if (cmd) { if (cmd) {
if (WITHIN(cmd, MMU_CMD_T0, MMU_CMD_T0 + EXTRUDERS - 1)) { if (WITHIN(cmd, MMU_CMD_T0, MMU_CMD_T0 + EXTRUDERS - 1)) {
// tool change // tool change
int filament = cmd - MMU_CMD_T0; const int filament = cmd - MMU_CMD_T0;
DEBUG_ECHOLNPGM("MMU <= T", filament); 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 TERN_(MMU_EXTRUDER_SENSOR, mmu_idl_sens = 1); // enable idler sensor, if any
state = 3; // wait for response state = 3; // wait for response
} }
else if (WITHIN(cmd, MMU_CMD_L0, MMU_CMD_L0 + EXTRUDERS - 1)) { else if (WITHIN(cmd, MMU_CMD_L0, MMU_CMD_L0 + EXTRUDERS - 1)) {
// load // load
int filament = cmd - MMU_CMD_L0; const int filament = cmd - MMU_CMD_L0;
DEBUG_ECHOLNPGM("MMU <= L", filament); 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 state = 3; // wait for response
} }
else if (cmd == MMU_CMD_C0) { 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)) { else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E0 + EXTRUDERS - 1)) {
// eject filament // eject filament
int filament = cmd - MMU_CMD_E0; const int filament = cmd - MMU_CMD_E0;
DEBUG_ECHOLNPGM("MMU <= E", filament); 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 state = 3; // wait for response
} }
else if (cmd == MMU_CMD_R0) { 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)) { else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F0 + EXTRUDERS - 1)) {
// filament type // filament type
int filament = cmd - MMU_CMD_F0; const int filament = cmd - MMU_CMD_F0;
DEBUG_ECHOLNPGM("MMU <= F", filament, " ", cmd_arg); 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 state = 3; // wait for response
} }
@ -356,13 +356,15 @@ void MMU2::mmu_loop() {
*/ */
bool MMU2::rx_start() { bool MMU2::rx_start() {
// check for start message // 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. * 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); uint8_t i = strlen(rx_buffer);
while (MMU2_SERIAL.available()) { while (MMU2_SERIAL.available()) {
@ -375,14 +377,14 @@ bool MMU2::rx_str_P(const char *str) {
} }
rx_buffer[i] = '\0'; rx_buffer[i] = '\0';
uint8_t len = strlen_P(str); uint8_t len = strlen_P(pstr);
if (i < len) return false; if (i < len) return false;
str += len; pstr += len;
while (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 == c1) continue;
if (c0 == '\r' && c1 == '\n') continue; // match cr as lf if (c0 == '\r' && c1 == '\n') continue; // match cr as lf
if (c0 == '\n' && c1 == '\r') continue; // match lf as cr 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 * Transfer data to MMU, no argument
*/ */
void MMU2::tx_str_P(const char *str) { void MMU2::tx_str(FSTR_P fstr) {
clear_rx_buffer(); clear_rx_buffer();
uint8_t len = strlen_P(str); PGM_P pstr = FTOP(fstr);
LOOP_L_N(i, len) MMU2_SERIAL.write(pgm_read_byte(str++)); while (const char c = pgm_read_byte(pstr)) { MMU2_SERIAL.write(c); pstr++; }
prev_request = millis(); prev_request = millis();
} }
/** /**
* Transfer data to MMU, single argument * 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(); 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]); LOOP_L_N(i, len) MMU2_SERIAL.write(tx_buffer[i]);
prev_request = millis(); prev_request = millis();
} }
@ -414,9 +416,9 @@ void MMU2::tx_printf_P(const char *format, int argument = -1) {
/** /**
* Transfer data to MMU, two arguments * 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(); 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]); LOOP_L_N(i, len) MMU2_SERIAL.write(tx_buffer[i]);
prev_request = millis(); prev_request = millis();
} }
@ -433,7 +435,7 @@ void MMU2::clear_rx_buffer() {
* Check if we received 'ok' from MMU * Check if we received 'ok' from MMU
*/ */
bool MMU2::rx_ok() { bool MMU2::rx_ok() {
if (rx_str_P(PSTR("ok\n"))) { if (rx_str(F("ok\n"))) {
prev_P0_request = millis(); prev_P0_request = millis();
return true; return true;
} }
@ -853,7 +855,7 @@ void MMU2::filament_runout() {
if (cmd == MMU_CMD_NONE && last_cmd == MMU_CMD_C0) { if (cmd == MMU_CMD_NONE && last_cmd == MMU_CMD_C0) {
if (present && !mmu2s_triggered) { if (present && !mmu2s_triggered) {
DEBUG_ECHOLNPGM("MMU <= 'A'"); DEBUG_ECHOLNPGM("MMU <= 'A'");
tx_str_P(PSTR("A\n")); tx_str(F("A\n"));
} }
// Slowly spin the extruder during C0 // Slowly spin the extruder during C0
else { else {

8
Marlin/src/feature/mmu/mmu2.h

@ -57,10 +57,10 @@ public:
static bool eject_filament(const uint8_t index, const bool recover); static bool eject_filament(const uint8_t index, const bool recover);
private: private:
static bool rx_str_P(const char *str); static inline bool rx_str(FSTR_P fstr);
static void tx_str_P(const char *str); static inline void tx_str(FSTR_P fstr);
static void tx_printf_P(const char *format, const int argument); static inline void tx_printf(FSTR_P ffmt, const int argument);
static void tx_printf_P(const char *format, const int argument1, const int argument2); static inline void tx_printf(FSTR_P ffmt, const int argument1, const int argument2);
static void clear_rx_buffer(); static void clear_rx_buffer();
static bool rx_ok(); static bool rx_ok();

4
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); 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) { int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) {
return lcd_put_u8str_max_cb(utf8_str_P, read_byte_rom, max_length); return lcd_put_u8str_max_cb(utf8_pstr, read_byte_rom, max_length);
} }
#if ENABLED(DEBUG_LCDPRINT) #if ENABLED(DEBUG_LCDPRINT)

45
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 // 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) { 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(text); uint8_t slen = utf8_strlen_P(FTOP(ftxt));
if (slen < len) { 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(' '); for (; slen < len; ++slen) lcd_put_wchar(' ');
safe_delay(time); safe_delay(time);
} }
else { else {
PGM_P p = text; PGM_P p = FTOP(ftxt);
int dly = time / _MAX(slen, 1); int dly = time / _MAX(slen, 1);
LOOP_LE_N(i, slen) { LOOP_LE_N(i, slen) {
@ -439,9 +439,9 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
static void logo_lines(PGM_P const extra) { static void logo_lines(PGM_P const extra) {
int16_t indent = (LCD_WIDTH - 8 - utf8_strlen_P(extra)) / 2; 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_wchar(indent, 0, '\x00'); lcd_put_u8str(F( "------" )); lcd_put_wchar('\x01');
lcd_put_u8str_P(indent, 1, PSTR("|Marlin|")); lcd_put_u8str_P(extra); lcd_put_u8str(indent, 1, F("|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, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_wchar('\x03');
} }
void MarlinUI::show_bootscreen() { void MarlinUI::show_bootscreen() {
@ -450,15 +450,16 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
#define LCD_EXTRA_SPACE (LCD_WIDTH-8) #define LCD_EXTRA_SPACE (LCD_WIDTH-8)
#define CENTER_OR_SCROLL(STRING,DELAY) \ #define CENTER_OR_SCROLL(STRING,DELAY) { \
lcd_erase_line(3); \ lcd_erase_line(3); \
if (utf8_strlen(STRING) <= LCD_WIDTH) { \ const int len = utf8_strlen(STRING); \
lcd_put_u8str_P((LCD_WIDTH - utf8_strlen_P(PSTR(STRING))) / 2, 3, PSTR(STRING)); \ if (len <= LCD_WIDTH) { \
lcd_put_u8str((LCD_WIDTH - len) / 2, 3, F(STRING)); \
safe_delay(DELAY); \ safe_delay(DELAY); \
} \ } \
else { \ else \
lcd_scroll(0, 3, PSTR(STRING), LCD_WIDTH, DELAY); \ lcd_scroll(0, 3, F(STRING), LCD_WIDTH, DELAY); \
} }
// //
// Show the Marlin logo with splash line 1 // 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_put_u8str(0, 0, status_message);
lcd_uint_t y = 2; lcd_uint_t y = 2;
#if LCD_HEIGHT >= 4 #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 #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)) else if (axis_should_home(axis))
while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?'); while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis)) 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 else
lcd_put_u8str(value); lcd_put_u8str(value);
} }
@ -613,11 +614,11 @@ FORCE_INLINE void _draw_bed_status(const bool blink) {
FORCE_INLINE void _draw_print_progress() { FORCE_INLINE void _draw_print_progress() {
const uint8_t progress = ui.get_progress_percent(); 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) if (progress)
lcd_put_u8str(ui8tostr3rj(progress)); lcd_put_u8str(ui8tostr3rj(progress));
else else
lcd_put_u8str_P(PSTR("---")); lcd_put_u8str(F("---"));
lcd_put_wchar('%'); lcd_put_wchar('%');
} }
@ -661,9 +662,9 @@ void MarlinUI::draw_status_message(const bool blink) {
// Alternate Status message and Filament display // Alternate Status message and Filament display
if (ELAPSED(millis(), next_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(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_u8str(i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled)));
lcd_put_wchar('%'); lcd_put_wchar('%');
return; return;
@ -1473,7 +1474,7 @@ void MarlinUI::draw_status_screen() {
if (!isnan(ubl.z_values[x_plot][y_plot])) if (!isnan(ubl.z_values[x_plot][y_plot]))
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
else else
lcd_put_u8str_P(PSTR(" -----")); lcd_put_u8str(F(" -----"));
#else // 16x4 or 20x4 display #else // 16x4 or 20x4 display
@ -1492,7 +1493,7 @@ void MarlinUI::draw_status_screen() {
if (!isnan(ubl.z_values[x_plot][y_plot])) if (!isnan(ubl.z_values[x_plot][y_plot]))
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
else else
lcd_put_u8str_P(PSTR(" -----")); lcd_put_u8str(F(" -----"));
#endif // LCD_HEIGHT > 3 #endif // LCD_HEIGHT > 3
} }

4
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); 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) { int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) {
return lcd_put_u8str_max_cb(utf8_str_P, read_byte_rom, max_length); return lcd_put_u8str_max_cb(utf8_pstr, read_byte_rom, max_length);
} }
#if ENABLED(DEBUG_LCDPRINT) #if ENABLED(DEBUG_LCDPRINT)

42
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; uint8_t indent = (LCD_WIDTH - 8) / 2;
// symbols 217 (bottom right corner) and 218 (top left corner) are using for letters in some languages // 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 // 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, 0); lcd.write(TLC); lcd_put_u8str(F("------")); lcd.write(TRC);
lcd.setCursor(indent, 1); lcd.write(LR); lcd_put_u8str_P(PSTR("Marlin")); lcd.write(LR); 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_P(PSTR("------")); lcd.write(BRC); 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(SHORT_BUILD_VERSION), 3);
center_text_P(PSTR(MARLIN_WEBSITE_URL), 4); center_text_P(PSTR(MARLIN_WEBSITE_URL), 4);
picBits = ICON_LOGO; 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)) else if (axis_should_home(axis))
while (const char c = *value++) lcd.write(c <= '.' ? c : '?'); while (const char c = *value++) lcd.write(c <= '.' ? c : '?');
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis)) 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 else
lcd_put_u8str(value); 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) { FORCE_INLINE void _draw_cooler_status(const bool blink) {
const celsius_t t2 = thermalManager.degTargetCooler(); 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, 6); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler()));
lcd.setCursor(1, 7); 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) #if ENABLED(LASER_COOLANT_FLOW_METER)
FORCE_INLINE void _draw_flowmeter_status() { 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(7, 6); lcd_put_wchar('L');
lcd.setCursor(6, 7); lcd_put_u8str(ftostr11ns(cooler.flowrate)); 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) #if ENABLED(I2C_AMMETER)
FORCE_INLINE void _draw_ammeter_status() { 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(); ammeter.read();
lcd.setCursor(11, 6); lcd.setCursor(11, 6);
if (ammeter.current <= 0.999f) 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 #if HAS_CUTTER
FORCE_INLINE void _draw_cutter_status() { 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) #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.setCursor(15, 7); lcd_put_u8str(ftostr31ns(float(cutter.unitPower) / 1000));
lcd_put_wchar('K'); lcd_put_wchar('K');
#elif CUTTER_UNIT_IS(PERCENT) #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; if (!PanelDetected) return;
const uint8_t progress = ui._get_progress(); const uint8_t progress = ui._get_progress();
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
lcd_put_u8str_P(PSTR("SD")); lcd_put_u8str(F("SD"));
#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) #elif ENABLED(LCD_SET_PROGRESS_MANUALLY)
lcd_put_u8str_P(PSTR("P:")); lcd_put_u8str(F("P:"));
#endif #endif
if (progress) if (progress)
lcd.print(ui8tostr3rj(progress)); lcd.print(ui8tostr3rj(progress));
else else
lcd_put_u8str_P(PSTR("---")); lcd_put_u8str(F("---"));
lcd.write('%'); lcd.write('%');
} }
@ -643,9 +643,9 @@ void MarlinUI::draw_status_message(const bool blink) {
// Alternate Status message and Filament display // Alternate Status message and Filament display
if (ELAPSED(millis(), next_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.print(ftostr12ns(filament_width_meas));
lcd_put_u8str_P(PSTR(" V")); lcd_put_u8str(F(" V"));
lcd.print(i16tostr3rj(100.0 * ( lcd.print(i16tostr3rj(100.0 * (
parser.volumetric_enabled parser.volumetric_enabled
? planner.volumetric_area_nominal / planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] ? 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.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) #if BOTH(SDSUPPORT, HAS_PRINT_PROGRESS)
lcd.setCursor(LCD_WIDTH / 2 - 3, 1); lcd.setCursor(LCD_WIDTH / 2 - 3, 1);
@ -895,7 +895,7 @@ void MarlinUI::draw_status_screen() {
#else #else
#define FANX 17 #define FANX 17
#endif #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 + 1, 6); lcd.write('%');
lcd.setCursor(FANX, 7); lcd.setCursor(FANX, 7);
lcd.print(i16tostr3rj(per)); 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) { void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
if (!PanelDetected) return; if (!PanelDetected) return;
lcd.setCursor((LCD_WIDTH - 14) / 2, row + 1); 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.wholeDegHotend(extruder))); lcd.write(LCD_STR_DEGREE[0]); lcd.write('/');
lcd.print(i16tostr3rj(thermalManager.degTargetHotend(extruder))); lcd.write(LCD_STR_DEGREE[0]); lcd.print(i16tostr3rj(thermalManager.degTargetHotend(extruder))); lcd.write(LCD_STR_DEGREE[0]);
lcd.print_line(); lcd.print_line();
@ -1064,18 +1064,18 @@ void MarlinUI::draw_status_screen() {
*fb++ = ','; lcd.print(i16tostr3left(y_plot)); *fb = ')'; *fb++ = ','; lcd.print(i16tostr3left(y_plot)); *fb = ')';
// Show all values // 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.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])))); lcd.print(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
// Show the location value // 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])) if (!isnan(ubl.z_values[x_plot][y_plot]))
lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot])); lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
else else
lcd_put_u8str_P(PSTR(" -----")); lcd_put_u8str(F(" -----"));
center_text_P(GET_TEXT(MSG_UBL_FINE_TUNE_MESH), 8); center_text_P(GET_TEXT(MSG_UBL_FINE_TUNE_MESH), 8);

4
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; 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(), 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); u8g.setPrintPos(x + ret, y);
return ret; return ret;
} }

10
Marlin/src/lcd/dogm/marlinui_DOGM.cpp

@ -217,8 +217,8 @@ bool MarlinUI::detected() { return true; }
auto _draw_bootscreen_bmp = [&](const uint8_t *bitmap) { auto _draw_bootscreen_bmp = [&](const uint8_t *bitmap) {
u8g.drawBitmapP(offx, offy, START_BMP_BYTEWIDTH, START_BMPHEIGHT, bitmap); u8g.drawBitmapP(offx, offy, START_BMP_BYTEWIDTH, START_BMPHEIGHT, bitmap);
set_font(FONT_MENU); 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(txt_offx_1, txt_base - (MENU_FONT_HEIGHT), F(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_2, txt_base, F(MARLIN_WEBSITE_URL));
}; };
auto draw_bootscreen_bmp = [&](const uint8_t *bitmap) { auto draw_bootscreen_bmp = [&](const uint8_t *bitmap) {
@ -331,8 +331,8 @@ void MarlinUI::draw_kill_screen() {
do { do {
set_font(FONT_MENU); set_font(FONT_MENU);
lcd_put_u8str(0, h4 * 1, status_message); lcd_put_u8str(0, h4 * 1, status_message);
lcd_put_u8str_P(0, h4 * 2, GET_TEXT(MSG_HALTED)); lcd_put_u8str(0, h4 * 2, GET_TEXT_F(MSG_HALTED));
lcd_put_u8str_P(0, h4 * 3, GET_TEXT(MSG_PLEASE_RESET)); lcd_put_u8str(0, h4 * 3, GET_TEXT_F(MSG_PLEASE_RESET));
} while (u8g.nextPage()); } 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])) if (!isnan(ubl.z_values[x_plot][y_plot]))
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
else else
lcd_put_u8str_P(PSTR(" -----")); lcd_put_u8str(F(" -----"));
} }
} }

14
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) { FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, const uint8_t ty) {
if (temp < 0) 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 { else {
const char *str = i16tostr3rj(temp); const char *str = i16tostr3rj(temp);
const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1; 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)) else if (axis_should_home(axis))
while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?'); while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis)) 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 else
lcd_put_u8str(value); lcd_put_u8str(value);
} }
@ -777,7 +777,7 @@ void MarlinUI::draw_status_screen() {
} }
} }
else if (progress_state == 2 && estimation_string[0]) { 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); lcd_put_u8str(estimation_x_pos, EXTRAS_BASELINE, estimation_string);
} }
else if (elapsed_string[0]) { else if (elapsed_string[0]) {
@ -879,7 +879,7 @@ void MarlinUI::draw_status_screen() {
if (show_e_total) { if (show_e_total) {
#if ENABLED(LCD_SHOW_E_TOTAL) #if ENABLED(LCD_SHOW_E_TOTAL)
_draw_axis_value(E_AXIS, xstring, true); _draw_axis_value(E_AXIS, xstring, true);
lcd_put_u8str_P(PSTR(" ")); lcd_put_u8str(F(" "));
#endif #endif
} }
else { else {
@ -918,7 +918,7 @@ void MarlinUI::draw_status_screen() {
lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring); lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring);
lcd_put_wchar('%'); lcd_put_wchar('%');
set_font(FONT_MENU); 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]); lcd_put_wchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]);
#endif #endif
} }
@ -932,10 +932,10 @@ void MarlinUI::draw_status_screen() {
#if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
// Alternate Status message and Filament display // Alternate Status message and Filament display
if (ELAPSED(millis(), next_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_wchar(':');
lcd_put_u8str(wstring); 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_wchar(':');
lcd_put_u8str(mstring); lcd_put_u8str(mstring);
lcd_put_wchar('%'); lcd_put_wchar('%');

12
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++); while (*str && len--) write_byte(*str++);
} }
void ST7920_Lite_Status_Screen::write_str_P(PGM_P const str) { void ST7920_Lite_Status_Screen::write_str(FSTR_P const fstr) {
PGM_P p_str = (PGM_P)str; PGM_P pstr = FTOP(fstr);
while (char c = pgm_read_byte(p_str++)) write_byte(c); 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*/) { 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 // Draw centered
if (value > 9) { if (value > 9) {
write_number(value, 4); write_number(value, 4);
write_str_P(PSTR("% ")); write_str(F("% "));
} }
else { else {
write_number(value, 3); 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 (targetStateChange) {
if (!showTarget) write_str_P(PSTR(" ")); if (!showTarget) write_str(F(" "));
draw_degree_symbol(5, line, !showTarget); draw_degree_symbol(5, line, !showTarget);
draw_degree_symbol(9, line, showTarget); draw_degree_symbol(9, line, showTarget);
} }

2
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);
static void write_str(const char *str, const uint8_t len); 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 write_number(const int16_t value, const uint8_t digits=3);
static void _extended_function_set(const bool extended, const bool graphics); static void _extended_function_set(const bool extended, const bool graphics);

4
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); 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) { int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) {
return lcd_put_u8str_max_cb(utf8_str_P, read_byte_rom, 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*/) { 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*/) {

4
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))); slen = utf8_strlen(S(GET_TEXT_F(MSG_HALTED)));
lcd_moveto(cx - (slen / 2), cy); 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))); slen = utf8_strlen(S(GET_TEXT_F(MSG_HALTED)));
lcd_moveto(cx - (slen / 2), cy + 1); 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));
} }
// //

23
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 * @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) * @param max_length : the pixel length of the string allowed (or number of slots in HD44780)
* *
* @return the pixel width * @return the pixel width
* *
* Draw a ROM UTF-8 string * Draw a ROM UTF-8 string
*/ */
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);
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) { 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); 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); 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); 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); 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) { 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); lcd_moveto(col, row);
return lcd_put_u8str_ind_P(pstr, ind, inStr, maxlen); 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 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, PGM_P const str) { inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, const char * const str) {
lcd_moveto(col, row); lcd_moveto(col, row);
return lcd_put_u8str(str); return lcd_put_u8str(str);
} }

2
Marlin/src/lcd/menu/game/game.cpp

@ -48,7 +48,7 @@ void MarlinGame::draw_game_over() {
u8g.setColorIndex(0); u8g.setColorIndex(0);
u8g.drawBox(lx - 1, ly - gohigh - 1, gowide + 2, gohigh + 2); u8g.drawBox(lx - 1, ly - gohigh - 1, gowide + 2, gohigh + 2);
u8g.setColorIndex(1); 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"));
} }
} }

4
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 // Display # of good points found vs total needed
if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) { if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) {
SETCURSOR(TERN(TFT_COLOR_UI, 2, 0), cy); 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)); IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, cy));
lcd_put_u8str(GOOD_POINTS_TO_STR(good_points)); lcd_put_u8str(GOOD_POINTS_TO_STR(good_points));
lcd_put_wchar('/'); lcd_put_wchar('/');
@ -192,7 +192,7 @@ static void _lcd_level_bed_corners_get_next_position() {
// Display the Last Z value // Display the Last Z value
if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) { if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) {
SETCURSOR(TERN(TFT_COLOR_UI, 2, 0), cy); 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)); IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, 2));
lcd_put_u8str(LAST_Z_TO_STR(last_z)); lcd_put_u8str(LAST_Z_TO_STR(last_z));
} }

4
Marlin/src/lcd/menu/menu_mixer.cpp

@ -57,7 +57,7 @@
if (ui.should_draw()) { if (ui.should_draw()) {
char tmp[16]; char tmp[16];
SETCURSOR(1, (LCD_HEIGHT - 1) / 2); 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); sprintf_P(tmp, PSTR("%4d.%d mm"), int(zvar), int(zvar * 10) % 10);
SETCURSOR_RJ(9, (LCD_HEIGHT - 1) / 2); SETCURSOR_RJ(9, (LCD_HEIGHT - 1) / 2);
lcd_put_u8str(tmp); lcd_put_u8str(tmp);
@ -114,7 +114,7 @@ static uint8_t v_index;
void _lcd_draw_mix(const uint8_t y) { void _lcd_draw_mix(const uint8_t y) {
char tmp[20]; // "100%_100%" char tmp[20]; // "100%_100%"
sprintf_P(tmp, PSTR("%3d%% %3d%%"), int(mixer.mix[0]), int(mixer.mix[1])); 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); SETCURSOR_RJ(10, y); lcd_put_u8str(tmp);
} }
#endif #endif

4
Marlin/src/lcd/menu/menu_tune.cpp

@ -73,12 +73,12 @@
TERN_(HAS_MARLINUI_U8GLIB, ui.set_font(FONT_MENU)); TERN_(HAS_MARLINUI_U8GLIB, ui.set_font(FONT_MENU));
#if ENABLED(TFT_COLOR_UI) #if ENABLED(TFT_COLOR_UI)
lcd_moveto(4, 3); 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_put_wchar(':');
lcd_moveto(10, 3); lcd_moveto(10, 3);
#else #else
lcd_moveto(0, TERN(HAS_MARLINUI_U8GLIB, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT, LCD_HEIGHT - 1)); 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(':'); lcd_put_wchar(':');
#endif #endif
lcd_put_u8str(BABYSTEP_TO_STR(mps * babystep.axis_total[BS_TOTAL_IND(axis)])); lcd_put_u8str(BABYSTEP_TO_STR(mps * babystep.axis_total[BS_TOTAL_IND(axis)]));

4
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(); 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; if (max_length < 1) return 0;
tft_string.set(utf8_str_P); tft_string.set(utf8_pstr);
tft_string.trim(); tft_string.trim();
tft_string.truncate(max_length); tft_string.truncate(max_length);
tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);

Loading…
Cancel
Save