|
@@ -214,18 +214,18 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
214
|
214
|
* START_SCREEN generates the init code for a screen function
|
215
|
215
|
*
|
216
|
216
|
* encoderLine is the position based on the encoder
|
217
|
|
- * currentMenuViewOffset is the top menu line to display
|
|
217
|
+ * encoderTopLine is the top menu line to display
|
218
|
218
|
* _drawLineNr is the index of the LCD line (0-3)
|
219
|
219
|
* _lineNr is the menu item to draw and process
|
220
|
220
|
* _menuItemNr is the index of each MENU_ITEM
|
221
|
221
|
*/
|
222
|
|
- #define _START_SCREEN(CODE) do { \
|
|
222
|
+ #define _START_SCREEN(CODE) \
|
223
|
223
|
ENCODER_DIRECTION_MENUS(); \
|
224
|
224
|
encoderRateMultiplierEnabled = false; \
|
225
|
225
|
if (encoderPosition > 0x8000) encoderPosition = 0; \
|
226
|
226
|
uint8_t encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; \
|
227
|
|
- NOMORE(currentMenuViewOffset, encoderLine); \
|
228
|
|
- uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
|
|
227
|
+ NOMORE(encoderTopLine, encoderLine); \
|
|
228
|
+ uint8_t _lineNr = encoderTopLine, _menuItemNr; \
|
229
|
229
|
CODE; \
|
230
|
230
|
for (uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
|
231
|
231
|
_menuItemNr = 0;
|
|
@@ -292,19 +292,25 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
292
|
292
|
_menuItemNr++
|
293
|
293
|
|
294
|
294
|
#define END_SCREEN() \
|
295
|
|
- if (encoderLine >= _menuItemNr) { \
|
296
|
|
- encoderPosition = _menuItemNr * (ENCODER_STEPS_PER_MENU_ITEM) - 1; \
|
297
|
|
- encoderLine = _menuItemNr - 1; \
|
298
|
|
- } \
|
299
|
|
- if (encoderLine >= currentMenuViewOffset + LCD_HEIGHT) { \
|
300
|
|
- currentMenuViewOffset = encoderLine - (LCD_HEIGHT) + 1; \
|
301
|
|
- lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
|
302
|
|
- _lineNr = currentMenuViewOffset - 1; \
|
303
|
|
- _drawLineNr = -1; \
|
304
|
|
- } \
|
305
|
|
- } } while(0)
|
|
295
|
+ } \
|
|
296
|
+ NOMORE(encoderLine, _menuItemNr - LCD_HEIGHT); \
|
|
297
|
+ NOLESS(encoderLine, 0); \
|
|
298
|
+ encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM); \
|
|
299
|
+ if (encoderTopLine != encoderLine) { \
|
|
300
|
+ encoderTopLine = encoderLine; \
|
|
301
|
+ lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
|
|
302
|
+ }
|
306
|
303
|
|
307
|
|
- #define END_MENU() END_SCREEN()
|
|
304
|
+ #define END_MENU() \
|
|
305
|
+ } \
|
|
306
|
+ if (encoderLine >= _menuItemNr) { \
|
|
307
|
+ encoderLine = _menuItemNr - 1; \
|
|
308
|
+ encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM); \
|
|
309
|
+ } \
|
|
310
|
+ if (encoderLine >= encoderTopLine + LCD_HEIGHT) { \
|
|
311
|
+ encoderTopLine = encoderLine - (LCD_HEIGHT - 1); \
|
|
312
|
+ lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
|
|
313
|
+ }
|
308
|
314
|
|
309
|
315
|
#if ENABLED(ENCODER_RATE_MULTIPLIER)
|
310
|
316
|
|
|
@@ -342,7 +348,7 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
342
|
348
|
#if ENABLED(LCD_HAS_SLOW_BUTTONS)
|
343
|
349
|
volatile uint8_t slow_buttons; // Bits of the pressed buttons.
|
344
|
350
|
#endif
|
345
|
|
- uint8_t currentMenuViewOffset; /* scroll offset in the current menu */
|
|
351
|
+ int8_t encoderTopLine; /* scroll offset in the current menu */
|
346
|
352
|
millis_t next_button_update_ms;
|
347
|
353
|
uint8_t lastEncoderBits;
|
348
|
354
|
uint32_t encoderPosition;
|
|
@@ -1888,13 +1894,13 @@ void kill_screen(const char* lcd_msg) {
|
1888
|
1894
|
#if !PIN_EXISTS(SD_DETECT)
|
1889
|
1895
|
static void lcd_sd_refresh() {
|
1890
|
1896
|
card.initsd();
|
1891
|
|
- currentMenuViewOffset = 0;
|
|
1897
|
+ encoderTopLine = 0;
|
1892
|
1898
|
}
|
1893
|
1899
|
#endif
|
1894
|
1900
|
|
1895
|
1901
|
static void lcd_sd_updir() {
|
1896
|
1902
|
card.updir();
|
1897
|
|
- currentMenuViewOffset = 0;
|
|
1903
|
+ encoderTopLine = 0;
|
1898
|
1904
|
}
|
1899
|
1905
|
|
1900
|
1906
|
/**
|