Selaa lähdekoodia

Fix/improve TURBO_BACK_MENU_ITEM (#15856)

Jason Smith 5 vuotta sitten
vanhempi
commit
b3f81eead5

+ 1
- 1
Marlin/src/lcd/menu/menu.cpp Näytä tiedosto

88
     screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items };
88
     screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items };
89
 }
89
 }
90
 
90
 
91
-void MarlinUI::goto_previous_screen(
91
+void MarlinUI::_goto_previous_screen(
92
   #if ENABLED(TURBO_BACK_MENU_ITEM)
92
   #if ENABLED(TURBO_BACK_MENU_ITEM)
93
     const bool is_back/*=false*/
93
     const bool is_back/*=false*/
94
   #endif
94
   #endif

+ 1
- 7
Marlin/src/lcd/menu/menu.h Näytä tiedosto

110
     FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) {
110
     FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) {
111
       _draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]);
111
       _draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]);
112
     }
112
     }
113
-    static inline void action(PGM_P const=nullptr) {
114
-      ui.goto_previous_screen(
115
-        #if ENABLED(TURBO_BACK_MENU_ITEM)
116
-          true
117
-        #endif
118
-      );
119
-    }
113
+    static inline void action(PGM_P const=nullptr) { ui.go_back(); }
120
 };
114
 };
121
 
115
 
122
 // SUBMENU(PLABEL, screen_handler)
116
 // SUBMENU(PLABEL, screen_handler)

+ 4
- 20
Marlin/src/lcd/menu/menu_info.cpp Näytä tiedosto

45
   // About Printer > Printer Stats
45
   // About Printer > Printer Stats
46
   //
46
   //
47
   void menu_info_stats() {
47
   void menu_info_stats() {
48
-    if (ui.use_click()) return ui.goto_previous_screen(
49
-      #if ENABLED(TURBO_BACK_MENU_ITEM)
50
-        true
51
-      #endif
52
-    );
48
+    if (ui.use_click()) return ui.go_back();
53
 
49
 
54
     char buffer[21];  // For macro usage
50
     char buffer[21];  // For macro usage
55
 
51
 
97
 // About Printer > Thermistors
93
 // About Printer > Thermistors
98
 //
94
 //
99
 void menu_info_thermistors() {
95
 void menu_info_thermistors() {
100
-  if (ui.use_click()) return ui.goto_previous_screen(
101
-    #if ENABLED(TURBO_BACK_MENU_ITEM)
102
-      true
103
-    #endif
104
-  );
96
+  if (ui.use_click()) return ui.go_back();
105
 
97
 
106
   char buffer[21];  // For macro usage
98
   char buffer[21];  // For macro usage
107
 
99
 
218
 // About Printer > Board Info
210
 // About Printer > Board Info
219
 //
211
 //
220
 void menu_info_board() {
212
 void menu_info_board() {
221
-  if (ui.use_click()) return ui.goto_previous_screen(
222
-    #if ENABLED(TURBO_BACK_MENU_ITEM)
223
-      true
224
-    #endif
225
-  );
213
+  if (ui.use_click()) return ui.go_back();
226
 
214
 
227
   char buffer[21];  // For macro usage
215
   char buffer[21];  // For macro usage
228
 
216
 
257
 #else
245
 #else
258
 
246
 
259
   void menu_info_printer() {
247
   void menu_info_printer() {
260
-    if (ui.use_click()) return ui.goto_previous_screen(
261
-      #if ENABLED(TURBO_BACK_MENU_ITEM)
262
-        true
263
-      #endif
264
-    );
248
+    if (ui.use_click()) return ui.go_back();
265
     START_SCREEN();
249
     START_SCREEN();
266
     STATIC_ITEM_P(PSTR(MSG_MARLIN), SS_CENTER|SS_INVERT);       // Marlin
250
     STATIC_ITEM_P(PSTR(MSG_MARLIN), SS_CENTER|SS_INVERT);       // Marlin
267
     STATIC_ITEM_P(PSTR(SHORT_BUILD_VERSION));                   // x.x.x-Branch
251
     STATIC_ITEM_P(PSTR(SHORT_BUILD_VERSION));                   // x.x.x-Branch

+ 8
- 8
Marlin/src/lcd/ultralcd.h Näytä tiedosto

463
     static screenFunc_t currentScreen;
463
     static screenFunc_t currentScreen;
464
     static void goto_screen(const screenFunc_t screen, const uint16_t encoder=0, const uint8_t top=0, const uint8_t items=0);
464
     static void goto_screen(const screenFunc_t screen, const uint16_t encoder=0, const uint8_t top=0, const uint8_t items=0);
465
     static void save_previous_screen();
465
     static void save_previous_screen();
466
-    static void goto_previous_screen(
467
-      #if ENABLED(TURBO_BACK_MENU_ITEM)
468
-        const bool is_back
469
-      #endif
470
-    );
471
 
466
 
467
+    // goto_previous_screen and go_back may also be used as menu item callbacks
472
     #if ENABLED(TURBO_BACK_MENU_ITEM)
468
     #if ENABLED(TURBO_BACK_MENU_ITEM)
473
-      // Various menu items require a "void (*)()" to point to
474
-      // this function so a default argument *won't* work
475
-      static inline void goto_previous_screen() { goto_previous_screen(false); }
469
+      static void _goto_previous_screen(const bool is_back);
470
+      static inline void goto_previous_screen() { _goto_previous_screen(false); }
471
+      static inline void go_back()              { _goto_previous_screen(true); }
472
+    #else
473
+      static void _goto_previous_screen();
474
+      FORCE_INLINE static void goto_previous_screen() { _goto_previous_screen(); }
475
+      FORCE_INLINE static void go_back()              { _goto_previous_screen(); }
476
     #endif
476
     #endif
477
 
477
 
478
     static void return_to_status();
478
     static void return_to_status();

Loading…
Peruuta
Tallenna