Merge upstream changes from Marlin 2.1.1

This commit is contained in:
Stefan Kalscheuer
2022-09-03 09:23:32 +02:00
parent 626283aadb
commit 986e416c7f
1610 changed files with 73839 additions and 40857 deletions

View File

@@ -26,38 +26,40 @@
#include "../inc/MarlinConfigPre.h"
#if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT && !IS_DWIN_MARLINUI
#if HAS_LCDPRINT
#include "marlinui.h"
#include "lcdprint.h"
/**
* lcd_put_u8str_ind_P
* lcd_put_u8str_P
*
* Print a string with an index substituted within it:
* Print a string with optional substitutions:
*
* $ displays the clipped string given by fstr or cstr
* = displays '0'....'10' for indexes 0 - 10
* ~ displays '1'....'11' for indexes 0 - 10
* * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL)
* @ displays an axis name such as XYZUVW, or E for an extruder
*/
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*/) {
lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char *cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/, const lcd_uint_t maxlen/*=LCD_WIDTH*/) {
const uint8_t prop = USE_WIDE_GLYPH ? 2 : 1;
uint8_t *p = (uint8_t*)pstr;
const uint8_t *p = (uint8_t*)ptpl;
int8_t n = maxlen;
while (n > 0) {
wchar_t ch;
p = get_utf8_value_cb(p, read_byte_rom, &ch);
if (!ch) break;
if (ch == '=' || ch == '~' || ch == '*') {
lchar_t wc;
p = get_utf8_value_cb(p, read_byte_rom, wc);
if (!wc) break;
if (wc == '=' || wc == '~' || wc == '*') {
if (ind >= 0) {
if (ch == '*') { lcd_put_wchar('E'); n--; }
if (wc == '*') { lcd_put_lchar('E'); n--; }
if (n) {
int8_t inum = ind + ((ch == '=') ? 0 : LCD_FIRST_TOOL);
int8_t inum = ind + ((wc == '=') ? 0 : LCD_FIRST_TOOL);
if (inum >= 10) {
lcd_put_wchar('0' + (inum / 10)); n--;
lcd_put_lchar('0' + (inum / 10)); n--;
inum %= 10;
}
if (n) { lcd_put_wchar('0' + inum); n--; }
if (n) { lcd_put_lchar('0' + inum); n--; }
}
}
else {
@@ -69,12 +71,19 @@ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const i
break;
}
}
else if (ch == '$' && inStr) {
n -= lcd_put_u8str_max_P(inStr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
else if (wc == '$' && fstr) {
n -= lcd_put_u8str_max_P(FTOP(fstr), n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
}
else if (wc == '$' && cstr) {
n -= lcd_put_u8str_max(cstr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
}
else if (wc == '@') {
lcd_put_lchar(AXIS_CHAR(ind));
n--;
}
else {
lcd_put_wchar(ch);
n -= ch > 255 ? prop : 1;
lcd_put_lchar(wc);
n -= wc > 255 ? prop : 1;
}
}
return n;
@@ -84,17 +93,17 @@ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const i
int calculateWidth(PGM_P const pstr) {
if (!USE_WIDE_GLYPH) return utf8_strlen_P(pstr) * MENU_FONT_WIDTH;
const uint8_t prop = 2;
uint8_t *p = (uint8_t*)pstr;
const uint8_t *p = (uint8_t*)pstr;
int n = 0;
do {
wchar_t ch;
p = get_utf8_value_cb(p, read_byte_rom, &ch);
if (!ch) break;
n += (ch > 255) ? prop : 1;
lchar_t wc;
p = get_utf8_value_cb(p, read_byte_rom, wc);
if (!wc) break;
n += (wc > 255) ? prop : 1;
} while (1);
return n * MENU_FONT_WIDTH;
}
#endif // HAS_WIRED_LCD
#endif // HAS_LCDPRINT