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

This commit is contained in:
Scott Lahteine
2021-09-25 23:52:41 -05:00
parent c3ae221a10
commit 9cf1c3cf05
20 changed files with 129 additions and 115 deletions

View File

@ -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;
}

View File

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

View File

@ -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('%');

View File

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

View File

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