|
|
|
@ -154,7 +154,10 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
|
|
|
|
uint16_t max_display_update_time = 0;
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DOGLCD)
|
|
|
|
|
bool drawing_screen = false;
|
|
|
|
|
bool drawing_screen, // = false
|
|
|
|
|
first_page;
|
|
|
|
|
#else
|
|
|
|
|
constexpr bool first_page = true;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DAC_STEPPER_CURRENT)
|
|
|
|
@ -173,6 +176,7 @@ uint16_t max_display_update_time = 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
bool no_reentry = false;
|
|
|
|
|
constexpr int8_t menu_bottom = LCD_HEIGHT - (TALL_FONT_CORRECTION);
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
///////////////// Menu Tree ////////////////
|
|
|
|
@ -394,22 +398,21 @@ uint16_t max_display_update_time = 0;
|
|
|
|
|
* _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
|
|
|
|
|
* _countedItems is the total number of items in the menu (after one call)
|
|
|
|
|
* 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; \
|
|
|
|
|
static int8_t _countedItems = 0; \
|
|
|
|
|
int8_t encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM); \
|
|
|
|
|
if (_countedItems > 0 && encoderLine >= _countedItems - (LIMIT)) { \
|
|
|
|
|
encoderLine = max(0, _countedItems - (LIMIT)); \
|
|
|
|
|
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 < LCD_HEIGHT - (TALL_FONT_CORRECTION); _lcdLineNr++, _menuLineNr++) { \
|
|
|
|
|
for (int8_t _lcdLineNr = 0; _lcdLineNr < menu_bottom; _lcdLineNr++, _menuLineNr++) { \
|
|
|
|
|
_thisItemNr = 0
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -420,28 +423,22 @@ uint16_t max_display_update_time = 0;
|
|
|
|
|
* Scroll as-needed to keep the selected line in view.
|
|
|
|
|
*/
|
|
|
|
|
#define START_SCREEN() \
|
|
|
|
|
START_SCREEN_OR_MENU(LCD_HEIGHT - (TALL_FONT_CORRECTION)); \
|
|
|
|
|
encoderTopLine = encoderLine; \
|
|
|
|
|
scroll_screen(menu_bottom, false); \
|
|
|
|
|
bool _skipStatic = false; \
|
|
|
|
|
SCREEN_OR_MENU_LOOP()
|
|
|
|
|
|
|
|
|
|
#define START_MENU() \
|
|
|
|
|
START_SCREEN_OR_MENU(1); \
|
|
|
|
|
screen_changed = false; \
|
|
|
|
|
NOMORE(encoderTopLine, encoderLine); \
|
|
|
|
|
if (encoderLine >= encoderTopLine + LCD_HEIGHT - (TALL_FONT_CORRECTION)) { \
|
|
|
|
|
encoderTopLine = encoderLine - (LCD_HEIGHT - (TALL_FONT_CORRECTION) - 1); \
|
|
|
|
|
} \
|
|
|
|
|
scroll_screen(1, true); \
|
|
|
|
|
bool _skipStatic = true; \
|
|
|
|
|
SCREEN_OR_MENU_LOOP()
|
|
|
|
|
|
|
|
|
|
#define END_SCREEN() \
|
|
|
|
|
} \
|
|
|
|
|
_countedItems = _thisItemNr
|
|
|
|
|
screen_items = _thisItemNr
|
|
|
|
|
|
|
|
|
|
#define END_MENU() \
|
|
|
|
|
} \
|
|
|
|
|
_countedItems = _thisItemNr; \
|
|
|
|
|
screen_items = _thisItemNr; \
|
|
|
|
|
UNUSED(_skipStatic)
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
@ -643,6 +640,29 @@ uint16_t max_display_update_time = 0;
|
|
|
|
|
lcd_goto_previous_menu();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Scrolling for menus and other line-based screens
|
|
|
|
|
*/
|
|
|
|
|
int8_t encoderLine, screen_items;
|
|
|
|
|
void scroll_screen(const uint8_t limit, const bool is_menu) {
|
|
|
|
|
if (encoderPosition > 0x8000) encoderPosition = 0;
|
|
|
|
|
if (first_page) {
|
|
|
|
|
encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
|
|
|
|
|
screen_changed = false;
|
|
|
|
|
}
|
|
|
|
|
if (screen_items > 0 && encoderLine >= screen_items - limit) {
|
|
|
|
|
encoderLine = max(0, screen_items - limit);
|
|
|
|
|
encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM);
|
|
|
|
|
}
|
|
|
|
|
if (is_menu) {
|
|
|
|
|
NOMORE(encoderTopLine, encoderLine);
|
|
|
|
|
if (encoderLine >= encoderTopLine + menu_bottom)
|
|
|
|
|
encoderTopLine = encoderLine - menu_bottom + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
encoderTopLine = encoderLine;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // ULTIPANEL
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -785,10 +805,7 @@ void kill_screen(const char* lcd_msg) {
|
|
|
|
|
|
|
|
|
|
void lcd_quick_feedback(const bool clear_buttons) {
|
|
|
|
|
lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
|
|
|
|
|
|
|
|
|
|
if (clear_buttons)
|
|
|
|
|
buttons = 0;
|
|
|
|
|
|
|
|
|
|
if (clear_buttons) buttons = 0;
|
|
|
|
|
next_button_update_ms = millis() + 500;
|
|
|
|
|
|
|
|
|
|
// Buzz and wait. The delay is needed for buttons to settle!
|
|
|
|
@ -3232,7 +3249,6 @@ void kill_screen(const char* lcd_msg) {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if HAS_LCD_CONTRAST
|
|
|
|
|
// please don't remove the "(int16_t*)" - it's needed for the VIKI2 display --- see PR #9132 before changing it
|
|
|
|
|
MENU_ITEM_EDIT_CALLBACK(int3, MSG_CONTRAST, &lcd_contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, lcd_callback_set_contrast, true);
|
|
|
|
|
#endif
|
|
|
|
|
#if ENABLED(FWRETRACT)
|
|
|
|
@ -5193,11 +5209,12 @@ void lcd_update() {
|
|
|
|
|
if (do_u8g_loop) {
|
|
|
|
|
if (!drawing_screen) { // If not already drawing pages
|
|
|
|
|
u8g.firstPage(); // Start the first page
|
|
|
|
|
drawing_screen = 1; // Flag as drawing pages
|
|
|
|
|
drawing_screen = first_page = true; // Flag as drawing pages
|
|
|
|
|
}
|
|
|
|
|
lcd_setFont(FONT_MENU); // Setup font for every page draw
|
|
|
|
|
u8g.setColorIndex(1); // And reset the color
|
|
|
|
|
CURRENTSCREEN(); // Draw and process the current screen
|
|
|
|
|
first_page = false;
|
|
|
|
|
|
|
|
|
|
// The screen handler can clear drawing_screen for an action that changes the screen.
|
|
|
|
|
// If still drawing and there's another page, update max-time and return now.
|
|
|
|
@ -5380,9 +5397,11 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
|
|
|
|
|
#if BUTTON_EXISTS(EN1)
|
|
|
|
|
if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if BUTTON_EXISTS(EN2)
|
|
|
|
|
if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if BUTTON_EXISTS(ENC)
|
|
|
|
|
if (BUTTON_PRESSED(ENC)) newbutton |= EN_C;
|
|
|
|
|
#endif
|
|
|
|
|