Browse Source

Fix menu history item selection

pull/1/head
Scott Lahteine 6 years ago
parent
commit
10b9632bed
  1. 23
      Marlin/src/lcd/menu/menu.cpp
  2. 4
      Marlin/src/lcd/menu/menu.h
  3. 2
      Marlin/src/lcd/ultralcd.h

23
Marlin/src/lcd/menu/menu.cpp

@ -54,10 +54,12 @@
////////////////////////////////////////////
// Menu Navigation
int8_t encoderTopLine;
int8_t encoderTopLine, encoderLine, screen_items;
typedef struct {
screenFunc_t menu_function;
uint32_t encoder_position;
uint8_t top_line, items;
} menuPosition;
menuPosition screen_history[6];
uint8_t screen_history_depth = 0;
@ -80,20 +82,14 @@ bool no_reentry = false;
void MarlinUI::return_to_status() { goto_screen(status_screen); }
void MarlinUI::save_previous_screen() {
if (screen_history_depth < COUNT(screen_history)) {
screen_history[screen_history_depth].menu_function = currentScreen;
screen_history[screen_history_depth].encoder_position = encoderPosition;
++screen_history_depth;
}
if (screen_history_depth < COUNT(screen_history))
screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items };
}
void MarlinUI::goto_previous_screen() {
if (screen_history_depth > 0) {
--screen_history_depth;
goto_screen(
screen_history[screen_history_depth].menu_function,
screen_history[screen_history_depth].encoder_position
);
menuPosition &sh = screen_history[--screen_history_depth];
goto_screen(sh.menu_function, sh.encoder_position, sh.top_line, sh.items);
}
else
return_to_status();
@ -197,7 +193,7 @@ bool printer_busy() {
/**
* General function to go directly to a screen
*/
void MarlinUI::goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
void MarlinUI::goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/, const uint8_t top/*=0*/, const uint8_t items/*=0*/) {
if (currentScreen != screen) {
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
@ -246,6 +242,8 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
currentScreen = screen;
encoderPosition = encoder;
encoderTopLine = top;
screen_items = items;
if (screen == status_screen) {
defer_status_screen(false);
#if ENABLED(AUTO_BED_LEVELING_UBL)
@ -314,7 +312,6 @@ void MarlinUI::synchronize(PGM_P const msg/*=NULL*/) {
* _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
* screen_items is the total number of items in the menu (after one call)
*/
int8_t encoderLine, screen_items;
void scroll_screen(const uint8_t limit, const bool is_menu) {
ui.encoder_direction_menus();
ENCODER_RATE_MULTIPLY(false);

4
Marlin/src/lcd/menu/menu.h

@ -309,8 +309,8 @@ class MenuItem_bool {
#define MENU_BACK(LABEL) MENU_ITEM(back, LABEL)
#define MENU_ITEM_DUMMY() do { _thisItemNr++; }while(0)
#define MENU_ITEM_P(TYPE, PLABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, , false, PLABEL, ## __VA_ARGS__)
#define MENU_ITEM(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, , false, PSTR(LABEL), ## __VA_ARGS__)
#define MENU_ITEM_P(TYPE, PLABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, , false, PLABEL, ## __VA_ARGS__)
#define MENU_ITEM(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, , false, PSTR(LABEL), ## __VA_ARGS__)
#define MENU_ITEM_EDIT(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
#define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
#define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _edit, true, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)

2
Marlin/src/lcd/ultralcd.h

@ -419,7 +419,7 @@ public:
static void synchronize(PGM_P const msg=NULL);
static screenFunc_t currentScreen;
static void goto_screen(const screenFunc_t screen, const uint32_t encoder=0);
static void goto_screen(const screenFunc_t screen, const uint32_t encoder=0, const uint8_t top=0, const uint8_t items=0);
static void save_previous_screen();
static void goto_previous_screen();
static void return_to_status();

Loading…
Cancel
Save