String interpolation for 2-digit numbers (#18998)

This commit is contained in:
Scott Lahteine
2020-08-12 16:46:51 -05:00
committed by GitHub
parent ca4eaf92b4
commit ee28a10795
4 changed files with 27 additions and 22 deletions

View File

@@ -44,22 +44,28 @@ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const i
if (ch == '=' || ch == '~' || ch == '*') {
if (ind >= 0) {
if (ch == '*') { lcd_put_wchar('E'); n--; }
if (n) { lcd_put_wchar(ind + ((ch == '=') ? '0' : LCD_FIRST_TOOL)); n--; }
if (n) {
int8_t inum = ind + ((ch == '=') ? 0 : LCD_FIRST_TOOL);
if (inum >= 10) {
lcd_put_wchar('0' + (inum / 10)); n--;
inum %= 10;
}
if (n) { lcd_put_wchar('0' + inum); n--; }
}
}
else {
PGM_P const b = ind == -2 ? GET_TEXT(MSG_CHAMBER) : GET_TEXT(MSG_BED);
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;
}
else if (ch == '$' && inStr) {
n -= lcd_put_u8str_max_P(inStr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
continue;
}
lcd_put_wchar(ch);
n--;
else {
lcd_put_wchar(ch);
n--;
}
}
return n;
}