Browse Source

Header for individual menus

Scott Lahteine 5 years ago
parent
commit
4f67642122

+ 0
- 11
Marlin/src/lcd/menu/menu.cpp View File

@@ -100,12 +100,6 @@ void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_b
100 100
 }
101 101
 
102 102
 ////////////////////////////////////////////
103
-/////////// Common Menu Actions ////////////
104
-////////////////////////////////////////////
105
-
106
-void MenuItem_gcode::action(PGM_P const, PGM_P const pgcode) { queue.inject_P(pgcode); }
107
-
108
-////////////////////////////////////////////
109 103
 /////////// Menu Editing Actions ///////////
110 104
 ////////////////////////////////////////////
111 105
 
@@ -193,11 +187,6 @@ DEFINE_MENU_EDIT_ITEM(float52sign); // +123.45
193 187
 DEFINE_MENU_EDIT_ITEM(long5);       // 12345      right-justified
194 188
 DEFINE_MENU_EDIT_ITEM(long5_25);    // 12345      right-justified (25 increment)
195 189
 
196
-void MenuItem_bool::action(PGM_P const, bool * const ptr, screenFunc_t callback) {
197
-  *ptr ^= true; ui.refresh();
198
-  if (callback) (*callback)();
199
-}
200
-
201 190
 ////////////////////////////////////////////
202 191
 ///////////////// Menu Tree ////////////////
203 192
 ////////////////////////////////////////////

+ 10
- 439
Marlin/src/lcd/menu/menu.h View File

@@ -43,14 +43,6 @@ typedef void (*selectFunc_t)();
43 43
   void _lcd_zoffset_overlay_gfx(const float zvalue);
44 44
 #endif
45 45
 
46
-#if HAS_BED_PROBE
47
-  #if Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
48
-    #define LCD_Z_OFFSET_TYPE float43    // Values from -9.000 to +9.000
49
-  #else
50
-    #define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99
51
-  #endif
52
-#endif
53
-
54 46
 #if ENABLED(BABYSTEP_ZPROBE_OFFSET) && Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
55 47
   #define BABYSTEP_TO_STR(N) ftostr43sign(N)
56 48
 #elif ENABLED(BABYSTEPPING)
@@ -81,13 +73,14 @@ class MenuItemBase {
81 73
     }
82 74
 };
83 75
 
76
+// STATIC_ITEM(LABEL,...)
84 77
 class MenuItem_static : public MenuItemBase {
85 78
   public:
86 79
     static void draw(const uint8_t row, PGM_P const pstr, const uint8_t style=SS_DEFAULT, const char * const vstr=nullptr);
87 80
 };
88 81
 
89
-// CONFIRM_ITEM(LABEL,Y,N,FY,FN,V...),
90
-// YESNO_ITEM(LABEL,FY,FN,V...)
82
+// CONFIRM_ITEM(LABEL,Y,N,FY,FN,...),
83
+// YESNO_ITEM(LABEL,FY,FN,...)
91 84
 class MenuItem_confirm : public MenuItemBase {
92 85
   public:
93 86
     FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
@@ -123,60 +116,6 @@ class MenuItem_confirm : public MenuItemBase {
123 116
     }
124 117
 };
125 118
 
126
-// BACK_ITEM(LABEL)
127
-class MenuItem_back : public MenuItemBase {
128
-  public:
129
-    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) {
130
-      _draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]);
131
-    }
132
-    // Back Item action goes back one step in history
133
-    FORCE_INLINE static void action(PGM_P const=nullptr) { ui.go_back(); }
134
-};
135
-
136
-// SUBMENU(LABEL, screen_handler)
137
-class MenuItem_submenu : public MenuItemBase {
138
-  public:
139
-    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
140
-      _draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]);
141
-    }
142
-    static inline void action(PGM_P const, const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); }
143
-};
144
-
145
-// Any menu item that invokes an immediate action
146
-class MenuItem_button : public MenuItemBase {
147
-  public:
148
-    // Button-y Items are selectable lines with no other indicator
149
-    static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
150
-      _draw(sel, row, pstr, '>', ' ');
151
-    }
152
-};
153
-
154
-// GCODES_ITEM(LABEL, GCODES)
155
-class MenuItem_gcode : public MenuItem_button {
156
-  public:
157
-    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
158
-      _draw(sel, row, pstr, '>', ' ');
159
-    }
160
-    static void action(PGM_P const, const char * const pgcode);
161
-    static inline void action(PGM_P const pstr, const uint8_t, const char * const pgcode) { action(pstr, pgcode); }
162
-};
163
-
164
-// ACTION_ITEM(LABEL, FUNC)
165
-class MenuItem_function : public MenuItem_button {
166
-  public:
167
-    //static inline void action(PGM_P const, const uint8_t, const menuAction_t func) { (*func)(); };
168
-    static inline void action(PGM_P const, const menuAction_t func) { (*func)(); };
169
-};
170
-
171
-#if ENABLED(SDSUPPORT)
172
-  class CardReader;
173
-  class MenuItem_sdbase {
174
-    public:
175
-      // Implemented for HD44780 and DOGM
176
-      static void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
177
-  };
178
-#endif
179
-
180 119
 ////////////////////////////////////////////
181 120
 ///////////// Edit Menu Items //////////////
182 121
 ////////////////////////////////////////////
@@ -233,361 +172,15 @@ class MenuEditItemBase : public MenuItemBase {
233 172
     static inline void draw_edit_screen(const char* const value) { draw_edit_screen(editLabel, value); }
234 173
 };
235 174
 
236
-// Template for specific Menu Edit Item Types
237
-template<typename NAME>
238
-class TMenuEditItem : MenuEditItemBase {
239
-  private:
240
-    typedef typename NAME::type_t type_t;
241
-    static inline float scale(const float value)      { return NAME::scale(value);            }
242
-    static inline float unscale(const float value)    { return NAME::unscale(value);          }
243
-    static const char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); }
244
-    static void load(void *ptr, const int32_t value)  { *((type_t*)ptr) = unscale(value);     }
245
-  public:
246
-    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t * const data, ...) {
247
-      MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(*(data)));
248
-    }
249
-    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t (*pget)(), ...) {
250
-      MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(pget()));
251
-    }
252
-    // Edit screen for this type of item
253
-    static void edit_screen() { MenuEditItemBase::edit_screen(to_string, load); }
254
-    static void action(
255
-      PGM_P const pstr,                     // Edit label
256
-      type_t * const ptr,                   // Value pointer
257
-      const type_t minValue,                // Value range
258
-      const type_t maxValue,
259
-      const screenFunc_t callback=nullptr,  // Value update callback
260
-      const bool live=false                 // Callback during editing
261
-    ) {
262
-      // Make sure minv and maxv fit within int32_t
263
-      const int32_t minv = _MAX(scale(minValue), INT32_MIN),
264
-                    maxv = _MIN(scale(maxValue), INT32_MAX);
265
-      goto_edit_screen(pstr, ptr, minv, maxv - minv, scale(*ptr) - minv,
266
-        edit_screen, callback, live);
267
-    }
268
-};
269
-
270
-// Provide a set of Edit Item Types which encompass a primitive
271
-// type, a string function, and a scale factor for edit and display.
272
-// These items call the Edit Item draw method passing the prepared string.
273
-#define __DOFIXfloat PROBE()
274
-#define _DOFIX(TYPE,V) TYPE(TERN(IS_PROBE(__DOFIX##TYPE),FIXFLOAT(V),(V)))
275
-#define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, V...) \
276
-  struct MenuEditItemInfo_##NAME { \
277
-    typedef TYPE type_t; \
278
-    static inline float scale(const float value)   { return value * (SCALE) + (V+0); } \
279
-    static inline float unscale(const float value) { return value / (SCALE) + (V+0); } \
280
-    static inline const char* strfunc(const float value) { return STRFUNC(_DOFIX(TYPE,value)); } \
281
-  }; \
282
-  typedef TMenuEditItem<MenuEditItemInfo_##NAME> MenuItem_##NAME
283
-
284
-//                         NAME         TYPE      STRFUNC          SCALE         +ROUND
285
-DEFINE_MENU_EDIT_ITEM_TYPE(percent     ,uint8_t  ,ui8tostr4pctrj  , 100.f/255.f, 0.5f);  // 100%   right-justified
286
-DEFINE_MENU_EDIT_ITEM_TYPE(int3        ,int16_t  ,i16tostr3rj     ,   1     );   // 123, -12   right-justified
287
-DEFINE_MENU_EDIT_ITEM_TYPE(int4        ,int16_t  ,i16tostr4signrj ,   1     );   // 1234, -123 right-justified
288
-DEFINE_MENU_EDIT_ITEM_TYPE(int8        ,int8_t   ,i8tostr3rj      ,   1     );   // 123, -12   right-justified
289
-DEFINE_MENU_EDIT_ITEM_TYPE(uint8       ,uint8_t  ,ui8tostr3rj     ,   1     );   // 123        right-justified
290
-DEFINE_MENU_EDIT_ITEM_TYPE(uint16_3    ,uint16_t ,ui16tostr3rj    ,   1     );   // 123        right-justified
291
-DEFINE_MENU_EDIT_ITEM_TYPE(uint16_4    ,uint16_t ,ui16tostr4rj    ,   0.1f  );   // 1234       right-justified
292
-DEFINE_MENU_EDIT_ITEM_TYPE(uint16_5    ,uint16_t ,ui16tostr5rj    ,   0.01f );   // 12345      right-justified
293
-DEFINE_MENU_EDIT_ITEM_TYPE(float3      ,float    ,ftostr3         ,   1     );   // 123        right-justified
294
-DEFINE_MENU_EDIT_ITEM_TYPE(float42_52  ,float    ,ftostr42_52     , 100     );   // _2.34, 12.34, -2.34 or 123.45, -23.45
295
-DEFINE_MENU_EDIT_ITEM_TYPE(float43     ,float    ,ftostr43sign    ,1000     );   // -1.234, _1.234, +1.234
296
-DEFINE_MENU_EDIT_ITEM_TYPE(float5      ,float    ,ftostr5rj       ,   1     );   // 12345      right-justified
297
-DEFINE_MENU_EDIT_ITEM_TYPE(float5_25   ,float    ,ftostr5rj       ,   0.04f );   // 12345      right-justified (25 increment)
298
-DEFINE_MENU_EDIT_ITEM_TYPE(float51     ,float    ,ftostr51rj      ,  10     );   // 1234.5     right-justified
299
-DEFINE_MENU_EDIT_ITEM_TYPE(float31sign ,float    ,ftostr31sign    ,  10     );   // +12.3
300
-DEFINE_MENU_EDIT_ITEM_TYPE(float41sign ,float    ,ftostr41sign    ,  10     );   // +123.4
301
-DEFINE_MENU_EDIT_ITEM_TYPE(float51sign ,float    ,ftostr51sign    ,  10     );   // +1234.5
302
-DEFINE_MENU_EDIT_ITEM_TYPE(float52sign ,float    ,ftostr52sign    , 100     );   // +123.45
303
-DEFINE_MENU_EDIT_ITEM_TYPE(long5       ,uint32_t ,ftostr5rj       ,   0.01f );   // 12345      right-justified
304
-DEFINE_MENU_EDIT_ITEM_TYPE(long5_25    ,uint32_t ,ftostr5rj       ,   0.04f );   // 12345      right-justified (25 increment)
305
-
306
-class MenuItem_bool : public MenuEditItemBase {
307
-  public:
308
-    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const bool onoff) {
309
-      MenuEditItemBase::draw(sel, row, pstr, onoff ? GET_TEXT(MSG_LCD_ON) : GET_TEXT(MSG_LCD_OFF), true);
310
-    }
311
-    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, bool * const data, ...) {
312
-      draw(sel, row, pstr, *data);
313
-    }
314
-    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, bool (*pget)(), ...) {
315
-      draw(sel, row, pstr, pget());
316
-    }
317
-    static void action(PGM_P const pstr, bool * const ptr, const screenFunc_t callbackFunc=nullptr);
318
-};
319
-
320
-////////////////////////////////////////////
321
-//////////// Menu System Macros ////////////
322
-////////////////////////////////////////////
323
-
324
-/**
325
- * Marlin's native menu screens work by running a loop from the top visible line index
326
- * to the bottom visible line index (according to how much the screen has been scrolled).
327
- * This complete loop is done on every menu screen call.
328
- *
329
- * The menu system is highly dynamic, so it doesn't know ahead of any menu loop which
330
- * items will be visible or hidden, so menu items don't have a fixed index number.
331
- *
332
- * During the loop, each menu item checks to see if its line is the current one. If it is,
333
- * then it checks to see if a click has arrived so it can run its action. If the action
334
- * doesn't redirect to another screen then the menu item calls its draw method.
335
- *
336
- * Menu item add-ons can do whatever they like.
337
- *
338
- * This mixture of drawing and processing inside a loop has the advantage that a single
339
- * line can be used to represent a menu item, and that is the rationale for this design.
340
- *
341
- * One of the pitfalls of this method is that DOGM displays call the screen handler 2x,
342
- * 4x, or 8x per screen update to draw just one segment of the screen. As a result, any
343
- * menu item that exists in two screen segments is drawn and processed twice per screen
344
- * update. With each item processed 5, 10, 20, or 40 times the logic has to be simple.
345
- *
346
- * To avoid repetition and side-effects, function calls for testing menu item conditions
347
- * should be done before the menu loop (START_MENU / START_SCREEN).
348
- */
349
-
350
-/**
351
- * SCREEN_OR_MENU_LOOP generates header code for a screen or menu
352
- *
353
- *   encoderTopLine is the top menu line to display
354
- *   _lcdLineNr is the index of the LCD line (e.g., 0-3)
355
- *   _menuLineNr is the menu item to draw and process
356
- *   _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
357
- */
358
-#define SCREEN_OR_MENU_LOOP(IS_MENU)                    \
359
-  scroll_screen(IS_MENU ? 1 : LCD_HEIGHT, IS_MENU);     \
360
-  int8_t _menuLineNr = encoderTopLine, _thisItemNr = 0; \
361
-  bool _skipStatic = IS_MENU; UNUSED(_thisItemNr);      \
362
-  for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT; _lcdLineNr++, _menuLineNr++) { \
363
-    _thisItemNr = 0
364
-
365
-/**
366
- * START_SCREEN  Opening code for a screen having only static items.
367
- *               Do simplified scrolling of the entire screen.
368
- *
369
- * START_MENU    Opening code for a screen with menu items.
370
- *               Scroll as-needed to keep the selected line in view.
371
- */
372
-#define START_SCREEN() SCREEN_OR_MENU_LOOP(false)
373
-#define START_MENU() SCREEN_OR_MENU_LOOP(true)
374
-#define NEXT_ITEM() (++_thisItemNr)
375
-#define SKIP_ITEM() NEXT_ITEM()
376
-#define END_SCREEN() } screen_items = _thisItemNr
377
-#define END_MENU() END_SCREEN(); UNUSED(_skipStatic)
378
-
379
-#if ENABLED(ENCODER_RATE_MULTIPLIER)
380
-  #define ENCODER_RATE_MULTIPLY(F) (ui.encoderRateMultiplierEnabled = F)
381
-  #define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) do{ if (USE_MULTIPLIER) ui.enable_encoder_multiplier(true); }while(0)
382
-  //#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
383
-#else
384
-  #define ENCODER_RATE_MULTIPLY(F) NOOP
385
-  #define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER)
175
+#if ENABLED(SDSUPPORT)
176
+  class CardReader;
177
+  class MenuItem_sdbase {
178
+    public:
179
+      // Implemented for HD44780 and DOGM
180
+      static void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
181
+  };
386 182
 #endif
387 183
 
388
-/**
389
- * MENU_ITEM generates draw & handler code for a menu item, potentially calling:
390
- *
391
- *   MenuItem_<type>::draw(sel, row, label, arg3...)
392
- *   MenuItem_<type>::action(arg3...)
393
- *
394
- * Examples:
395
- *   BACK_ITEM(MSG_INFO_SCREEN)
396
- *     MenuItem_back::action(plabel, ...)
397
- *     MenuItem_back::draw(sel, row, plabel, ...)
398
- *
399
- *   ACTION_ITEM(MSG_PAUSE_PRINT, lcd_sdcard_pause)
400
- *     MenuItem_function::action(plabel, lcd_sdcard_pause)
401
- *     MenuItem_function::draw(sel, row, plabel, lcd_sdcard_pause)
402
- *
403
- *   EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
404
- *     MenuItem_int3::action(plabel, &feedrate_percentage, 10, 999)
405
- *     MenuItem_int3::draw(sel, row, plabel, &feedrate_percentage, 10, 999)
406
- */
407
-
408
-#define _MENU_INNER_P(TYPE, USE_MULTIPLIER, PLABEL, V...) do { \
409
-  PGM_P const plabel = PLABEL;                                 \
410
-  if (encoderLine == _thisItemNr && ui.use_click()) {          \
411
-    _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER);               \
412
-    MenuItem_##TYPE::action(plabel, ##V);                      \
413
-    if (ui.screen_changed) return;                             \
414
-  }                                                            \
415
-  if (ui.should_draw())                                        \
416
-    MenuItem_##TYPE::draw                                      \
417
-      (encoderLine == _thisItemNr, _lcdLineNr, plabel, ##V);   \
418
-}while(0)
419
-
420
-#define _MENU_ITEM_P(TYPE, V...) do { \
421
-  if (_menuLineNr == _thisItemNr) {   \
422
-    _skipStatic = false;              \
423
-    _MENU_INNER_P(TYPE, ##V);         \
424
-  }                                   \
425
-  NEXT_ITEM();                        \
426
-}while(0)
427
-
428
-// Indexed items set a global index value and optional data
429
-#define _MENU_ITEM_N_S_P(TYPE, N, S, V...) do{ \
430
-  if (_menuLineNr == _thisItemNr) {            \
431
-    _skipStatic = false;                       \
432
-    MenuItemBase::init(N, S);                  \
433
-    _MENU_INNER_P(TYPE, ##V);                  \
434
-  }                                            \
435
-  NEXT_ITEM();                                 \
436
-}while(0)
437
-
438
-// Indexed items set a global index value
439
-#define _MENU_ITEM_N_P(TYPE, N, V...) do{ \
440
-  if (_menuLineNr == _thisItemNr) {       \
441
-    _skipStatic = false;                  \
442
-    MenuItemBase::itemIndex = N;          \
443
-    _MENU_INNER_P(TYPE, ##V);             \
444
-  }                                       \
445
-  NEXT_ITEM();                            \
446
-}while(0)
447
-
448
-// Items with a unique string
449
-#define _MENU_ITEM_S_P(TYPE, S, V...) do{ \
450
-  if (_menuLineNr == _thisItemNr) {       \
451
-    _skipStatic = false;                  \
452
-    MenuItemBase::itemString = S;         \
453
-    _MENU_INNER_P(TYPE, ##V);             \
454
-  }                                       \
455
-  NEXT_ITEM();                            \
456
-}while(0)
457
-
458
-// STATIC_ITEM draws a styled string with no highlight.
459
-// Parameters: label [, style [, char *value] ]
460
-
461
-#define STATIC_ITEM_INNER_P(PLABEL, V...) do{           \
462
-  if (_skipStatic && encoderLine <= _thisItemNr) {      \
463
-    ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;  \
464
-    ++encoderLine;                                      \
465
-  }                                                     \
466
-  if (ui.should_draw())                                 \
467
-    MenuItem_static::draw(_lcdLineNr, PLABEL, ##V);     \
468
-} while(0)
469
-
470
-#define STATIC_ITEM_P(PLABEL, V...) do{ \
471
-  if (_menuLineNr == _thisItemNr)       \
472
-    STATIC_ITEM_INNER_P(PLABEL, ##V);   \
473
-  NEXT_ITEM();                          \
474
-} while(0)
475
-
476
-#define STATIC_ITEM_N_P(PLABEL, N, V...) do{ \
477
-  if (_menuLineNr == _thisItemNr) {          \
478
-    MenuItemBase::init(N);                   \
479
-    STATIC_ITEM_INNER_P(PLABEL, ##V);        \
480
-  }                                          \
481
-  NEXT_ITEM();                               \
482
-}while(0)
483
-
484
-#define STATIC_ITEM(LABEL,      V...)                  STATIC_ITEM_P(GET_TEXT(LABEL), ##V)
485
-#define STATIC_ITEM_N(LABEL, N, V...)                STATIC_ITEM_N_P(GET_TEXT(LABEL), ##V)
486
-
487
-#define MENU_ITEM_N_S_P(TYPE, N, S, PLABEL, V...)   _MENU_ITEM_N_S_P(TYPE, N, S, false, PLABEL, ##V)
488
-#define MENU_ITEM_N_S(TYPE, N, S, LABEL, V...)       MENU_ITEM_N_S_P(TYPE, N, S, GET_TEXT(LABEL), ##V)
489
-#define MENU_ITEM_S_P(TYPE, S, PLABEL, V...)          _MENU_ITEM_S_P(TYPE, S, false, PLABEL, ##V)
490
-#define MENU_ITEM_S(TYPE, S, LABEL, V...)              MENU_ITEM_S_P(TYPE, S, GET_TEXT(LABEL), ##V)
491
-#define MENU_ITEM_N_P(TYPE, N, PLABEL, V...)          _MENU_ITEM_N_P(TYPE, N, false, PLABEL, ##V)
492
-#define MENU_ITEM_N(TYPE, N, LABEL, V...)              MENU_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
493
-#define MENU_ITEM_P(TYPE, PLABEL, V...)                 _MENU_ITEM_P(TYPE, false, PLABEL, ##V)
494
-#define MENU_ITEM(TYPE, LABEL, V...)                     MENU_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
495
-
496
-#define BACK_ITEM(LABEL)                                   MENU_ITEM(back, LABEL)
497
-
498
-#define ACTION_ITEM_N_S_P(N, S, PLABEL, ACTION)      MENU_ITEM_N_S_P(function, N, S, PLABEL, ACTION)
499
-#define ACTION_ITEM_N_S(N, S, LABEL, ACTION)       ACTION_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ACTION)
500
-#define ACTION_ITEM_S_P(S, PLABEL, ACTION)             MENU_ITEM_S_P(function, S, PLABEL, ACTION)
501
-#define ACTION_ITEM_S(S, LABEL, ACTION)              ACTION_ITEM_S_P(S, GET_TEXT(LABEL), ACTION)
502
-#define ACTION_ITEM_N_P(N, PLABEL, ACTION)             MENU_ITEM_N_P(function, N, PLABEL, ACTION)
503
-#define ACTION_ITEM_N(N, LABEL, ACTION)              ACTION_ITEM_N_P(N, GET_TEXT(LABEL), ACTION)
504
-#define ACTION_ITEM_P(PLABEL, ACTION)                    MENU_ITEM_P(function, PLABEL, ACTION)
505
-#define ACTION_ITEM(LABEL, ACTION)                     ACTION_ITEM_P(GET_TEXT(LABEL), ACTION)
506
-
507
-#define GCODES_ITEM_N_S_P(N, S, PLABEL, GCODES)      MENU_ITEM_N_S_P(gcode, N, S, PLABEL, GCODES)
508
-#define GCODES_ITEM_N_S(N, S, LABEL, GCODES)       GCODES_ITEM_N_S_P(N, S, GET_TEXT(LABEL), GCODES)
509
-#define GCODES_ITEM_S_P(S, PLABEL, GCODES)             MENU_ITEM_S_P(gcode, S, PLABEL, GCODES)
510
-#define GCODES_ITEM_S(S, LABEL, GCODES)              GCODES_ITEM_S_P(S, GET_TEXT(LABEL), GCODES)
511
-#define GCODES_ITEM_N_P(N, PLABEL, GCODES)             MENU_ITEM_N_P(gcode, N, PLABEL, GCODES)
512
-#define GCODES_ITEM_N(N, LABEL, GCODES)              GCODES_ITEM_N_P(N, GET_TEXT(LABEL), GCODES)
513
-#define GCODES_ITEM_P(PLABEL, GCODES)                    MENU_ITEM_P(gcode, PLABEL, GCODES)
514
-#define GCODES_ITEM(LABEL, GCODES)                     GCODES_ITEM_P(GET_TEXT(LABEL), GCODES)
515
-
516
-#define SUBMENU_N_S_P(N, S, PLABEL, DEST)            MENU_ITEM_N_S_P(submenu, N, S, PLABEL, DEST)
517
-#define SUBMENU_N_S(N, S, LABEL, DEST)                 SUBMENU_N_S_P(N, S, GET_TEXT(LABEL), DEST)
518
-#define SUBMENU_S_P(S, PLABEL, DEST)                   MENU_ITEM_S_P(submenu, S, PLABEL, DEST)
519
-#define SUBMENU_S(S, LABEL, DEST)                        SUBMENU_S_P(S, GET_TEXT(LABEL), DEST)
520
-#define SUBMENU_N_P(N, PLABEL, DEST)                   MENU_ITEM_N_P(submenu, N, PLABEL, DEST)
521
-#define SUBMENU_N(N, LABEL, DEST)                        SUBMENU_N_P(N, GET_TEXT(LABEL), DEST)
522
-#define SUBMENU_P(PLABEL, DEST)                          MENU_ITEM_P(submenu, PLABEL, DEST)
523
-#define SUBMENU(LABEL, DEST)                               SUBMENU_P(GET_TEXT(LABEL), DEST)
524
-
525
-#define EDIT_ITEM_N_S_P(TYPE, N, S, PLABEL, V...)    MENU_ITEM_N_S_P(TYPE, N, S, PLABEL, ##V)
526
-#define EDIT_ITEM_N_S(TYPE, N, S, LABEL, V...)       EDIT_ITEM_N_S_P(TYPE, N, S, GET_TEXT(LABEL), ##V)
527
-#define EDIT_ITEM_S_P(TYPE, S, PLABEL, V...)           MENU_ITEM_S_P(TYPE, S, PLABEL, ##V)
528
-#define EDIT_ITEM_S(TYPE, S, LABEL, V...)              EDIT_ITEM_S_P(TYPE, S, GET_TEXT(LABEL), ##V)
529
-#define EDIT_ITEM_N_P(TYPE, N, PLABEL, V...)           MENU_ITEM_N_P(TYPE, N, PLABEL, ##V)
530
-#define EDIT_ITEM_N(TYPE, N, LABEL, V...)              EDIT_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
531
-#define EDIT_ITEM_P(TYPE, PLABEL, V...)                  MENU_ITEM_P(TYPE, PLABEL, ##V)
532
-#define EDIT_ITEM(TYPE, LABEL, V...)                     EDIT_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
533
-
534
-#define EDIT_ITEM_FAST_N_S_P(TYPE, N, S, PLABEL, V...)  _MENU_ITEM_N_S_P(TYPE, N, S, true, PLABEL, ##V)
535
-#define EDIT_ITEM_FAST_N_S(TYPE, N, S, LABEL, V...) EDIT_ITEM_FAST_N_S_P(TYPE, N, S, true, GET_TEXT(LABEL), ##V)
536
-#define EDIT_ITEM_FAST_S_P(TYPE, S, PLABEL, V...)         _MENU_ITEM_S_P(TYPE, S, true, PLABEL, ##V)
537
-#define EDIT_ITEM_FAST_S(TYPE, S, LABEL, V...)        EDIT_ITEM_FAST_S_P(TYPE, S, GET_TEXT(LABEL), ##V)
538
-#define EDIT_ITEM_FAST_N_P(TYPE, N, PLABEL, V...)         _MENU_ITEM_N_P(TYPE, N, true, PLABEL, ##V)
539
-#define EDIT_ITEM_FAST_N(TYPE, N, LABEL, V...)        EDIT_ITEM_FAST_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
540
-#define EDIT_ITEM_FAST_P(TYPE, PLABEL, V...)                _MENU_ITEM_P(TYPE, true, PLABEL, ##V)
541
-#define EDIT_ITEM_FAST(TYPE, LABEL, V...)               EDIT_ITEM_FAST_P(TYPE, GET_TEXT(LABEL), ##V)
542
-
543
-#define _CONFIRM_ITEM_INNER_P(PLABEL, V...) do {             \
544
-  if (encoderLine == _thisItemNr && ui.use_click()) {        \
545
-    ui.save_previous_screen();                               \
546
-    ui.goto_screen([]{MenuItem_confirm::select_screen(V);}); \
547
-    return;                                                  \
548
-  }                                                          \
549
-  if (ui.should_draw()) MenuItem_confirm::draw               \
550
-    (encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ##V);   \
551
-}while(0)
552
-
553
-// Indexed items set a global index value and optional data
554
-#define _CONFIRM_ITEM_P(PLABEL, V...) do { \
555
-  if (_menuLineNr == _thisItemNr) {        \
556
-    _skipStatic = false;                   \
557
-    _CONFIRM_ITEM_INNER_P(PLABEL, ##V);    \
558
-  }                                        \
559
-  NEXT_ITEM();                             \
560
-}while(0)
561
-
562
-// Indexed items set a global index value
563
-#define _CONFIRM_ITEM_N_S_P(N, S, V...) do{ \
564
-  if (_menuLineNr == _thisItemNr) {         \
565
-    _skipStatic = false;                    \
566
-    MenuItemBase::init(N, S);               \
567
-    _CONFIRM_ITEM_INNER_P(TYPE, ##V);       \
568
-  }                                         \
569
-  NEXT_ITEM();                              \
570
-}while(0)
571
-
572
-// Indexed items set a global index value
573
-#define _CONFIRM_ITEM_N_P(N, V...) _CONFIRM_ITEM_N_S_P(N, nullptr, V)
574
-
575
-#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
576
-#define CONFIRM_ITEM(LABEL, V...)        CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V)
577
-
578
-#define YESNO_ITEM_P(PLABEL, V...)      _CONFIRM_ITEM_P(PLABEL, ##V)
579
-#define YESNO_ITEM(LABEL, V...)            YESNO_ITEM_P(GET_TEXT(LABEL), ##V)
580
-
581
-#define CONFIRM_ITEM_N_S_P(N,S,PLABEL,A,B,V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
582
-#define CONFIRM_ITEM_N_S(N,S,LABEL,V...)         CONFIRM_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V)
583
-#define CONFIRM_ITEM_N_P(N,PLABEL,A,B,V...)       _CONFIRM_ITEM_N_P(N, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
584
-#define CONFIRM_ITEM_N(N,LABEL, V...)              CONFIRM_ITEM_N_P(N, GET_TEXT(LABEL), ##V)
585
-
586
-#define YESNO_ITEM_N_S_P(N,S,PLABEL, V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, ##V)
587
-#define YESNO_ITEM_N_S(N,S,LABEL, V...)       YESNO_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V)
588
-#define YESNO_ITEM_N_P(N,PLABEL, V...)       _CONFIRM_ITEM_N_P(N, PLABEL, ##V)
589
-#define YESNO_ITEM_N(N,LABEL, V...)             YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V)
590
-
591 184
 ////////////////////////////////////////////
592 185
 /////////////// Menu Screens ///////////////
593 186
 ////////////////////////////////////////////
@@ -599,20 +192,10 @@ void menu_move();
599 192
   void menu_media();
600 193
 #endif
601 194
 
602
-// First Fan Speed title in "Tune" and "Control>Temperature" menus
603
-#if HAS_FAN && HAS_FAN0
604
-  #if FAN_COUNT > 1
605
-    #define FAN_SPEED_1_SUFFIX " 1"
606
-  #else
607
-    #define FAN_SPEED_1_SUFFIX ""
608
-  #endif
609
-#endif
610
-
611 195
 ////////////////////////////////////////////
612 196
 //////// Menu Item Helper Functions ////////
613 197
 ////////////////////////////////////////////
614 198
 
615
-void lcd_move_z();
616 199
 void _lcd_draw_homing();
617 200
 
618 201
 #define HAS_LINE_TO_Z ANY(DELTA, PROBE_MANUALLY, MESH_BED_LEVELING, LEVEL_BED_CORNERS)
@@ -625,10 +208,6 @@ void _lcd_draw_homing();
625 208
   void _lcd_zoffset_overlay_gfx(const float zvalue);
626 209
 #endif
627 210
 
628
-#if ENABLED(LEVEL_BED_CORNERS)
629
-  void _lcd_level_bed_corners();
630
-#endif
631
-
632 211
 #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
633 212
   void _lcd_toggle_bed_leveling();
634 213
 #endif
@@ -651,11 +230,3 @@ void _lcd_draw_homing();
651 230
   #endif
652 231
 
653 232
 #endif
654
-
655
-#if ENABLED(POWER_LOSS_RECOVERY)
656
-  void menu_job_recovery();
657
-#endif
658
-
659
-#if ENABLED(TOUCH_SCREEN_CALIBRATION)
660
-  void touch_screen_calibration();
661
-#endif

+ 1
- 1
Marlin/src/lcd/menu/menu_advanced.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if HAS_LCD_MENU
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../module/planner.h"
33 33
 
34 34
 #if DISABLED(NO_VOLUMETRICS)

+ 1
- 1
Marlin/src/lcd/menu/menu_backlash.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if BOTH(HAS_LCD_MENU, BACKLASH_GCODE)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 
33 33
 #include "../../feature/backlash.h"
34 34
 

+ 1
- 1
Marlin/src/lcd/menu/menu_bed_corners.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if BOTH(HAS_LCD_MENU, LEVEL_BED_CORNERS)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../module/motion.h"
33 33
 #include "../../module/planner.h"
34 34
 

+ 1
- 1
Marlin/src/lcd/menu/menu_bed_leveling.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if ENABLED(LCD_BED_LEVELING)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../module/planner.h"
33 33
 #include "../../feature/bedlevel/bedlevel.h"
34 34
 

+ 1
- 1
Marlin/src/lcd/menu/menu_cancelobject.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if BOTH(HAS_LCD_MENU, CANCEL_OBJECTS)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "menu_addon.h"
33 33
 
34 34
 #include "../../feature/cancel_object.h"

+ 1
- 1
Marlin/src/lcd/menu/menu_configuration.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if HAS_LCD_MENU
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 
33 33
 #if HAS_FILAMENT_SENSOR
34 34
   #include "../../feature/runout.h"

+ 1
- 1
Marlin/src/lcd/menu/menu_custom.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if BOTH(HAS_LCD_MENU, CUSTOM_USER_MENUS)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../gcode/queue.h"
33 33
 
34 34
 #ifdef USER_SCRIPT_DONE

+ 1
- 1
Marlin/src/lcd/menu/menu_delta_calibrate.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if HAS_LCD_MENU && EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../module/delta.h"
33 33
 #include "../../module/motion.h"
34 34
 

+ 1
- 1
Marlin/src/lcd/menu/menu_filament.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if BOTH(HAS_LCD_MENU, ADVANCED_PAUSE_FEATURE)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../module/temperature.h"
33 33
 #include "../../feature/pause.h"
34 34
 #include "../../gcode/queue.h"

+ 1
- 1
Marlin/src/lcd/menu/menu_game.cpp View File

@@ -24,7 +24,7 @@
24 24
 
25 25
 #if HAS_GAME_MENU
26 26
 
27
-#include "menu.h"
27
+#include "menu_item.h"
28 28
 #include "game/game.h"
29 29
 
30 30
 void menu_game() {

+ 1
- 1
Marlin/src/lcd/menu/menu_info.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if BOTH(HAS_LCD_MENU, LCD_INFO_MENU)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 
33 33
 #if HAS_GAMES
34 34
   #include "game/game.h"

+ 450
- 0
Marlin/src/lcd/menu/menu_item.h View File

@@ -0,0 +1,450 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "menu.h"
25
+#include "../ultralcd.h"
26
+#include "../../gcode/queue.h" // for inject_P
27
+
28
+#include "../../inc/MarlinConfigPre.h"
29
+
30
+void lcd_move_z();
31
+
32
+////////////////////////////////////////////
33
+///////////// Base Menu Items //////////////
34
+////////////////////////////////////////////
35
+
36
+// BACK_ITEM(LABEL)
37
+class MenuItem_back : public MenuItemBase {
38
+  public:
39
+    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) {
40
+      _draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]);
41
+    }
42
+    // Back Item action goes back one step in history
43
+    FORCE_INLINE static void action(PGM_P const=nullptr) { ui.go_back(); }
44
+};
45
+
46
+// SUBMENU(LABEL, screen_handler)
47
+class MenuItem_submenu : public MenuItemBase {
48
+  public:
49
+    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
50
+      _draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]);
51
+    }
52
+    static inline void action(PGM_P const, const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); }
53
+};
54
+
55
+// Any menu item that invokes an immediate action
56
+class MenuItem_button : public MenuItemBase {
57
+  public:
58
+    // Button-y Items are selectable lines with no other indicator
59
+    static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
60
+      _draw(sel, row, pstr, '>', ' ');
61
+    }
62
+};
63
+
64
+// ACTION_ITEM(LABEL, FUNC)
65
+class MenuItem_function : public MenuItem_button {
66
+  public:
67
+    //static inline void action(PGM_P const, const uint8_t, const menuAction_t func) { (*func)(); };
68
+    static inline void action(PGM_P const, const menuAction_t func) { (*func)(); };
69
+};
70
+
71
+// GCODES_ITEM(LABEL, GCODES)
72
+class MenuItem_gcode : public MenuItem_button {
73
+  public:
74
+    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
75
+      _draw(sel, row, pstr, '>', ' ');
76
+    }
77
+    static void action(PGM_P const, PGM_P const pgcode) { queue.inject_P(pgcode); }
78
+    static inline void action(PGM_P const pstr, const uint8_t, const char * const pgcode) { action(pstr, pgcode); }
79
+};
80
+
81
+////////////////////////////////////////////
82
+///////////// Edit Menu Items //////////////
83
+////////////////////////////////////////////
84
+
85
+// Template for specific Menu Edit Item Types
86
+template<typename NAME>
87
+class TMenuEditItem : MenuEditItemBase {
88
+  private:
89
+    typedef typename NAME::type_t type_t;
90
+    static inline float scale(const float value)      { return NAME::scale(value);            }
91
+    static inline float unscale(const float value)    { return NAME::unscale(value);          }
92
+    static const char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); }
93
+    static void load(void *ptr, const int32_t value)  { *((type_t*)ptr) = unscale(value);     }
94
+  public:
95
+    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t * const data, ...) {
96
+      MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(*(data)));
97
+    }
98
+    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t (*pget)(), ...) {
99
+      MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(pget()));
100
+    }
101
+    // Edit screen for this type of item
102
+    static void edit_screen() { MenuEditItemBase::edit_screen(to_string, load); }
103
+    static void action(
104
+      PGM_P const pstr,                     // Edit label
105
+      type_t * const ptr,                   // Value pointer
106
+      const type_t minValue,                // Value range
107
+      const type_t maxValue,
108
+      const screenFunc_t callback=nullptr,  // Value update callback
109
+      const bool live=false                 // Callback during editing
110
+    ) {
111
+      // Make sure minv and maxv fit within int32_t
112
+      const int32_t minv = _MAX(scale(minValue), INT32_MIN),
113
+                    maxv = _MIN(scale(maxValue), INT32_MAX);
114
+      goto_edit_screen(pstr, ptr, minv, maxv - minv, scale(*ptr) - minv,
115
+        edit_screen, callback, live);
116
+    }
117
+};
118
+
119
+// Provide a set of Edit Item Types which encompass a primitive
120
+// type, a string function, and a scale factor for edit and display.
121
+// These items call the Edit Item draw method passing the prepared string.
122
+#define __DOFIXfloat PROBE()
123
+#define _DOFIX(TYPE,V) TYPE(TERN(IS_PROBE(__DOFIX##TYPE),FIXFLOAT(V),(V)))
124
+#define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, V...) \
125
+  struct MenuEditItemInfo_##NAME { \
126
+    typedef TYPE type_t; \
127
+    static inline float scale(const float value)   { return value * (SCALE) + (V+0); } \
128
+    static inline float unscale(const float value) { return value / (SCALE) + (V+0); } \
129
+    static inline const char* strfunc(const float value) { return STRFUNC(_DOFIX(TYPE,value)); } \
130
+  }; \
131
+  typedef TMenuEditItem<MenuEditItemInfo_##NAME> MenuItem_##NAME
132
+
133
+//                         NAME         TYPE      STRFUNC          SCALE         +ROUND
134
+DEFINE_MENU_EDIT_ITEM_TYPE(percent     ,uint8_t  ,ui8tostr4pctrj  , 100.f/255.f, 0.5f);  // 100%   right-justified
135
+DEFINE_MENU_EDIT_ITEM_TYPE(int3        ,int16_t  ,i16tostr3rj     ,   1     );   // 123, -12   right-justified
136
+DEFINE_MENU_EDIT_ITEM_TYPE(int4        ,int16_t  ,i16tostr4signrj ,   1     );   // 1234, -123 right-justified
137
+DEFINE_MENU_EDIT_ITEM_TYPE(int8        ,int8_t   ,i8tostr3rj      ,   1     );   // 123, -12   right-justified
138
+DEFINE_MENU_EDIT_ITEM_TYPE(uint8       ,uint8_t  ,ui8tostr3rj     ,   1     );   // 123        right-justified
139
+DEFINE_MENU_EDIT_ITEM_TYPE(uint16_3    ,uint16_t ,ui16tostr3rj    ,   1     );   // 123        right-justified
140
+DEFINE_MENU_EDIT_ITEM_TYPE(uint16_4    ,uint16_t ,ui16tostr4rj    ,   0.1f  );   // 1234       right-justified
141
+DEFINE_MENU_EDIT_ITEM_TYPE(uint16_5    ,uint16_t ,ui16tostr5rj    ,   0.01f );   // 12345      right-justified
142
+DEFINE_MENU_EDIT_ITEM_TYPE(float3      ,float    ,ftostr3         ,   1     );   // 123        right-justified
143
+DEFINE_MENU_EDIT_ITEM_TYPE(float42_52  ,float    ,ftostr42_52     , 100     );   // _2.34, 12.34, -2.34 or 123.45, -23.45
144
+DEFINE_MENU_EDIT_ITEM_TYPE(float43     ,float    ,ftostr43sign    ,1000     );   // -1.234, _1.234, +1.234
145
+DEFINE_MENU_EDIT_ITEM_TYPE(float5      ,float    ,ftostr5rj       ,   1     );   // 12345      right-justified
146
+DEFINE_MENU_EDIT_ITEM_TYPE(float5_25   ,float    ,ftostr5rj       ,   0.04f );   // 12345      right-justified (25 increment)
147
+DEFINE_MENU_EDIT_ITEM_TYPE(float51     ,float    ,ftostr51rj      ,  10     );   // 1234.5     right-justified
148
+DEFINE_MENU_EDIT_ITEM_TYPE(float31sign ,float    ,ftostr31sign    ,  10     );   // +12.3
149
+DEFINE_MENU_EDIT_ITEM_TYPE(float41sign ,float    ,ftostr41sign    ,  10     );   // +123.4
150
+DEFINE_MENU_EDIT_ITEM_TYPE(float51sign ,float    ,ftostr51sign    ,  10     );   // +1234.5
151
+DEFINE_MENU_EDIT_ITEM_TYPE(float52sign ,float    ,ftostr52sign    , 100     );   // +123.45
152
+DEFINE_MENU_EDIT_ITEM_TYPE(long5       ,uint32_t ,ftostr5rj       ,   0.01f );   // 12345      right-justified
153
+DEFINE_MENU_EDIT_ITEM_TYPE(long5_25    ,uint32_t ,ftostr5rj       ,   0.04f );   // 12345      right-justified (25 increment)
154
+
155
+#if HAS_BED_PROBE
156
+  #if Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
157
+    #define LCD_Z_OFFSET_TYPE float43    // Values from -9.000 to +9.000
158
+  #else
159
+    #define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99
160
+  #endif
161
+#endif
162
+
163
+class MenuItem_bool : public MenuEditItemBase {
164
+  public:
165
+    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const bool onoff) {
166
+      MenuEditItemBase::draw(sel, row, pstr, onoff ? GET_TEXT(MSG_LCD_ON) : GET_TEXT(MSG_LCD_OFF), true);
167
+    }
168
+    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, bool * const data, ...) {
169
+      draw(sel, row, pstr, *data);
170
+    }
171
+    FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, bool (*pget)(), ...) {
172
+      draw(sel, row, pstr, pget());
173
+    }
174
+    static void action(PGM_P const pstr, bool * const ptr, const screenFunc_t callbackFunc=nullptr) {
175
+      *ptr ^= true; ui.refresh();
176
+      if (callbackFunc) (*callbackFunc)();
177
+    }
178
+};
179
+
180
+/**
181
+ * ////////////////////////////////////////////
182
+ * //////////// Menu System Macros ////////////
183
+ * ////////////////////////////////////////////
184
+ *
185
+ * Marlin's native menu screens work by running a loop from the top visible line index
186
+ * to the bottom visible line index (according to how much the screen has been scrolled).
187
+ * This complete loop is done on every menu screen call.
188
+ *
189
+ * The menu system is highly dynamic, so it doesn't know ahead of any menu loop which
190
+ * items will be visible or hidden, so menu items don't have a fixed index number.
191
+ *
192
+ * During the loop, each menu item checks to see if its line is the current one. If it is,
193
+ * then it checks to see if a click has arrived so it can run its action. If the action
194
+ * doesn't redirect to another screen then the menu item calls its draw method.
195
+ *
196
+ * Menu item add-ons can do whatever they like.
197
+ *
198
+ * This mixture of drawing and processing inside a loop has the advantage that a single
199
+ * line can be used to represent a menu item, and that is the rationale for this design.
200
+ *
201
+ * One of the pitfalls of this method is that DOGM displays call the screen handler 2x,
202
+ * 4x, or 8x per screen update to draw just one segment of the screen. As a result, any
203
+ * menu item that exists in two screen segments is drawn and processed twice per screen
204
+ * update. With each item processed 5, 10, 20, or 40 times the logic has to be simple.
205
+ *
206
+ * To avoid repetition and side-effects, function calls for testing menu item conditions
207
+ * should be done before the menu loop (START_MENU / START_SCREEN).
208
+ */
209
+
210
+/**
211
+ * SCREEN_OR_MENU_LOOP generates header code for a screen or menu
212
+ *
213
+ *   encoderTopLine is the top menu line to display
214
+ *   _lcdLineNr is the index of the LCD line (e.g., 0-3)
215
+ *   _menuLineNr is the menu item to draw and process
216
+ *   _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
217
+ */
218
+#define SCREEN_OR_MENU_LOOP(IS_MENU)                    \
219
+  scroll_screen(IS_MENU ? 1 : LCD_HEIGHT, IS_MENU);     \
220
+  int8_t _menuLineNr = encoderTopLine, _thisItemNr = 0; \
221
+  bool _skipStatic = IS_MENU; UNUSED(_thisItemNr);      \
222
+  for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT; _lcdLineNr++, _menuLineNr++) { \
223
+    _thisItemNr = 0
224
+
225
+/**
226
+ * START_SCREEN  Opening code for a screen having only static items.
227
+ *               Do simplified scrolling of the entire screen.
228
+ *
229
+ * START_MENU    Opening code for a screen with menu items.
230
+ *               Scroll as-needed to keep the selected line in view.
231
+ */
232
+#define START_SCREEN() SCREEN_OR_MENU_LOOP(false)
233
+#define START_MENU() SCREEN_OR_MENU_LOOP(true)
234
+#define NEXT_ITEM() (++_thisItemNr)
235
+#define SKIP_ITEM() NEXT_ITEM()
236
+#define END_SCREEN() } screen_items = _thisItemNr
237
+#define END_MENU() END_SCREEN(); UNUSED(_skipStatic)
238
+
239
+/**
240
+ * MENU_ITEM generates draw & handler code for a menu item, potentially calling:
241
+ *
242
+ *   MenuItem_<type>::draw(sel, row, label, arg3...)
243
+ *   MenuItem_<type>::action(arg3...)
244
+ *
245
+ * Examples:
246
+ *   BACK_ITEM(MSG_INFO_SCREEN)
247
+ *     MenuItem_back::action(plabel, ...)
248
+ *     MenuItem_back::draw(sel, row, plabel, ...)
249
+ *
250
+ *   ACTION_ITEM(MSG_PAUSE_PRINT, lcd_sdcard_pause)
251
+ *     MenuItem_function::action(plabel, lcd_sdcard_pause)
252
+ *     MenuItem_function::draw(sel, row, plabel, lcd_sdcard_pause)
253
+ *
254
+ *   EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
255
+ *     MenuItem_int3::action(plabel, &feedrate_percentage, 10, 999)
256
+ *     MenuItem_int3::draw(sel, row, plabel, &feedrate_percentage, 10, 999)
257
+ */
258
+
259
+#if ENABLED(ENCODER_RATE_MULTIPLIER)
260
+  #define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) do{ if (USE_MULTIPLIER) ui.enable_encoder_multiplier(true); }while(0)
261
+#else
262
+  #define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER)
263
+#endif
264
+
265
+#define _MENU_INNER_P(TYPE, USE_MULTIPLIER, PLABEL, V...) do { \
266
+  PGM_P const plabel = PLABEL;                                 \
267
+  if (encoderLine == _thisItemNr && ui.use_click()) {          \
268
+    _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER);               \
269
+    MenuItem_##TYPE::action(plabel, ##V);                      \
270
+    if (ui.screen_changed) return;                             \
271
+  }                                                            \
272
+  if (ui.should_draw())                                        \
273
+    MenuItem_##TYPE::draw                                      \
274
+      (encoderLine == _thisItemNr, _lcdLineNr, plabel, ##V);   \
275
+}while(0)
276
+
277
+#define _MENU_ITEM_P(TYPE, V...) do { \
278
+  if (_menuLineNr == _thisItemNr) {   \
279
+    _skipStatic = false;              \
280
+    _MENU_INNER_P(TYPE, ##V);         \
281
+  }                                   \
282
+  NEXT_ITEM();                        \
283
+}while(0)
284
+
285
+// Indexed items set a global index value and optional data
286
+#define _MENU_ITEM_N_S_P(TYPE, N, S, V...) do{ \
287
+  if (_menuLineNr == _thisItemNr) {            \
288
+    _skipStatic = false;                       \
289
+    MenuItemBase::init(N, S);                  \
290
+    _MENU_INNER_P(TYPE, ##V);                  \
291
+  }                                            \
292
+  NEXT_ITEM();                                 \
293
+}while(0)
294
+
295
+// Indexed items set a global index value
296
+#define _MENU_ITEM_N_P(TYPE, N, V...) do{ \
297
+  if (_menuLineNr == _thisItemNr) {       \
298
+    _skipStatic = false;                  \
299
+    MenuItemBase::itemIndex = N;          \
300
+    _MENU_INNER_P(TYPE, ##V);             \
301
+  }                                       \
302
+  NEXT_ITEM();                            \
303
+}while(0)
304
+
305
+// Items with a unique string
306
+#define _MENU_ITEM_S_P(TYPE, S, V...) do{ \
307
+  if (_menuLineNr == _thisItemNr) {       \
308
+    _skipStatic = false;                  \
309
+    MenuItemBase::itemString = S;         \
310
+    _MENU_INNER_P(TYPE, ##V);             \
311
+  }                                       \
312
+  NEXT_ITEM();                            \
313
+}while(0)
314
+
315
+// STATIC_ITEM draws a styled string with no highlight.
316
+// Parameters: label [, style [, char *value] ]
317
+
318
+#define STATIC_ITEM_INNER_P(PLABEL, V...) do{           \
319
+  if (_skipStatic && encoderLine <= _thisItemNr) {      \
320
+    ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;  \
321
+    ++encoderLine;                                      \
322
+  }                                                     \
323
+  if (ui.should_draw())                                 \
324
+    MenuItem_static::draw(_lcdLineNr, PLABEL, ##V);     \
325
+} while(0)
326
+
327
+#define STATIC_ITEM_P(PLABEL, V...) do{ \
328
+  if (_menuLineNr == _thisItemNr)       \
329
+    STATIC_ITEM_INNER_P(PLABEL, ##V);   \
330
+  NEXT_ITEM();                          \
331
+} while(0)
332
+
333
+#define STATIC_ITEM_N_P(PLABEL, N, V...) do{ \
334
+  if (_menuLineNr == _thisItemNr) {          \
335
+    MenuItemBase::init(N);                   \
336
+    STATIC_ITEM_INNER_P(PLABEL, ##V);        \
337
+  }                                          \
338
+  NEXT_ITEM();                               \
339
+}while(0)
340
+
341
+#define STATIC_ITEM(LABEL,      V...)                  STATIC_ITEM_P(GET_TEXT(LABEL), ##V)
342
+#define STATIC_ITEM_N(LABEL, N, V...)                STATIC_ITEM_N_P(GET_TEXT(LABEL), ##V)
343
+
344
+#define MENU_ITEM_N_S_P(TYPE, N, S, PLABEL, V...)   _MENU_ITEM_N_S_P(TYPE, N, S, false, PLABEL, ##V)
345
+#define MENU_ITEM_N_S(TYPE, N, S, LABEL, V...)       MENU_ITEM_N_S_P(TYPE, N, S, GET_TEXT(LABEL), ##V)
346
+#define MENU_ITEM_S_P(TYPE, S, PLABEL, V...)          _MENU_ITEM_S_P(TYPE, S, false, PLABEL, ##V)
347
+#define MENU_ITEM_S(TYPE, S, LABEL, V...)              MENU_ITEM_S_P(TYPE, S, GET_TEXT(LABEL), ##V)
348
+#define MENU_ITEM_N_P(TYPE, N, PLABEL, V...)          _MENU_ITEM_N_P(TYPE, N, false, PLABEL, ##V)
349
+#define MENU_ITEM_N(TYPE, N, LABEL, V...)              MENU_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
350
+#define MENU_ITEM_P(TYPE, PLABEL, V...)                 _MENU_ITEM_P(TYPE, false, PLABEL, ##V)
351
+#define MENU_ITEM(TYPE, LABEL, V...)                     MENU_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
352
+
353
+#define BACK_ITEM(LABEL)                                   MENU_ITEM(back, LABEL)
354
+
355
+#define ACTION_ITEM_N_S_P(N, S, PLABEL, ACTION)      MENU_ITEM_N_S_P(function, N, S, PLABEL, ACTION)
356
+#define ACTION_ITEM_N_S(N, S, LABEL, ACTION)       ACTION_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ACTION)
357
+#define ACTION_ITEM_S_P(S, PLABEL, ACTION)             MENU_ITEM_S_P(function, S, PLABEL, ACTION)
358
+#define ACTION_ITEM_S(S, LABEL, ACTION)              ACTION_ITEM_S_P(S, GET_TEXT(LABEL), ACTION)
359
+#define ACTION_ITEM_N_P(N, PLABEL, ACTION)             MENU_ITEM_N_P(function, N, PLABEL, ACTION)
360
+#define ACTION_ITEM_N(N, LABEL, ACTION)              ACTION_ITEM_N_P(N, GET_TEXT(LABEL), ACTION)
361
+#define ACTION_ITEM_P(PLABEL, ACTION)                    MENU_ITEM_P(function, PLABEL, ACTION)
362
+#define ACTION_ITEM(LABEL, ACTION)                     ACTION_ITEM_P(GET_TEXT(LABEL), ACTION)
363
+
364
+#define GCODES_ITEM_N_S_P(N, S, PLABEL, GCODES)      MENU_ITEM_N_S_P(gcode, N, S, PLABEL, GCODES)
365
+#define GCODES_ITEM_N_S(N, S, LABEL, GCODES)       GCODES_ITEM_N_S_P(N, S, GET_TEXT(LABEL), GCODES)
366
+#define GCODES_ITEM_S_P(S, PLABEL, GCODES)             MENU_ITEM_S_P(gcode, S, PLABEL, GCODES)
367
+#define GCODES_ITEM_S(S, LABEL, GCODES)              GCODES_ITEM_S_P(S, GET_TEXT(LABEL), GCODES)
368
+#define GCODES_ITEM_N_P(N, PLABEL, GCODES)             MENU_ITEM_N_P(gcode, N, PLABEL, GCODES)
369
+#define GCODES_ITEM_N(N, LABEL, GCODES)              GCODES_ITEM_N_P(N, GET_TEXT(LABEL), GCODES)
370
+#define GCODES_ITEM_P(PLABEL, GCODES)                    MENU_ITEM_P(gcode, PLABEL, GCODES)
371
+#define GCODES_ITEM(LABEL, GCODES)                     GCODES_ITEM_P(GET_TEXT(LABEL), GCODES)
372
+
373
+#define SUBMENU_N_S_P(N, S, PLABEL, DEST)            MENU_ITEM_N_S_P(submenu, N, S, PLABEL, DEST)
374
+#define SUBMENU_N_S(N, S, LABEL, DEST)                 SUBMENU_N_S_P(N, S, GET_TEXT(LABEL), DEST)
375
+#define SUBMENU_S_P(S, PLABEL, DEST)                   MENU_ITEM_S_P(submenu, S, PLABEL, DEST)
376
+#define SUBMENU_S(S, LABEL, DEST)                        SUBMENU_S_P(S, GET_TEXT(LABEL), DEST)
377
+#define SUBMENU_N_P(N, PLABEL, DEST)                   MENU_ITEM_N_P(submenu, N, PLABEL, DEST)
378
+#define SUBMENU_N(N, LABEL, DEST)                        SUBMENU_N_P(N, GET_TEXT(LABEL), DEST)
379
+#define SUBMENU_P(PLABEL, DEST)                          MENU_ITEM_P(submenu, PLABEL, DEST)
380
+#define SUBMENU(LABEL, DEST)                               SUBMENU_P(GET_TEXT(LABEL), DEST)
381
+
382
+#define EDIT_ITEM_N_S_P(TYPE, N, S, PLABEL, V...)    MENU_ITEM_N_S_P(TYPE, N, S, PLABEL, ##V)
383
+#define EDIT_ITEM_N_S(TYPE, N, S, LABEL, V...)       EDIT_ITEM_N_S_P(TYPE, N, S, GET_TEXT(LABEL), ##V)
384
+#define EDIT_ITEM_S_P(TYPE, S, PLABEL, V...)           MENU_ITEM_S_P(TYPE, S, PLABEL, ##V)
385
+#define EDIT_ITEM_S(TYPE, S, LABEL, V...)              EDIT_ITEM_S_P(TYPE, S, GET_TEXT(LABEL), ##V)
386
+#define EDIT_ITEM_N_P(TYPE, N, PLABEL, V...)           MENU_ITEM_N_P(TYPE, N, PLABEL, ##V)
387
+#define EDIT_ITEM_N(TYPE, N, LABEL, V...)              EDIT_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
388
+#define EDIT_ITEM_P(TYPE, PLABEL, V...)                  MENU_ITEM_P(TYPE, PLABEL, ##V)
389
+#define EDIT_ITEM(TYPE, LABEL, V...)                     EDIT_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
390
+
391
+#define EDIT_ITEM_FAST_N_S_P(TYPE, N, S, PLABEL, V...)  _MENU_ITEM_N_S_P(TYPE, N, S, true, PLABEL, ##V)
392
+#define EDIT_ITEM_FAST_N_S(TYPE, N, S, LABEL, V...) EDIT_ITEM_FAST_N_S_P(TYPE, N, S, true, GET_TEXT(LABEL), ##V)
393
+#define EDIT_ITEM_FAST_S_P(TYPE, S, PLABEL, V...)         _MENU_ITEM_S_P(TYPE, S, true, PLABEL, ##V)
394
+#define EDIT_ITEM_FAST_S(TYPE, S, LABEL, V...)        EDIT_ITEM_FAST_S_P(TYPE, S, GET_TEXT(LABEL), ##V)
395
+#define EDIT_ITEM_FAST_N_P(TYPE, N, PLABEL, V...)         _MENU_ITEM_N_P(TYPE, N, true, PLABEL, ##V)
396
+#define EDIT_ITEM_FAST_N(TYPE, N, LABEL, V...)        EDIT_ITEM_FAST_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
397
+#define EDIT_ITEM_FAST_P(TYPE, PLABEL, V...)                _MENU_ITEM_P(TYPE, true, PLABEL, ##V)
398
+#define EDIT_ITEM_FAST(TYPE, LABEL, V...)               EDIT_ITEM_FAST_P(TYPE, GET_TEXT(LABEL), ##V)
399
+
400
+#define _CONFIRM_ITEM_INNER_P(PLABEL, V...) do {             \
401
+  if (encoderLine == _thisItemNr && ui.use_click()) {        \
402
+    ui.save_previous_screen();                               \
403
+    ui.goto_screen([]{MenuItem_confirm::select_screen(V);}); \
404
+    return;                                                  \
405
+  }                                                          \
406
+  if (ui.should_draw()) MenuItem_confirm::draw               \
407
+    (encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ##V);   \
408
+}while(0)
409
+
410
+// Indexed items set a global index value and optional data
411
+#define _CONFIRM_ITEM_P(PLABEL, V...) do { \
412
+  if (_menuLineNr == _thisItemNr) {        \
413
+    _skipStatic = false;                   \
414
+    _CONFIRM_ITEM_INNER_P(PLABEL, ##V);    \
415
+  }                                        \
416
+  NEXT_ITEM();                             \
417
+}while(0)
418
+
419
+// Indexed items set a global index value
420
+#define _CONFIRM_ITEM_N_S_P(N, S, V...) do{ \
421
+  if (_menuLineNr == _thisItemNr) {         \
422
+    _skipStatic = false;                    \
423
+    MenuItemBase::init(N, S);               \
424
+    _CONFIRM_ITEM_INNER_P(TYPE, ##V);       \
425
+  }                                         \
426
+  NEXT_ITEM();                              \
427
+}while(0)
428
+
429
+// Indexed items set a global index value
430
+#define _CONFIRM_ITEM_N_P(N, V...) _CONFIRM_ITEM_N_S_P(N, nullptr, V)
431
+
432
+#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
433
+#define CONFIRM_ITEM(LABEL, V...)        CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V)
434
+
435
+#define YESNO_ITEM_P(PLABEL, V...)      _CONFIRM_ITEM_P(PLABEL, ##V)
436
+#define YESNO_ITEM(LABEL, V...)            YESNO_ITEM_P(GET_TEXT(LABEL), ##V)
437
+
438
+#define CONFIRM_ITEM_N_S_P(N,S,PLABEL,A,B,V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
439
+#define CONFIRM_ITEM_N_S(N,S,LABEL,V...)         CONFIRM_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V)
440
+#define CONFIRM_ITEM_N_P(N,PLABEL,A,B,V...)       _CONFIRM_ITEM_N_P(N, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
441
+#define CONFIRM_ITEM_N(N,LABEL, V...)              CONFIRM_ITEM_N_P(N, GET_TEXT(LABEL), ##V)
442
+
443
+#define YESNO_ITEM_N_S_P(N,S,PLABEL, V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, ##V)
444
+#define YESNO_ITEM_N_S(N,S,LABEL, V...)       YESNO_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V)
445
+#define YESNO_ITEM_N_P(N,PLABEL, V...)       _CONFIRM_ITEM_N_P(N, PLABEL, ##V)
446
+#define YESNO_ITEM_N(N,LABEL, V...)             YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V)
447
+
448
+#if ENABLED(LEVEL_BED_CORNERS)
449
+  void _lcd_level_bed_corners();
450
+#endif

+ 1
- 1
Marlin/src/lcd/menu/menu_job_recovery.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if BOTH(HAS_LCD_MENU, POWER_LOSS_RECOVERY)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../gcode/queue.h"
33 33
 #include "../../sd/cardreader.h"
34 34
 #include "../../feature/powerloss.h"

+ 1
- 1
Marlin/src/lcd/menu/menu_led.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if HAS_LCD_MENU && EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 
33 33
 #if ENABLED(LED_CONTROL_MENU)
34 34
   #include "../../feature/leds/leds.h"

+ 1
- 1
Marlin/src/lcd/menu/menu_main.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if HAS_LCD_MENU
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../module/temperature.h"
33 33
 #include "../../gcode/queue.h"
34 34
 #include "../../module/printcounter.h"

+ 1
- 1
Marlin/src/lcd/menu/menu_media.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if BOTH(HAS_LCD_MENU, SDSUPPORT)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../sd/cardreader.h"
33 33
 
34 34
 void lcd_sd_updir() {

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

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if BOTH(HAS_LCD_MENU, MIXING_EXTRUDER)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "menu_addon.h"
33 33
 
34 34
 #include "../../feature/mixing.h"

+ 1
- 1
Marlin/src/lcd/menu/menu_mmu2.cpp View File

@@ -26,7 +26,7 @@
26 26
 
27 27
 #include "../../feature/mmu2/mmu2.h"
28 28
 #include "menu_mmu2.h"
29
-#include "menu.h"
29
+#include "menu_item.h"
30 30
 
31 31
 uint8_t currentTool;
32 32
 bool mmuMenuWait;

+ 1
- 1
Marlin/src/lcd/menu/menu_motion.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if HAS_LCD_MENU
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "menu_addon.h"
33 33
 
34 34
 #include "../../module/motion.h"

+ 1
- 1
Marlin/src/lcd/menu/menu_password.cpp View File

@@ -30,7 +30,7 @@
30 30
 
31 31
 #include "../../feature/password/password.h"
32 32
 
33
-#include "menu.h"
33
+#include "menu_item.h"
34 34
 #include "menu_addon.h"
35 35
 
36 36
 void menu_advanced_settings();

+ 1
- 1
Marlin/src/lcd/menu/menu_power_monitor.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if HAS_LCD_MENU && HAS_POWER_MONITOR
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../feature/power_monitor.h"
33 33
 
34 34
 void menu_power_monitor() {

+ 1
- 1
Marlin/src/lcd/menu/menu_spindle_laser.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if HAS_LCD_MENU && HAS_CUTTER
30 30
 
31
-  #include "menu.h"
31
+  #include "menu_item.h"
32 32
 
33 33
   #include "../../feature/spindle_laser.h"
34 34
 

+ 1
- 1
Marlin/src/lcd/menu/menu_temperature.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if HAS_LCD_MENU && HAS_TEMPERATURE
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../module/temperature.h"
33 33
 
34 34
 #if FAN_COUNT > 1 || ENABLED(SINGLENOZZLE)

+ 1
- 1
Marlin/src/lcd/menu/menu_tmc.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if HAS_LCD_MENU && HAS_TRINAMIC_CONFIG
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../module/stepper/indirection.h"
33 33
 #include "../../feature/tmc_util.h"
34 34
 

+ 1
- 1
Marlin/src/lcd/menu/menu_touch_screen.cpp View File

@@ -24,7 +24,7 @@
24 24
 
25 25
 #if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION)
26 26
 
27
-#include "menu.h"
27
+#include "menu_item.h"
28 28
 #include "../ultralcd.h"
29 29
 
30 30
 void touch_screen_calibration() {

+ 1
- 1
Marlin/src/lcd/menu/menu_tune.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if HAS_LCD_MENU
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../module/motion.h"
33 33
 #include "../../module/planner.h"
34 34
 #include "../../module/temperature.h"

+ 1
- 1
Marlin/src/lcd/menu/menu_ubl.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL)
30 30
 
31
-#include "menu.h"
31
+#include "menu_item.h"
32 32
 #include "../../gcode/gcode.h"
33 33
 #include "../../gcode/queue.h"
34 34
 #include "../../module/motion.h"

+ 3
- 2
Marlin/src/lcd/tft/touch.cpp View File

@@ -23,8 +23,9 @@
23 23
 
24 24
 #include "touch.h"
25 25
 
26
-#include "../ultralcd.h"
27
-#include "../menu/menu.h"
26
+#include "../ultralcd.h"  // for ui methods
27
+#include "../menu/menu.h" // for touch_screen_calibration
28
+
28 29
 #include "../../module/temperature.h"
29 30
 #include "../../module/planner.h"
30 31
 

+ 2
- 0
Marlin/src/lcd/ultralcd.cpp View File

@@ -938,6 +938,8 @@ void MarlinUI::update() {
938 938
                 if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC)     encoderMultiplier = 100;
939 939
                 else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10;
940 940
 
941
+                // Enable to output the encoder steps per second value
942
+                //#define ENCODER_RATE_MULTIPLIER_DEBUG
941 943
                 #if ENABLED(ENCODER_RATE_MULTIPLIER_DEBUG)
942 944
                   SERIAL_ECHO_START();
943 945
                   SERIAL_ECHOPAIR("Enc Step Rate: ", encoderStepRate);

+ 3
- 0
Marlin/src/lcd/ultralcd.h View File

@@ -514,6 +514,9 @@ public:
514 514
       static bool encoderRateMultiplierEnabled;
515 515
       static millis_t lastEncoderMovementMillis;
516 516
       static void enable_encoder_multiplier(const bool onoff);
517
+      #define ENCODER_RATE_MULTIPLY(F) (ui.encoderRateMultiplierEnabled = F)
518
+    #else
519
+      #define ENCODER_RATE_MULTIPLY(F) NOOP
517 520
     #endif
518 521
 
519 522
     // Manual Movement

Loading…
Cancel
Save