Browse Source

Fix/improve TURBO_BACK_MENU_ITEM (#15856)

pull/1/head
Jason Smith 5 years ago
committed by Scott Lahteine
parent
commit
b3f81eead5
  1. 2
      Marlin/src/lcd/menu/menu.cpp
  2. 8
      Marlin/src/lcd/menu/menu.h
  3. 24
      Marlin/src/lcd/menu/menu_info.cpp
  4. 16
      Marlin/src/lcd/ultralcd.h

2
Marlin/src/lcd/menu/menu.cpp

@ -88,7 +88,7 @@ void MarlinUI::save_previous_screen() {
screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items }; screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items };
} }
void MarlinUI::goto_previous_screen( void MarlinUI::_goto_previous_screen(
#if ENABLED(TURBO_BACK_MENU_ITEM) #if ENABLED(TURBO_BACK_MENU_ITEM)
const bool is_back/*=false*/ const bool is_back/*=false*/
#endif #endif

8
Marlin/src/lcd/menu/menu.h

@ -110,13 +110,7 @@ class MenuItem_back : public MenuItemBase {
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) { FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) {
_draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]); _draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]);
} }
static inline void action(PGM_P const=nullptr) { static inline void action(PGM_P const=nullptr) { ui.go_back(); }
ui.goto_previous_screen(
#if ENABLED(TURBO_BACK_MENU_ITEM)
true
#endif
);
}
}; };
// SUBMENU(PLABEL, screen_handler) // SUBMENU(PLABEL, screen_handler)

24
Marlin/src/lcd/menu/menu_info.cpp

@ -45,11 +45,7 @@
// About Printer > Printer Stats // About Printer > Printer Stats
// //
void menu_info_stats() { void menu_info_stats() {
if (ui.use_click()) return ui.goto_previous_screen( if (ui.use_click()) return ui.go_back();
#if ENABLED(TURBO_BACK_MENU_ITEM)
true
#endif
);
char buffer[21]; // For macro usage char buffer[21]; // For macro usage
@ -97,11 +93,7 @@
// About Printer > Thermistors // About Printer > Thermistors
// //
void menu_info_thermistors() { void menu_info_thermistors() {
if (ui.use_click()) return ui.goto_previous_screen( if (ui.use_click()) return ui.go_back();
#if ENABLED(TURBO_BACK_MENU_ITEM)
true
#endif
);
char buffer[21]; // For macro usage char buffer[21]; // For macro usage
@ -218,11 +210,7 @@ void menu_info_thermistors() {
// About Printer > Board Info // About Printer > Board Info
// //
void menu_info_board() { void menu_info_board() {
if (ui.use_click()) return ui.goto_previous_screen( if (ui.use_click()) return ui.go_back();
#if ENABLED(TURBO_BACK_MENU_ITEM)
true
#endif
);
char buffer[21]; // For macro usage char buffer[21]; // For macro usage
@ -257,11 +245,7 @@ void menu_info_board() {
#else #else
void menu_info_printer() { void menu_info_printer() {
if (ui.use_click()) return ui.goto_previous_screen( if (ui.use_click()) return ui.go_back();
#if ENABLED(TURBO_BACK_MENU_ITEM)
true
#endif
);
START_SCREEN(); START_SCREEN();
STATIC_ITEM_P(PSTR(MSG_MARLIN), SS_CENTER|SS_INVERT); // Marlin STATIC_ITEM_P(PSTR(MSG_MARLIN), SS_CENTER|SS_INVERT); // Marlin
STATIC_ITEM_P(PSTR(SHORT_BUILD_VERSION)); // x.x.x-Branch STATIC_ITEM_P(PSTR(SHORT_BUILD_VERSION)); // x.x.x-Branch

16
Marlin/src/lcd/ultralcd.h

@ -463,16 +463,16 @@ public:
static screenFunc_t currentScreen; static screenFunc_t currentScreen;
static void goto_screen(const screenFunc_t screen, const uint16_t encoder=0, const uint8_t top=0, const uint8_t items=0); static void goto_screen(const screenFunc_t screen, const uint16_t encoder=0, const uint8_t top=0, const uint8_t items=0);
static void save_previous_screen(); static void save_previous_screen();
static void goto_previous_screen(
#if ENABLED(TURBO_BACK_MENU_ITEM)
const bool is_back
#endif
);
// goto_previous_screen and go_back may also be used as menu item callbacks
#if ENABLED(TURBO_BACK_MENU_ITEM) #if ENABLED(TURBO_BACK_MENU_ITEM)
// Various menu items require a "void (*)()" to point to static void _goto_previous_screen(const bool is_back);
// this function so a default argument *won't* work static inline void goto_previous_screen() { _goto_previous_screen(false); }
static inline void goto_previous_screen() { goto_previous_screen(false); } static inline void go_back() { _goto_previous_screen(true); }
#else
static void _goto_previous_screen();
FORCE_INLINE static void goto_previous_screen() { _goto_previous_screen(); }
FORCE_INLINE static void go_back() { _goto_previous_screen(); }
#endif #endif
static void return_to_status(); static void return_to_status();

Loading…
Cancel
Save