Fix / improve menu items (#18644)

This commit is contained in:
Scott Lahteine
2020-07-13 19:59:32 -05:00
committed by GitHub
parent b670001269
commit 0e1cb10909
11 changed files with 78 additions and 52 deletions

View File

@@ -37,20 +37,18 @@
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*/) {
uint8_t *p = (uint8_t*)pstr;
int8_t n = maxlen;
for (; n > 0; n--) {
while (n > 0) {
wchar_t ch;
p = get_utf8_value_cb(p, read_byte_rom, &ch);
if (!ch) break;
if (ch == '=' || ch == '~' || ch == '*') {
// lcd_put_int(ind); n--; if (ind >= 10) n--;
if (ind >= 0) {
if (ch == '*') { lcd_put_wchar('E'); n--; }
if (n) { lcd_put_wchar(ind + ((ch == '=') ? '0' : LCD_FIRST_TOOL)); n--; }
}
else {
PGM_P const b = ind == -2 ? GET_TEXT(MSG_CHAMBER) : GET_TEXT(MSG_BED);
lcd_put_u8str_P(b);
n -= utf8_strlen_P(b);
n -= lcd_put_u8str_max_P(b, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
}
if (n) n -= lcd_put_u8str_max_P((PGM_P)p, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
continue;
@@ -61,6 +59,7 @@ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const i
}
lcd_put_wchar(ch);
n--;
}
return n;
}