Browse Source

Fix up mixer menu display

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
f860152a35
  1. 1
      Marlin/src/lcd/dogm/ultralcd_DOGM.cpp
  2. 11
      Marlin/src/lcd/lcdprint.h
  3. 7
      Marlin/src/lcd/menu/menu_addon.h
  4. 71
      Marlin/src/lcd/menu/menu_mixer.cpp

1
Marlin/src/lcd/dogm/ultralcd_DOGM.cpp

@ -439,6 +439,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
lcd_put_u8str(value); 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) { inline void draw_boxed_string(const u8g_uint_t x, const u8g_uint_t y, PGM_P const pstr, const bool inv) {

11
Marlin/src/lcd/lcdprint.h

@ -76,8 +76,8 @@
#define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT) #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT)
#define INFO_FONT_WIDTH 6 #define INFO_FONT_WIDTH 6
#define SETCURSOR(col, row) lcd_moveto(col * (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)) #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH), ((row) + 1) * (MENU_FONT_HEIGHT))
#else #else
@ -94,12 +94,13 @@
#define LCD_PIXEL_WIDTH LCD_WIDTH #define LCD_PIXEL_WIDTH LCD_WIDTH
#define LCD_PIXEL_HEIGHT LCD_HEIGHT #define LCD_PIXEL_HEIGHT LCD_HEIGHT
#define SETCURSOR(col, row) lcd_moveto(col, row) #define SETCURSOR(col, row) lcd_moveto(col, row)
#define SETCURSOR_RJ(len, row) lcd_moveto(LCD_WIDTH - (len), row) #define SETCURSOR_RJ(len, row) SETCURSOR(LCD_WIDTH - (len), row)
#endif #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) #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
int lcd_glyph_height(); int lcd_glyph_height();

7
Marlin/src/lcd/menu/menu_addon.h

@ -23,8 +23,11 @@
#include "../lcdprint.h" #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) { \ 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) #define MENU_ITEM_ADDON_END() } }while(0)

71
Marlin/src/lcd/menu/menu_mixer.cpp

@ -37,52 +37,33 @@
#if ENABLED(GRADIENT_MIX) #if ENABLED(GRADIENT_MIX)
void lcd_mixer_gradient_z_start_edit() { void _lcd_mixer_gradient_z_edit(const bool isend) {
ui.defer_status_screen(); ui.defer_status_screen();
ENCODER_RATE_MULTIPLY(true); ENCODER_RATE_MULTIPLY(true);
if (ui.encoderPosition != 0) {
mixer.gradient.start_z += float(int32_t(ui.encoderPosition)) * 0.1;
ui.encoderPosition = 0;
NOLESS(mixer.gradient.start_z, 0);
NOMORE(mixer.gradient.start_z, 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);
lcd_put_u8str(tmp);
}
if (ui.lcd_clicked) { float &zvar = isend ? mixer.gradient.end_z : mixer.gradient.start_z;
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() { if (ui.encoderPosition) {
ui.defer_status_screen(); zvar += float(int32_t(ui.encoderPosition)) * 0.1;
ENCODER_RATE_MULTIPLY(true);
if (ui.encoderPosition != 0) {
mixer.gradient.end_z += float(int32_t(ui.encoderPosition)) * 0.1;
ui.encoderPosition = 0; ui.encoderPosition = 0;
NOLESS(mixer.gradient.end_z, 0); NOLESS(zvar, 0);
NOMORE(mixer.gradient.end_z, Z_MAX_POS); NOMORE(zvar, Z_MAX_POS);
} }
if (ui.should_draw()) { if (ui.should_draw()) {
char tmp[21]; char tmp[16];
strcpy_P(tmp, GET_TEXT(MSG_END_Z)); SETCURSOR(1, (LCD_HEIGHT - 1) / 2);
sprintf_P(tmp + strlen(tmp), PSTR(": %4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10); lcd_put_u8str_P(isend ? GET_TEXT(MSG_END_Z) : GET_TEXT(MSG_START_Z));
SETCURSOR(2, (LCD_HEIGHT - 1) / 2); sprintf_P(tmp, PSTR("%4d.%d mm"), int(zvar), int(zvar * 10) % 10);
SETCURSOR_RJ(9, (LCD_HEIGHT - 1) / 2);
lcd_put_u8str(tmp); lcd_put_u8str(tmp);
} }
if (ui.lcd_clicked) { if (ui.lcd_clicked) {
if (mixer.gradient.end_z < mixer.gradient.start_z) if (isend && zvar < mixer.gradient.start_z)
mixer.gradient.start_z = mixer.gradient.end_z; mixer.gradient.start_z = zvar;
else if (!isend && zvar > mixer.gradient.end_z)
mixer.gradient.end_z = zvar;
mixer.refresh_gradient(); mixer.refresh_gradient();
ui.goto_previous_screen(); 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); EDIT_ITEM(int8, MSG_END_VTOOL, &mixer.gradient.end_vtool, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient);
#if ENABLED(GRADIENT_VTOOL) #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 #endif
char tmp[18]; char tmp[18];
SUBMENU(MSG_START_Z, lcd_mixer_gradient_z_start_edit); PGM_P const slabel = GET_TEXT(MSG_START_Z);
MENU_ITEM_ADDON_START(9); 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); sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10);
lcd_put_u8str(tmp); lcd_put_u8str(tmp);
MENU_ITEM_ADDON_END(); MENU_ITEM_ADDON_END();
SUBMENU(MSG_END_Z, lcd_mixer_gradient_z_end_edit); PGM_P const elabel = GET_TEXT(MSG_END_Z);
MENU_ITEM_ADDON_START(9); 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); sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10);
lcd_put_u8str(tmp); lcd_put_u8str(tmp);
MENU_ITEM_ADDON_END(); MENU_ITEM_ADDON_END();
@ -125,7 +108,7 @@ static uint8_t v_index;
char tmp[20]; // "100%_100%" char tmp[20]; // "100%_100%"
sprintf_P(tmp, PSTR("%3d%% %3d%%"), int(mixer.mix[0]), int(mixer.mix[1])); 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(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 #endif
@ -157,7 +140,7 @@ void lcd_mixer_mix_edit() {
#if HAS_DUAL_MIXING && !CHANNEL_MIX_EDITING #if HAS_DUAL_MIXING && !CHANNEL_MIX_EDITING
// Adjust 2-channel mix from the encoder // Adjust 2-channel mix from the encoder
if (ui.encoderPosition != 0) { if (ui.encoderPosition) {
mixer.mix[0] += int32_t(ui.encoderPosition); mixer.mix[0] += int32_t(ui.encoderPosition);
ui.encoderPosition = 0; ui.encoderPosition = 0;
if (mixer.mix[0] < 0) mixer.mix[0] += 101; if (mixer.mix[0] < 0) mixer.mix[0] += 101;
@ -241,9 +224,9 @@ void menu_mixer() {
#if HAS_DUAL_MIXING #if HAS_DUAL_MIXING
{ {
char tmp[10]; char tmp[11];
SUBMENU(MSG_MIX, lcd_mixer_mix_edit); SUBMENU(MSG_MIX, lcd_mixer_mix_edit);
MENU_ITEM_ADDON_START(10); MENU_ITEM_ADDON_START_RJ(9);
mixer.update_mix_from_vtool(); mixer.update_mix_from_vtool();
sprintf_P(tmp, PSTR("%3d;%3d%%"), int(mixer.mix[0]), int(mixer.mix[1])); sprintf_P(tmp, PSTR("%3d;%3d%%"), int(mixer.mix[0]), int(mixer.mix[1]));
lcd_put_u8str(tmp); lcd_put_u8str(tmp);
@ -272,7 +255,7 @@ void menu_mixer() {
{ {
char tmp[13]; char tmp[13];
SUBMENU(MSG_GRADIENT, lcd_mixer_edit_gradient_menu); 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); sprintf_P(tmp, PSTR("T%i->T%i"), mixer.gradient.start_vtool, mixer.gradient.end_vtool);
lcd_put_u8str(tmp); lcd_put_u8str(tmp);
MENU_ITEM_ADDON_END(); MENU_ITEM_ADDON_END();

Loading…
Cancel
Save