|
@@ -249,7 +249,7 @@ static void lcd_status_screen();
|
249
|
249
|
#endif //!ENCODER_RATE_MULTIPLIER
|
250
|
250
|
#define END_MENU() \
|
251
|
251
|
if (encoderLine >= _menuItemNr) { encoderPosition = _menuItemNr * (ENCODER_STEPS_PER_MENU_ITEM) - 1; encoderLine = _menuItemNr - 1; }\
|
252
|
|
- if (encoderLine >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = encoderLine - (LCD_HEIGHT) + 1; lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_REDRAW; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
|
|
252
|
+ if (encoderLine >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = encoderLine - (LCD_HEIGHT) + 1; lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
|
253
|
253
|
} } while(0)
|
254
|
254
|
|
255
|
255
|
/** Used variables to keep track of the menu */
|
|
@@ -289,14 +289,15 @@ bool ignore_click = false;
|
289
|
289
|
bool wait_for_unclick;
|
290
|
290
|
bool defer_return_to_status = false;
|
291
|
291
|
|
292
|
|
-enum LCDHandlerAction {
|
293
|
|
- LCD_DRAW_UPDATE_NONE,
|
294
|
|
- LCD_DRAW_UPDATE_CALL_REDRAW,
|
295
|
|
- LCD_DRAW_UPDATE_CLEAR_CALL_REDRAW,
|
296
|
|
- LCD_DRAW_UPDATE_CALL_NO_REDRAW
|
|
292
|
+enum LCDViewAction {
|
|
293
|
+ LCDVIEW_NONE,
|
|
294
|
+ LCDVIEW_REDRAW_NOW,
|
|
295
|
+ LCDVIEW_CALL_REDRAW_NEXT,
|
|
296
|
+ LCDVIEW_CLEAR_CALL_REDRAW,
|
|
297
|
+ LCDVIEW_CALL_NO_REDRAW
|
297
|
298
|
};
|
298
|
299
|
|
299
|
|
-uint8_t lcdDrawUpdate = LCD_DRAW_UPDATE_CLEAR_CALL_REDRAW; // Set 1 or 2 when the LCD needs to draw, decrements after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial)
|
|
300
|
+uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to draw, decrements after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial)
|
300
|
301
|
|
301
|
302
|
// Variables used when editing values.
|
302
|
303
|
const char* editLabel;
|
|
@@ -314,7 +315,7 @@ float raw_Ki, raw_Kd;
|
314
|
315
|
static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const uint32_t encoder = 0) {
|
315
|
316
|
if (currentMenu != menu) {
|
316
|
317
|
currentMenu = menu;
|
317
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CLEAR_CALL_REDRAW;
|
|
318
|
+ lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
|
318
|
319
|
#if ENABLED(NEWPANEL)
|
319
|
320
|
encoderPosition = encoder;
|
320
|
321
|
if (feedback) lcd_quick_feedback();
|
|
@@ -556,7 +557,7 @@ void lcd_set_home_offsets() {
|
556
|
557
|
if (encoderPosition) {
|
557
|
558
|
int distance = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
|
558
|
559
|
encoderPosition = 0;
|
559
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_REDRAW;
|
|
560
|
+ lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
560
|
561
|
#if ENABLED(COREXY) || ENABLED(COREXZ)
|
561
|
562
|
#if ENABLED(BABYSTEP_XY)
|
562
|
563
|
switch(axis) {
|
|
@@ -894,7 +895,7 @@ void lcd_cooldown() {
|
894
|
895
|
// if they call st_synchronize or plan_buffer_line. So
|
895
|
896
|
// while waiting for a move we just ignore new input.
|
896
|
897
|
if (mbl_wait_for_move) {
|
897
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_NO_REDRAW;
|
|
898
|
+ lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
898
|
899
|
return;
|
899
|
900
|
}
|
900
|
901
|
|
|
@@ -908,7 +909,7 @@ void lcd_cooldown() {
|
908
|
909
|
if (max_software_endstops) NOMORE(current_position[Z_AXIS], Z_MAX_POS);
|
909
|
910
|
encoderPosition = 0;
|
910
|
911
|
line_to_current(Z_AXIS);
|
911
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_NO_REDRAW;
|
|
912
|
+ lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
912
|
913
|
}
|
913
|
914
|
|
914
|
915
|
// Update on first display, then only on updates to Z position
|
|
@@ -919,7 +920,7 @@ void lcd_cooldown() {
|
919
|
920
|
|
920
|
921
|
// We want subsequent calls, but don't force redraw
|
921
|
922
|
// Set here so it can be overridden by lcd_return_to_status below
|
922
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_NO_REDRAW;
|
|
923
|
+ lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
923
|
924
|
|
924
|
925
|
// Click sets the current Z and moves to the next position
|
925
|
926
|
static bool debounce_click = false;
|
|
@@ -970,7 +971,7 @@ void lcd_cooldown() {
|
970
|
971
|
|
971
|
972
|
static void _lcd_level_bed_homing_done() {
|
972
|
973
|
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING), NULL);
|
973
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_NO_REDRAW;
|
|
974
|
+ lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
974
|
975
|
if (LCD_CLICKED) {
|
975
|
976
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
976
|
977
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
@@ -987,7 +988,7 @@ void lcd_cooldown() {
|
987
|
988
|
*/
|
988
|
989
|
static void _lcd_level_bed_homing() {
|
989
|
990
|
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
|
990
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_NO_REDRAW;
|
|
991
|
+ lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
991
|
992
|
if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])
|
992
|
993
|
lcd_goto_menu(_lcd_level_bed_homing_done);
|
993
|
994
|
}
|
|
@@ -1131,7 +1132,7 @@ static void _lcd_move(const char* name, AxisEnum axis, float min, float max) {
|
1131
|
1132
|
if (max_software_endstops) NOMORE(current_position[axis], max);
|
1132
|
1133
|
encoderPosition = 0;
|
1133
|
1134
|
line_to_current(axis);
|
1134
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_REDRAW;
|
|
1135
|
+ lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
1135
|
1136
|
}
|
1136
|
1137
|
if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
|
1137
|
1138
|
if (LCD_CLICKED) lcd_goto_previous_menu(true);
|
|
@@ -1160,7 +1161,7 @@ static void lcd_move_e(
|
1160
|
1161
|
current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
|
1161
|
1162
|
encoderPosition = 0;
|
1162
|
1163
|
line_to_current(E_AXIS);
|
1163
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_REDRAW;
|
|
1164
|
+ lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
1164
|
1165
|
}
|
1165
|
1166
|
if (lcdDrawUpdate) {
|
1166
|
1167
|
PGM_P pos_label;
|
|
@@ -1650,7 +1651,7 @@ static void lcd_control_volumetric_menu() {
|
1650
|
1651
|
lcd_contrast &= 0x3F;
|
1651
|
1652
|
#endif
|
1652
|
1653
|
encoderPosition = 0;
|
1653
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_REDRAW;
|
|
1654
|
+ lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
1654
|
1655
|
u8g.setContrast(lcd_contrast);
|
1655
|
1656
|
}
|
1656
|
1657
|
if (lcdDrawUpdate) {
|
|
@@ -1791,7 +1792,7 @@ static void lcd_control_volumetric_menu() {
|
1791
|
1792
|
static void _menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) { \
|
1792
|
1793
|
lcd_save_previous_menu(); \
|
1793
|
1794
|
\
|
1794
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CLEAR_CALL_REDRAW; \
|
|
1795
|
+ lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; \
|
1795
|
1796
|
\
|
1796
|
1797
|
editLabel = pstr; \
|
1797
|
1798
|
editValue = ptr; \
|
|
@@ -1872,7 +1873,7 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01);
|
1872
|
1873
|
#endif
|
1873
|
1874
|
|
1874
|
1875
|
void lcd_quick_feedback() {
|
1875
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CLEAR_CALL_REDRAW;
|
|
1876
|
+ lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
|
1876
|
1877
|
next_button_update_ms = millis() + 500;
|
1877
|
1878
|
|
1878
|
1879
|
#if ENABLED(LCD_USE_I2C_BUZZER)
|
|
@@ -2039,24 +2040,24 @@ bool lcd_blink() {
|
2039
|
2040
|
* - Act on RepRap World keypad input
|
2040
|
2041
|
* - Update the encoder position
|
2041
|
2042
|
* - Apply acceleration to the encoder position
|
2042
|
|
- * - Set lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_REDRAW on controller events
|
|
2043
|
+ * - Set lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT on controller events
|
2043
|
2044
|
* - Reset the Info Screen timeout if there's any input
|
2044
|
2045
|
* - Update status indicators, if any
|
2045
|
2046
|
*
|
2046
|
2047
|
* Run the current LCD menu handler callback function:
|
2047
|
|
- * - Call the handler only if lcdDrawUpdate != LCD_DRAW_UPDATE_NONE
|
2048
|
|
- * - Before calling the handler, LCD_DRAW_UPDATE_CALL_NO_REDRAW => LCD_DRAW_UPDATE_NONE
|
|
2048
|
+ * - Call the handler only if lcdDrawUpdate != LCDVIEW_NONE
|
|
2049
|
+ * - Before calling the handler, LCDVIEW_CALL_NO_REDRAW => LCDVIEW_NONE
|
2049
|
2050
|
* - Call the menu handler. Menu handlers should do the following:
|
2050
|
|
- * - If a value changes, set lcdDrawUpdate to LCD_DRAW_UPDATE_CALL_REDRAW
|
|
2051
|
+ * - If a value changes, set lcdDrawUpdate to LCDVIEW_REDRAW_NOW
|
2051
|
2052
|
* - if (lcdDrawUpdate) { redraw }
|
2052
|
2053
|
* - Before exiting the handler set lcdDrawUpdate to:
|
2053
|
|
- * - LCD_DRAW_UPDATE_CALL_REDRAW or LCD_DRAW_UPDATE_NONE for no callbacks until the next controller event.
|
2054
|
|
- * - LCD_DRAW_UPDATE_CLEAR_CALL_REDRAW to clear screen, LCD_DRAW_UPDATE_CALL_REDRAW on the next loop.
|
2055
|
|
- * - LCD_DRAW_UPDATE_CALL_NO_REDRAW for a callback with no forced redraw on the next loop.
|
|
2054
|
+ * - LCDVIEW_REDRAW_NOW or LCDVIEW_NONE for no callbacks until the next controller event.
|
|
2055
|
+ * - LCDVIEW_CLEAR_CALL_REDRAW to clear screen and set LCDVIEW_CALL_REDRAW_NEXT.
|
|
2056
|
+ * - LCDVIEW_CALL_NO_REDRAW for a callback with no forced redraw on the next loop.
|
2056
|
2057
|
* - NOTE: For some displays, the menu handler may be called 2 or more times per loop.
|
2057
|
2058
|
*
|
2058
|
2059
|
* After the menu handler callback runs (or not):
|
2059
|
|
- * - Clear the LCD if lcdDrawUpdate == LCD_DRAW_UPDATE_CLEAR_CALL_REDRAW
|
|
2060
|
+ * - Clear the LCD if lcdDrawUpdate == LCDVIEW_CLEAR_CALL_REDRAW
|
2060
|
2061
|
* - Update lcdDrawUpdate for the next loop (i.e., move one state down, usually)
|
2061
|
2062
|
*
|
2062
|
2063
|
* No worries. This function is only called from the main thread.
|
|
@@ -2072,7 +2073,7 @@ void lcd_update() {
|
2072
|
2073
|
|
2073
|
2074
|
bool sd_status = IS_SD_INSERTED;
|
2074
|
2075
|
if (sd_status != lcd_sd_status && lcd_detected()) {
|
2075
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CLEAR_CALL_REDRAW;
|
|
2076
|
+ lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
|
2076
|
2077
|
lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
|
2077
|
2078
|
#if ENABLED(LCD_PROGRESS_BAR)
|
2078
|
2079
|
currentMenu == lcd_status_screen
|
|
@@ -2096,6 +2097,12 @@ void lcd_update() {
|
2096
|
2097
|
millis_t ms = millis();
|
2097
|
2098
|
if (ELAPSED(ms, next_lcd_update_ms)) {
|
2098
|
2099
|
|
|
2100
|
+ next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
|
|
2101
|
+
|
|
2102
|
+ #if ENABLED(LCD_HAS_STATUS_INDICATORS)
|
|
2103
|
+ lcd_implementation_update_indicators();
|
|
2104
|
+ #endif
|
|
2105
|
+
|
2099
|
2106
|
#if ENABLED(LCD_HAS_SLOW_BUTTONS)
|
2100
|
2107
|
slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
|
2101
|
2108
|
#endif
|
|
@@ -2160,23 +2167,27 @@ void lcd_update() {
|
2160
|
2167
|
encoderDiff = 0;
|
2161
|
2168
|
}
|
2162
|
2169
|
return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
|
2163
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_REDRAW;
|
|
2170
|
+ lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
2164
|
2171
|
}
|
2165
|
2172
|
#endif //ULTIPANEL
|
2166
|
2173
|
|
2167
|
|
- if (currentMenu == lcd_status_screen) {
|
2168
|
|
- if (!lcd_status_update_delay) {
|
2169
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_REDRAW;
|
2170
|
|
- lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */
|
2171
|
|
- }
|
2172
|
|
- else {
|
2173
|
|
- lcd_status_update_delay--;
|
2174
|
|
- }
|
2175
|
|
- }
|
|
2174
|
+ // Simply redraw the Info Screen 10 times a second
|
|
2175
|
+ if (currentMenu == lcd_status_screen && !(++lcd_status_update_delay % 10))
|
|
2176
|
+ lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
2176
|
2177
|
|
2177
|
2178
|
if (lcdDrawUpdate) {
|
2178
|
2179
|
|
2179
|
|
- if (lcdDrawUpdate == LCD_DRAW_UPDATE_CALL_NO_REDRAW) lcdDrawUpdate = LCD_DRAW_UPDATE_NONE;
|
|
2180
|
+ switch (lcdDrawUpdate) {
|
|
2181
|
+ case LCDVIEW_CALL_NO_REDRAW:
|
|
2182
|
+ lcdDrawUpdate = LCDVIEW_NONE;
|
|
2183
|
+ break;
|
|
2184
|
+ case LCDVIEW_CLEAR_CALL_REDRAW: // set by handlers, then altered after (rarely occurs here)
|
|
2185
|
+ case LCDVIEW_CALL_REDRAW_NEXT: // set by handlers, then altered after (never occurs here?)
|
|
2186
|
+ lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
|
2187
|
+ case LCDVIEW_REDRAW_NOW: // set above, or by a handler through LCDVIEW_CALL_REDRAW_NEXT
|
|
2188
|
+ case LCDVIEW_NONE:
|
|
2189
|
+ break;
|
|
2190
|
+ }
|
2180
|
2191
|
|
2181
|
2192
|
#if ENABLED(DOGLCD) // Changes due to different driver architecture of the DOGM display
|
2182
|
2193
|
bool blink = lcd_blink();
|
|
@@ -2194,37 +2205,29 @@ void lcd_update() {
|
2194
|
2205
|
#endif
|
2195
|
2206
|
}
|
2196
|
2207
|
|
2197
|
|
- #if ENABLED(LCD_HAS_STATUS_INDICATORS)
|
2198
|
|
- lcd_implementation_update_indicators();
|
2199
|
|
- #endif
|
2200
|
|
-
|
2201
|
2208
|
#if ENABLED(ULTIPANEL)
|
2202
|
2209
|
|
2203
|
2210
|
// Return to Status Screen after a timeout
|
2204
|
|
- if (defer_return_to_status)
|
|
2211
|
+ if (currentMenu == lcd_status_screen || defer_return_to_status)
|
2205
|
2212
|
return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
|
2206
|
|
- else if (currentMenu != lcd_status_screen && ms > return_to_status_ms) {
|
|
2213
|
+ else if (ELAPSED(ms, return_to_status_ms))
|
2207
|
2214
|
lcd_return_to_status();
|
2208
|
|
- }
|
2209
|
2215
|
|
2210
|
2216
|
#endif // ULTIPANEL
|
2211
|
2217
|
|
2212
|
2218
|
switch (lcdDrawUpdate) {
|
2213
|
|
- case LCD_DRAW_UPDATE_NONE:
|
2214
|
|
- // do nothing
|
2215
|
|
- case LCD_DRAW_UPDATE_CALL_NO_REDRAW:
|
2216
|
|
- // changes to LCD_DRAW_UPDATE_NONE before call
|
2217
|
|
- break;
|
2218
|
|
- case LCD_DRAW_UPDATE_CLEAR_CALL_REDRAW:
|
|
2219
|
+ case LCDVIEW_CLEAR_CALL_REDRAW:
|
2219
|
2220
|
lcd_implementation_clear();
|
2220
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CALL_REDRAW;
|
|
2221
|
+ case LCDVIEW_CALL_REDRAW_NEXT:
|
|
2222
|
+ lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
2221
|
2223
|
break;
|
2222
|
|
- case LCD_DRAW_UPDATE_CALL_REDRAW:
|
2223
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_NONE;
|
|
2224
|
+ case LCDVIEW_REDRAW_NOW:
|
|
2225
|
+ lcdDrawUpdate = LCDVIEW_NONE;
|
|
2226
|
+ break;
|
|
2227
|
+ case LCDVIEW_NONE:
|
2224
|
2228
|
break;
|
2225
|
2229
|
}
|
2226
|
2230
|
|
2227
|
|
- next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
|
2228
|
2231
|
}
|
2229
|
2232
|
}
|
2230
|
2233
|
|
|
@@ -2244,7 +2247,7 @@ void lcd_finishstatus(bool persist=false) {
|
2244
|
2247
|
expire_status_ms = persist ? 0 : progress_bar_ms + PROGRESS_MSG_EXPIRE;
|
2245
|
2248
|
#endif
|
2246
|
2249
|
#endif
|
2247
|
|
- lcdDrawUpdate = LCD_DRAW_UPDATE_CLEAR_CALL_REDRAW;
|
|
2250
|
+ lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
|
2248
|
2251
|
|
2249
|
2252
|
#if ENABLED(FILAMENT_LCD_DISPLAY)
|
2250
|
2253
|
previous_lcd_status_ms = millis(); //get status message to show up for a while
|