♻️ Apply F() to more LCD code (#24228)
This commit is contained in:
committed by
Scott Lahteine
parent
9a74bcd4cf
commit
28f8646aa6
@@ -410,7 +410,7 @@ 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, FSTR_P const ftxt, const uint8_t len, const int16_t time) {
|
||||
uint8_t slen = utf8_strlen_P(FTOP(ftxt));
|
||||
uint8_t slen = utf8_strlen(ftxt);
|
||||
if (slen < len) {
|
||||
lcd_put_u8str_max(col, line, ftxt, len);
|
||||
for (; slen < len; ++slen) lcd_put_wchar(' ');
|
||||
@@ -437,10 +437,10 @@ 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;
|
||||
static void logo_lines(FSTR_P const extra) {
|
||||
int16_t indent = (LCD_WIDTH - 8 - utf8_strlen(extra)) / 2;
|
||||
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_u8str(indent, 1, F("|Marlin|")); lcd_put_u8str(extra);
|
||||
lcd_put_wchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_wchar('\x03');
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
|
||||
//
|
||||
// Show the Marlin logo, splash line1, and splash line 2
|
||||
//
|
||||
logo_lines(PSTR(" " SHORT_BUILD_VERSION));
|
||||
logo_lines(F(" " SHORT_BUILD_VERSION));
|
||||
CENTER_OR_SCROLL(MARLIN_WEBSITE_URL, 2000);
|
||||
}
|
||||
else {
|
||||
@@ -476,7 +476,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
|
||||
// Show the Marlin logo and short build version
|
||||
// After a delay show the website URL
|
||||
//
|
||||
logo_lines(NUL_STR);
|
||||
logo_lines(FPSTR(NUL_STR));
|
||||
CENTER_OR_SCROLL(SHORT_BUILD_VERSION, 1500);
|
||||
CENTER_OR_SCROLL(MARLIN_WEBSITE_URL, 1500);
|
||||
#ifdef STRING_SPLASH_LINE3
|
||||
@@ -1067,33 +1067,33 @@ void MarlinUI::draw_status_screen() {
|
||||
#endif // ADVANCED_PAUSE_FEATURE
|
||||
|
||||
// Draw a static item with no left-right margin required. Centered by default.
|
||||
void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) {
|
||||
void MenuItem_static::draw(const uint8_t row, FSTR_P const fstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) {
|
||||
int8_t n = LCD_WIDTH;
|
||||
lcd_moveto(0, row);
|
||||
const int8_t plen = pstr ? utf8_strlen_P(pstr) : 0,
|
||||
const int8_t plen = fstr ? utf8_strlen(fstr) : 0,
|
||||
vlen = vstr ? utf8_strlen(vstr) : 0;
|
||||
if (style & SS_CENTER) {
|
||||
int8_t pad = (LCD_WIDTH - plen - vlen) / 2;
|
||||
while (--pad >= 0) { lcd_put_wchar(' '); n--; }
|
||||
}
|
||||
if (plen) n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, n);
|
||||
if (plen) n = lcd_put_u8str_ind(fstr, itemIndex, itemString, n);
|
||||
if (vlen) n -= lcd_put_u8str_max(vstr, n);
|
||||
for (; n > 0; --n) lcd_put_wchar(' ');
|
||||
}
|
||||
|
||||
// Draw a generic menu item with pre_char (if selected) and post_char
|
||||
void MenuItemBase::_draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char) {
|
||||
void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char pre_char, const char post_char) {
|
||||
lcd_put_wchar(0, row, sel ? pre_char : ' ');
|
||||
uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2);
|
||||
uint8_t n = lcd_put_u8str_ind(fstr, itemIndex, itemString, LCD_WIDTH - 2);
|
||||
for (; n; --n) lcd_put_wchar(' ');
|
||||
lcd_put_wchar(post_char);
|
||||
}
|
||||
|
||||
// Draw a menu item with a (potentially) editable value
|
||||
void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const inStr, const bool pgm) {
|
||||
void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char * const inStr, const bool pgm) {
|
||||
const uint8_t vlen = inStr ? (pgm ? utf8_strlen_P(inStr) : utf8_strlen(inStr)) : 0;
|
||||
lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
|
||||
uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2 - vlen);
|
||||
uint8_t n = lcd_put_u8str_ind(fstr, itemIndex, itemString, LCD_WIDTH - 2 - vlen);
|
||||
if (vlen) {
|
||||
lcd_put_wchar(':');
|
||||
for (; n; --n) lcd_put_wchar(' ');
|
||||
@@ -1102,9 +1102,9 @@ void MarlinUI::draw_status_screen() {
|
||||
}
|
||||
|
||||
// Low-level draw_edit_screen can be used to draw an edit screen from anyplace
|
||||
void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) {
|
||||
void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const value/*=nullptr*/) {
|
||||
ui.encoder_direction_normal();
|
||||
uint8_t n = lcd_put_u8str_ind_P(0, 1, pstr, itemIndex, itemString, LCD_WIDTH - 1);
|
||||
uint8_t n = lcd_put_u8str_ind(0, 1, fstr, itemIndex, itemString, LCD_WIDTH - 1);
|
||||
if (value) {
|
||||
lcd_put_wchar(':'); n--;
|
||||
const uint8_t len = utf8_strlen(value) + 1; // Plus one for a leading space
|
||||
@@ -1115,21 +1115,21 @@ void MarlinUI::draw_status_screen() {
|
||||
}
|
||||
|
||||
// The Select Screen presents a prompt and two "buttons"
|
||||
void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
|
||||
void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, const bool yesno, FSTR_P const pref, const char * const string/*=nullptr*/, FSTR_P const suff/*=nullptr*/) {
|
||||
ui.draw_select_screen_prompt(pref, string, suff);
|
||||
if (no) {
|
||||
SETCURSOR(0, LCD_HEIGHT - 1);
|
||||
lcd_put_wchar(yesno ? ' ' : '['); lcd_put_u8str_P(no); lcd_put_wchar(yesno ? ' ' : ']');
|
||||
lcd_put_wchar(yesno ? ' ' : '['); lcd_put_u8str(no); lcd_put_wchar(yesno ? ' ' : ']');
|
||||
}
|
||||
if (yes) {
|
||||
SETCURSOR_RJ(utf8_strlen_P(yes) + 2, LCD_HEIGHT - 1);
|
||||
lcd_put_wchar(yesno ? '[' : ' '); lcd_put_u8str_P(yes); lcd_put_wchar(yesno ? ']' : ' ');
|
||||
SETCURSOR_RJ(utf8_strlen(yes) + 2, LCD_HEIGHT - 1);
|
||||
lcd_put_wchar(yesno ? '[' : ' '); lcd_put_u8str(yes); lcd_put_wchar(yesno ? ']' : ' ');
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
|
||||
void MenuItem_sdbase::draw(const bool sel, const uint8_t row, PGM_P const, CardReader &theCard, const bool isDir) {
|
||||
void MenuItem_sdbase::draw(const bool sel, const uint8_t row, FSTR_P const, CardReader &theCard, const bool isDir) {
|
||||
lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' ');
|
||||
constexpr uint8_t maxlen = LCD_WIDTH - 2;
|
||||
uint8_t n = maxlen - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen);
|
||||
|
Reference in New Issue
Block a user