Browse Source

Merge pull request #3500 from thinkyhead/rc_shrink_menu_macros

Reduce redundancy in MENU_ITEM code
Scott Lahteine 8 years ago
parent
commit
866c5be395
1 changed files with 16 additions and 18 deletions
  1. 16
    18
      Marlin/ultralcd.cpp

+ 16
- 18
Marlin/ultralcd.cpp View File

@@ -199,19 +199,25 @@ static void lcd_status_screen();
199 199
    *     menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999)
200 200
    *
201 201
    */
202
-  #define MENU_ITEM(type, label, args...) do { \
202
+  #define _MENU_ITEM_PART_1(type, label, args...) \
203 203
     if (_menuItemNr == _lineNr) { \
204 204
       itemSelected = encoderLine == _menuItemNr; \
205 205
       if (lcdDrawUpdate) \
206 206
         lcd_implementation_drawmenu_ ## type(itemSelected, _drawLineNr, PSTR(label), ## args); \
207 207
       if (wasClicked && itemSelected) { \
208
-        lcd_quick_feedback(); \
208
+        lcd_quick_feedback()
209
+
210
+  #define _MENU_ITEM_PART_2(type, args...) \
209 211
         menu_action_ ## type(args); \
210 212
         return; \
211 213
       } \
212 214
     } \
213
-    _menuItemNr++; \
214
-  } while(0)
215
+    _menuItemNr++
216
+
217
+  #define MENU_ITEM(type, label, args...) do { \
218
+      _MENU_ITEM_PART_1(type, label, ## args); \
219
+      _MENU_ITEM_PART_2(type, ## args); \
220
+    } while(0)
215 221
 
216 222
   #if ENABLED(ENCODER_RATE_MULTIPLIER)
217 223
 
@@ -221,20 +227,12 @@ static void lcd_status_screen();
221 227
      * MENU_MULTIPLIER_ITEM generates drawing and handling code for a multiplier menu item
222 228
      */
223 229
     #define MENU_MULTIPLIER_ITEM(type, label, args...) do { \
224
-      if (_menuItemNr == _lineNr) { \
225
-        itemSelected = encoderLine == _menuItemNr; \
226
-        if (lcdDrawUpdate) \
227
-          lcd_implementation_drawmenu_ ## type(itemSelected, _drawLineNr, PSTR(label), ## args); \
228
-        if (wasClicked && itemSelected) { \
229
-          lcd_quick_feedback(); \
230
-          encoderRateMultiplierEnabled = true; \
231
-          lastEncoderMovementMillis = 0; \
232
-          menu_action_ ## type(args); \
233
-          return; \
234
-        } \
235
-      } \
236
-      _menuItemNr++; \
237
-    } while(0)
230
+        _MENU_ITEM_PART_1(type, label, ## args); \
231
+        encoderRateMultiplierEnabled = true; \
232
+        lastEncoderMovementMillis = 0; \
233
+        _MENU_ITEM_PART_2(type, ## args); \
234
+      } while(0)
235
+
238 236
   #endif //ENCODER_RATE_MULTIPLIER
239 237
 
240 238
   #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)

Loading…
Cancel
Save