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:
@ -1004,7 +1004,7 @@ void MarlinUI::draw_status_screen() {
|
||||
int8_t pad = (LCD_WIDTH - utf8_strlen_P(pstr)) / 2;
|
||||
while (--pad >= 0) { lcd_put_wchar(' '); n--; }
|
||||
}
|
||||
n = lcd_put_u8str_ind_P(pstr, itemIndex, n);
|
||||
n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, n);
|
||||
if (valstr) n -= lcd_put_u8str_max(valstr, n);
|
||||
for (; n > 0; --n) lcd_put_wchar(' ');
|
||||
}
|
||||
@ -1012,20 +1012,20 @@ void MarlinUI::draw_status_screen() {
|
||||
// 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) {
|
||||
lcd_put_wchar(0, row, sel ? pre_char : ' ');
|
||||
uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, LCD_WIDTH - 2);
|
||||
uint8_t n = lcd_put_u8str_ind_P(pstr, 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 data, const bool pgm) {
|
||||
const uint8_t vlen = data ? (pgm ? utf8_strlen_P(data) : utf8_strlen(data)) : 0;
|
||||
void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, 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, LCD_WIDTH - 2 - vlen);
|
||||
uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2 - vlen);
|
||||
if (vlen) {
|
||||
lcd_put_wchar(':');
|
||||
for (; n; --n) lcd_put_wchar(' ');
|
||||
if (pgm) lcd_put_u8str_P(data); else lcd_put_u8str(data);
|
||||
if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str(inStr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1033,7 +1033,7 @@ void MarlinUI::draw_status_screen() {
|
||||
void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
|
||||
ui.encoder_direction_normal();
|
||||
|
||||
uint8_t n = lcd_put_u8str_ind_P(0, 1, pstr, itemIndex, LCD_WIDTH - 1);
|
||||
uint8_t n = lcd_put_u8str_ind_P(0, 1, pstr, itemIndex, itemString, LCD_WIDTH - 1);
|
||||
if (value != nullptr) {
|
||||
lcd_put_wchar(':');
|
||||
int len = utf8_strlen(value);
|
||||
|
Reference in New Issue
Block a user