|
@@ -154,7 +154,10 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
154
|
154
|
uint16_t max_display_update_time = 0;
|
155
|
155
|
|
156
|
156
|
#if ENABLED(DOGLCD)
|
157
|
|
- bool drawing_screen = false;
|
|
157
|
+ bool drawing_screen, // = false
|
|
158
|
+ first_page;
|
|
159
|
+#else
|
|
160
|
+ constexpr bool first_page = true;
|
158
|
161
|
#endif
|
159
|
162
|
|
160
|
163
|
#if ENABLED(DAC_STEPPER_CURRENT)
|
|
@@ -173,6 +176,7 @@ uint16_t max_display_update_time = 0;
|
173
|
176
|
#endif
|
174
|
177
|
|
175
|
178
|
bool no_reentry = false;
|
|
179
|
+ constexpr int8_t menu_bottom = LCD_HEIGHT - (TALL_FONT_CORRECTION);
|
176
|
180
|
|
177
|
181
|
////////////////////////////////////////////
|
178
|
182
|
///////////////// Menu Tree ////////////////
|
|
@@ -394,22 +398,21 @@ uint16_t max_display_update_time = 0;
|
394
|
398
|
* _lcdLineNr is the index of the LCD line (e.g., 0-3)
|
395
|
399
|
* _menuLineNr is the menu item to draw and process
|
396
|
400
|
* _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
|
397
|
|
- * _countedItems is the total number of items in the menu (after one call)
|
|
401
|
+ * screen_items is the total number of items in the menu (after one call)
|
398
|
402
|
*/
|
399
|
403
|
#define START_SCREEN_OR_MENU(LIMIT) \
|
400
|
404
|
ENCODER_DIRECTION_MENUS(); \
|
401
|
405
|
ENCODER_RATE_MULTIPLY(false); \
|
402
|
406
|
if (encoderPosition > 0x8000) encoderPosition = 0; \
|
403
|
|
- static int8_t _countedItems = 0; \
|
404
|
|
- int8_t encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM); \
|
405
|
|
- if (_countedItems > 0 && encoderLine >= _countedItems - (LIMIT)) { \
|
406
|
|
- encoderLine = max(0, _countedItems - (LIMIT)); \
|
|
407
|
+ if (first_page) encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM); \
|
|
408
|
+ if (screen_items > 0 && encoderLine >= screen_items - (LIMIT)) { \
|
|
409
|
+ encoderLine = max(0, screen_items - (LIMIT)); \
|
407
|
410
|
encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM); \
|
408
|
411
|
}
|
409
|
412
|
|
410
|
413
|
#define SCREEN_OR_MENU_LOOP() \
|
411
|
414
|
int8_t _menuLineNr = encoderTopLine, _thisItemNr; \
|
412
|
|
- for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT - (TALL_FONT_CORRECTION); _lcdLineNr++, _menuLineNr++) { \
|
|
415
|
+ for (int8_t _lcdLineNr = 0; _lcdLineNr < menu_bottom; _lcdLineNr++, _menuLineNr++) { \
|
413
|
416
|
_thisItemNr = 0
|
414
|
417
|
|
415
|
418
|
/**
|
|
@@ -420,28 +423,22 @@ uint16_t max_display_update_time = 0;
|
420
|
423
|
* Scroll as-needed to keep the selected line in view.
|
421
|
424
|
*/
|
422
|
425
|
#define START_SCREEN() \
|
423
|
|
- START_SCREEN_OR_MENU(LCD_HEIGHT - (TALL_FONT_CORRECTION)); \
|
424
|
|
- encoderTopLine = encoderLine; \
|
|
426
|
+ scroll_screen(menu_bottom, false); \
|
425
|
427
|
bool _skipStatic = false; \
|
426
|
428
|
SCREEN_OR_MENU_LOOP()
|
427
|
429
|
|
428
|
430
|
#define START_MENU() \
|
429
|
|
- START_SCREEN_OR_MENU(1); \
|
430
|
|
- screen_changed = false; \
|
431
|
|
- NOMORE(encoderTopLine, encoderLine); \
|
432
|
|
- if (encoderLine >= encoderTopLine + LCD_HEIGHT - (TALL_FONT_CORRECTION)) { \
|
433
|
|
- encoderTopLine = encoderLine - (LCD_HEIGHT - (TALL_FONT_CORRECTION) - 1); \
|
434
|
|
- } \
|
|
431
|
+ scroll_screen(1, true); \
|
435
|
432
|
bool _skipStatic = true; \
|
436
|
433
|
SCREEN_OR_MENU_LOOP()
|
437
|
434
|
|
438
|
435
|
#define END_SCREEN() \
|
439
|
436
|
} \
|
440
|
|
- _countedItems = _thisItemNr
|
|
437
|
+ screen_items = _thisItemNr
|
441
|
438
|
|
442
|
439
|
#define END_MENU() \
|
443
|
440
|
} \
|
444
|
|
- _countedItems = _thisItemNr; \
|
|
441
|
+ screen_items = _thisItemNr; \
|
445
|
442
|
UNUSED(_skipStatic)
|
446
|
443
|
|
447
|
444
|
////////////////////////////////////////////
|
|
@@ -643,6 +640,29 @@ uint16_t max_display_update_time = 0;
|
643
|
640
|
lcd_goto_previous_menu();
|
644
|
641
|
}
|
645
|
642
|
|
|
643
|
+ /**
|
|
644
|
+ * Scrolling for menus and other line-based screens
|
|
645
|
+ */
|
|
646
|
+ int8_t encoderLine, screen_items;
|
|
647
|
+ void scroll_screen(const uint8_t limit, const bool is_menu) {
|
|
648
|
+ if (encoderPosition > 0x8000) encoderPosition = 0;
|
|
649
|
+ if (first_page) {
|
|
650
|
+ encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
|
|
651
|
+ screen_changed = false;
|
|
652
|
+ }
|
|
653
|
+ if (screen_items > 0 && encoderLine >= screen_items - limit) {
|
|
654
|
+ encoderLine = max(0, screen_items - limit);
|
|
655
|
+ encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM);
|
|
656
|
+ }
|
|
657
|
+ if (is_menu) {
|
|
658
|
+ NOMORE(encoderTopLine, encoderLine);
|
|
659
|
+ if (encoderLine >= encoderTopLine + menu_bottom)
|
|
660
|
+ encoderTopLine = encoderLine - menu_bottom + 1;
|
|
661
|
+ }
|
|
662
|
+ else
|
|
663
|
+ encoderTopLine = encoderLine;
|
|
664
|
+ }
|
|
665
|
+
|
646
|
666
|
#endif // ULTIPANEL
|
647
|
667
|
|
648
|
668
|
/**
|
|
@@ -785,10 +805,7 @@ void kill_screen(const char* lcd_msg) {
|
785
|
805
|
|
786
|
806
|
void lcd_quick_feedback(const bool clear_buttons) {
|
787
|
807
|
lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
|
788
|
|
-
|
789
|
|
- if (clear_buttons)
|
790
|
|
- buttons = 0;
|
791
|
|
-
|
|
808
|
+ if (clear_buttons) buttons = 0;
|
792
|
809
|
next_button_update_ms = millis() + 500;
|
793
|
810
|
|
794
|
811
|
// Buzz and wait. The delay is needed for buttons to settle!
|
|
@@ -3232,7 +3249,6 @@ void kill_screen(const char* lcd_msg) {
|
3232
|
3249
|
#endif
|
3233
|
3250
|
|
3234
|
3251
|
#if HAS_LCD_CONTRAST
|
3235
|
|
- // please don't remove the "(int16_t*)" - it's needed for the VIKI2 display --- see PR #9132 before changing it
|
3236
|
3252
|
MENU_ITEM_EDIT_CALLBACK(int3, MSG_CONTRAST, &lcd_contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, lcd_callback_set_contrast, true);
|
3237
|
3253
|
#endif
|
3238
|
3254
|
#if ENABLED(FWRETRACT)
|
|
@@ -5193,11 +5209,12 @@ void lcd_update() {
|
5193
|
5209
|
if (do_u8g_loop) {
|
5194
|
5210
|
if (!drawing_screen) { // If not already drawing pages
|
5195
|
5211
|
u8g.firstPage(); // Start the first page
|
5196
|
|
- drawing_screen = 1; // Flag as drawing pages
|
|
5212
|
+ drawing_screen = first_page = true; // Flag as drawing pages
|
5197
|
5213
|
}
|
5198
|
5214
|
lcd_setFont(FONT_MENU); // Setup font for every page draw
|
5199
|
5215
|
u8g.setColorIndex(1); // And reset the color
|
5200
|
5216
|
CURRENTSCREEN(); // Draw and process the current screen
|
|
5217
|
+ first_page = false;
|
5201
|
5218
|
|
5202
|
5219
|
// The screen handler can clear drawing_screen for an action that changes the screen.
|
5203
|
5220
|
// 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; }
|
5380
|
5397
|
#if BUTTON_EXISTS(EN1)
|
5381
|
5398
|
if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
|
5382
|
5399
|
#endif
|
|
5400
|
+
|
5383
|
5401
|
#if BUTTON_EXISTS(EN2)
|
5384
|
5402
|
if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
|
5385
|
5403
|
#endif
|
|
5404
|
+
|
5386
|
5405
|
#if BUTTON_EXISTS(ENC)
|
5387
|
5406
|
if (BUTTON_PRESSED(ENC)) newbutton |= EN_C;
|
5388
|
5407
|
#endif
|