MarlinUI support for up to 5 Material Presets (#18488)
- Add `I` preset parameter to `G26`, `M106`, `M140`, and `M190`. - Extend menu items to permit a string interpolation. - Keep material names in a list and interpolate in menu items. - Extend material presets to support up to 5 predefined materials. Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
@@ -28,17 +28,16 @@
|
||||
|
||||
#if HAS_SPI_LCD
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
#include "lcdprint.h"
|
||||
|
||||
/**
|
||||
* lcd_put_u8str_ind_P
|
||||
* Print a string with an index substituted within it
|
||||
*/
|
||||
lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, const lcd_uint_t maxlen/*=LCD_WIDTH*/) {
|
||||
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;
|
||||
lcd_uint_t n = maxlen;
|
||||
for (; n; n--) {
|
||||
int8_t n = maxlen;
|
||||
for (; n > 0; n--) {
|
||||
wchar_t ch;
|
||||
p = get_utf8_value_cb(p, read_byte_rom, &ch);
|
||||
if (!ch) break;
|
||||
@@ -46,17 +45,21 @@ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, const lcd_uin
|
||||
// lcd_put_int(ind); n--; if (ind >= 10) n--;
|
||||
if (ind >= 0) {
|
||||
if (ch == '*') { lcd_put_wchar('E'); n--; }
|
||||
lcd_put_wchar(ind + ((ch == '=') ? '0' : LCD_FIRST_TOOL));
|
||||
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);
|
||||
}
|
||||
if (n) n -= lcd_put_u8str_max_P((PGM_P)p, n);
|
||||
break;
|
||||
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);
|
||||
}
|
||||
return n;
|
||||
|
||||
Reference in New Issue
Block a user