Browse Source

Merge pull request #3586 from thinkyhead/rc_revert_mbl_menu_hack

Revert MBL menus to "known" working point
Scott Lahteine 8 years ago
parent
commit
ce141deba2
1 changed files with 50 additions and 26 deletions
  1. 50
    26
      Marlin/ultralcd.cpp

+ 50
- 26
Marlin/ultralcd.cpp View File

262
   uint8_t currentMenuViewOffset;              /* scroll offset in the current menu */
262
   uint8_t currentMenuViewOffset;              /* scroll offset in the current menu */
263
   millis_t next_button_update_ms;
263
   millis_t next_button_update_ms;
264
   uint8_t lastEncoderBits;
264
   uint8_t lastEncoderBits;
265
-  uint32_t encoderPosition, nextEncoderPosition;
265
+  uint32_t encoderPosition;
266
   #if PIN_EXISTS(SD_DETECT)
266
   #if PIN_EXISTS(SD_DETECT)
267
     uint8_t lcd_sd_status;
267
     uint8_t lcd_sd_status;
268
   #endif
268
   #endif
277
 } menuPosition;
277
 } menuPosition;
278
 
278
 
279
 menuFunc_t currentMenu = lcd_status_screen; // pointer to the currently active menu handler
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
 menuPosition menu_history[10];
281
 menuPosition menu_history[10];
283
 uint8_t menu_history_depth = 0;
282
 uint8_t menu_history_depth = 0;
312
  * Remembers the previous position
311
  * Remembers the previous position
313
  */
312
  */
314
 static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const uint32_t encoder = 0) {
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
     #if ENABLED(NEWPANEL)
317
     #if ENABLED(NEWPANEL)
318
+      encoderPosition = encoder;
319
       if (feedback) lcd_quick_feedback();
319
       if (feedback) lcd_quick_feedback();
320
     #endif
320
     #endif
321
     if (menu == lcd_status_screen) {
321
     if (menu == lcd_status_screen) {
322
       defer_return_to_status = false;
322
       defer_return_to_status = false;
323
       menu_history_depth = 0;
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
 
918
 
915
   static void _lcd_level_bed_done() {
919
   static void _lcd_level_bed_done() {
916
     if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_DONE));
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
       NOLESS(current_position[Z_AXIS], 0);
940
       NOLESS(current_position[Z_AXIS], 0);
930
       NOMORE(current_position[Z_AXIS], MESH_HOME_SEARCH_Z * 2);
941
       NOMORE(current_position[Z_AXIS], MESH_HOME_SEARCH_Z * 2);
931
       line_to_current(Z_AXIS);
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
     encoderPosition = 0;
951
     encoderPosition = 0;
934
 
952
 
984
       sprintf_P(msg, PSTR("%i / %u"), (int)(_lcd_level_bed_position + 1), (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS));
1002
       sprintf_P(msg, PSTR("%i / %u"), (int)(_lcd_level_bed_position + 1), (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS));
985
       lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
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
   static void _lcd_level_bed_homing() {
1048
   static void _lcd_level_bed_homing() {
1023
     if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
1049
     if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
1024
     if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
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
       lcd_goto_menu(_lcd_level_bed_homing_done);
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
     if (min_software_endstops) NOLESS(current_position[axis], min);
1197
     if (min_software_endstops) NOLESS(current_position[axis], min);
1166
     if (max_software_endstops) NOMORE(current_position[axis], max);
1198
     if (max_software_endstops) NOMORE(current_position[axis], max);
1167
     line_to_current(axis);
1199
     line_to_current(axis);
1200
+    lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1168
   }
1201
   }
1169
   encoderPosition = 0;
1202
   encoderPosition = 0;
1170
   if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
1203
   if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
1193
   if (encoderPosition && movesplanned() <= 3) {
1226
   if (encoderPosition && movesplanned() <= 3) {
1194
     current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1227
     current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1195
     line_to_current(E_AXIS);
1228
     line_to_current(E_AXIS);
1229
+    lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1196
   }
1230
   }
1197
   encoderPosition = 0;
1231
   encoderPosition = 0;
1198
   if (lcdDrawUpdate) {
1232
   if (lcdDrawUpdate) {
1683
         lcd_contrast &= 0x3F;
1717
         lcd_contrast &= 0x3F;
1684
       #endif
1718
       #endif
1685
       encoderPosition = 0;
1719
       encoderPosition = 0;
1720
+      lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1686
       u8g.setContrast(lcd_contrast);
1721
       u8g.setContrast(lcd_contrast);
1687
     }
1722
     }
1688
     if (lcdDrawUpdate) {
1723
     if (lcdDrawUpdate) {
1759
     for (uint16_t i = 0; i < fileCnt; i++) {
1794
     for (uint16_t i = 0; i < fileCnt; i++) {
1760
       if (_menuItemNr == _lineNr) {
1795
       if (_menuItemNr == _lineNr) {
1761
         card.getfilename(
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
         if (card.filenameIsDir)
1803
         if (card.filenameIsDir)
1768
           MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename);
1804
           MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename);
1769
         else
1805
         else
1833
   } \
1869
   } \
1834
   static void menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) { \
1870
   static void menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) { \
1835
     _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
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
   static void menu_action_setting_edit_callback_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue, menuFunc_t callback) { \
1874
   static void menu_action_setting_edit_callback_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue, menuFunc_t callback) { \
1839
     _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
1875
     _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
1876
+    currentMenu = menu_edit_callback_ ## _name; \
1840
     callbackFunc = callback; \
1877
     callbackFunc = callback; \
1841
-    lcd_goto_menu(menu_edit_callback_ ## _name); \
1842
   }
1878
   }
1843
 menu_edit_type(int, int3, itostr3, 1);
1879
 menu_edit_type(int, int3, itostr3, 1);
1844
 menu_edit_type(float, float3, ftostr3, 1);
1880
 menu_edit_type(float, float3, ftostr3, 1);
1904
 #endif
1940
 #endif
1905
 
1941
 
1906
 void lcd_quick_feedback() {
1942
 void lcd_quick_feedback() {
1943
+  lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
1907
   next_button_update_ms = millis() + 500;
1944
   next_button_update_ms = millis() + 500;
1908
 
1945
 
1909
   #if ENABLED(LCD_USE_I2C_BUZZER)
1946
   #if ENABLED(LCD_USE_I2C_BUZZER)
2090
  *             so don't change lcdDrawUpdate without considering this.
2127
  *             so don't change lcdDrawUpdate without considering this.
2091
  *
2128
  *
2092
  *   After the menu handler callback runs (or not):
2129
  *   After the menu handler callback runs (or not):
2093
- *   - Set lcdDrawUpdate to nextLcdDrawUpdate (usually unchanged)
2094
  *   - Clear the LCD if lcdDrawUpdate == LCDVIEW_CLEAR_CALL_REDRAW
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
  * No worries. This function is only called from the main thread.
2133
  * No worries. This function is only called from the main thread.
2098
  */
2134
  */
2250
 
2286
 
2251
     #endif // ULTIPANEL
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
     switch (lcdDrawUpdate) {
2289
     switch (lcdDrawUpdate) {
2266
       case LCDVIEW_CLEAR_CALL_REDRAW:
2290
       case LCDVIEW_CLEAR_CALL_REDRAW:
2267
         lcd_implementation_clear();
2291
         lcd_implementation_clear();

Loading…
Cancel
Save