Browse Source

Fix menu history item selection

Scott Lahteine 6 years ago
parent
commit
10b9632bed
3 changed files with 13 additions and 16 deletions
  1. 10
    13
      Marlin/src/lcd/menu/menu.cpp
  2. 2
    2
      Marlin/src/lcd/menu/menu.h
  3. 1
    1
      Marlin/src/lcd/ultralcd.h

+ 10
- 13
Marlin/src/lcd/menu/menu.cpp View File

54
 ////////////////////////////////////////////
54
 ////////////////////////////////////////////
55
 
55
 
56
 // Menu Navigation
56
 // Menu Navigation
57
-int8_t encoderTopLine;
57
+int8_t encoderTopLine, encoderLine, screen_items;
58
+
58
 typedef struct {
59
 typedef struct {
59
   screenFunc_t menu_function;
60
   screenFunc_t menu_function;
60
   uint32_t encoder_position;
61
   uint32_t encoder_position;
62
+  uint8_t top_line, items;
61
 } menuPosition;
63
 } menuPosition;
62
 menuPosition screen_history[6];
64
 menuPosition screen_history[6];
63
 uint8_t screen_history_depth = 0;
65
 uint8_t screen_history_depth = 0;
80
 void MarlinUI::return_to_status() { goto_screen(status_screen); }
82
 void MarlinUI::return_to_status() { goto_screen(status_screen); }
81
 
83
 
82
 void MarlinUI::save_previous_screen() {
84
 void MarlinUI::save_previous_screen() {
83
-  if (screen_history_depth < COUNT(screen_history)) {
84
-    screen_history[screen_history_depth].menu_function = currentScreen;
85
-    screen_history[screen_history_depth].encoder_position = encoderPosition;
86
-    ++screen_history_depth;
87
-  }
85
+  if (screen_history_depth < COUNT(screen_history))
86
+    screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items };
88
 }
87
 }
89
 
88
 
90
 void MarlinUI::goto_previous_screen() {
89
 void MarlinUI::goto_previous_screen() {
91
   if (screen_history_depth > 0) {
90
   if (screen_history_depth > 0) {
92
-    --screen_history_depth;
93
-    goto_screen(
94
-      screen_history[screen_history_depth].menu_function,
95
-      screen_history[screen_history_depth].encoder_position
96
-    );
91
+    menuPosition &sh = screen_history[--screen_history_depth];
92
+    goto_screen(sh.menu_function, sh.encoder_position, sh.top_line, sh.items);
97
   }
93
   }
98
   else
94
   else
99
     return_to_status();
95
     return_to_status();
197
 /**
193
 /**
198
  * General function to go directly to a screen
194
  * General function to go directly to a screen
199
  */
195
  */
200
-void MarlinUI::goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
196
+void MarlinUI::goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/, const uint8_t top/*=0*/, const uint8_t items/*=0*/) {
201
   if (currentScreen != screen) {
197
   if (currentScreen != screen) {
202
 
198
 
203
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
199
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
246
 
242
 
247
     currentScreen = screen;
243
     currentScreen = screen;
248
     encoderPosition = encoder;
244
     encoderPosition = encoder;
245
+    encoderTopLine = top;
246
+    screen_items = items;
249
     if (screen == status_screen) {
247
     if (screen == status_screen) {
250
       defer_status_screen(false);
248
       defer_status_screen(false);
251
       #if ENABLED(AUTO_BED_LEVELING_UBL)
249
       #if ENABLED(AUTO_BED_LEVELING_UBL)
314
  *   _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
312
  *   _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
315
  *   screen_items is the total number of items in the menu (after one call)
313
  *   screen_items is the total number of items in the menu (after one call)
316
  */
314
  */
317
-int8_t encoderLine, screen_items;
318
 void scroll_screen(const uint8_t limit, const bool is_menu) {
315
 void scroll_screen(const uint8_t limit, const bool is_menu) {
319
   ui.encoder_direction_menus();
316
   ui.encoder_direction_menus();
320
   ENCODER_RATE_MULTIPLY(false);
317
   ENCODER_RATE_MULTIPLY(false);

+ 2
- 2
Marlin/src/lcd/menu/menu.h View File

309
 
309
 
310
 #define MENU_BACK(LABEL) MENU_ITEM(back, LABEL)
310
 #define MENU_BACK(LABEL) MENU_ITEM(back, LABEL)
311
 #define MENU_ITEM_DUMMY() do { _thisItemNr++; }while(0)
311
 #define MENU_ITEM_DUMMY() do { _thisItemNr++; }while(0)
312
-#define MENU_ITEM_P(TYPE, PLABEL, ...)                       _MENU_ITEM_VARIANT_P(TYPE,              , false, PLABEL,                   ## __VA_ARGS__)
313
-#define MENU_ITEM(TYPE, LABEL, ...)                          _MENU_ITEM_VARIANT_P(TYPE,              , false, PSTR(LABEL),              ## __VA_ARGS__)
312
+#define MENU_ITEM_P(TYPE, PLABEL, ...)                       _MENU_ITEM_VARIANT_P(TYPE,      , false, PLABEL,                   ## __VA_ARGS__)
313
+#define MENU_ITEM(TYPE, LABEL, ...)                          _MENU_ITEM_VARIANT_P(TYPE,      , false, PSTR(LABEL),              ## __VA_ARGS__)
314
 #define MENU_ITEM_EDIT(TYPE, LABEL, ...)                     _MENU_ITEM_VARIANT_P(TYPE, _edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
314
 #define MENU_ITEM_EDIT(TYPE, LABEL, ...)                     _MENU_ITEM_VARIANT_P(TYPE, _edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
315
 #define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...)            _MENU_ITEM_VARIANT_P(TYPE, _edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
315
 #define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...)            _MENU_ITEM_VARIANT_P(TYPE, _edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
316
 #define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...)          _MENU_ITEM_VARIANT_P(TYPE, _edit,  true, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
316
 #define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...)          _MENU_ITEM_VARIANT_P(TYPE, _edit,  true, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)

+ 1
- 1
Marlin/src/lcd/ultralcd.h View File

419
     static void synchronize(PGM_P const msg=NULL);
419
     static void synchronize(PGM_P const msg=NULL);
420
 
420
 
421
     static screenFunc_t currentScreen;
421
     static screenFunc_t currentScreen;
422
-    static void goto_screen(const screenFunc_t screen, const uint32_t encoder=0);
422
+    static void goto_screen(const screenFunc_t screen, const uint32_t encoder=0, const uint8_t top=0, const uint8_t items=0);
423
     static void save_previous_screen();
423
     static void save_previous_screen();
424
     static void goto_previous_screen();
424
     static void goto_previous_screen();
425
     static void return_to_status();
425
     static void return_to_status();

Loading…
Cancel
Save