Преглед изворни кода

LULZBOT_TOUCH_UI performance/cosmetic fixes (#15319)

Marcio Teixeira пре 5 година
родитељ
комит
bafcd084cc

+ 6
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/screen_types.h Прегледај датотеку

@@ -199,6 +199,9 @@ class CachedScreen {
199 199
 
200 200
   public:
201 201
     static void onRefresh() {
202
+      #if ENABLED(TOUCH_UI_DEBUG)
203
+        const uint32_t start_time = millis();
204
+      #endif
202 205
       using namespace FTDI;
203 206
       DLCache dlcache(DL_SLOT);
204 207
       CommandProcessor cmd;
@@ -220,5 +223,8 @@ class CachedScreen {
220 223
       cmd.cmd(DL::DL_DISPLAY);
221 224
       cmd.cmd(CMD_SWAP);
222 225
       cmd.execute();
226
+      #if ENABLED(TOUCH_UI_DEBUG)
227
+        SERIAL_ECHOLNPAIR("Time to draw screen (ms): ", millis() - start_time);
228
+      #endif
223 229
     }
224 230
 };

+ 14
- 6
Marlin/src/lcd/extensible_ui/lib/lulzbot/language/language_en.h Прегледај датотеку

@@ -197,7 +197,7 @@
197 197
 #else
198 198
   #define LULZBOT_BIOPRINTER_STRINGS ,\
199 199
     MAIN_MENU, \
200
-    UNLOCK_XY_AXIS, \
200
+    RELEASE_XY_AXIS, \
201 201
     LOAD_SYRINGE, \
202 202
     BED_TEMPERATURE, \
203 203
     LOADING_WARNING, \
@@ -302,7 +302,11 @@ namespace Language_en {
302 302
   PROGMEM Language_Str PLEASE_RESET             = u8"Please reset";
303 303
 
304 304
   PROGMEM Language_Str COLOR_TOUCH_PANEL        = u8"Color Touch Panel";
305
-  PROGMEM Language_Str ABOUT_ALEPH_OBJECTS      = u8"(C) 2019 Aleph Objects, Inc.\n\nwww.lulzbot.com";
305
+  #if ENABLED(TOUCH_UI_UTF8_COPYRIGHT)
306
+    PROGMEM Language_Str ABOUT_ALEPH_OBJECTS    = u8"© 2019 Aleph Objects, Inc.\n\nwww.lulzbot.com";
307
+  #else
308
+    PROGMEM Language_Str ABOUT_ALEPH_OBJECTS    = u8"(C) 2019 Aleph Objects, Inc.\n\nwww.lulzbot.com";
309
+  #endif
306 310
 
307 311
   PROGMEM Language_Str FIRMWARE_FOR_TOOLHEAD    = u8"Firmware for toolhead:\n%s\n\n";
308 312
 
@@ -327,10 +331,14 @@ namespace Language_en {
327 331
   PROGMEM Language_Str UNITS_MILLIAMP           = u8"mA";
328 332
   PROGMEM Language_Str UNITS_MM                 = u8"mm";
329 333
   PROGMEM Language_Str UNITS_MM_S               = u8"mm/s";
330
-  PROGMEM Language_Str UNITS_MM_S2              = u8"mm/s^2";
334
+  #if ENABLED(TOUCH_UI_UTF8_WESTERN_CHARSET)
335
+    PROGMEM Language_Str UNITS_MM_S2            = u8"mm/s²";
336
+  #else
337
+    PROGMEM Language_Str UNITS_MM_S2            = u8"mm/s^2";
338
+  #endif
331 339
   PROGMEM Language_Str UNITS_STEP_MM            = u8"st/mm";
332 340
   PROGMEM Language_Str UNITS_PERCENT            = u8"%";
333
-  #if defined(TOUCH_UI_USE_UTF8) && defined(TOUCH_UI_UTF8_WESTERN_CHARSET)
341
+  #if ENABLED(TOUCH_UI_UTF8_WESTERN_CHARSET)
334 342
     PROGMEM Language_Str UNITS_C                = u8"°C";
335 343
   #else
336 344
     PROGMEM Language_Str UNITS_C                = u8" C";
@@ -399,10 +407,10 @@ namespace Language_en {
399 407
 
400 408
   #ifdef LULZBOT_USE_BIOPRINTER_UI
401 409
     PROGMEM Language_Str MAIN_MENU              = u8"Main Menu";
402
-    PROGMEM Language_Str UNLOCK_XY_AXIS         = u8"Unlock XY Axis";
410
+    PROGMEM Language_Str RELEASE_XY_AXIS        = u8"Release XY Axis";
403 411
     PROGMEM Language_Str LOAD_SYRINGE           = u8"Load Syringe";
404 412
     PROGMEM Language_Str BED_TEMPERATURE        = u8"Bed Temperature";
405
-    PROGMEM Language_Str LOADING_WARNING        = u8"About to home to loading position.\nEnsure the top and the bed of the printer are clear.\n\nContinue?";
413
+    PROGMEM Language_Str LOADING_WARNING        = u8"About to home to loading position. Ensure the top and the bed of the printer are clear.\n\nContinue?";
406 414
     PROGMEM Language_Str HOMING_WARNING         = u8"About to re-home plunger and auto-level. Remove syringe prior to proceeding.\n\nContinue?";
407 415
   #endif
408 416
 

+ 154
- 122
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/base_numeric_adjustment_screen.cpp Прегледај датотеку

@@ -33,34 +33,84 @@ using namespace Theme;
33 33
 #ifdef TOUCH_UI_PORTRAIT
34 34
   #define GRID_COLS 13
35 35
   #define GRID_ROWS 10
36
+  #define LAYOUT_FONT font_small
36 37
 #else
37 38
   #define GRID_COLS 18
38 39
   #define GRID_ROWS  7
40
+  #define LAYOUT_FONT font_medium
39 41
 #endif
40 42
 
41 43
 BaseNumericAdjustmentScreen::widgets_t::widgets_t(draw_mode_t what) : _what(what) {
44
+  CommandProcessor cmd;
45
+
42 46
   if (what & BACKGROUND) {
43
-    CommandProcessor cmd;
44 47
     cmd.cmd(CLEAR_COLOR_RGB(bg_color))
45
-       .cmd(CLEAR(true,true,true));
48
+       .cmd(CLEAR(true,true,true))
49
+       .colors(normal_btn)
50
+       .cmd(COLOR_RGB(bg_text_enabled));
46 51
   }
47 52
 
48
-  if (what & FOREGROUND) {
49
-    CommandProcessor cmd;
50
-    cmd.font(font_medium)
51
-       .colors(action_btn)
53
+  cmd.font(font_medium);
54
+  _button(cmd, 1,
52 55
     #ifdef TOUCH_UI_PORTRAIT
53
-       .tag(1).button( BTN_POS(1,10), BTN_SIZE(13,1), GET_TEXTF(BACK))
56
+      BTN_POS(1,10), BTN_SIZE(13,1),
54 57
     #else
55
-       .tag(1).button( BTN_POS(15,7), BTN_SIZE(4,1),  GET_TEXTF(BACK))
58
+      BTN_POS(15,7), BTN_SIZE(4,1),
56 59
     #endif
57
-       .colors(normal_btn);
58
-  }
60
+    GET_TEXTF(BACK), true, true
61
+  );
59 62
 
60 63
   _line = 1;
61 64
   _units = F("");
62 65
 }
63 66
 
67
+/**
68
+ * Speed optimization for changing button style.
69
+ */
70
+void BaseNumericAdjustmentScreen::widgets_t::_button_style(CommandProcessor &cmd, BaseNumericAdjustmentScreen::widgets_t::style_t style) {
71
+  if (_style != style) {
72
+    const btn_colors *old_colors = &normal_btn;
73
+    const btn_colors *new_colors = &normal_btn;
74
+
75
+    switch(_style) {
76
+      case BTN_ACTION:   old_colors = &action_btn;   break;
77
+      case BTN_TOGGLE:   old_colors = &ui_toggle;    break;
78
+      case BTN_DISABLED: old_colors = &disabled_btn; break;
79
+      default: break;
80
+    }
81
+    switch(style) {
82
+      case BTN_ACTION:   new_colors = &action_btn;   break;
83
+      case BTN_TOGGLE:   new_colors = &ui_toggle;    break;
84
+      case BTN_DISABLED: new_colors = &disabled_btn; break;
85
+      default: break;
86
+    }
87
+
88
+    const bool rgb_changed  =  old_colors->rgb  != new_colors->rgb;
89
+    const bool grad_changed =  old_colors->grad != new_colors->grad;
90
+    const bool fg_changed   = (old_colors->fg   != new_colors->fg) || (_style == TEXT_AREA);
91
+    const bool bg_changed   =  old_colors->bg   != new_colors->bg;
92
+
93
+    if (rgb_changed)  cmd.cmd(COLOR_RGB(new_colors->rgb));
94
+    if (grad_changed) cmd.gradcolor(new_colors->grad);
95
+    if (fg_changed)   cmd.fgcolor(new_colors->fg);
96
+    if (bg_changed)   cmd.bgcolor(new_colors->bg);
97
+
98
+    _style = style;
99
+  }
100
+}
101
+
102
+/**
103
+ * Speed optimization for drawing buttons. Draw all unpressed buttons in the
104
+ * background layer and draw only the pressed button in the foreground layer.
105
+ */
106
+void BaseNumericAdjustmentScreen::widgets_t::_button(CommandProcessor &cmd, uint8_t tag, int16_t x, int16_t y, int16_t w, int16_t h, progmem_str text, bool enabled, bool highlight) {
107
+  if (_what & BACKGROUND) enabled = true;
108
+  if ((_what & BACKGROUND) || buttonIsPressed(tag) || highlight || !enabled) {
109
+    _button_style(cmd, (!enabled) ? BTN_DISABLED : (highlight ? BTN_ACTION : BTN_NORMAL));
110
+    cmd.tag(enabled ? tag : 0).button(x, y, w, h, text);
111
+  }
112
+}
113
+
64 114
 BaseNumericAdjustmentScreen::widgets_t &BaseNumericAdjustmentScreen::widgets_t::precision(uint8_t decimals, precision_default_t initial) {
65 115
   _decimals = decimals;
66 116
   if (screen_data.BaseNumericAdjustmentScreen.increment == 0) {
@@ -70,14 +120,17 @@ BaseNumericAdjustmentScreen::widgets_t &BaseNumericAdjustmentScreen::widgets_t::
70 120
 }
71 121
 
72 122
 void BaseNumericAdjustmentScreen::widgets_t::heading(progmem_str label) {
73
-  CommandProcessor cmd;
74
-  cmd.font(font_medium).cmd(COLOR_RGB(bg_text_enabled));
75 123
   if (_what & BACKGROUND) {
76
-    #ifdef TOUCH_UI_PORTRAIT
77
-      cmd.tag(0).fgcolor(bg_color).button( BTN_POS(1, _line), BTN_SIZE(12,1), label, OPT_FLAT);
78
-    #else
79
-      cmd.tag(0).fgcolor(bg_color).button( BTN_POS(5, _line), BTN_SIZE(8,1),  label, OPT_FLAT);
80
-    #endif
124
+    CommandProcessor cmd;
125
+    cmd.font(font_medium)
126
+       .text(
127
+         #ifdef TOUCH_UI_PORTRAIT
128
+           BTN_POS(1, _line), BTN_SIZE(12,1),
129
+         #else
130
+           BTN_POS(5, _line), BTN_SIZE(8,1),
131
+         #endif
132
+         label
133
+       );
81 134
   }
82 135
 
83 136
   _line++;
@@ -93,8 +146,7 @@ void BaseNumericAdjustmentScreen::widgets_t::heading(progmem_str label) {
93 146
   #endif
94 147
 #endif
95 148
 
96
-void BaseNumericAdjustmentScreen::widgets_t::_draw_increment_btn(uint8_t, const uint8_t tag) {
97
-  CommandProcessor  cmd;
149
+void BaseNumericAdjustmentScreen::widgets_t::_draw_increment_btn(CommandProcessor &cmd, uint8_t, const uint8_t tag) {
98 150
   const char        *label = PSTR("?");
99 151
   uint8_t            pos;
100 152
   uint8_t &          increment = screen_data.BaseNumericAdjustmentScreen.increment;
@@ -112,48 +164,43 @@ void BaseNumericAdjustmentScreen::widgets_t::_draw_increment_btn(uint8_t, const
112 164
     default:  label = PSTR("100"    ); pos = _decimals + 2; break;
113 165
   }
114 166
 
115
-  cmd.tag(tag)
116
-     .colors(increment == tag ? action_btn : normal_btn)
117
-  #ifdef TOUCH_UI_PORTRAIT
118
-     .font(font_small);
119
-  #else
120
-     .font(font_medium);
121
-  #endif
167
+  const bool highlight = (_what & FOREGROUND) && (increment == tag);
168
+
122 169
   switch (pos) {
123 170
     #ifdef TOUCH_UI_PORTRAIT
124
-      case 0: cmd.button( BTN_POS(5,_line), BTN_SIZE(2,1), progmem_str(label)); break;
125
-      case 1: cmd.button( BTN_POS(7,_line), BTN_SIZE(2,1), progmem_str(label)); break;
126
-      case 2: cmd.button( BTN_POS(9,_line), BTN_SIZE(2,1), progmem_str(label)); break;
171
+      case 0: _button(cmd, tag, BTN_POS(5,_line), BTN_SIZE(2,1), progmem_str(label), true, highlight); break;
172
+      case 1: _button(cmd, tag, BTN_POS(7,_line), BTN_SIZE(2,1), progmem_str(label), true, highlight); break;
173
+      case 2: _button(cmd, tag, BTN_POS(9,_line), BTN_SIZE(2,1), progmem_str(label), true, highlight); break;
127 174
     #else
128
-      case 0: cmd.button( BTN_POS(15,2),    BTN_SIZE(4,1), progmem_str(label)); break;
129
-      case 1: cmd.button( BTN_POS(15,3),    BTN_SIZE(4,1), progmem_str(label)); break;
130
-      case 2: cmd.button( BTN_POS(15,4),    BTN_SIZE(4,1), progmem_str(label)); break;
175
+      case 0: _button(cmd, tag, BTN_POS(15,2),    BTN_SIZE(4,1), progmem_str(label), true, highlight); break;
176
+      case 1: _button(cmd, tag, BTN_POS(15,3),    BTN_SIZE(4,1), progmem_str(label), true, highlight); break;
177
+      case 2: _button(cmd, tag, BTN_POS(15,4),    BTN_SIZE(4,1), progmem_str(label), true, highlight); break;
131 178
     #endif
132 179
   }
133
-  cmd.colors(normal_btn);
134 180
 }
135 181
 
136
-
137 182
 void BaseNumericAdjustmentScreen::widgets_t::increments() {
183
+  CommandProcessor cmd;
184
+
185
+  cmd.font(LAYOUT_FONT);
186
+
138 187
   if (_what & BACKGROUND) {
139
-    CommandProcessor cmd;
140
-    cmd.fgcolor(bg_color)
141
-       .tag(0)
142
-    #ifdef TOUCH_UI_PORTRAIT
143
-       .font(font_small).button( BTN_POS(1, _line),  BTN_SIZE(4,1), GET_TEXTF(INCREMENT), OPT_FLAT);
144
-    #else
145
-       .font(font_medium).button( BTN_POS(15,1),     BTN_SIZE(4,1), GET_TEXTF(INCREMENT), OPT_FLAT);
146
-    #endif
188
+    cmd.text(
189
+      #ifdef TOUCH_UI_PORTRAIT
190
+        BTN_POS(1, _line), BTN_SIZE(4,1),
191
+      #else
192
+        BTN_POS(15,    1), BTN_SIZE(4,1),
193
+      #endif
194
+      GET_TEXTF(INCREMENT)
195
+    );
147 196
   }
148 197
 
149
-  if (_what & FOREGROUND) {
150
-      _draw_increment_btn(_line+1, 245 - _decimals);
151
-      _draw_increment_btn(_line+1, 244 - _decimals);
152
-      _draw_increment_btn(_line+1, 243 - _decimals);
153
-  }
198
+  _draw_increment_btn(cmd, _line+1, 245 - _decimals);
199
+  _draw_increment_btn(cmd, _line+1, 244 - _decimals);
200
+  _draw_increment_btn(cmd, _line+1, 243 - _decimals);
154 201
 
155 202
   #ifdef TOUCH_UI_PORTRAIT
156
-  _line++;
203
+    _line++;
157 204
   #endif
158 205
 }
159 206
 
@@ -161,19 +208,22 @@ void BaseNumericAdjustmentScreen::widgets_t::adjuster_sram_val(uint8_t tag, prog
161 208
   CommandProcessor cmd;
162 209
 
163 210
   if (_what & BACKGROUND) {
164
-    cmd.enabled(1)
211
+    _button_style(cmd, TEXT_AREA);
212
+    cmd.tag(0)
165 213
        .font(font_small)
166
-       .fgcolor(_color)            .tag(0).button( BTN_POS(5,_line), BTN_SIZE(5,1), F(""),               OPT_FLAT)
167
-       .cmd(COLOR_RGB(bg_text_enabled))
168
-       .fgcolor(bg_color) .tag(0).button( BTN_POS(1,_line), BTN_SIZE(4,1), (progmem_str) label, OPT_FLAT);
214
+       .text( BTN_POS(1,_line), BTN_SIZE(4,1), label)
215
+       .fgcolor(_color).button( BTN_POS(5,_line), BTN_SIZE(5,1), F(""), OPT_FLAT);
169 216
   }
170 217
 
171
-  if (_what & FOREGROUND) {
172
-    cmd.colors(normal_btn)
173
-       .font(font_medium)
174
-       .tag(is_enabled ? tag   : 0).enabled(is_enabled).button( BTN_POS(10,_line), BTN_SIZE(2,1),  F("-"))
175
-       .tag(is_enabled ? tag+1 : 0).enabled(is_enabled).button( BTN_POS(12,_line), BTN_SIZE(2,1),  F("+"))
176
-       .tag(0).font(font_small)                        .text  ( BTN_POS(5,_line),  BTN_SIZE(5,1),  is_enabled ? value : "-");
218
+  cmd.font(font_medium);
219
+  _button(cmd, tag,     BTN_POS(10,_line), BTN_SIZE(2,1),  F("-"), is_enabled);
220
+  _button(cmd, tag + 1, BTN_POS(12,_line), BTN_SIZE(2,1),  F("+"), is_enabled);
221
+
222
+  if ((_what & FOREGROUND) && is_enabled) {
223
+    _button_style(cmd, BTN_NORMAL);
224
+    cmd.tag(0)
225
+       .font(font_small)
226
+       .text(BTN_POS(5,_line), BTN_SIZE(5,1), value);
177 227
   }
178 228
 
179 229
   _line++;
@@ -206,18 +256,9 @@ void BaseNumericAdjustmentScreen::widgets_t::adjuster(uint8_t tag, progmem_str l
206 256
 }
207 257
 
208 258
 void BaseNumericAdjustmentScreen::widgets_t::button(uint8_t tag, progmem_str label, bool is_enabled) {
209
-  if (_what & FOREGROUND) {
210
-    CommandProcessor cmd;
211
-    cmd.colors(normal_btn)
212
-       .tag(is_enabled ? tag   : 0)
213
-       .enabled(is_enabled)
214
-    #ifdef TOUCH_UI_PORTRAIT
215
-       .font(font_small)
216
-    #else
217
-       .font(font_medium)
218
-    #endif
219
-    .button(BTN_POS(5,_line), BTN_SIZE(9,1), label);
220
-  }
259
+  CommandProcessor cmd;
260
+  cmd.font(LAYOUT_FONT);
261
+  _button(cmd, tag, BTN_POS(5,_line), BTN_SIZE(9,1), label, is_enabled);
221 262
 
222 263
   _line++;
223 264
 }
@@ -226,89 +267,78 @@ void BaseNumericAdjustmentScreen::widgets_t::text_field(uint8_t tag, progmem_str
226 267
   CommandProcessor cmd;
227 268
 
228 269
   if (_what & BACKGROUND) {
270
+    _button_style(cmd, TEXT_AREA);
229 271
     cmd.enabled(1)
272
+       .tag(0)
230 273
        .font(font_small)
231
-       .cmd(COLOR_RGB(bg_text_enabled))
232
-       .fgcolor(_color).tag(0).button( BTN_POS(5,_line), BTN_SIZE(9,1), F(""),               OPT_FLAT)
233
-       .fgcolor(bg_color) .tag(0).button( BTN_POS(1,_line), BTN_SIZE(4,1), label, OPT_FLAT);
274
+       .text(   BTN_POS(1,_line), BTN_SIZE(4,1), label)
275
+       .fgcolor(_color)
276
+       .tag(tag)
277
+       .button( BTN_POS(5,_line), BTN_SIZE(9,1), F(""), OPT_FLAT);
234 278
   }
235 279
 
236 280
   if (_what & FOREGROUND) {
237
-    cmd.colors(normal_btn)
238
-       .font(font_medium)
239
-       .tag(tag).font(font_small).text ( BTN_POS(5,_line), BTN_SIZE(9,1), is_enabled ? value : "-");
281
+    cmd.font(font_small).text( BTN_POS(5,_line), BTN_SIZE(9,1), is_enabled ? value : "-");
240 282
   }
241 283
 
242 284
   _line++;
243 285
 }
244 286
 
245 287
 void BaseNumericAdjustmentScreen::widgets_t::two_buttons(uint8_t tag1, progmem_str label1, uint8_t tag2, progmem_str label2, bool is_enabled) {
246
-  if (_what & FOREGROUND) {
247
-    CommandProcessor cmd;
248
-    cmd.enabled(is_enabled)
249
-    #ifdef TOUCH_UI_PORTRAIT
250
-       .font(font_small)
251
-    #else
252
-       .font(font_medium)
253
-    #endif
254
-    .tag(is_enabled ? tag1: 0).button(BTN_POS(5,_line),   BTN_SIZE(4.5,1), label1)
255
-    .tag(is_enabled ? tag2: 0).button(BTN_POS(9.5,_line), BTN_SIZE(4.5,1), label2);
256
-  }
288
+  CommandProcessor cmd;
289
+  cmd.font(LAYOUT_FONT);
290
+  _button(cmd, tag1, BTN_POS(5,_line),   BTN_SIZE(4.5,1), label1, is_enabled);
291
+  _button(cmd, tag2, BTN_POS(9.5,_line), BTN_SIZE(4.5,1), label2, is_enabled);
257 292
 
258 293
   _line++;
259 294
 }
260 295
 
261 296
 void BaseNumericAdjustmentScreen::widgets_t::toggle(uint8_t tag, progmem_str label, bool value, bool is_enabled) {
297
+  CommandProcessor cmd;
298
+
262 299
   if (_what & BACKGROUND) {
263
-    CommandProcessor cmd;
264
-    cmd.fgcolor(bg_color)
265
-       .tag(0)
266
-       .font(font_small)
267
-    #ifdef TOUCH_UI_PORTRAIT
268
-       .button( BTN_POS(1, _line), BTN_SIZE( 8,1), label, OPT_FLAT);
269
-    #else
270
-       .button( BTN_POS(1, _line), BTN_SIZE(10,1), label, OPT_FLAT);
271
-    #endif
300
+    cmd.font(font_small)
301
+       .text(
302
+         #ifdef TOUCH_UI_PORTRAIT
303
+           BTN_POS(1, _line), BTN_SIZE( 8,1),
304
+         #else
305
+           BTN_POS(1, _line), BTN_SIZE(10,1),
306
+         #endif
307
+         label
308
+       );
272 309
   }
273 310
 
274 311
   if (_what & FOREGROUND) {
275
-    CommandProcessor cmd;
312
+    _button_style(cmd, BTN_TOGGLE);
276 313
     cmd.tag(is_enabled ? tag   : 0)
277 314
        .enabled(is_enabled)
278 315
        .font(font_small)
279
-       .colors(ui_toggle)
280
-    #ifdef TOUCH_UI_PORTRAIT
281
-      .toggle2(BTN_POS( 9,_line), BTN_SIZE(5,1), GET_TEXTF(NO), GET_TEXTF(YES), value);
282
-    #else
283
-      .toggle2(BTN_POS(10,_line), BTN_SIZE(4,1), GET_TEXTF(NO), GET_TEXTF(YES), value);
284
-    #endif
316
+       .toggle2(
317
+         #ifdef TOUCH_UI_PORTRAIT
318
+           BTN_POS( 9,_line), BTN_SIZE(5,1),
319
+         #else
320
+           BTN_POS(10,_line), BTN_SIZE(4,1),
321
+         #endif
322
+         GET_TEXTF(NO), GET_TEXTF(YES), value
323
+       );
285 324
   }
286 325
 
287 326
   _line++;
288 327
 }
289 328
 
290 329
 void BaseNumericAdjustmentScreen::widgets_t::home_buttons(uint8_t tag) {
330
+  CommandProcessor cmd;
331
+
291 332
   if (_what & BACKGROUND) {
292
-    CommandProcessor cmd;
293
-    cmd.fgcolor(bg_color)
294
-       .tag(0)
295
-       .font(font_small)
296
-       .button( BTN_POS(1, _line),  BTN_SIZE(4,1), GET_TEXTF(HOME), OPT_FLAT);
333
+    cmd.font(font_small)
334
+       .text(BTN_POS(1, _line), BTN_SIZE(4,1), GET_TEXTF(HOME));
297 335
   }
298 336
 
299
-  if (_what & FOREGROUND) {
300
-    CommandProcessor cmd;
301
-    cmd
302
-    #ifdef TOUCH_UI_PORTRAIT
303
-       .font(font_small)
304
-    #else
305
-       .font(font_medium)
306
-    #endif
307
-       .tag(tag+0).button(BTN_POS(5,_line),  BTN_SIZE(2,1), GET_TEXTF(AXIS_X))
308
-       .tag(tag+1).button(BTN_POS(7,_line),  BTN_SIZE(2,1), GET_TEXTF(AXIS_Y))
309
-       .tag(tag+2).button(BTN_POS(9,_line),  BTN_SIZE(2,1), GET_TEXTF(AXIS_Z))
310
-       .tag(tag+3).button(BTN_POS(11,_line), BTN_SIZE(3,1), GET_TEXTF(AXIS_ALL));
311
-  }
337
+  cmd.font(LAYOUT_FONT);
338
+ _button(cmd, tag+0, BTN_POS(5,_line),  BTN_SIZE(2,1), GET_TEXTF(AXIS_X));
339
+ _button(cmd, tag+1, BTN_POS(7,_line),  BTN_SIZE(2,1), GET_TEXTF(AXIS_Y));
340
+ _button(cmd, tag+2, BTN_POS(9,_line),  BTN_SIZE(2,1), GET_TEXTF(AXIS_Z));
341
+ _button(cmd, tag+3, BTN_POS(11,_line), BTN_SIZE(3,1), GET_TEXTF(AXIS_ALL));
312 342
 
313 343
   _line++;
314 344
 }
@@ -316,11 +346,13 @@ void BaseNumericAdjustmentScreen::widgets_t::home_buttons(uint8_t tag) {
316 346
 void BaseNumericAdjustmentScreen::onEntry() {
317 347
   screen_data.BaseNumericAdjustmentScreen.increment = 0; // This will force the increment to be picked while drawing.
318 348
   BaseScreen::onEntry();
349
+  CommandProcessor cmd;
350
+  cmd.set_button_style_callback(nullptr);
319 351
 }
320 352
 
321 353
 bool BaseNumericAdjustmentScreen::onTouchEnd(uint8_t tag) {
322 354
   switch (tag) {
323
-    case 1:           GOTO_PREVIOUS();                            return true;
355
+    case 1:           GOTO_PREVIOUS(); return true;
324 356
     case 240 ... 245: screen_data.BaseNumericAdjustmentScreen.increment = tag; break;
325 357
     default:          return current_screen.onTouchHeld(tag);
326 358
   }

+ 6
- 2
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/base_screen.cpp Прегледај датотеку

@@ -36,6 +36,10 @@ void BaseScreen::onEntry() {
36 36
   UIScreen::onEntry();
37 37
 }
38 38
 
39
+bool BaseScreen::buttonIsPressed(uint8_t tag) {
40
+  return tag != 0 && EventLoop::get_pressed_tag() == tag;
41
+}
42
+
39 43
 bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t &style, uint16_t &options, bool post) {
40 44
   if (post) {
41 45
     cmd.colors(normal_btn);
@@ -48,7 +52,7 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t
48 52
     }
49 53
   #endif
50 54
 
51
-  if (tag != 0 && EventLoop::get_pressed_tag() == tag) {
55
+  if (buttonIsPressed(tag)) {
52 56
     options = OPT_FLAT;
53 57
   }
54 58
 
@@ -65,7 +69,7 @@ void BaseScreen::onIdle() {
65 69
   #ifdef LCD_TIMEOUT_TO_STATUS
66 70
     if ((millis() - last_interaction) > LCD_TIMEOUT_TO_STATUS) {
67 71
       reset_menu_timeout();
68
-      #ifdef UI_FRAMEWORK_DEBUG
72
+      #if ENABLED(TOUCH_UI_DEBUG)
69 73
         SERIAL_ECHO_MSG("Returning to status due to menu timeout");
70 74
       #endif
71 75
       GOTO_SCREEN(StatusScreen);

+ 1
- 1
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_main_menu.cpp Прегледај датотеку

@@ -46,7 +46,7 @@ void MainMenu::onRedraw(draw_mode_t what) {
46 46
        .colors(normal_btn)
47 47
        .font(font_medium)
48 48
        .tag(2).button( BTN_POS(1,2), BTN_SIZE(2,1), GET_TEXTF(LOAD_SYRINGE))
49
-       .tag(3).button( BTN_POS(1,3), BTN_SIZE(2,1), GET_TEXTF(UNLOCK_XY_AXIS))
49
+       .tag(3).button( BTN_POS(1,3), BTN_SIZE(2,1), GET_TEXTF(RELEASE_XY_AXIS))
50 50
        .tag(4).button( BTN_POS(1,4), BTN_SIZE(2,1), GET_TEXTF(BED_TEMPERATURE))
51 51
        .tag(5).button( BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXTF(INTERFACE_SETTINGS))
52 52
        .tag(6).button( BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXTF(ADVANCED_SETTINGS))

+ 17
- 18
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_status_screen.cpp Прегледај датотеку

@@ -37,9 +37,10 @@
37 37
 #define POLY(A) PolyUI::poly_reader_t(A, sizeof(A)/sizeof(A[0]))
38 38
 
39 39
 const uint8_t shadow_depth = 5;
40
-const float   max_speed = 0.30;
41
-const float   min_speed = 0.05;
42
-const uint8_t num_speeds = 10;
40
+const float   max_speed  = 1.00;
41
+const float   min_speed  = 0.02;
42
+const float   emax_speed = 2.00;
43
+const float   emin_speed = 0.70;
43 44
 
44 45
 using namespace FTDI;
45 46
 using namespace Theme;
@@ -251,7 +252,7 @@ void StatusScreen::onRedraw(draw_mode_t what) {
251 252
 }
252 253
 
253 254
 bool StatusScreen::onTouchStart(uint8_t) {
254
-  increment = min_speed;
255
+  increment = 0;
255 256
   return true;
256 257
 }
257 258
 
@@ -288,7 +289,7 @@ bool StatusScreen::onTouchEnd(uint8_t tag) {
288 289
 
289 290
 bool StatusScreen::onTouchHeld(uint8_t tag) {
290 291
   if (tag >= 1 && tag <= 4 && !jog_xy) return false;
291
-  const float s = fine_motion ? min_speed : increment;
292
+  const float s  = min_speed  + (fine_motion ? 0 : (max_speed  - min_speed)  * sq(increment));
292 293
   switch (tag) {
293 294
     case 1: jog(-s,  0,  0); break;
294 295
     case 2: jog( s,  0,  0); break;
@@ -297,22 +298,20 @@ bool StatusScreen::onTouchHeld(uint8_t tag) {
297 298
     case 5: jog( 0,  0, -s); break;
298 299
     case 6: jog( 0,  0,  s); break;
299 300
     case 7:
300
-      if (ExtUI::isMoving()) return false;
301
-      MoveAxisScreen::setManualFeedrate(E0, 1);
302
-      UI_INCREMENT(AxisPosition_mm, E0);
303
-      current_screen.onRefresh();
304
-      break;
305 301
     case 8:
302
+    {
306 303
       if (ExtUI::isMoving()) return false;
307
-      MoveAxisScreen::setManualFeedrate(E0, 1);
308
-      UI_DECREMENT(AxisPosition_mm, E0);
304
+      const float feedrate  =  emin_speed + (fine_motion ? 0 : (emax_speed - emin_speed) * sq(increment));
305
+      const float increment = 0.25 * feedrate * (tag == 7 ? -1 : 1);
306
+      MoveAxisScreen::setManualFeedrate(E0, feedrate);
307
+      UI_INCREMENT(AxisPosition_mm, E0);
309 308
       current_screen.onRefresh();
310 309
       break;
310
+    }
311 311
     default:
312 312
       return false;
313 313
   }
314
-  if (increment < max_speed)
315
-    increment += (max_speed - min_speed) / num_speeds;
314
+  increment = min(1.0f, increment + 0.1f);
316 315
   return false;
317 316
 }
318 317
 
@@ -325,11 +324,11 @@ void StatusScreen::setStatusMessage(const char * const str) {
325 324
 }
326 325
 
327 326
 void StatusScreen::onIdle() {
328
-  if (isPrintingFromMedia())
329
-    BioPrintingDialogBox::show();
330
-
331 327
   if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
332
-    onRefresh();
328
+    if (!EventLoop::is_touch_held())
329
+      onRefresh();
330
+    if (isPrintingFromMedia())
331
+      BioPrintingDialogBox::show();
333 332
     refresh_timer.start();
334 333
   }
335 334
 }

+ 1
- 1
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_tune_menu.cpp Прегледај датотеку

@@ -56,7 +56,7 @@ void TuneMenu::onRedraw(draw_mode_t what) {
56 56
         #endif
57 57
                               .tag(4).button( BTN_POS(1,4), BTN_SIZE(2,1), GET_TEXTF(NUDGE_NOZZLE))
58 58
        .enabled(!isPrinting()).tag(5).button( BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXTF(LOAD_SYRINGE))
59
-       .enabled(!isPrinting()).tag(6).button( BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXTF(UNLOCK_XY_AXIS))
59
+       .enabled(!isPrinting()).tag(6).button( BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXTF(RELEASE_XY_AXIS))
60 60
        .colors(action_btn)    .tag(1).button( BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXTF(BACK));
61 61
   }
62 62
   #undef GRID_COLS

+ 19
- 18
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/move_axis_screen.cpp Прегледај датотеку

@@ -46,30 +46,31 @@ void MoveAxisScreen::onRedraw(draw_mode_t what) {
46 46
   widgets_t w(what);
47 47
   w.precision(1);
48 48
   w.units(GET_TEXTF(UNITS_MM));
49
-  w.heading(                                GET_TEXTF(MOVE_AXIS));
49
+  w.heading(                           GET_TEXTF(MOVE_AXIS));
50 50
   w.home_buttons(20);
51
-  w.color(Theme::x_axis  )   .adjuster(  2, GET_TEXTF(AXIS_X),  getAxisPosition_mm(X), canMove(X));
52
-  w.color(Theme::y_axis  )   .adjuster(  4, GET_TEXTF(AXIS_Y),  getAxisPosition_mm(Y), canMove(Y));
53
-  w.color(Theme::z_axis  )   .adjuster(  6, GET_TEXTF(AXIS_Z),  getAxisPosition_mm(Z), canMove(Z));
51
+  w.color(Theme::x_axis).adjuster(  2, GET_TEXTF(AXIS_X),  getAxisPosition_mm(X), canMove(X));
52
+  w.color(Theme::y_axis).adjuster(  4, GET_TEXTF(AXIS_Y),  getAxisPosition_mm(Y), canMove(Y));
53
+  w.color(Theme::z_axis).adjuster(  6, GET_TEXTF(AXIS_Z),  getAxisPosition_mm(Z), canMove(Z));
54 54
 
55
+  w.color(Theme::e_axis);
55 56
   #if EXTRUDERS == 1
56
-    w.color(Theme::e_axis)   .adjuster(  8, GET_TEXTF(AXIS_E),  screen_data.MoveAxisScreen.e_rel[0], canMove(E0));
57
+    w.adjuster(  8, GET_TEXTF(AXIS_E),  screen_data.MoveAxisScreen.e_rel[0], canMove(E0));
57 58
   #elif EXTRUDERS > 1
58
-    w.color(Theme::e_axis)   .adjuster(  8, GET_TEXTF(AXIS_E1), screen_data.MoveAxisScreen.e_rel[0], canMove(E0));
59
-    w.color(Theme::e_axis)   .adjuster( 10, GET_TEXTF(AXIS_E2), screen_data.MoveAxisScreen.e_rel[1], canMove(E1));
59
+    w.adjuster(  8, GET_TEXTF(AXIS_E1), screen_data.MoveAxisScreen.e_rel[0], canMove(E0));
60
+    w.adjuster( 10, GET_TEXTF(AXIS_E2), screen_data.MoveAxisScreen.e_rel[1], canMove(E1));
60 61
     #if EXTRUDERS > 2
61
-      w.color(Theme::e_axis) .adjuster( 12, GET_TEXTF(AXIS_E3), screen_data.MoveAxisScreen.e_rel[2], canMove(E2));
62
+      w.adjuster( 12, GET_TEXTF(AXIS_E3), screen_data.MoveAxisScreen.e_rel[2], canMove(E2));
62 63
     #endif
63 64
     #if EXTRUDERS > 3
64
-      w.color(Theme::e_axis) .adjuster( 14, GET_TEXTF(AXIS_E4), screen_data.MoveAxisScreen.e_rel[3], canMove(E3));
65
+      w.adjuster( 14, GET_TEXTF(AXIS_E4), screen_data.MoveAxisScreen.e_rel[3], canMove(E3));
65 66
     #endif
66 67
   #endif
67 68
   w.increments();
68 69
 }
69 70
 
70 71
 bool MoveAxisScreen::onTouchHeld(uint8_t tag) {
71
-  #define UI_INCREMENT_AXIS(axis) setManualFeedrate(axis, increment); UI_INCREMENT(AxisPosition_mm, axis);
72
-  #define UI_DECREMENT_AXIS(axis) setManualFeedrate(axis, increment); UI_DECREMENT(AxisPosition_mm, axis);
72
+  #define UI_INCREMENT_AXIS(axis) UI_INCREMENT(AxisPosition_mm, axis);
73
+  #define UI_DECREMENT_AXIS(axis) UI_DECREMENT(AxisPosition_mm, axis);
73 74
   const float increment = getIncrement();
74 75
   switch (tag) {
75 76
     case  2: UI_DECREMENT_AXIS(X); break;
@@ -93,10 +94,10 @@ bool MoveAxisScreen::onTouchHeld(uint8_t tag) {
93 94
     case 14: UI_DECREMENT_AXIS(E3); screen_data.MoveAxisScreen.e_rel[3] -= increment; break;
94 95
     case 15: UI_INCREMENT_AXIS(E3); screen_data.MoveAxisScreen.e_rel[3] += increment; break;
95 96
     #endif
96
-    case 20: injectCommands_P(PSTR("G28 X")); break;
97
-    case 21: injectCommands_P(PSTR("G28 Y")); break;
98
-    case 22: injectCommands_P(PSTR("G28 Z")); break;
99
-    case 23: injectCommands_P(PSTR("G28"));   break;
97
+    case 20: SpinnerDialogBox::enqueueAndWait_P(F("G28 X")); break;
98
+    case 21: SpinnerDialogBox::enqueueAndWait_P(F("G28 Y")); break;
99
+    case 22: SpinnerDialogBox::enqueueAndWait_P(F("G28 Z")); break;
100
+    case 23: SpinnerDialogBox::enqueueAndWait_P(F("G28"));   break;
100 101
     default:
101 102
       return false;
102 103
   }
@@ -109,9 +110,9 @@ float MoveAxisScreen::getManualFeedrate(uint8_t axis, float increment_mm) {
109 110
   // Compute feedrate so that the tool lags the adjuster when it is
110 111
   // being held down, this allows enough margin for the planner to
111 112
   // connect segments and even out the motion.
112
-  constexpr float max_manual_feedrate[XYZE] = MAX_MANUAL_FEEDRATE;
113
-  return min(max_manual_feedrate[axis]/60, abs(increment_mm * TOUCH_REPEATS_PER_SECOND * 0.80));
114
-  return min(max_manual_feedrate[axis] / 60, abs(increment_mm * TOUCH_REPEATS_PER_SECOND * 0.80));
113
+  constexpr float manual_feedrate[XYZE] = MANUAL_FEEDRATE;
114
+  return min(manual_feedrate[axis] / 60, abs(increment_mm * TOUCH_REPEATS_PER_SECOND * 0.80));
115
+  return min(manual_feedrate[axis] / 60, abs(increment_mm * TOUCH_REPEATS_PER_SECOND * 0.80));
115 116
 }
116 117
 
117 118
 void MoveAxisScreen::setManualFeedrate(ExtUI::axis_t axis, float increment_mm) {

+ 12
- 2
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/screens.h Прегледај датотеку

@@ -97,6 +97,8 @@ class BaseScreen : public UIScreen {
97 97
       static uint32_t last_interaction;
98 98
     #endif
99 99
 
100
+    static bool buttonIsPressed(uint8_t tag);
101
+
100 102
   public:
101 103
     static bool buttonStyleCallback(CommandProcessor &, uint8_t, uint8_t &, uint16_t &, bool);
102 104
 
@@ -353,10 +355,18 @@ class BaseNumericAdjustmentScreen : public BaseScreen {
353 355
         uint32_t    _color;
354 356
         uint8_t     _decimals;
355 357
         progmem_str _units;
358
+        enum style_t {
359
+          BTN_NORMAL,
360
+          BTN_ACTION,
361
+          BTN_TOGGLE,
362
+          BTN_DISABLED,
363
+          TEXT_AREA
364
+        } _style;
356 365
 
357 366
       protected:
358
-        void _draw_increment_btn(uint8_t line, const uint8_t tag);
359
-
367
+        void _draw_increment_btn(CommandProcessor &, uint8_t line, const uint8_t tag);
368
+        void _button(CommandProcessor &, uint8_t tag, int16_t x, int16_t y, int16_t w, int16_t h, progmem_str, bool enabled = true, bool highlight = false);
369
+        void _button_style(CommandProcessor &cmd, style_t style);
360 370
       public:
361 371
         widgets_t(draw_mode_t);
362 372
 

Loading…
Откажи
Сачувај