Browse Source

Revert MBL menus to "known" working point

Scott Lahteine 8 years ago
parent
commit
003aab6dfd
1 changed files with 50 additions and 26 deletions
  1. 50
    26
      Marlin/ultralcd.cpp

+ 50
- 26
Marlin/ultralcd.cpp View File

@@ -262,7 +262,7 @@ static void lcd_status_screen();
262 262
   uint8_t currentMenuViewOffset;              /* scroll offset in the current menu */
263 263
   millis_t next_button_update_ms;
264 264
   uint8_t lastEncoderBits;
265
-  uint32_t encoderPosition, nextEncoderPosition;
265
+  uint32_t encoderPosition;
266 266
   #if PIN_EXISTS(SD_DETECT)
267 267
     uint8_t lcd_sd_status;
268 268
   #endif
@@ -277,7 +277,6 @@ typedef struct {
277 277
 } menuPosition;
278 278
 
279 279
 menuFunc_t currentMenu = lcd_status_screen; // pointer to the currently active menu handler
280
-menuFunc_t nextMenu = NULL; // the next menu handler to activate
281 280
 
282 281
 menuPosition menu_history[10];
283 282
 uint8_t menu_history_depth = 0;
@@ -312,16 +311,21 @@ float raw_Ki, raw_Kd;
312 311
  * Remembers the previous position
313 312
  */
314 313
 static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const uint32_t encoder = 0) {
315
-  if (currentMenu != menu && nextMenu != menu) {
316
-    nextMenu = menu;
317
-    nextEncoderPosition = encoder;
314
+  if (currentMenu != menu) {
315
+    currentMenu = menu;
316
+    lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
318 317
     #if ENABLED(NEWPANEL)
318
+      encoderPosition = encoder;
319 319
       if (feedback) lcd_quick_feedback();
320 320
     #endif
321 321
     if (menu == lcd_status_screen) {
322 322
       defer_return_to_status = false;
323 323
       menu_history_depth = 0;
324 324
     }
325
+    #if ENABLED(LCD_PROGRESS_BAR)
326
+      // For LCD_PROGRESS_BAR re-initialize custom characters
327
+      lcd_set_custom_characters(menu == lcd_status_screen);
328
+    #endif
325 329
   }
326 330
 }
327 331
 
@@ -914,6 +918,13 @@ void lcd_cooldown() {
914 918
 
915 919
   static void _lcd_level_bed_done() {
916 920
     if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_DONE));
921
+    lcdDrawUpdate =
922
+      #if ENABLED(DOGLCD)
923
+        LCDVIEW_CALL_REDRAW_NEXT
924
+      #else
925
+        LCDVIEW_CALL_NO_REDRAW
926
+      #endif
927
+    ;
917 928
   }
918 929
 
919 930
   /**
@@ -929,6 +940,13 @@ void lcd_cooldown() {
929 940
       NOLESS(current_position[Z_AXIS], 0);
930 941
       NOMORE(current_position[Z_AXIS], MESH_HOME_SEARCH_Z * 2);
931 942
       line_to_current(Z_AXIS);
943
+      lcdDrawUpdate =
944
+        #if ENABLED(DOGLCD)
945
+          LCDVIEW_CALL_REDRAW_NEXT
946
+        #else
947
+          LCDVIEW_REDRAW_NOW
948
+        #endif
949
+      ;
932 950
     }
933 951
     encoderPosition = 0;
934 952
 
@@ -984,6 +1002,14 @@ void lcd_cooldown() {
984 1002
       sprintf_P(msg, PSTR("%i / %u"), (int)(_lcd_level_bed_position + 1), (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS));
985 1003
       lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
986 1004
     }
1005
+
1006
+    lcdDrawUpdate =
1007
+      #if ENABLED(DOGLCD)
1008
+        LCDVIEW_CALL_REDRAW_NEXT
1009
+      #else
1010
+        LCDVIEW_CALL_NO_REDRAW
1011
+      #endif
1012
+    ;
987 1013
   }
988 1014
 
989 1015
   /**
@@ -1022,8 +1048,14 @@ void lcd_cooldown() {
1022 1048
   static void _lcd_level_bed_homing() {
1023 1049
     if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
1024 1050
     if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
1051
+    lcdDrawUpdate =
1052
+      #if ENABLED(DOGLCD)
1053
+        LCDVIEW_CALL_REDRAW_NEXT
1054
+      #else
1055
+        LCDVIEW_CALL_NO_REDRAW
1056
+      #endif
1057
+    ;
1025 1058
       lcd_goto_menu(_lcd_level_bed_homing_done);
1026
-    lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW; // counts as a draw flag during graphical loop
1027 1059
   }
1028 1060
 
1029 1061
   /**
@@ -1165,6 +1197,7 @@ static void _lcd_move(const char* name, AxisEnum axis, float min, float max) {
1165 1197
     if (min_software_endstops) NOLESS(current_position[axis], min);
1166 1198
     if (max_software_endstops) NOMORE(current_position[axis], max);
1167 1199
     line_to_current(axis);
1200
+    lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1168 1201
   }
1169 1202
   encoderPosition = 0;
1170 1203
   if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
@@ -1193,6 +1226,7 @@ static void lcd_move_e(
1193 1226
   if (encoderPosition && movesplanned() <= 3) {
1194 1227
     current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1195 1228
     line_to_current(E_AXIS);
1229
+    lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1196 1230
   }
1197 1231
   encoderPosition = 0;
1198 1232
   if (lcdDrawUpdate) {
@@ -1683,6 +1717,7 @@ static void lcd_control_volumetric_menu() {
1683 1717
         lcd_contrast &= 0x3F;
1684 1718
       #endif
1685 1719
       encoderPosition = 0;
1720
+      lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1686 1721
       u8g.setContrast(lcd_contrast);
1687 1722
     }
1688 1723
     if (lcdDrawUpdate) {
@@ -1759,11 +1794,12 @@ static void lcd_control_volumetric_menu() {
1759 1794
     for (uint16_t i = 0; i < fileCnt; i++) {
1760 1795
       if (_menuItemNr == _lineNr) {
1761 1796
         card.getfilename(
1762
-          #if ENABLED(SDCARD_RATHERRECENTFIRST)
1763
-            fileCnt-1 -
1764
-          #endif
1765
-          i
1797
+           #if ENABLED(SDCARD_RATHERRECENTFIRST)
1798
+             fileCnt-1 -
1799
+           #endif
1800
+           i
1766 1801
         );
1802
+
1767 1803
         if (card.filenameIsDir)
1768 1804
           MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename);
1769 1805
         else
@@ -1833,12 +1869,12 @@ static void lcd_control_volumetric_menu() {
1833 1869
   } \
1834 1870
   static void menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) { \
1835 1871
     _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
1836
-    lcd_goto_menu(menu_edit_ ## _name); \
1872
+    currentMenu = menu_edit_ ## _name; \
1837 1873
   }\
1838 1874
   static void menu_action_setting_edit_callback_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue, menuFunc_t callback) { \
1839 1875
     _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
1876
+    currentMenu = menu_edit_callback_ ## _name; \
1840 1877
     callbackFunc = callback; \
1841
-    lcd_goto_menu(menu_edit_callback_ ## _name); \
1842 1878
   }
1843 1879
 menu_edit_type(int, int3, itostr3, 1);
1844 1880
 menu_edit_type(float, float3, ftostr3, 1);
@@ -1904,6 +1940,7 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01);
1904 1940
 #endif
1905 1941
 
1906 1942
 void lcd_quick_feedback() {
1943
+  lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
1907 1944
   next_button_update_ms = millis() + 500;
1908 1945
 
1909 1946
   #if ENABLED(LCD_USE_I2C_BUZZER)
@@ -2090,9 +2127,8 @@ bool lcd_blink() {
2090 2127
  *             so don't change lcdDrawUpdate without considering this.
2091 2128
  *
2092 2129
  *   After the menu handler callback runs (or not):
2093
- *   - Set lcdDrawUpdate to nextLcdDrawUpdate (usually unchanged)
2094 2130
  *   - Clear the LCD if lcdDrawUpdate == LCDVIEW_CLEAR_CALL_REDRAW
2095
- *   - Transition lcdDrawUpdate to the next state
2131
+ *   - Update lcdDrawUpdate for the next loop (i.e., move one state down, usually)
2096 2132
  *
2097 2133
  * No worries. This function is only called from the main thread.
2098 2134
  */
@@ -2250,18 +2286,6 @@ void lcd_update() {
2250 2286
 
2251 2287
     #endif // ULTIPANEL
2252 2288
 
2253
-    // If a new menu was set, update the pointer, set to clear & redraw
2254
-    if (nextMenu) {
2255
-      currentMenu = nextMenu;
2256
-      encoderPosition = nextEncoderPosition;
2257
-      nextMenu = NULL;
2258
-      lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
2259
-      #if ENABLED(LCD_PROGRESS_BAR)
2260
-        // For LCD_PROGRESS_BAR re-initialize custom characters
2261
-        lcd_set_custom_characters(currentMenu == lcd_status_screen);
2262
-      #endif
2263
-    }
2264
-
2265 2289
     switch (lcdDrawUpdate) {
2266 2290
       case LCDVIEW_CLEAR_CALL_REDRAW:
2267 2291
         lcd_implementation_clear();

Loading…
Cancel
Save