Browse Source

Improvements to LCD menu macros

Scott Lahteine 6 years ago
parent
commit
455592eee8
1 changed files with 19 additions and 15 deletions
  1. 19
    15
      Marlin/src/lcd/ultralcd.cpp

+ 19
- 15
Marlin/src/lcd/ultralcd.cpp View File

@@ -303,36 +303,40 @@ uint16_t max_display_update_time = 0;
303 303
       if (encoderLine == _thisItemNr && lcd_clicked) { \
304 304
         lcd_clicked = false
305 305
 
306
-  #define _MENU_ITEM_PART_2(TYPE, LABEL, ...) \
306
+  #define _MENU_ITEM_PART_2(TYPE, PLABEL, ...) \
307 307
         menu_action_ ## TYPE(__VA_ARGS__); \
308 308
         if (screen_changed) return; \
309 309
       } \
310 310
       if (lcdDrawUpdate) \
311
-        lcd_implementation_drawmenu_ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PSTR(LABEL), ## __VA_ARGS__); \
311
+        lcd_implementation_drawmenu_ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ## __VA_ARGS__); \
312 312
     } \
313 313
     ++_thisItemNr
314 314
 
315
-  #define MENU_ITEM(TYPE, LABEL, ...) do { \
315
+  #define MENU_ITEM_P(TYPE, PLABEL, ...) do { \
316 316
       _skipStatic = false; \
317 317
       _MENU_ITEM_PART_1(TYPE, ## __VA_ARGS__); \
318
-      _MENU_ITEM_PART_2(TYPE, LABEL, ## __VA_ARGS__); \
318
+      _MENU_ITEM_PART_2(TYPE, PLABEL, ## __VA_ARGS__); \
319 319
     }while(0)
320 320
 
321
+  #define MENU_ITEM(TYPE, LABEL, ...) MENU_ITEM_P(TYPE, PSTR(LABEL), ## __VA_ARGS__)
322
+
321 323
   #define MENU_BACK(LABEL) MENU_ITEM(back, LABEL, 0)
322 324
 
323 325
   // Used to print static text with no visible cursor.
324 326
   // Parameters: label [, bool center [, bool invert [, char *value] ] ]
325
-  #define STATIC_ITEM(LABEL, ...) \
327
+  #define STATIC_ITEM_P(LABEL, ...) \
326 328
     if (_menuLineNr == _thisItemNr) { \
327 329
       if (_skipStatic && encoderLine <= _thisItemNr) { \
328 330
         encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
329 331
         ++encoderLine; \
330 332
       } \
331 333
       if (lcdDrawUpdate) \
332
-        lcd_implementation_drawmenu_static(_lcdLineNr, PSTR(LABEL), ## __VA_ARGS__); \
334
+        lcd_implementation_drawmenu_static(_lcdLineNr, LABEL, ## __VA_ARGS__); \
333 335
     } \
334 336
     ++_thisItemNr
335 337
 
338
+  #define STATIC_ITEM(LABEL, ...) STATIC_ITEM_P(PSTR(LABEL), ## __VA_ARGS__)
339
+
336 340
   #if ENABLED(ENCODER_RATE_MULTIPLIER)
337 341
 
338 342
     bool encoderRateMultiplierEnabled;
@@ -343,11 +347,11 @@ uint16_t max_display_update_time = 0;
343 347
     /**
344 348
      * MENU_MULTIPLIER_ITEM generates drawing and handling code for a multiplier menu item
345 349
      */
346
-    #define MENU_MULTIPLIER_ITEM(type, label, ...) do { \
347
-        _MENU_ITEM_PART_1(type, ## __VA_ARGS__); \
350
+    #define MENU_MULTIPLIER_ITEM(TYPE, LABEL, ...) do { \
351
+        _MENU_ITEM_PART_1(TYPE, ## __VA_ARGS__); \
348 352
         encoderRateMultiplierEnabled = true; \
349 353
         lastEncoderMovementMillis = 0; \
350
-        _MENU_ITEM_PART_2(type, label, ## __VA_ARGS__); \
354
+        _MENU_ITEM_PART_2(TYPE, PSTR(LABEL), ## __VA_ARGS__); \
351 355
       }while(0)
352 356
 
353 357
   #else // !ENCODER_RATE_MULTIPLIER
@@ -355,14 +359,14 @@ uint16_t max_display_update_time = 0;
355 359
   #endif // !ENCODER_RATE_MULTIPLIER
356 360
 
357 361
   #define MENU_ITEM_DUMMY() do { _thisItemNr++; }while(0)
358
-  #define MENU_ITEM_EDIT(type, label, ...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## __VA_ARGS__)
359
-  #define MENU_ITEM_EDIT_CALLBACK(type, label, ...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## __VA_ARGS__)
362
+  #define MENU_ITEM_EDIT(TYPE, LABEL, ...) MENU_ITEM(setting_edit_ ## TYPE, LABEL, PSTR(LABEL), ## __VA_ARGS__)
363
+  #define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) MENU_ITEM(setting_edit_callback_ ## TYPE, LABEL, PSTR(LABEL), ## __VA_ARGS__)
360 364
   #if ENABLED(ENCODER_RATE_MULTIPLIER)
361
-    #define MENU_MULTIPLIER_ITEM_EDIT(type, label, ...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label), ## __VA_ARGS__)
362
-    #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, ...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## __VA_ARGS__)
365
+    #define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...) MENU_MULTIPLIER_ITEM(setting_edit_ ## TYPE, LABEL, PSTR(LABEL), ## __VA_ARGS__)
366
+    #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## TYPE, LABEL, PSTR(LABEL), ## __VA_ARGS__)
363 367
   #else // !ENCODER_RATE_MULTIPLIER
364
-    #define MENU_MULTIPLIER_ITEM_EDIT(type, label, ...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## __VA_ARGS__)
365
-    #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, ...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## __VA_ARGS__)
368
+    #define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...) MENU_ITEM(setting_edit_ ## TYPE, LABEL, PSTR(LABEL), ## __VA_ARGS__)
369
+    #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) MENU_ITEM(setting_edit_callback_ ## TYPE, LABEL, PSTR(LABEL), ## __VA_ARGS__)
366 370
   #endif // !ENCODER_RATE_MULTIPLIER
367 371
 
368 372
   /**

Loading…
Cancel
Save