From eb6f44372e14487c7178ac341084cdaa967e2baa Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 11 Mar 2018 04:44:28 -0500 Subject: [PATCH] Finish scroll_screen, fixing direction/multiplier Fixes #10041 --- Marlin/ultralcd.cpp | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 4993aaa87..33e2a583e 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -383,26 +383,6 @@ uint16_t max_display_update_time = 0; #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) MENU_ITEM(setting_edit_callback_ ## TYPE, LABEL, PSTR(LABEL), ## __VA_ARGS__) #endif // !ENCODER_RATE_MULTIPLIER - /** - * START_SCREEN_OR_MENU generates init code for a screen or menu - * - * encoderLine is the position based on the encoder - * encoderTopLine is the top menu line to display - * _lcdLineNr is the index of the LCD line (e.g., 0-3) - * _menuLineNr is the menu item to draw and process - * _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) - */ - #define START_SCREEN_OR_MENU(LIMIT) \ - ENCODER_DIRECTION_MENUS(); \ - ENCODER_RATE_MULTIPLY(false); \ - if (encoderPosition > 0x8000) encoderPosition = 0; \ - if (first_page) encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM); \ - if (screen_items > 0 && encoderLine >= screen_items - (LIMIT)) { \ - encoderLine = max(0, screen_items - (LIMIT)); \ - encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM); \ - } - #define SCREEN_OR_MENU_LOOP() \ int8_t _menuLineNr = encoderTopLine, _thisItemNr; \ for (int8_t _lcdLineNr = 0; _lcdLineNr < menu_bottom; _lcdLineNr++, _menuLineNr++) { \ @@ -635,9 +615,18 @@ uint16_t max_display_update_time = 0; /** * Scrolling for menus and other line-based screens + * + * encoderLine is the position based on the encoder + * encoderTopLine is the top menu line to display + * _lcdLineNr is the index of the LCD line (e.g., 0-3) + * _menuLineNr is the menu item to draw and process + * _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) { + ENCODER_DIRECTION_MENUS(); + ENCODER_RATE_MULTIPLY(false); if (encoderPosition > 0x8000) encoderPosition = 0; if (first_page) { encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);