|
@@ -267,7 +267,7 @@ static void lcd_status_screen();
|
267
|
267
|
uint8_t currentMenuViewOffset; /* scroll offset in the current menu */
|
268
|
268
|
millis_t next_button_update_ms;
|
269
|
269
|
uint8_t lastEncoderBits;
|
270
|
|
- uint32_t encoderPosition;
|
|
270
|
+ uint32_t encoderPosition, prevEncoderPosition;
|
271
|
271
|
#if PIN_EXISTS(SD_DETECT)
|
272
|
272
|
uint8_t lcd_sd_status;
|
273
|
273
|
#endif
|
|
@@ -279,16 +279,15 @@ millis_t next_lcd_update_ms;
|
279
|
279
|
uint8_t lcd_status_update_delay;
|
280
|
280
|
bool ignore_click = false;
|
281
|
281
|
bool wait_for_unclick;
|
|
282
|
+bool defer_return_to_status = false;
|
282
|
283
|
uint8_t lcdDrawUpdate = 2; /* Set to none-zero when the LCD needs to draw, decreased after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial) */
|
283
|
284
|
|
284
|
|
-//prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings.
|
285
|
|
-menuFunc_t prevMenu = NULL;
|
286
|
|
-uint16_t prevEncoderPosition;
|
287
|
|
-//Variables used when editing values.
|
|
285
|
+// Variables used when editing values.
|
288
|
286
|
const char* editLabel;
|
289
|
287
|
void* editValue;
|
290
|
288
|
int32_t minEditValue, maxEditValue;
|
291
|
|
-menuFunc_t callbackFunc;
|
|
289
|
+menuFunc_t prevMenu = NULL; // return here after editing (also prevEncoderPosition)
|
|
290
|
+menuFunc_t callbackFunc; // call this after editing
|
292
|
291
|
|
293
|
292
|
// place-holders for Ki and Kd edits
|
294
|
293
|
float raw_Ki, raw_Kd;
|
|
@@ -299,6 +298,7 @@ float raw_Ki, raw_Kd;
|
299
|
298
|
static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const uint32_t encoder = 0) {
|
300
|
299
|
if (currentMenu != menu) {
|
301
|
300
|
currentMenu = menu;
|
|
301
|
+ lcdDrawUpdate = 2;
|
302
|
302
|
#if ENABLED(NEWPANEL)
|
303
|
303
|
encoderPosition = encoder;
|
304
|
304
|
if (feedback) lcd_quick_feedback();
|
|
@@ -310,9 +310,20 @@ static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const ui
|
310
|
310
|
}
|
311
|
311
|
}
|
312
|
312
|
|
313
|
|
-inline void lcd_save_previous_menu() { prevMenu = currentMenu; prevEncoderPosition = encoderPosition; }
|
|
313
|
+inline void lcd_save_previous_menu() {
|
|
314
|
+ prevMenu = currentMenu;
|
|
315
|
+ #if ENABLED(ULTIPANEL)
|
|
316
|
+ prevEncoderPosition = encoderPosition;
|
|
317
|
+ #endif
|
|
318
|
+}
|
314
|
319
|
|
315
|
|
-static void lcd_goto_previous_menu() { lcd_goto_menu(prevMenu, true, prevEncoderPosition); }
|
|
320
|
+static void lcd_goto_previous_menu() {
|
|
321
|
+ lcd_goto_menu(prevMenu, true
|
|
322
|
+ #if ENABLED(ULTIPANEL)
|
|
323
|
+ , prevEncoderPosition
|
|
324
|
+ #endif
|
|
325
|
+ );
|
|
326
|
+}
|
316
|
327
|
|
317
|
328
|
/**
|
318
|
329
|
*
|
|
@@ -420,7 +431,10 @@ static void lcd_status_screen() {
|
420
|
431
|
|
421
|
432
|
#if ENABLED(ULTIPANEL)
|
422
|
433
|
|
423
|
|
-static void lcd_return_to_status() { lcd_goto_menu(lcd_status_screen); }
|
|
434
|
+static void lcd_return_to_status() {
|
|
435
|
+ defer_return_to_status = false;
|
|
436
|
+ lcd_goto_menu(lcd_status_screen);
|
|
437
|
+}
|
424
|
438
|
|
425
|
439
|
#if ENABLED(SDSUPPORT)
|
426
|
440
|
|
|
@@ -536,7 +550,7 @@ void lcd_set_home_offsets() {
|
536
|
550
|
babystepsTodo[axis] += distance;
|
537
|
551
|
#endif
|
538
|
552
|
}
|
539
|
|
- if (lcdDrawUpdate) lcd_implementation_drawedit(msg, "");
|
|
553
|
+ if (lcdDrawUpdate) lcd_implementation_drawedit(msg, NULL);
|
540
|
554
|
if (LCD_CLICKED) lcd_goto_previous_menu();
|
541
|
555
|
}
|
542
|
556
|
|
|
@@ -1140,7 +1154,7 @@ static void lcd_control_menu() {
|
1140
|
1154
|
_PIDTEMP_BASE_FUNCTIONS(eindex); \
|
1141
|
1155
|
void lcd_autotune_callback_E ## eindex() { _lcd_autotune(eindex); }
|
1142
|
1156
|
#else
|
1143
|
|
- #define _PIDTEMP_FUNCTIONS(eindex) _PIDTEMP_BASE_FUNCTIONS(eindex);
|
|
1157
|
+ #define _PIDTEMP_FUNCTIONS(eindex) _PIDTEMP_BASE_FUNCTIONS(eindex)
|
1144
|
1158
|
#endif
|
1145
|
1159
|
|
1146
|
1160
|
_PIDTEMP_FUNCTIONS(0);
|
|
@@ -1808,9 +1822,10 @@ int lcd_strlen_P(const char* s) {
|
1808
|
1822
|
bool lcd_blink() {
|
1809
|
1823
|
static uint8_t blink = 0;
|
1810
|
1824
|
static millis_t next_blink_ms = 0;
|
1811
|
|
- if (millis() >= next_blink_ms) {
|
|
1825
|
+ millis_t ms = millis();
|
|
1826
|
+ if (ms >= next_blink_ms) {
|
1812
|
1827
|
blink ^= 0xFF;
|
1813
|
|
- next_blink_ms = millis() + LCD_UPDATE_INTERVAL - 50;
|
|
1828
|
+ next_blink_ms = ms + 1000 - LCD_UPDATE_INTERVAL / 2;
|
1814
|
1829
|
}
|
1815
|
1830
|
return blink != 0;
|
1816
|
1831
|
}
|
|
@@ -1956,13 +1971,7 @@ void lcd_update() {
|
1956
|
1971
|
#if ENABLED(ULTIPANEL)
|
1957
|
1972
|
|
1958
|
1973
|
// Return to Status Screen after a timeout
|
1959
|
|
- if (currentMenu != lcd_status_screen &&
|
1960
|
|
- #if ENABLED(MANUAL_BED_LEVELING)
|
1961
|
|
- currentMenu != _lcd_level_bed &&
|
1962
|
|
- currentMenu != _lcd_level_bed_homing &&
|
1963
|
|
- #endif
|
1964
|
|
- millis() > return_to_status_ms
|
1965
|
|
- ) {
|
|
1974
|
+ if (!defer_return_to_status && currentMenu != lcd_status_screen && millis() > return_to_status_ms) {
|
1966
|
1975
|
lcd_return_to_status();
|
1967
|
1976
|
lcdDrawUpdate = 2;
|
1968
|
1977
|
}
|
|
@@ -2219,11 +2228,11 @@ char* ftostr43(const float& x) {
|
2219
|
2228
|
long xx = x * 1000;
|
2220
|
2229
|
char *conv_ptr = conv;
|
2221
|
2230
|
if (xx >= 0) {
|
2222
|
|
- *conv_ptr++ = ' ';
|
|
2231
|
+ conv_ptr++;
|
2223
|
2232
|
}
|
2224
|
2233
|
else {
|
2225
|
|
- conv[0] = '-';
|
2226
|
2234
|
xx = -xx;
|
|
2235
|
+ conv[0] = '-';
|
2227
|
2236
|
}
|
2228
|
2237
|
conv[1] = (xx / 1000) % 10 + '0';
|
2229
|
2238
|
conv[2] = '.';
|
|
@@ -2440,9 +2449,12 @@ char* ftostr52(const float& x) {
|
2440
|
2449
|
if (max_software_endstops) NOMORE(current_position[Z_AXIS], Z_MAX_POS);
|
2441
|
2450
|
encoderPosition = 0;
|
2442
|
2451
|
line_to_current(Z_AXIS);
|
2443
|
|
- lcdDrawUpdate = 2;
|
|
2452
|
+ lcdDrawUpdate = 1;
|
|
2453
|
+ }
|
|
2454
|
+ if (lcdDrawUpdate) {
|
|
2455
|
+ float v = current_position[Z_AXIS] - MESH_HOME_SEARCH_Z;
|
|
2456
|
+ lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43(v + (v < 0 ? -0.0001 : 0.0001)));
|
2444
|
2457
|
}
|
2445
|
|
- if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Z"), ftostr43(current_position[Z_AXIS]));
|
2446
|
2458
|
static bool debounce_click = false;
|
2447
|
2459
|
if (LCD_CLICKED) {
|
2448
|
2460
|
if (!debounce_click) {
|
|
@@ -2469,7 +2481,7 @@ char* ftostr52(const float& x) {
|
2469
|
2481
|
current_position[X_AXIS] = mbl.get_x(ix);
|
2470
|
2482
|
current_position[Y_AXIS] = mbl.get_y(iy);
|
2471
|
2483
|
line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS);
|
2472
|
|
- lcdDrawUpdate = 2;
|
|
2484
|
+ lcdDrawUpdate = 1;
|
2473
|
2485
|
}
|
2474
|
2486
|
}
|
2475
|
2487
|
}
|
|
@@ -2482,7 +2494,8 @@ char* ftostr52(const float& x) {
|
2482
|
2494
|
* MBL Move to mesh starting point
|
2483
|
2495
|
*/
|
2484
|
2496
|
static void _lcd_level_bed_homing() {
|
2485
|
|
- if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("XYZ"), MSG_LEVEL_BED_HOMING);
|
|
2497
|
+ if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
|
|
2498
|
+ lcdDrawUpdate = 1;
|
2486
|
2499
|
if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]) {
|
2487
|
2500
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
2488
|
2501
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
@@ -2492,17 +2505,16 @@ char* ftostr52(const float& x) {
|
2492
|
2505
|
_lcd_level_bed_position = 0;
|
2493
|
2506
|
lcd_goto_menu(_lcd_level_bed);
|
2494
|
2507
|
}
|
2495
|
|
- lcdDrawUpdate = 2;
|
2496
|
2508
|
}
|
2497
|
2509
|
|
2498
|
2510
|
/**
|
2499
|
2511
|
* MBL entry-point
|
2500
|
2512
|
*/
|
2501
|
2513
|
static void lcd_level_bed() {
|
|
2514
|
+ defer_return_to_status = true;
|
2502
|
2515
|
axis_known_position[X_AXIS] = axis_known_position[Y_AXIS] = axis_known_position[Z_AXIS] = false;
|
2503
|
2516
|
mbl.reset();
|
2504
|
2517
|
enqueue_and_echo_commands_P(PSTR("G28"));
|
2505
|
|
- lcdDrawUpdate = 2;
|
2506
|
2518
|
lcd_goto_menu(_lcd_level_bed_homing);
|
2507
|
2519
|
}
|
2508
|
2520
|
|