浏览代码

Fix/improve TURBO_BACK_MENU_ITEM (#15856)

Jason Smith 5 年前
父节点
当前提交
b3f81eead5
共有 4 个文件被更改,包括 14 次插入36 次删除
  1. 1
    1
      Marlin/src/lcd/menu/menu.cpp
  2. 1
    7
      Marlin/src/lcd/menu/menu.h
  3. 4
    20
      Marlin/src/lcd/menu/menu_info.cpp
  4. 8
    8
      Marlin/src/lcd/ultralcd.h

+ 1
- 1
Marlin/src/lcd/menu/menu.cpp 查看文件

@@ -88,7 +88,7 @@ void MarlinUI::save_previous_screen() {
88 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 92
   #if ENABLED(TURBO_BACK_MENU_ITEM)
93 93
     const bool is_back/*=false*/
94 94
   #endif

+ 1
- 7
Marlin/src/lcd/menu/menu.h 查看文件

@@ -110,13 +110,7 @@ class MenuItem_back : public MenuItemBase {
110 110
     FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) {
111 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 116
 // SUBMENU(PLABEL, screen_handler)

+ 4
- 20
Marlin/src/lcd/menu/menu_info.cpp 查看文件

@@ -45,11 +45,7 @@
45 45
   // About Printer > Printer Stats
46 46
   //
47 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 50
     char buffer[21];  // For macro usage
55 51
 
@@ -97,11 +93,7 @@
97 93
 // About Printer > Thermistors
98 94
 //
99 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 98
   char buffer[21];  // For macro usage
107 99
 
@@ -218,11 +210,7 @@ void menu_info_thermistors() {
218 210
 // About Printer > Board Info
219 211
 //
220 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 215
   char buffer[21];  // For macro usage
228 216
 
@@ -257,11 +245,7 @@ void menu_info_board() {
257 245
 #else
258 246
 
259 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 249
     START_SCREEN();
266 250
     STATIC_ITEM_P(PSTR(MSG_MARLIN), SS_CENTER|SS_INVERT);       // Marlin
267 251
     STATIC_ITEM_P(PSTR(SHORT_BUILD_VERSION));                   // x.x.x-Branch

+ 8
- 8
Marlin/src/lcd/ultralcd.h 查看文件

@@ -463,16 +463,16 @@ public:
463 463
     static screenFunc_t currentScreen;
464 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 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 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 476
     #endif
477 477
 
478 478
     static void return_to_status();

正在加载...
取消
保存