|
@@ -243,7 +243,6 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
243
|
243
|
*
|
244
|
244
|
* START_MENU Opening code for a screen with menu items.
|
245
|
245
|
* Scroll as-needed to keep the selected line in view.
|
246
|
|
- * 'wasClicked' indicates the controller was clicked.
|
247
|
246
|
*/
|
248
|
247
|
#define START_SCREEN() \
|
249
|
248
|
START_SCREEN_OR_MENU(LCD_HEIGHT); \
|
|
@@ -257,7 +256,6 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
257
|
256
|
if (encoderLine >= encoderTopLine + LCD_HEIGHT) { \
|
258
|
257
|
encoderTopLine = encoderLine - (LCD_HEIGHT - 1); \
|
259
|
258
|
} \
|
260
|
|
- bool wasClicked = LCD_CLICKED; \
|
261
|
259
|
bool _skipStatic = true; \
|
262
|
260
|
SCREEN_OR_MENU_LOOP()
|
263
|
261
|
|
|
@@ -288,8 +286,7 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
288
|
286
|
if (_menuLineNr == _thisItemNr) { \
|
289
|
287
|
if (lcdDrawUpdate) \
|
290
|
288
|
lcd_implementation_drawmenu_ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PSTR(LABEL), ## __VA_ARGS__); \
|
291
|
|
- if (wasClicked && encoderLine == _thisItemNr) { \
|
292
|
|
- lcd_quick_feedback()
|
|
289
|
+ if (lcd_clicked && encoderLine == _thisItemNr) {
|
293
|
290
|
|
294
|
291
|
#define _MENU_ITEM_PART_2(TYPE, ...) \
|
295
|
292
|
menu_action_ ## TYPE(__VA_ARGS__); \
|
|
@@ -381,9 +378,8 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
381
|
378
|
menuPosition screen_history[10];
|
382
|
379
|
uint8_t screen_history_depth = 0;
|
383
|
380
|
|
384
|
|
- bool ignore_click = false;
|
385
|
|
- bool wait_for_unclick;
|
386
|
|
- bool defer_return_to_status = false;
|
|
381
|
+ // LCD and menu clicks
|
|
382
|
+ bool lcd_clicked, wait_for_unclick, defer_return_to_status;
|
387
|
383
|
|
388
|
384
|
// Variables used when editing values.
|
389
|
385
|
const char* editLabel;
|
|
@@ -392,9 +388,9 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
392
|
388
|
screenFunc_t callbackFunc; // call this after editing
|
393
|
389
|
|
394
|
390
|
/**
|
395
|
|
- * General function to go directly to a menu
|
|
391
|
+ * General function to go directly to a screen
|
396
|
392
|
*/
|
397
|
|
- static void lcd_goto_screen(screenFunc_t screen, const bool feedback = false, const uint32_t encoder = 0) {
|
|
393
|
+ static void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder = 0) {
|
398
|
394
|
if (currentScreen != screen) {
|
399
|
395
|
currentScreen = screen;
|
400
|
396
|
encoderPosition = encoder;
|
|
@@ -402,7 +398,6 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
402
|
398
|
defer_return_to_status = false;
|
403
|
399
|
screen_history_depth = 0;
|
404
|
400
|
}
|
405
|
|
- if (feedback) lcd_quick_feedback();
|
406
|
401
|
lcd_implementation_clear();
|
407
|
402
|
#if ENABLED(LCD_PROGRESS_BAR)
|
408
|
403
|
// For LCD_PROGRESS_BAR re-initialize custom characters
|
|
@@ -427,7 +422,6 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
427
|
422
|
--screen_history_depth;
|
428
|
423
|
lcd_goto_screen(
|
429
|
424
|
screen_history[screen_history_depth].menu_function,
|
430
|
|
- feedback,
|
431
|
425
|
screen_history[screen_history_depth].encoder_position
|
432
|
426
|
);
|
433
|
427
|
}
|
|
@@ -435,11 +429,6 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
435
|
429
|
lcd_return_to_status();
|
436
|
430
|
}
|
437
|
431
|
|
438
|
|
- void lcd_ignore_click(bool b) {
|
439
|
|
- ignore_click = b;
|
440
|
|
- wait_for_unclick = false;
|
441
|
|
- }
|
442
|
|
-
|
443
|
432
|
#endif // ULTIPANEL
|
444
|
433
|
|
445
|
434
|
/**
|
|
@@ -493,23 +482,7 @@ static void lcd_status_screen() {
|
493
|
482
|
|
494
|
483
|
#if ENABLED(ULTIPANEL)
|
495
|
484
|
|
496
|
|
- bool current_click = LCD_CLICKED;
|
497
|
|
-
|
498
|
|
- if (ignore_click) {
|
499
|
|
- if (wait_for_unclick) {
|
500
|
|
- if (!current_click)
|
501
|
|
- ignore_click = wait_for_unclick = false;
|
502
|
|
- else
|
503
|
|
- current_click = false;
|
504
|
|
- }
|
505
|
|
- else if (current_click) {
|
506
|
|
- lcd_quick_feedback();
|
507
|
|
- wait_for_unclick = true;
|
508
|
|
- current_click = false;
|
509
|
|
- }
|
510
|
|
- }
|
511
|
|
-
|
512
|
|
- if (current_click) {
|
|
485
|
+ if (lcd_clicked) {
|
513
|
486
|
#if ENABLED(FILAMENT_LCD_DISPLAY)
|
514
|
487
|
previous_lcd_status_ms = millis(); // get status message to show up for a while
|
515
|
488
|
#endif
|
|
@@ -518,7 +491,7 @@ static void lcd_status_screen() {
|
518
|
491
|
false
|
519
|
492
|
#endif
|
520
|
493
|
);
|
521
|
|
- lcd_goto_screen(lcd_main_menu, true);
|
|
494
|
+ lcd_goto_screen(lcd_main_menu);
|
522
|
495
|
}
|
523
|
496
|
|
524
|
497
|
#if ENABLED(ULTIPANEL_FEEDMULTIPLY)
|
|
@@ -676,7 +649,7 @@ void kill_screen(const char* lcd_msg) {
|
676
|
649
|
long babysteps_done = 0;
|
677
|
650
|
|
678
|
651
|
static void _lcd_babystep(const AxisEnum axis, const char* msg) {
|
679
|
|
- if (LCD_CLICKED) { defer_return_to_status = false; lcd_goto_previous_menu(true); return; }
|
|
652
|
+ if (lcd_clicked) { defer_return_to_status = false; return lcd_goto_previous_menu(true); }
|
680
|
653
|
ENCODER_DIRECTION_NORMAL();
|
681
|
654
|
if (encoderPosition) {
|
682
|
655
|
int babystep_increment = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
|
|
@@ -1092,12 +1065,12 @@ void kill_screen(const char* lcd_msg) {
|
1092
|
1065
|
}
|
1093
|
1066
|
|
1094
|
1067
|
static bool debounce_click = false;
|
1095
|
|
- if (LCD_CLICKED) {
|
|
1068
|
+ if (lcd_clicked) {
|
1096
|
1069
|
if (!debounce_click) {
|
1097
|
1070
|
debounce_click = true; // ignore multiple "clicks" in a row
|
1098
|
1071
|
mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
|
1099
|
1072
|
if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
|
1100
|
|
- lcd_goto_screen(_lcd_level_bed_done, true);
|
|
1073
|
+ lcd_goto_screen(_lcd_level_bed_done);
|
1101
|
1074
|
|
1102
|
1075
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + Z_HOMING_HEIGHT;
|
1103
|
1076
|
line_to_current(Z_AXIS);
|
|
@@ -1113,7 +1086,7 @@ void kill_screen(const char* lcd_msg) {
|
1113
|
1086
|
#endif
|
1114
|
1087
|
}
|
1115
|
1088
|
else {
|
1116
|
|
- lcd_goto_screen(_lcd_level_goto_next_point, true);
|
|
1089
|
+ lcd_goto_screen(_lcd_level_goto_next_point);
|
1117
|
1090
|
}
|
1118
|
1091
|
}
|
1119
|
1092
|
}
|
|
@@ -1171,7 +1144,7 @@ void kill_screen(const char* lcd_msg) {
|
1171
|
1144
|
*/
|
1172
|
1145
|
static void _lcd_level_bed_homing_done() {
|
1173
|
1146
|
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
|
1174
|
|
- if (LCD_CLICKED) {
|
|
1147
|
+ if (lcd_clicked) {
|
1175
|
1148
|
_lcd_level_bed_position = 0;
|
1176
|
1149
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
|
1177
|
1150
|
#if Z_HOME_DIR > 0
|
|
@@ -1179,7 +1152,7 @@ void kill_screen(const char* lcd_msg) {
|
1179
|
1152
|
#endif
|
1180
|
1153
|
;
|
1181
|
1154
|
planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1182
|
|
- lcd_goto_screen(_lcd_level_goto_next_point, true);
|
|
1155
|
+ lcd_goto_screen(_lcd_level_goto_next_point);
|
1183
|
1156
|
}
|
1184
|
1157
|
}
|
1185
|
1158
|
|
|
@@ -1385,7 +1358,7 @@ void kill_screen(const char* lcd_msg) {
|
1385
|
1358
|
*/
|
1386
|
1359
|
|
1387
|
1360
|
static void _lcd_move_xyz(const char* name, AxisEnum axis) {
|
1388
|
|
- if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
|
|
1361
|
+ if (lcd_clicked) { return lcd_goto_previous_menu(true); }
|
1389
|
1362
|
ENCODER_DIRECTION_NORMAL();
|
1390
|
1363
|
if (encoderPosition) {
|
1391
|
1364
|
refresh_cmd_timeout();
|
|
@@ -1425,7 +1398,7 @@ void kill_screen(const char* lcd_msg) {
|
1425
|
1398
|
int8_t eindex=-1
|
1426
|
1399
|
#endif
|
1427
|
1400
|
) {
|
1428
|
|
- if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
|
|
1401
|
+ if (lcd_clicked) { return lcd_goto_previous_menu(true); }
|
1429
|
1402
|
ENCODER_DIRECTION_NORMAL();
|
1430
|
1403
|
if (encoderPosition) {
|
1431
|
1404
|
current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
|
|
@@ -1924,7 +1897,7 @@ void kill_screen(const char* lcd_msg) {
|
1924
|
1897
|
*/
|
1925
|
1898
|
#if HAS_LCD_CONTRAST
|
1926
|
1899
|
static void lcd_set_contrast() {
|
1927
|
|
- if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
|
|
1900
|
+ if (lcd_clicked) { return lcd_goto_previous_menu(true); }
|
1928
|
1901
|
ENCODER_DIRECTION_NORMAL();
|
1929
|
1902
|
if (encoderPosition) {
|
1930
|
1903
|
set_lcd_contrast(lcd_contrast + encoderPosition);
|
|
@@ -1991,7 +1964,7 @@ void kill_screen(const char* lcd_msg) {
|
1991
|
1964
|
*/
|
1992
|
1965
|
void lcd_sdcard_menu() {
|
1993
|
1966
|
ENCODER_DIRECTION_MENUS();
|
1994
|
|
- if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) return; // nothing to do (so don't thrash the SD card)
|
|
1967
|
+ if (!lcdDrawUpdate && !lcd_clicked) return; // nothing to do (so don't thrash the SD card)
|
1995
|
1968
|
uint16_t fileCnt = card.getnrfilenames();
|
1996
|
1969
|
START_MENU();
|
1997
|
1970
|
MENU_BACK(MSG_MAIN);
|
|
@@ -2037,7 +2010,7 @@ void kill_screen(const char* lcd_msg) {
|
2037
|
2010
|
*
|
2038
|
2011
|
*/
|
2039
|
2012
|
static void lcd_info_stats_menu() {
|
2040
|
|
- if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
|
|
2013
|
+ if (lcd_clicked) { return lcd_goto_previous_menu(true); }
|
2041
|
2014
|
|
2042
|
2015
|
char buffer[21];
|
2043
|
2016
|
printStatistics stats = print_job_timer.getStats();
|
|
@@ -2071,7 +2044,7 @@ void kill_screen(const char* lcd_msg) {
|
2071
|
2044
|
*
|
2072
|
2045
|
*/
|
2073
|
2046
|
static void lcd_info_thermistors_menu() {
|
2074
|
|
- if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
|
|
2047
|
+ if (lcd_clicked) { return lcd_goto_previous_menu(true); }
|
2075
|
2048
|
START_SCREEN();
|
2076
|
2049
|
#define THERMISTOR_ID TEMP_SENSOR_0
|
2077
|
2050
|
#include "thermistornames.h"
|
|
@@ -2123,7 +2096,7 @@ void kill_screen(const char* lcd_msg) {
|
2123
|
2096
|
*
|
2124
|
2097
|
*/
|
2125
|
2098
|
static void lcd_info_board_menu() {
|
2126
|
|
- if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
|
|
2099
|
+ if (lcd_clicked) { return lcd_goto_previous_menu(true); }
|
2127
|
2100
|
START_SCREEN();
|
2128
|
2101
|
STATIC_ITEM(BOARD_NAME, true, true); // MyPrinterController
|
2129
|
2102
|
STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
|
|
@@ -2144,7 +2117,7 @@ void kill_screen(const char* lcd_msg) {
|
2144
|
2117
|
*
|
2145
|
2118
|
*/
|
2146
|
2119
|
static void lcd_info_printer_menu() {
|
2147
|
|
- if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
|
|
2120
|
+ if (lcd_clicked) { return lcd_goto_previous_menu(true); }
|
2148
|
2121
|
START_SCREEN();
|
2149
|
2122
|
STATIC_ITEM(MSG_MARLIN, true, true); // Marlin
|
2150
|
2123
|
STATIC_ITEM(SHORT_BUILD_VERSION, true); // x.x.x-Branch
|
|
@@ -2334,16 +2307,15 @@ void kill_screen(const char* lcd_msg) {
|
2334
|
2307
|
#define menu_edit_type(_type, _name, _strFunc, scale) \
|
2335
|
2308
|
bool _menu_edit_ ## _name () { \
|
2336
|
2309
|
ENCODER_DIRECTION_NORMAL(); \
|
2337
|
|
- bool isClicked = LCD_CLICKED; \
|
2338
|
2310
|
if ((int32_t)encoderPosition < 0) encoderPosition = 0; \
|
2339
|
2311
|
if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
|
2340
|
2312
|
if (lcdDrawUpdate) \
|
2341
|
2313
|
lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
|
2342
|
|
- if (isClicked) { \
|
|
2314
|
+ if (lcd_clicked) { \
|
2343
|
2315
|
*((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \
|
2344
|
2316
|
lcd_goto_previous_menu(true); \
|
2345
|
2317
|
} \
|
2346
|
|
- return isClicked; \
|
|
2318
|
+ return lcd_clicked; \
|
2347
|
2319
|
} \
|
2348
|
2320
|
void menu_edit_ ## _name () { _menu_edit_ ## _name(); } \
|
2349
|
2321
|
void menu_edit_callback_ ## _name () { if (_menu_edit_ ## _name ()) (*callbackFunc)(); } \
|
|
@@ -2614,9 +2586,20 @@ void lcd_update() {
|
2614
|
2586
|
#if ENABLED(ULTIPANEL)
|
2615
|
2587
|
static millis_t return_to_status_ms = 0;
|
2616
|
2588
|
manage_manual_move();
|
2617
|
|
- #endif
|
2618
|
2589
|
|
2619
|
|
- lcd_buttons_update();
|
|
2590
|
+ lcd_buttons_update();
|
|
2591
|
+
|
|
2592
|
+ // If the action button is pressed...
|
|
2593
|
+ if (LCD_CLICKED) {
|
|
2594
|
+ if (!wait_for_unclick) { // If not waiting for a debounce release:
|
|
2595
|
+ wait_for_unclick = true; // Set debounce flag to ignore continous clicks
|
|
2596
|
+ lcd_clicked = !wait_for_user; // Keep the click if not waiting for a user-click
|
|
2597
|
+ wait_for_user = false; // Any click clears wait for user
|
|
2598
|
+ lcd_quick_feedback(); // Always make a click sound
|
|
2599
|
+ }
|
|
2600
|
+ }
|
|
2601
|
+ else wait_for_unclick = false;
|
|
2602
|
+ #endif
|
2620
|
2603
|
|
2621
|
2604
|
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
|
2622
|
2605
|
|
|
@@ -2691,7 +2674,7 @@ void lcd_update() {
|
2691
|
2674
|
#endif // REPRAPWORLD_KEYPAD
|
2692
|
2675
|
|
2693
|
2676
|
bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
|
2694
|
|
- if (encoderPastThreshold || LCD_CLICKED) {
|
|
2677
|
+ if (encoderPastThreshold || lcd_clicked) {
|
2695
|
2678
|
if (encoderPastThreshold) {
|
2696
|
2679
|
int32_t encoderMultiplier = 1;
|
2697
|
2680
|
|
|
@@ -2757,7 +2740,7 @@ void lcd_update() {
|
2757
|
2740
|
}
|
2758
|
2741
|
|
2759
|
2742
|
#if ENABLED(ULTIPANEL)
|
2760
|
|
- #define CURRENTSCREEN() (*currentScreen)()
|
|
2743
|
+ #define CURRENTSCREEN() (*currentScreen)(), lcd_clicked = false
|
2761
|
2744
|
#else
|
2762
|
2745
|
#define CURRENTSCREEN() lcd_status_screen()
|
2763
|
2746
|
#endif
|
|
@@ -3020,8 +3003,6 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
|
3020
|
3003
|
#endif
|
3021
|
3004
|
}
|
3022
|
3005
|
|
3023
|
|
- bool lcd_clicked() { return LCD_CLICKED; }
|
3024
|
|
-
|
3025
|
3006
|
#endif // ULTIPANEL
|
3026
|
3007
|
|
3027
|
3008
|
#endif // ULTRA_LCD
|