Browse Source

Fix up mixer menu display

Scott Lahteine 3 years ago
parent
commit
db8522b411

+ 1
- 0
Marlin/src/lcd/dogm/ultralcd_DOGM.cpp View File

@@ -439,6 +439,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
439 439
         lcd_put_u8str(value);
440 440
       }
441 441
     }
442
+    TERN_(USE_BIG_EDIT_FONT, ui.set_font(FONT_MENU));
442 443
   }
443 444
 
444 445
   inline void draw_boxed_string(const u8g_uint_t x, const u8g_uint_t y, PGM_P const pstr, const bool inv) {

+ 6
- 5
Marlin/src/lcd/lcdprint.h View File

@@ -76,8 +76,8 @@
76 76
   #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT)
77 77
   #define INFO_FONT_WIDTH   6
78 78
 
79
-  #define SETCURSOR(col, row) lcd_moveto(col * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT))
80
-  #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT))
79
+  #define SETCURSOR(col, row)    lcd_moveto((col) * (MENU_FONT_WIDTH), ((row) + 1) * (MENU_FONT_HEIGHT))
80
+  #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH), ((row) + 1) * (MENU_FONT_HEIGHT))
81 81
 
82 82
 #else
83 83
 
@@ -94,12 +94,13 @@
94 94
   #define LCD_PIXEL_WIDTH   LCD_WIDTH
95 95
   #define LCD_PIXEL_HEIGHT  LCD_HEIGHT
96 96
 
97
-  #define SETCURSOR(col, row) lcd_moveto(col, row)
98
-  #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_WIDTH - (len), row)
97
+  #define SETCURSOR(col, row)    lcd_moveto(col, row)
98
+  #define SETCURSOR_RJ(len, row) SETCURSOR(LCD_WIDTH - (len), row)
99 99
 
100 100
 #endif
101 101
 
102
-#define SETCURSOR_X(col) SETCURSOR(col, _lcdLineNr)
102
+#define SETCURSOR_X(col)    SETCURSOR(col, _lcdLineNr)
103
+#define SETCURSOR_X_RJ(len) SETCURSOR_RJ(len, _lcdLineNr)
103 104
 #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
104 105
 
105 106
 int lcd_glyph_height();

+ 5
- 2
Marlin/src/lcd/menu/menu_addon.h View File

@@ -23,8 +23,11 @@
23 23
 
24 24
 #include "../lcdprint.h"
25 25
 
26
-#define MENU_ITEM_ADDON_START(X) do{ \
26
+#define _MENU_ITEM_ADDON_START(N,X) do{ \
27 27
   if (ui.should_draw() && _menuLineNr == _thisItemNr - 1) { \
28
-    SETCURSOR_X(X)
28
+    N(X)
29
+
30
+#define MENU_ITEM_ADDON_START(X)    _MENU_ITEM_ADDON_START(SETCURSOR_X,    X)
31
+#define MENU_ITEM_ADDON_START_RJ(X) _MENU_ITEM_ADDON_START(SETCURSOR_X_RJ, X)
29 32
 
30 33
 #define MENU_ITEM_ADDON_END() } }while(0)

+ 27
- 44
Marlin/src/lcd/menu/menu_mixer.cpp View File

@@ -37,52 +37,33 @@
37 37
 
38 38
 #if ENABLED(GRADIENT_MIX)
39 39
 
40
-  void lcd_mixer_gradient_z_start_edit() {
40
+  void _lcd_mixer_gradient_z_edit(const bool isend) {
41 41
     ui.defer_status_screen();
42 42
     ENCODER_RATE_MULTIPLY(true);
43
-    if (ui.encoderPosition != 0) {
44
-      mixer.gradient.start_z += float(int32_t(ui.encoderPosition)) * 0.1;
45
-      ui.encoderPosition = 0;
46
-      NOLESS(mixer.gradient.start_z, 0);
47
-      NOMORE(mixer.gradient.start_z, Z_MAX_POS);
48
-    }
49
-    if (ui.should_draw()) {
50
-      char tmp[21];
51
-      strcpy_P(tmp, GET_TEXT(MSG_START_Z));
52
-      sprintf_P(tmp + strlen(tmp), PSTR(": %4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10);
53
-      SETCURSOR(2, (LCD_HEIGHT - 1) / 2);
54
-      lcd_put_u8str(tmp);
55
-    }
56 43
 
57
-    if (ui.lcd_clicked) {
58
-      if (mixer.gradient.start_z > mixer.gradient.end_z)
59
-        mixer.gradient.end_z = mixer.gradient.start_z;
60
-      mixer.refresh_gradient();
61
-      ui.goto_previous_screen();
62
-    }
63
-  }
44
+    float &zvar = isend ? mixer.gradient.end_z : mixer.gradient.start_z;
64 45
 
65
-  void lcd_mixer_gradient_z_end_edit() {
66
-    ui.defer_status_screen();
67
-    ENCODER_RATE_MULTIPLY(true);
68
-    if (ui.encoderPosition != 0) {
69
-      mixer.gradient.end_z += float(int32_t(ui.encoderPosition)) * 0.1;
46
+    if (ui.encoderPosition) {
47
+      zvar += float(int32_t(ui.encoderPosition)) * 0.1;
70 48
       ui.encoderPosition = 0;
71
-      NOLESS(mixer.gradient.end_z, 0);
72
-      NOMORE(mixer.gradient.end_z, Z_MAX_POS);
49
+      NOLESS(zvar, 0);
50
+      NOMORE(zvar, Z_MAX_POS);
73 51
     }
74 52
 
75 53
     if (ui.should_draw()) {
76
-      char tmp[21];
77
-      strcpy_P(tmp, GET_TEXT(MSG_END_Z));
78
-      sprintf_P(tmp + strlen(tmp), PSTR(": %4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10);
79
-      SETCURSOR(2, (LCD_HEIGHT - 1) / 2);
54
+      char tmp[16];
55
+      SETCURSOR(1, (LCD_HEIGHT - 1) / 2);
56
+      lcd_put_u8str_P(isend ? GET_TEXT(MSG_END_Z) : GET_TEXT(MSG_START_Z));
57
+      sprintf_P(tmp, PSTR("%4d.%d mm"), int(zvar), int(zvar * 10) % 10);
58
+      SETCURSOR_RJ(9, (LCD_HEIGHT - 1) / 2);
80 59
       lcd_put_u8str(tmp);
81 60
     }
82 61
 
83 62
     if (ui.lcd_clicked) {
84
-      if (mixer.gradient.end_z < mixer.gradient.start_z)
85
-        mixer.gradient.start_z = mixer.gradient.end_z;
63
+      if (isend && zvar < mixer.gradient.start_z)
64
+        mixer.gradient.start_z = zvar;
65
+      else if (!isend && zvar > mixer.gradient.end_z)
66
+        mixer.gradient.end_z = zvar;
86 67
       mixer.refresh_gradient();
87 68
       ui.goto_previous_screen();
88 69
     }
@@ -96,19 +77,21 @@
96 77
     EDIT_ITEM(int8, MSG_END_VTOOL, &mixer.gradient.end_vtool, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient);
97 78
 
98 79
     #if ENABLED(GRADIENT_VTOOL)
99
-      EDIT_ITEM(int8, MSG_GRADIENT_ALIAS, &mixer.gradient.vtool_index, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient);
80
+      EDIT_ITEM(int8, MSG_GRADIENT_ALIAS, &mixer.gradient.vtool_index, -1, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient);
100 81
     #endif
101 82
 
102 83
     char tmp[18];
103 84
 
104
-    SUBMENU(MSG_START_Z, lcd_mixer_gradient_z_start_edit);
105
-    MENU_ITEM_ADDON_START(9);
85
+    PGM_P const slabel = GET_TEXT(MSG_START_Z);
86
+    SUBMENU_P(slabel, []{ _lcd_mixer_gradient_z_edit(false); });
87
+    MENU_ITEM_ADDON_START_RJ(11);
106 88
       sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10);
107 89
       lcd_put_u8str(tmp);
108 90
     MENU_ITEM_ADDON_END();
109 91
 
110
-    SUBMENU(MSG_END_Z, lcd_mixer_gradient_z_end_edit);
111
-    MENU_ITEM_ADDON_START(9);
92
+    PGM_P const elabel = GET_TEXT(MSG_END_Z);
93
+    SUBMENU_P(elabel, []{ _lcd_mixer_gradient_z_edit(true); });
94
+    MENU_ITEM_ADDON_START_RJ(11);
112 95
       sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10);
113 96
       lcd_put_u8str(tmp);
114 97
     MENU_ITEM_ADDON_END();
@@ -125,7 +108,7 @@ static uint8_t v_index;
125 108
     char tmp[20]; // "100%_100%"
126 109
     sprintf_P(tmp, PSTR("%3d%% %3d%%"), int(mixer.mix[0]), int(mixer.mix[1]));
127 110
     SETCURSOR(2, y); lcd_put_u8str_P(GET_TEXT(MSG_MIX));
128
-    SETCURSOR_RJ(9, y); lcd_put_u8str(tmp);
111
+    SETCURSOR_RJ(10, y); lcd_put_u8str(tmp);
129 112
   }
130 113
 #endif
131 114
 
@@ -157,7 +140,7 @@ void lcd_mixer_mix_edit() {
157 140
   #if HAS_DUAL_MIXING && !CHANNEL_MIX_EDITING
158 141
 
159 142
     // Adjust 2-channel mix from the encoder
160
-    if (ui.encoderPosition != 0) {
143
+    if (ui.encoderPosition) {
161 144
       mixer.mix[0] += int32_t(ui.encoderPosition);
162 145
       ui.encoderPosition = 0;
163 146
       if (mixer.mix[0] < 0) mixer.mix[0] += 101;
@@ -241,9 +224,9 @@ void menu_mixer() {
241 224
 
242 225
   #if HAS_DUAL_MIXING
243 226
   {
244
-    char tmp[10];
227
+    char tmp[11];
245 228
     SUBMENU(MSG_MIX, lcd_mixer_mix_edit);
246
-    MENU_ITEM_ADDON_START(10);
229
+    MENU_ITEM_ADDON_START_RJ(9);
247 230
       mixer.update_mix_from_vtool();
248 231
       sprintf_P(tmp, PSTR("%3d;%3d%%"), int(mixer.mix[0]), int(mixer.mix[1]));
249 232
       lcd_put_u8str(tmp);
@@ -272,7 +255,7 @@ void menu_mixer() {
272 255
   {
273 256
     char tmp[13];
274 257
     SUBMENU(MSG_GRADIENT, lcd_mixer_edit_gradient_menu);
275
-    MENU_ITEM_ADDON_START(10);
258
+    MENU_ITEM_ADDON_START_RJ(9);
276 259
       sprintf_P(tmp, PSTR("T%i->T%i"), mixer.gradient.start_vtool, mixer.gradient.end_vtool);
277 260
       lcd_put_u8str(tmp);
278 261
     MENU_ITEM_ADDON_END();

Loading…
Cancel
Save