diff --git a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp index d17c336eec..7ebabd6950 100644 --- a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp +++ b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp @@ -439,6 +439,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop lcd_put_u8str(value); } } + TERN_(USE_BIG_EDIT_FONT, ui.set_font(FONT_MENU)); } inline void draw_boxed_string(const u8g_uint_t x, const u8g_uint_t y, PGM_P const pstr, const bool inv) { diff --git a/Marlin/src/lcd/lcdprint.h b/Marlin/src/lcd/lcdprint.h index 00139808ae..031d467bf9 100644 --- a/Marlin/src/lcd/lcdprint.h +++ b/Marlin/src/lcd/lcdprint.h @@ -76,8 +76,8 @@ #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT) #define INFO_FONT_WIDTH 6 - #define SETCURSOR(col, row) lcd_moveto(col * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT)) - #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT)) + #define SETCURSOR(col, row) lcd_moveto((col) * (MENU_FONT_WIDTH), ((row) + 1) * (MENU_FONT_HEIGHT)) + #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH), ((row) + 1) * (MENU_FONT_HEIGHT)) #else @@ -94,12 +94,13 @@ #define LCD_PIXEL_WIDTH LCD_WIDTH #define LCD_PIXEL_HEIGHT LCD_HEIGHT - #define SETCURSOR(col, row) lcd_moveto(col, row) - #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_WIDTH - (len), row) + #define SETCURSOR(col, row) lcd_moveto(col, row) + #define SETCURSOR_RJ(len, row) SETCURSOR(LCD_WIDTH - (len), row) #endif -#define SETCURSOR_X(col) SETCURSOR(col, _lcdLineNr) +#define SETCURSOR_X(col) SETCURSOR(col, _lcdLineNr) +#define SETCURSOR_X_RJ(len) SETCURSOR_RJ(len, _lcdLineNr) #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u) int lcd_glyph_height(); diff --git a/Marlin/src/lcd/menu/menu_addon.h b/Marlin/src/lcd/menu/menu_addon.h index b6eb8e1634..73e7061bf3 100644 --- a/Marlin/src/lcd/menu/menu_addon.h +++ b/Marlin/src/lcd/menu/menu_addon.h @@ -23,8 +23,11 @@ #include "../lcdprint.h" -#define MENU_ITEM_ADDON_START(X) do{ \ +#define _MENU_ITEM_ADDON_START(N,X) do{ \ if (ui.should_draw() && _menuLineNr == _thisItemNr - 1) { \ - SETCURSOR_X(X) + N(X) + +#define MENU_ITEM_ADDON_START(X) _MENU_ITEM_ADDON_START(SETCURSOR_X, X) +#define MENU_ITEM_ADDON_START_RJ(X) _MENU_ITEM_ADDON_START(SETCURSOR_X_RJ, X) #define MENU_ITEM_ADDON_END() } }while(0) diff --git a/Marlin/src/lcd/menu/menu_mixer.cpp b/Marlin/src/lcd/menu/menu_mixer.cpp index 2bcde1c286..abb56e4c5a 100644 --- a/Marlin/src/lcd/menu/menu_mixer.cpp +++ b/Marlin/src/lcd/menu/menu_mixer.cpp @@ -37,52 +37,33 @@ #if ENABLED(GRADIENT_MIX) - void lcd_mixer_gradient_z_start_edit() { + void _lcd_mixer_gradient_z_edit(const bool isend) { ui.defer_status_screen(); ENCODER_RATE_MULTIPLY(true); - if (ui.encoderPosition != 0) { - mixer.gradient.start_z += float(int32_t(ui.encoderPosition)) * 0.1; + + float &zvar = isend ? mixer.gradient.end_z : mixer.gradient.start_z; + + if (ui.encoderPosition) { + zvar += float(int32_t(ui.encoderPosition)) * 0.1; ui.encoderPosition = 0; - NOLESS(mixer.gradient.start_z, 0); - NOMORE(mixer.gradient.start_z, Z_MAX_POS); + NOLESS(zvar, 0); + NOMORE(zvar, Z_MAX_POS); } + if (ui.should_draw()) { - char tmp[21]; - strcpy_P(tmp, GET_TEXT(MSG_START_Z)); - sprintf_P(tmp + strlen(tmp), PSTR(": %4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10); - SETCURSOR(2, (LCD_HEIGHT - 1) / 2); + char tmp[16]; + SETCURSOR(1, (LCD_HEIGHT - 1) / 2); + lcd_put_u8str_P(isend ? GET_TEXT(MSG_END_Z) : GET_TEXT(MSG_START_Z)); + sprintf_P(tmp, PSTR("%4d.%d mm"), int(zvar), int(zvar * 10) % 10); + SETCURSOR_RJ(9, (LCD_HEIGHT - 1) / 2); lcd_put_u8str(tmp); } if (ui.lcd_clicked) { - if (mixer.gradient.start_z > mixer.gradient.end_z) - mixer.gradient.end_z = mixer.gradient.start_z; - mixer.refresh_gradient(); - ui.goto_previous_screen(); - } - } - - void lcd_mixer_gradient_z_end_edit() { - ui.defer_status_screen(); - ENCODER_RATE_MULTIPLY(true); - if (ui.encoderPosition != 0) { - mixer.gradient.end_z += float(int32_t(ui.encoderPosition)) * 0.1; - ui.encoderPosition = 0; - NOLESS(mixer.gradient.end_z, 0); - NOMORE(mixer.gradient.end_z, Z_MAX_POS); - } - - if (ui.should_draw()) { - char tmp[21]; - strcpy_P(tmp, GET_TEXT(MSG_END_Z)); - sprintf_P(tmp + strlen(tmp), PSTR(": %4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10); - SETCURSOR(2, (LCD_HEIGHT - 1) / 2); - lcd_put_u8str(tmp); - } - - if (ui.lcd_clicked) { - if (mixer.gradient.end_z < mixer.gradient.start_z) - mixer.gradient.start_z = mixer.gradient.end_z; + if (isend && zvar < mixer.gradient.start_z) + mixer.gradient.start_z = zvar; + else if (!isend && zvar > mixer.gradient.end_z) + mixer.gradient.end_z = zvar; mixer.refresh_gradient(); ui.goto_previous_screen(); } @@ -96,19 +77,21 @@ EDIT_ITEM(int8, MSG_END_VTOOL, &mixer.gradient.end_vtool, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient); #if ENABLED(GRADIENT_VTOOL) - EDIT_ITEM(int8, MSG_GRADIENT_ALIAS, &mixer.gradient.vtool_index, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient); + EDIT_ITEM(int8, MSG_GRADIENT_ALIAS, &mixer.gradient.vtool_index, -1, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient); #endif char tmp[18]; - SUBMENU(MSG_START_Z, lcd_mixer_gradient_z_start_edit); - MENU_ITEM_ADDON_START(9); + PGM_P const slabel = GET_TEXT(MSG_START_Z); + SUBMENU_P(slabel, []{ _lcd_mixer_gradient_z_edit(false); }); + MENU_ITEM_ADDON_START_RJ(11); sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10); lcd_put_u8str(tmp); MENU_ITEM_ADDON_END(); - SUBMENU(MSG_END_Z, lcd_mixer_gradient_z_end_edit); - MENU_ITEM_ADDON_START(9); + PGM_P const elabel = GET_TEXT(MSG_END_Z); + SUBMENU_P(elabel, []{ _lcd_mixer_gradient_z_edit(true); }); + MENU_ITEM_ADDON_START_RJ(11); sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10); lcd_put_u8str(tmp); MENU_ITEM_ADDON_END(); @@ -125,7 +108,7 @@ static uint8_t v_index; char tmp[20]; // "100%_100%" sprintf_P(tmp, PSTR("%3d%% %3d%%"), int(mixer.mix[0]), int(mixer.mix[1])); SETCURSOR(2, y); lcd_put_u8str_P(GET_TEXT(MSG_MIX)); - SETCURSOR_RJ(9, y); lcd_put_u8str(tmp); + SETCURSOR_RJ(10, y); lcd_put_u8str(tmp); } #endif @@ -157,7 +140,7 @@ void lcd_mixer_mix_edit() { #if HAS_DUAL_MIXING && !CHANNEL_MIX_EDITING // Adjust 2-channel mix from the encoder - if (ui.encoderPosition != 0) { + if (ui.encoderPosition) { mixer.mix[0] += int32_t(ui.encoderPosition); ui.encoderPosition = 0; if (mixer.mix[0] < 0) mixer.mix[0] += 101; @@ -241,9 +224,9 @@ void menu_mixer() { #if HAS_DUAL_MIXING { - char tmp[10]; + char tmp[11]; SUBMENU(MSG_MIX, lcd_mixer_mix_edit); - MENU_ITEM_ADDON_START(10); + MENU_ITEM_ADDON_START_RJ(9); mixer.update_mix_from_vtool(); sprintf_P(tmp, PSTR("%3d;%3d%%"), int(mixer.mix[0]), int(mixer.mix[1])); lcd_put_u8str(tmp); @@ -272,7 +255,7 @@ void menu_mixer() { { char tmp[13]; SUBMENU(MSG_GRADIENT, lcd_mixer_edit_gradient_menu); - MENU_ITEM_ADDON_START(10); + MENU_ITEM_ADDON_START_RJ(9); sprintf_P(tmp, PSTR("T%i->T%i"), mixer.gradient.start_vtool, mixer.gradient.end_vtool); lcd_put_u8str(tmp); MENU_ITEM_ADDON_END();