Browse Source

Clean up and organize ultralcd.cpp

Scott Lahteine 7 years ago
parent
commit
1286d9603d
1 changed files with 178 additions and 163 deletions
  1. 178
    163
      Marlin/ultralcd.cpp

+ 178
- 163
Marlin/ultralcd.cpp View File

@@ -90,50 +90,25 @@ uint16_t max_display_update_time = 0;
90 90
 
91 91
 #if ENABLED(ULTIPANEL)
92 92
 
93
-  // place-holders for Ki and Kd edits
94
-  float raw_Ki, raw_Kd;
95
-
96
-  /**
97
-   * REVERSE_MENU_DIRECTION
98
-   *
99
-   * To reverse the menu direction we need a general way to reverse
100
-   * the direction of the encoder everywhere. So encoderDirection is
101
-   * added to allow the encoder to go the other way.
102
-   *
103
-   * This behavior is limited to scrolling Menus and SD card listings,
104
-   * and is disabled in other contexts.
105
-   */
106
-  #if ENABLED(REVERSE_MENU_DIRECTION)
107
-    int8_t encoderDirection = 1;
108
-    #define ENCODER_DIRECTION_NORMAL() (encoderDirection = 1)
109
-    #define ENCODER_DIRECTION_MENUS() (encoderDirection = -1)
110
-  #else
111
-    #define ENCODER_DIRECTION_NORMAL() ;
112
-    #define ENCODER_DIRECTION_MENUS() ;
93
+  #ifndef TALL_FONT_CORRECTION
94
+    #define TALL_FONT_CORRECTION 0
113 95
   #endif
114 96
 
115
-  int8_t encoderDiff; // updated from interrupt context and added to encoderPosition every LCD update
97
+  // Function pointer to menu functions.
98
+  typedef void (*screenFunc_t)();
116 99
 
117
-  millis_t manual_move_start_time = 0;
118
-  int8_t manual_move_axis = (int8_t)NO_AXIS;
119
-  #if EXTRUDERS > 1
120
-    int8_t manual_move_e_index = 0;
121
-  #else
122
-    #define manual_move_e_index 0
100
+  #if HAS_POWER_SWITCH
101
+    extern bool powersupply;
123 102
   #endif
124 103
 
125
-  bool encoderRateMultiplierEnabled;
126
-  int32_t lastEncoderMovementMillis;
127
-
128 104
   #if ENABLED(AUTO_BED_LEVELING_UBL)
129 105
     #include "ubl.h"
130 106
   #endif
131 107
 
132
-  #if HAS_POWER_SWITCH
133
-    extern bool powersupply;
134
-  #endif
108
+  ////////////////////////////////////////////
109
+  ///////////////// Menu Tree ////////////////
110
+  ////////////////////////////////////////////
135 111
 
136
-  const float manual_feedrate_mm_m[] = MANUAL_FEEDRATE;
137 112
   void lcd_main_menu();
138 113
   void lcd_tune_menu();
139 114
   void lcd_prepare_menu();
@@ -145,13 +120,6 @@ uint16_t max_display_update_time = 0;
145 120
   void lcd_control_motion_menu();
146 121
   void lcd_control_filament_menu();
147 122
 
148
-  #if ENABLED(DAC_STEPPER_CURRENT)
149
-    void dac_driver_commit();
150
-    void dac_driver_getValues();
151
-    void lcd_dac_menu();
152
-    void lcd_dac_write_eeprom();
153
-  #endif
154
-
155 123
   #if ENABLED(LCD_INFO_MENU)
156 124
     #if ENABLED(PRINTCOUNTER)
157 125
       void lcd_info_stats_menu();
@@ -173,6 +141,13 @@ uint16_t max_display_update_time = 0;
173 141
     void lcd_filament_change_resume_message();
174 142
   #endif
175 143
 
144
+  #if ENABLED(DAC_STEPPER_CURRENT)
145
+    void dac_driver_commit();
146
+    void dac_driver_getValues();
147
+    void lcd_dac_menu();
148
+    void lcd_dac_write_eeprom();
149
+  #endif
150
+
176 151
   #if HAS_LCD_CONTRAST
177 152
     void lcd_set_contrast();
178 153
   #endif
@@ -189,10 +164,10 @@ uint16_t max_display_update_time = 0;
189 164
     #include "mesh_bed_leveling.h"
190 165
   #endif
191 166
 
192
-  // Function pointer to menu functions.
193
-  typedef void (*screenFunc_t)();
167
+  ////////////////////////////////////////////
168
+  //////////// Menu System Actions ///////////
169
+  ////////////////////////////////////////////
194 170
 
195
-  // Different types of actions that can be used in menu items.
196 171
   #define menu_action_back(dummy) _menu_action_back()
197 172
   void _menu_action_back();
198 173
   void menu_action_submenu(screenFunc_t data);
@@ -230,7 +205,9 @@ uint16_t max_display_update_time = 0;
230 205
     void menu_action_sddirectory(const char* filename, char* longFilename);
231 206
   #endif
232 207
 
233
-  /* Helper macros for menus */
208
+  ////////////////////////////////////////////
209
+  //////////// Menu System Macros ////////////
210
+  ////////////////////////////////////////////
234 211
 
235 212
   #ifndef ENCODER_FEEDRATE_DEADZONE
236 213
     #define ENCODER_FEEDRATE_DEADZONE 10
@@ -242,59 +219,6 @@ uint16_t max_display_update_time = 0;
242 219
     #define ENCODER_PULSES_PER_STEP 1
243 220
   #endif
244 221
 
245
-  #ifndef TALL_FONT_CORRECTION
246
-    #define TALL_FONT_CORRECTION 0
247
-  #endif
248
-
249
-  /**
250
-   * START_SCREEN_OR_MENU generates init code for a screen or menu
251
-   *
252
-   *   encoderLine is the position based on the encoder
253
-   *   encoderTopLine is the top menu line to display
254
-   *   _lcdLineNr is the index of the LCD line (e.g., 0-3)
255
-   *   _menuLineNr is the menu item to draw and process
256
-   *   _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
257
-   *   _countedItems is the total number of items in the menu (after one call)
258
-   */
259
-  #define START_SCREEN_OR_MENU(LIMIT) \
260
-    ENCODER_DIRECTION_MENUS(); \
261
-    encoderRateMultiplierEnabled = false; \
262
-    if (encoderPosition > 0x8000) encoderPosition = 0; \
263
-    static int8_t _countedItems = 0; \
264
-    int8_t encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM); \
265
-    if (_countedItems > 0 && encoderLine >= _countedItems - (LIMIT)) { \
266
-      encoderLine = max(0, _countedItems - (LIMIT)); \
267
-      encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM); \
268
-    }
269
-
270
-  #define SCREEN_OR_MENU_LOOP() \
271
-    int8_t _menuLineNr = encoderTopLine, _thisItemNr; \
272
-    for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT - (TALL_FONT_CORRECTION); _lcdLineNr++, _menuLineNr++) { \
273
-      _thisItemNr = 0
274
-
275
-  /**
276
-   * START_SCREEN  Opening code for a screen having only static items.
277
-   *               Do simplified scrolling of the entire screen.
278
-   *
279
-   * START_MENU    Opening code for a screen with menu items.
280
-   *               Scroll as-needed to keep the selected line in view.
281
-   */
282
-  #define START_SCREEN() \
283
-    START_SCREEN_OR_MENU(LCD_HEIGHT - (TALL_FONT_CORRECTION)); \
284
-    encoderTopLine = encoderLine; \
285
-    bool _skipStatic = false; \
286
-    SCREEN_OR_MENU_LOOP()
287
-
288
-  #define START_MENU() \
289
-    START_SCREEN_OR_MENU(1); \
290
-    screen_changed = false; \
291
-    NOMORE(encoderTopLine, encoderLine); \
292
-    if (encoderLine >= encoderTopLine + LCD_HEIGHT - (TALL_FONT_CORRECTION)) { \
293
-      encoderTopLine = encoderLine - (LCD_HEIGHT - (TALL_FONT_CORRECTION) - 1); \
294
-    } \
295
-    bool _skipStatic = true; \
296
-    SCREEN_OR_MENU_LOOP()
297
-
298 222
   /**
299 223
    * MENU_ITEM generates draw & handler code for a menu item, potentially calling:
300 224
    *
@@ -352,17 +276,11 @@ uint16_t max_display_update_time = 0;
352 276
     } \
353 277
     ++_thisItemNr
354 278
 
355
-  #define END_SCREEN() \
356
-    } \
357
-    _countedItems = _thisItemNr
358
-
359
-  #define END_MENU() \
360
-    } \
361
-    _countedItems = _thisItemNr; \
362
-    UNUSED(_skipStatic)
363
-
364 279
   #if ENABLED(ENCODER_RATE_MULTIPLIER)
365 280
 
281
+    bool encoderRateMultiplierEnabled;
282
+    #define ENCODER_RATE_MULTIPLY(F) (encoderRateMultiplierEnabled = F)
283
+
366 284
     //#define ENCODER_RATE_MULTIPLIER_DEBUG  // If defined, output the encoder steps per second value
367 285
 
368 286
     /**
@@ -375,7 +293,9 @@ uint16_t max_display_update_time = 0;
375 293
         _MENU_ITEM_PART_2(type, ## __VA_ARGS__); \
376 294
       } while(0)
377 295
 
378
-  #endif //ENCODER_RATE_MULTIPLIER
296
+  #else  // !ENCODER_RATE_MULTIPLIER
297
+    #define ENCODER_RATE_MULTIPLY(F) NOOP
298
+  #endif // !ENCODER_RATE_MULTIPLIER
379 299
 
380 300
   #define MENU_ITEM_DUMMY() do { _thisItemNr++; } while(0)
381 301
   #define MENU_ITEM_EDIT(type, label, ...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## __VA_ARGS__)
@@ -391,43 +311,137 @@ uint16_t max_display_update_time = 0;
391 311
     #define MENU_MULTIPLIER_ITEM_EDIT_ACCESSOR(type, label, ...) MENU_ITEM(setting_edit_accessor_ ## type, label, PSTR(label), ## __VA_ARGS__)
392 312
   #endif //!ENCODER_RATE_MULTIPLIER
393 313
 
394
-  /** Used variables to keep track of the menu */
395
-  volatile uint8_t buttons;  //the last checked buttons in a bit array.
396
-  #if ENABLED(REPRAPWORLD_KEYPAD)
397
-    volatile uint8_t buttons_reprapworld_keypad; // to store the keypad shift register values
398
-  #endif
314
+  /**
315
+   * START_SCREEN_OR_MENU generates init code for a screen or menu
316
+   *
317
+   *   encoderLine is the position based on the encoder
318
+   *   encoderTopLine is the top menu line to display
319
+   *   _lcdLineNr is the index of the LCD line (e.g., 0-3)
320
+   *   _menuLineNr is the menu item to draw and process
321
+   *   _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
322
+   *   _countedItems is the total number of items in the menu (after one call)
323
+   */
324
+  #define START_SCREEN_OR_MENU(LIMIT) \
325
+    ENCODER_DIRECTION_MENUS(); \
326
+    ENCODER_RATE_MULTIPLY(false); \
327
+    if (encoderPosition > 0x8000) encoderPosition = 0; \
328
+    static int8_t _countedItems = 0; \
329
+    int8_t encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM); \
330
+    if (_countedItems > 0 && encoderLine >= _countedItems - (LIMIT)) { \
331
+      encoderLine = max(0, _countedItems - (LIMIT)); \
332
+      encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM); \
333
+    }
399 334
 
400
-  #if ENABLED(LCD_HAS_SLOW_BUTTONS)
401
-    volatile uint8_t slow_buttons; // Bits of the pressed buttons.
335
+  #define SCREEN_OR_MENU_LOOP() \
336
+    int8_t _menuLineNr = encoderTopLine, _thisItemNr; \
337
+    for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT - (TALL_FONT_CORRECTION); _lcdLineNr++, _menuLineNr++) { \
338
+      _thisItemNr = 0
339
+
340
+  /**
341
+   * START_SCREEN  Opening code for a screen having only static items.
342
+   *               Do simplified scrolling of the entire screen.
343
+   *
344
+   * START_MENU    Opening code for a screen with menu items.
345
+   *               Scroll as-needed to keep the selected line in view.
346
+   */
347
+  #define START_SCREEN() \
348
+    START_SCREEN_OR_MENU(LCD_HEIGHT - (TALL_FONT_CORRECTION)); \
349
+    encoderTopLine = encoderLine; \
350
+    bool _skipStatic = false; \
351
+    SCREEN_OR_MENU_LOOP()
352
+
353
+  #define START_MENU() \
354
+    START_SCREEN_OR_MENU(1); \
355
+    screen_changed = false; \
356
+    NOMORE(encoderTopLine, encoderLine); \
357
+    if (encoderLine >= encoderTopLine + LCD_HEIGHT - (TALL_FONT_CORRECTION)) { \
358
+      encoderTopLine = encoderLine - (LCD_HEIGHT - (TALL_FONT_CORRECTION) - 1); \
359
+    } \
360
+    bool _skipStatic = true; \
361
+    SCREEN_OR_MENU_LOOP()
362
+
363
+  #define END_SCREEN() \
364
+    } \
365
+    _countedItems = _thisItemNr
366
+
367
+  #define END_MENU() \
368
+    } \
369
+    _countedItems = _thisItemNr; \
370
+    UNUSED(_skipStatic)
371
+
372
+  ////////////////////////////////////////////
373
+  ///////////// Global Variables /////////////
374
+  ////////////////////////////////////////////
375
+
376
+  /**
377
+   * REVERSE_MENU_DIRECTION
378
+   *
379
+   * To reverse the menu direction we need a general way to reverse
380
+   * the direction of the encoder everywhere. So encoderDirection is
381
+   * added to allow the encoder to go the other way.
382
+   *
383
+   * This behavior is limited to scrolling Menus and SD card listings,
384
+   * and is disabled in other contexts.
385
+   */
386
+  #if ENABLED(REVERSE_MENU_DIRECTION)
387
+    int8_t encoderDirection = 1;
388
+    #define ENCODER_DIRECTION_NORMAL() (encoderDirection = 1)
389
+    #define ENCODER_DIRECTION_MENUS() (encoderDirection = -1)
390
+  #else
391
+    #define ENCODER_DIRECTION_NORMAL() ;
392
+    #define ENCODER_DIRECTION_MENUS() ;
402 393
   #endif
403
-  int8_t encoderTopLine;              /* scroll offset in the current menu */
404
-  millis_t next_button_update_ms;
405
-  uint8_t lastEncoderBits;
394
+
395
+  // Encoder Movement
396
+  volatile int8_t encoderDiff; // Updated in lcd_buttons_update, added to encoderPosition every LCD update
406 397
   uint32_t encoderPosition;
407
-  #if PIN_EXISTS(SD_DETECT)
408
-    uint8_t lcd_sd_status;
398
+  millis_t lastEncoderMovementMillis = 0;
399
+
400
+  // Button States
401
+  bool lcd_clicked, wait_for_unclick;
402
+  volatile uint8_t buttons;
403
+  millis_t next_button_update_ms;
404
+  #if ENABLED(REPRAPWORLD_KEYPAD)
405
+    volatile uint8_t buttons_reprapworld_keypad;
406
+  #endif
407
+  #if ENABLED(LCD_HAS_SLOW_BUTTONS)
408
+    volatile uint8_t slow_buttons;
409 409
   #endif
410 410
 
411
+  // Menu System Navigation
412
+  screenFunc_t currentScreen = lcd_status_screen;
413
+  int8_t encoderTopLine;
411 414
   typedef struct {
412 415
     screenFunc_t menu_function;
413 416
     uint32_t encoder_position;
414 417
   } menuPosition;
418
+  menuPosition screen_history[6];
419
+  uint8_t screen_history_depth = 0;
420
+  bool screen_changed, defer_return_to_status;
415 421
 
416
-  screenFunc_t currentScreen = lcd_status_screen; // pointer to the currently active menu handler
422
+  // Value Editing
423
+  const char *editLabel;
424
+  void *editValue, *editSetter;
425
+  int32_t minEditValue, maxEditValue;
426
+  screenFunc_t callbackFunc;
417 427
 
418
-  menuPosition screen_history[10];
419
-  uint8_t screen_history_depth = 0;
420
-  bool screen_changed;
428
+  // Manual Moves
429
+  const float manual_feedrate_mm_m[] = MANUAL_FEEDRATE;
430
+  millis_t manual_move_start_time = 0;
431
+  int8_t manual_move_axis = (int8_t)NO_AXIS;
432
+  #if EXTRUDERS > 1
433
+    int8_t manual_move_e_index = 0;
434
+  #else
435
+    #define manual_move_e_index 0
436
+  #endif
421 437
 
422
-  // LCD and menu clicks
423
-  bool lcd_clicked, wait_for_unclick, defer_return_to_status;
438
+  #if PIN_EXISTS(SD_DETECT)
439
+    uint8_t lcd_sd_status;
440
+  #endif
424 441
 
425
-  // Variables used when editing values.
426
-  const char* editLabel;
427
-  void* editValue;
428
-  void* editSetter;
429
-  int32_t minEditValue, maxEditValue;
430
-  screenFunc_t callbackFunc;              // call this after editing
442
+  #if ENABLED(PIDTEMP)
443
+    float raw_Ki, raw_Kd; // place-holders for Ki and Kd edits
444
+  #endif
431 445
 
432 446
   /**
433 447
    * General function to go directly to a screen
@@ -528,7 +542,7 @@ void lcd_status_screen() {
528 542
 
529 543
   #if ENABLED(ULTIPANEL)
530 544
     ENCODER_DIRECTION_NORMAL();
531
-    encoderRateMultiplierEnabled = false;
545
+    ENCODER_RATE_MULTIPLY(false);
532 546
   #endif
533 547
 
534 548
   #if ENABLED(LCD_PROGRESS_BAR)
@@ -2186,28 +2200,28 @@ void kill_screen(const char* lcd_msg) {
2186 2200
       PID_PARAM(Kd, e) = scalePID_d(raw_Kd);
2187 2201
       thermalManager.updatePID();
2188 2202
     }
2189
-    #define _PIDTEMP_BASE_FUNCTIONS(N) \
2203
+    #define _DEFINE_PIDTEMP_BASE_FUNCS(N) \
2190 2204
       void copy_and_scalePID_i_E ## N() { copy_and_scalePID_i(N); } \
2191 2205
       void copy_and_scalePID_d_E ## N() { copy_and_scalePID_d(N); }
2192 2206
 
2193 2207
     #if ENABLED(PID_AUTOTUNE_MENU)
2194
-      #define _PIDTEMP_FUNCTIONS(N) \
2195
-        _PIDTEMP_BASE_FUNCTIONS(N); \
2196
-        void lcd_autotune_callback_E ## N() { _lcd_autotune(N); }
2208
+      #define DEFINE_PIDTEMP_FUNCS(N) \
2209
+        _DEFINE_PIDTEMP_BASE_FUNCS(N); \
2210
+        void lcd_autotune_callback_E ## N() { _lcd_autotune(N); } typedef void _pid_##N##_void
2197 2211
     #else
2198
-      #define _PIDTEMP_FUNCTIONS(N) _PIDTEMP_BASE_FUNCTIONS(N)
2212
+      #define DEFINE_PIDTEMP_FUNCS(N) _DEFINE_PIDTEMP_BASE_FUNCS(N) typedef void _pid_##N##_void
2199 2213
     #endif
2200 2214
 
2201
-    _PIDTEMP_FUNCTIONS(0)
2215
+    DEFINE_PIDTEMP_FUNCS(0);
2202 2216
     #if ENABLED(PID_PARAMS_PER_HOTEND)
2203 2217
       #if HOTENDS > 1
2204
-        _PIDTEMP_FUNCTIONS(1)
2218
+        DEFINE_PIDTEMP_FUNCS(1);
2205 2219
         #if HOTENDS > 2
2206
-          _PIDTEMP_FUNCTIONS(2)
2220
+          DEFINE_PIDTEMP_FUNCS(2);
2207 2221
           #if HOTENDS > 3
2208
-            _PIDTEMP_FUNCTIONS(3)
2222
+            DEFINE_PIDTEMP_FUNCS(3);
2209 2223
             #if HOTENDS > 4
2210
-              _PIDTEMP_FUNCTIONS(4)
2224
+              DEFINE_PIDTEMP_FUNCS(4);
2211 2225
             #endif // HOTENDS > 4
2212 2226
           #endif // HOTENDS > 3
2213 2227
         #endif // HOTENDS > 2
@@ -2660,7 +2674,7 @@ void kill_screen(const char* lcd_msg) {
2660 2674
     void lcd_sdcard_menu() {
2661 2675
       ENCODER_DIRECTION_MENUS();
2662 2676
       if (!lcdDrawUpdate && !lcd_clicked) return; // nothing to do (so don't thrash the SD card)
2663
-      uint16_t fileCnt = card.getnrfilenames();
2677
+      const uint16_t fileCnt = card.getnrfilenames();
2664 2678
       START_MENU();
2665 2679
       MENU_BACK(MSG_MAIN);
2666 2680
       card.getWorkDirName();
@@ -2675,11 +2689,11 @@ void kill_screen(const char* lcd_msg) {
2675 2689
 
2676 2690
       for (uint16_t i = 0; i < fileCnt; i++) {
2677 2691
         if (_menuLineNr == _thisItemNr) {
2678
-          #if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA)
2679
-            int nr = fileCnt - 1 - i;
2680
-          #else
2681
-            int nr = i;
2682
-          #endif
2692
+          const uint16_t nr =
2693
+            #if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA)
2694
+              fileCnt - 1 -
2695
+            #endif
2696
+          i;
2683 2697
 
2684 2698
           #if ENABLED(SDCARD_SORT_ALPHA)
2685 2699
             card.getfilename_sorted(nr);
@@ -3104,9 +3118,9 @@ void kill_screen(const char* lcd_msg) {
3104 3118
    *
3105 3119
    * Functions for editing single values
3106 3120
    *
3107
-   * The "menu_edit_type" macro generates the functions needed to edit a numerical value.
3121
+   * The "DEFINE_MENU_EDIT_TYPE" macro generates the functions needed to edit a numerical value.
3108 3122
    *
3109
-   * For example, menu_edit_type(int, int3, itostr3, 1) expands into these functions:
3123
+   * For example, DEFINE_MENU_EDIT_TYPE(int, int3, itostr3, 1) expands into these functions:
3110 3124
    *
3111 3125
    *   bool _menu_edit_int3();
3112 3126
    *   void menu_edit_int3(); // edit int (interactively)
@@ -3131,7 +3145,7 @@ void kill_screen(const char* lcd_msg) {
3131 3145
    * Values that are get/set via functions (As opposed to global variables) can use the accessor form:
3132 3146
    *   MENU_ITEM_EDIT_ACCESSOR(int3, MSG_SPEED, get_feedrate_percentage, set_feedrate_percentage, 10, 999)
3133 3147
    */
3134
-  #define menu_edit_type(_type, _name, _strFunc, _scale) \
3148
+  #define DEFINE_MENU_EDIT_TYPE(_type, _name, _strFunc, _scale) \
3135 3149
     bool _menu_edit_ ## _name () { \
3136 3150
       ENCODER_DIRECTION_NORMAL(); \
3137 3151
       if ((int32_t)encoderPosition < 0) encoderPosition = 0; \
@@ -3189,15 +3203,15 @@ void kill_screen(const char* lcd_msg) {
3189 3203
     } \
3190 3204
     typedef void _name
3191 3205
 
3192
-  menu_edit_type(int, int3, itostr3, 1);
3193
-  menu_edit_type(float, float3, ftostr3, 1.0);
3194
-  menu_edit_type(float, float32, ftostr32, 100.0);
3195
-  menu_edit_type(float, float43, ftostr43sign, 1000.0);
3196
-  menu_edit_type(float, float5, ftostr5rj, 0.01);
3197
-  menu_edit_type(float, float51, ftostr51sign, 10.0);
3198
-  menu_edit_type(float, float52, ftostr52sign, 100.0);
3199
-  menu_edit_type(float, float62, ftostr62rj, 100.0);
3200
-  menu_edit_type(unsigned long, long5, ftostr5rj, 0.01);
3206
+  DEFINE_MENU_EDIT_TYPE(int, int3, itostr3, 1);
3207
+  DEFINE_MENU_EDIT_TYPE(float, float3, ftostr3, 1.0);
3208
+  DEFINE_MENU_EDIT_TYPE(float, float32, ftostr32, 100.0);
3209
+  DEFINE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000.0);
3210
+  DEFINE_MENU_EDIT_TYPE(float, float5, ftostr5rj, 0.01);
3211
+  DEFINE_MENU_EDIT_TYPE(float, float51, ftostr51sign, 10.0);
3212
+  DEFINE_MENU_EDIT_TYPE(float, float52, ftostr52sign, 100.0);
3213
+  DEFINE_MENU_EDIT_TYPE(float, float62, ftostr62rj, 100.0);
3214
+  DEFINE_MENU_EDIT_TYPE(unsigned long, long5, ftostr5rj, 0.01);
3201 3215
 
3202 3216
   /**
3203 3217
    *
@@ -3466,7 +3480,7 @@ void lcd_update() {
3466 3480
 
3467 3481
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
3468 3482
 
3469
-    bool sd_status = IS_SD_INSERTED;
3483
+    const bool sd_status = IS_SD_INSERTED;
3470 3484
     if (sd_status != lcd_sd_status && lcd_detected()) {
3471 3485
 
3472 3486
       if (sd_status) {
@@ -3489,7 +3503,7 @@ void lcd_update() {
3489 3503
 
3490 3504
   #endif //SDSUPPORT && SD_DETECT_PIN
3491 3505
 
3492
-  millis_t ms = millis();
3506
+  const millis_t ms = millis();
3493 3507
   if (ELAPSED(ms, next_lcd_update_ms)
3494 3508
     #if ENABLED(DOGLCD)
3495 3509
       || drawing_screen
@@ -3759,6 +3773,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
3759 3773
    * Warning: This function is called from interrupt context!
3760 3774
    */
3761 3775
   void lcd_buttons_update() {
3776
+    static uint8_t lastEncoderBits;
3762 3777
     millis_t now = millis();
3763 3778
     if (ELAPSED(now, next_button_update_ms)) {
3764 3779
 

Loading…
Cancel
Save