🧑‍💻 Apply F() to some LCD / TFT strings

Followup to #24228
This commit is contained in:
Scott Lahteine
2022-06-13 20:43:23 -05:00
parent c605c1ebb5
commit 78a3ea0ed4
20 changed files with 160 additions and 109 deletions

View File

@ -176,9 +176,13 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit=0xFFFF);
inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, FSTR_P const ftitle) {
char ctitle[strlen_P(FTOP(ftitle)) + 1];
strcpy_P(ctitle, FTOP(ftitle));
DWIN_Draw_String(bShow, size, color, bColor, x, y, ctitle);
#ifdef __AVR__
char ctitle[strlen_P(FTOP(ftitle)) + 1];
strcpy_P(ctitle, FTOP(ftitle));
DWIN_Draw_String(bShow, size, color, bColor, x, y, ctitle);
#else
DWIN_Draw_String(bShow, size, color, bColor, x, y, FTOP(ftitle));
#endif
}
// Draw a positive integer

View File

@ -4307,9 +4307,13 @@ void DWIN_StatusChanged(const char * const cstr/*=nullptr*/) {
}
void DWIN_StatusChanged(FSTR_P const fstr) {
char str[strlen_P(FTOP(fstr)) + 1];
strcpy_P(str, FTOP(fstr));
DWIN_StatusChanged(str);
#ifdef __AVR__
char str[strlen_P(FTOP(fstr)) + 1];
strcpy_P(str, FTOP(fstr));
DWIN_StatusChanged(str);
#else
DWIN_StatusChanged(FTOP(fstr));
#endif
}
#endif // DWIN_CREALITY_LCD

View File

@ -274,7 +274,7 @@ void MarlinUI::draw_status_message(const bool blink) {
dwin_font.solid = false;
dwin_font.fg = Color_White;
dwin_string.set("E");
dwin_string.set('E');
dwin_string.add('1' + extruder);
dwin_string.add(' ');
dwin_string.add(i16tostr3rj(thermalManager.degHotend(extruder)));
@ -282,7 +282,7 @@ void MarlinUI::draw_status_message(const bool blink) {
if (get_blink() || !thermalManager.heater_idle[thermalManager.idle_index_for_id(extruder)].timed_out)
dwin_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder)));
else
dwin_string.add(PSTR(" "));
dwin_string.add(F(" "));
lcd_moveto(LCD_WIDTH - dwin_string.length, row);
lcd_put_dwin_string();
@ -540,11 +540,11 @@ void MarlinUI::draw_status_message(const bool blink) {
lcd_put_u8str(ftostr52(lpos.y));
// Print plot position
dwin_string.set("(");
dwin_string.set('(');
dwin_string.add(i8tostr3rj(x_plot));
dwin_string.add(",");
dwin_string.add(',');
dwin_string.add(i8tostr3rj(y_plot));
dwin_string.add(")");
dwin_string.add(')');
lcd_moveto(
TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length),
TERN(DWIN_MARLINUI_LANDSCAPE, LCD_HEIGHT - 2, ((y_offset + y_map_pixels) / MENU_LINE_HEIGHT) + 1)
@ -556,7 +556,7 @@ void MarlinUI::draw_status_message(const bool blink) {
if (!isnan(bedlevel.z_values[x_plot][y_plot]))
dwin_string.add(ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
else
dwin_string.add(PSTR(" -----"));
dwin_string.add(F(" -----"));
lcd_moveto(
TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length),
TERN(DWIN_MARLINUI_LANDSCAPE, LCD_HEIGHT - 1, ((y_offset + y_map_pixels) / MENU_LINE_HEIGHT) + 2)

View File

@ -88,7 +88,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
// For E_TOTAL there may be some characters to cover up
if (BOTH(DWIN_MARLINUI_PORTRAIT, LCD_SHOW_E_TOTAL) && axis == X_AXIS)
dwin_string.add(" ");
dwin_string.add(F(" "));
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string()));
@ -117,7 +117,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
// For E_TOTAL there may be some characters to cover up
if (ENABLED(LCD_SHOW_E_TOTAL) && (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) && axis == X_AXIS)
dwin_string.add(" ");
dwin_string.add(F(" "));
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 32, y + 4, S(dwin_string.string()));
@ -133,7 +133,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
if (!ui.did_first_redraw) {
// Extra spaces to erase previous value
dwin_string.set("E ");
dwin_string.set(F("E "));
DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (4 * 14 / 2) - 7, y + 2, S(dwin_string.string()));
}
@ -146,7 +146,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
#else // !DWIN_MARLINUI_PORTRAIT
if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) {
dwin_string.set("E ");
dwin_string.set(F("E "));
DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string()));
}
@ -176,7 +176,7 @@ FORCE_INLINE void _draw_fan_status(const uint16_t x, const uint16_t y) {
else {
DWIN_ICON_AnimationControl(0x0000); // disable all icon animations (this is the only one)
DWIN_ICON_Show(ICON, ICON_Fan0, x + fanx, y);
dwin_string.set(PSTR(" "));
dwin_string.set(F(" "));
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string()));
}
}
@ -289,7 +289,7 @@ FORCE_INLINE void _draw_feedrate_status(const char *value, uint16_t x, uint16_t
}
dwin_string.set(value);
dwin_string.add(PSTR("%"));
dwin_string.add('%');
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 14, y, S(dwin_string.string()));
}
@ -396,7 +396,7 @@ void MarlinUI::draw_status_screen() {
// landscape mode shows both elapsed and remaining (if SHOW_REMAINING_TIME)
time = print_job_timer.duration();
time.toDigital(buffer);
dwin_string.set(" ");
dwin_string.set(' ');
dwin_string.add(buffer);
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 230, 170, S(dwin_string.string()));
@ -405,7 +405,7 @@ void MarlinUI::draw_status_screen() {
time = get_remaining_time();
DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(" R "));
if (print_job_timer.isPaused() && blink)
dwin_string.set(" ");
dwin_string.set(F(" "));
else {
time.toDigital(buffer);
dwin_string.set(buffer);
@ -413,7 +413,7 @@ void MarlinUI::draw_status_screen() {
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 378, 170, S(dwin_string.string()));
}
else if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) {
dwin_string.set(" ");
dwin_string.set(F(" "));
DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(dwin_string.string()));
}
#endif
@ -449,7 +449,7 @@ void MarlinUI::draw_status_screen() {
#if ENABLED(SHOW_SD_PERCENT)
dwin_string.set(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))));
dwin_string.add(PSTR("%"));
dwin_string.add('%');
DWIN_Draw_String(
false, font16x32, Percent_Color, Color_Bg_Black,
pb_left + (pb_width - dwin_string.length * 16) / 2,