|
@@ -262,7 +262,7 @@ static void lcd_status_screen();
|
262
|
262
|
uint8_t currentMenuViewOffset; /* scroll offset in the current menu */
|
263
|
263
|
millis_t next_button_update_ms;
|
264
|
264
|
uint8_t lastEncoderBits;
|
265
|
|
- uint32_t encoderPosition;
|
|
265
|
+ uint32_t encoderPosition, nextEncoderPosition;
|
266
|
266
|
#if PIN_EXISTS(SD_DETECT)
|
267
|
267
|
uint8_t lcd_sd_status;
|
268
|
268
|
#endif
|
|
@@ -277,6 +277,7 @@ typedef struct {
|
277
|
277
|
} menuPosition;
|
278
|
278
|
|
279
|
279
|
menuFunc_t currentMenu = lcd_status_screen; // pointer to the currently active menu handler
|
|
280
|
+menuFunc_t nextMenu = NULL; // the next menu handler to activate
|
280
|
281
|
|
281
|
282
|
menuPosition menu_history[10];
|
282
|
283
|
uint8_t menu_history_depth = 0;
|
|
@@ -311,21 +312,16 @@ float raw_Ki, raw_Kd;
|
311
|
312
|
* Remembers the previous position
|
312
|
313
|
*/
|
313
|
314
|
static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const uint32_t encoder = 0) {
|
314
|
|
- if (currentMenu != menu) {
|
315
|
|
- currentMenu = menu;
|
316
|
|
- lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
|
|
315
|
+ if (currentMenu != menu && nextMenu != menu) {
|
|
316
|
+ nextMenu = menu;
|
|
317
|
+ nextEncoderPosition = encoder;
|
317
|
318
|
#if ENABLED(NEWPANEL)
|
318
|
|
- encoderPosition = encoder;
|
319
|
319
|
if (feedback) lcd_quick_feedback();
|
320
|
320
|
#endif
|
321
|
321
|
if (menu == lcd_status_screen) {
|
322
|
322
|
defer_return_to_status = false;
|
323
|
323
|
menu_history_depth = 0;
|
324
|
324
|
}
|
325
|
|
- #if ENABLED(LCD_PROGRESS_BAR)
|
326
|
|
- // For LCD_PROGRESS_BAR re-initialize custom characters
|
327
|
|
- lcd_set_custom_characters(menu == lcd_status_screen);
|
328
|
|
- #endif
|
329
|
325
|
}
|
330
|
326
|
}
|
331
|
327
|
|
|
@@ -918,13 +914,6 @@ void lcd_cooldown() {
|
918
|
914
|
|
919
|
915
|
static void _lcd_level_bed_done() {
|
920
|
916
|
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_DONE));
|
921
|
|
- lcdDrawUpdate =
|
922
|
|
- #if ENABLED(DOGLCD)
|
923
|
|
- LCDVIEW_CALL_REDRAW_NEXT
|
924
|
|
- #else
|
925
|
|
- LCDVIEW_CALL_NO_REDRAW
|
926
|
|
- #endif
|
927
|
|
- ;
|
928
|
917
|
}
|
929
|
918
|
|
930
|
919
|
/**
|
|
@@ -940,13 +929,6 @@ void lcd_cooldown() {
|
940
|
929
|
NOLESS(current_position[Z_AXIS], 0);
|
941
|
930
|
NOMORE(current_position[Z_AXIS], MESH_HOME_SEARCH_Z * 2);
|
942
|
931
|
line_to_current(Z_AXIS);
|
943
|
|
- lcdDrawUpdate =
|
944
|
|
- #if ENABLED(DOGLCD)
|
945
|
|
- LCDVIEW_CALL_REDRAW_NEXT
|
946
|
|
- #else
|
947
|
|
- LCDVIEW_REDRAW_NOW
|
948
|
|
- #endif
|
949
|
|
- ;
|
950
|
932
|
}
|
951
|
933
|
encoderPosition = 0;
|
952
|
934
|
|
|
@@ -1002,14 +984,6 @@ void lcd_cooldown() {
|
1002
|
984
|
sprintf_P(msg, PSTR("%i / %u"), (int)(_lcd_level_bed_position + 1), (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS));
|
1003
|
985
|
lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
|
1004
|
986
|
}
|
1005
|
|
-
|
1006
|
|
- lcdDrawUpdate =
|
1007
|
|
- #if ENABLED(DOGLCD)
|
1008
|
|
- LCDVIEW_CALL_REDRAW_NEXT
|
1009
|
|
- #else
|
1010
|
|
- LCDVIEW_CALL_NO_REDRAW
|
1011
|
|
- #endif
|
1012
|
|
- ;
|
1013
|
987
|
}
|
1014
|
988
|
|
1015
|
989
|
/**
|
|
@@ -1047,15 +1021,9 @@ void lcd_cooldown() {
|
1047
|
1021
|
*/
|
1048
|
1022
|
static void _lcd_level_bed_homing() {
|
1049
|
1023
|
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
|
1050
|
|
- lcdDrawUpdate =
|
1051
|
|
- #if ENABLED(DOGLCD)
|
1052
|
|
- LCDVIEW_CALL_REDRAW_NEXT
|
1053
|
|
- #else
|
1054
|
|
- LCDVIEW_CALL_NO_REDRAW
|
1055
|
|
- #endif
|
1056
|
|
- ;
|
1057
|
1024
|
if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
|
1058
|
1025
|
lcd_goto_menu(_lcd_level_bed_homing_done);
|
|
1026
|
+ lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW; // counts as a draw flag during graphical loop
|
1059
|
1027
|
}
|
1060
|
1028
|
|
1061
|
1029
|
/**
|
|
@@ -1197,7 +1165,6 @@ static void _lcd_move(const char* name, AxisEnum axis, float min, float max) {
|
1197
|
1165
|
if (min_software_endstops) NOLESS(current_position[axis], min);
|
1198
|
1166
|
if (max_software_endstops) NOMORE(current_position[axis], max);
|
1199
|
1167
|
line_to_current(axis);
|
1200
|
|
- lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
1201
|
1168
|
}
|
1202
|
1169
|
encoderPosition = 0;
|
1203
|
1170
|
if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
|
|
@@ -1226,7 +1193,6 @@ static void lcd_move_e(
|
1226
|
1193
|
if (encoderPosition && movesplanned() <= 3) {
|
1227
|
1194
|
current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
|
1228
|
1195
|
line_to_current(E_AXIS);
|
1229
|
|
- lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
1230
|
1196
|
}
|
1231
|
1197
|
encoderPosition = 0;
|
1232
|
1198
|
if (lcdDrawUpdate) {
|
|
@@ -1717,7 +1683,6 @@ static void lcd_control_volumetric_menu() {
|
1717
|
1683
|
lcd_contrast &= 0x3F;
|
1718
|
1684
|
#endif
|
1719
|
1685
|
encoderPosition = 0;
|
1720
|
|
- lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
1721
|
1686
|
u8g.setContrast(lcd_contrast);
|
1722
|
1687
|
}
|
1723
|
1688
|
if (lcdDrawUpdate) {
|
|
@@ -1868,12 +1833,12 @@ static void lcd_control_volumetric_menu() {
|
1868
|
1833
|
} \
|
1869
|
1834
|
static void menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) { \
|
1870
|
1835
|
_menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
|
1871
|
|
- currentMenu = menu_edit_ ## _name; \
|
|
1836
|
+ lcd_goto_menu(menu_edit_ ## _name); \
|
1872
|
1837
|
}\
|
1873
|
1838
|
static void menu_action_setting_edit_callback_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue, menuFunc_t callback) { \
|
1874
|
1839
|
_menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
|
1875
|
|
- currentMenu = menu_edit_callback_ ## _name; \
|
1876
|
1840
|
callbackFunc = callback; \
|
|
1841
|
+ lcd_goto_menu(menu_edit_callback_ ## _name); \
|
1877
|
1842
|
}
|
1878
|
1843
|
menu_edit_type(int, int3, itostr3, 1);
|
1879
|
1844
|
menu_edit_type(float, float3, ftostr3, 1);
|
|
@@ -1939,7 +1904,6 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01);
|
1939
|
1904
|
#endif
|
1940
|
1905
|
|
1941
|
1906
|
void lcd_quick_feedback() {
|
1942
|
|
- lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
|
1943
|
1907
|
next_button_update_ms = millis() + 500;
|
1944
|
1908
|
|
1945
|
1909
|
#if ENABLED(LCD_USE_I2C_BUZZER)
|
|
@@ -2106,7 +2070,7 @@ bool lcd_blink() {
|
2106
|
2070
|
* - Act on RepRap World keypad input
|
2107
|
2071
|
* - Update the encoder position
|
2108
|
2072
|
* - Apply acceleration to the encoder position
|
2109
|
|
- * - Set lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT on controller events
|
|
2073
|
+ * - Set lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NOW on controller events
|
2110
|
2074
|
* - Reset the Info Screen timeout if there's any input
|
2111
|
2075
|
* - Update status indicators, if any
|
2112
|
2076
|
*
|
|
@@ -2114,17 +2078,21 @@ bool lcd_blink() {
|
2114
|
2078
|
* - Call the handler only if lcdDrawUpdate != LCDVIEW_NONE
|
2115
|
2079
|
* - Before calling the handler, LCDVIEW_CALL_NO_REDRAW => LCDVIEW_NONE
|
2116
|
2080
|
* - Call the menu handler. Menu handlers should do the following:
|
2117
|
|
- * - If a value changes, set lcdDrawUpdate to LCDVIEW_REDRAW_NOW
|
|
2081
|
+ * - If a value changes, set lcdDrawUpdate to LCDVIEW_REDRAW_NOW and draw the value
|
|
2082
|
+ * (Encoder events automatically set lcdDrawUpdate for you.)
|
2118
|
2083
|
* - if (lcdDrawUpdate) { redraw }
|
2119
|
2084
|
* - Before exiting the handler set lcdDrawUpdate to:
|
2120
|
|
- * - LCDVIEW_REDRAW_NOW or LCDVIEW_NONE for no callbacks until the next controller event.
|
2121
|
2085
|
* - LCDVIEW_CLEAR_CALL_REDRAW to clear screen and set LCDVIEW_CALL_REDRAW_NEXT.
|
2122
|
|
- * - LCDVIEW_CALL_NO_REDRAW for a callback with no forced redraw on the next loop.
|
2123
|
|
- * - NOTE: For some displays, the menu handler may be called 2 or more times per loop.
|
|
2086
|
+ * - LCDVIEW_REDRAW_NOW or LCDVIEW_NONE to keep drawingm but only in this loop.
|
|
2087
|
+ * - LCDVIEW_REDRAW_NEXT to keep drawing and draw on the next loop also.
|
|
2088
|
+ * - LCDVIEW_CALL_NO_REDRAW to keep drawing (or start drawing) with no redraw on the next loop.
|
|
2089
|
+ * - NOTE: For graphical displays menu handlers may be called 2 or more times per loop,
|
|
2090
|
+ * so don't change lcdDrawUpdate without considering this.
|
2124
|
2091
|
*
|
2125
|
2092
|
* After the menu handler callback runs (or not):
|
|
2093
|
+ * - Set lcdDrawUpdate to nextLcdDrawUpdate (usually unchanged)
|
2126
|
2094
|
* - Clear the LCD if lcdDrawUpdate == LCDVIEW_CLEAR_CALL_REDRAW
|
2127
|
|
- * - Update lcdDrawUpdate for the next loop (i.e., move one state down, usually)
|
|
2095
|
+ * - Transition lcdDrawUpdate to the next state
|
2128
|
2096
|
*
|
2129
|
2097
|
* No worries. This function is only called from the main thread.
|
2130
|
2098
|
*/
|
|
@@ -2282,6 +2250,18 @@ void lcd_update() {
|
2282
|
2250
|
|
2283
|
2251
|
#endif // ULTIPANEL
|
2284
|
2252
|
|
|
2253
|
+ // If a new menu was set, update the pointer, set to clear & redraw
|
|
2254
|
+ if (nextMenu) {
|
|
2255
|
+ currentMenu = nextMenu;
|
|
2256
|
+ encoderPosition = nextEncoderPosition;
|
|
2257
|
+ nextMenu = NULL;
|
|
2258
|
+ lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
|
|
2259
|
+ #if ENABLED(LCD_PROGRESS_BAR)
|
|
2260
|
+ // For LCD_PROGRESS_BAR re-initialize custom characters
|
|
2261
|
+ lcd_set_custom_characters(currentMenu == lcd_status_screen);
|
|
2262
|
+ #endif
|
|
2263
|
+ }
|
|
2264
|
+
|
2285
|
2265
|
switch (lcdDrawUpdate) {
|
2286
|
2266
|
case LCDVIEW_CLEAR_CALL_REDRAW:
|
2287
|
2267
|
lcd_implementation_clear();
|