@@ -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;
@@ -435,11 +431,6 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
435
431
lcd_return_to_status ();
436
432
}
437
433
438
- void lcd_ignore_click (bool b) {
439
- ignore_click = b;
440
- wait_for_unclick = false ;
441
- }
442
-
443
434
#endif // ULTIPANEL
444
435
445
436
/* *
@@ -493,23 +484,7 @@ static void lcd_status_screen() {
493
484
494
485
#if ENABLED(ULTIPANEL)
495
486
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) {
487
+ if (lcd_clicked) {
513
488
#if ENABLED(FILAMENT_LCD_DISPLAY)
514
489
previous_lcd_status_ms = millis (); // get status message to show up for a while
515
490
#endif
@@ -676,7 +651,7 @@ void kill_screen(const char* lcd_msg) {
676
651
long babysteps_done = 0 ;
677
652
678
653
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 ; }
654
+ if (lcd_clicked ) { defer_return_to_status = false ; return lcd_goto_previous_menu (true ); }
680
655
ENCODER_DIRECTION_NORMAL ();
681
656
if (encoderPosition) {
682
657
int babystep_increment = (int32_t )encoderPosition * BABYSTEP_MULTIPLICATOR;
@@ -1092,7 +1067,7 @@ void kill_screen(const char* lcd_msg) {
1092
1067
}
1093
1068
1094
1069
static bool debounce_click = false ;
1095
- if (LCD_CLICKED ) {
1070
+ if (lcd_clicked ) {
1096
1071
if (!debounce_click) {
1097
1072
debounce_click = true ; // ignore multiple "clicks" in a row
1098
1073
mbl.set_zigzag_z (_lcd_level_bed_position++, current_position[Z_AXIS]);
@@ -1171,7 +1146,7 @@ void kill_screen(const char* lcd_msg) {
1171
1146
*/
1172
1147
static void _lcd_level_bed_homing_done () {
1173
1148
if (lcdDrawUpdate) lcd_implementation_drawedit (PSTR (MSG_LEVEL_BED_WAITING));
1174
- if (LCD_CLICKED ) {
1149
+ if (lcd_clicked ) {
1175
1150
_lcd_level_bed_position = 0 ;
1176
1151
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
1177
1152
#if Z_HOME_DIR > 0
@@ -1385,7 +1360,7 @@ void kill_screen(const char* lcd_msg) {
1385
1360
*/
1386
1361
1387
1362
static void _lcd_move_xyz (const char * name, AxisEnum axis) {
1388
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
1363
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
1389
1364
ENCODER_DIRECTION_NORMAL ();
1390
1365
if (encoderPosition) {
1391
1366
refresh_cmd_timeout ();
@@ -1425,7 +1400,7 @@ void kill_screen(const char* lcd_msg) {
1425
1400
int8_t eindex=-1
1426
1401
#endif
1427
1402
) {
1428
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
1403
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
1429
1404
ENCODER_DIRECTION_NORMAL ();
1430
1405
if (encoderPosition) {
1431
1406
current_position[E_AXIS] += float ((int32_t )encoderPosition) * move_menu_scale;
@@ -1924,7 +1899,7 @@ void kill_screen(const char* lcd_msg) {
1924
1899
*/
1925
1900
#if HAS_LCD_CONTRAST
1926
1901
static void lcd_set_contrast () {
1927
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
1902
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
1928
1903
ENCODER_DIRECTION_NORMAL ();
1929
1904
if (encoderPosition) {
1930
1905
set_lcd_contrast (lcd_contrast + encoderPosition);
@@ -1991,7 +1966,7 @@ void kill_screen(const char* lcd_msg) {
1991
1966
*/
1992
1967
void lcd_sdcard_menu () {
1993
1968
ENCODER_DIRECTION_MENUS ();
1994
- if (lcdDrawUpdate == 0 && LCD_CLICKED == 0 ) return ; // nothing to do (so don't thrash the SD card)
1969
+ if (! lcdDrawUpdate && !lcd_clicked ) return ; // nothing to do (so don't thrash the SD card)
1995
1970
uint16_t fileCnt = card.getnrfilenames ();
1996
1971
START_MENU ();
1997
1972
MENU_BACK (MSG_MAIN);
@@ -2037,7 +2012,7 @@ void kill_screen(const char* lcd_msg) {
2037
2012
*
2038
2013
*/
2039
2014
static void lcd_info_stats_menu () {
2040
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
2015
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
2041
2016
2042
2017
char buffer[21 ];
2043
2018
printStatistics stats = print_job_timer.getStats ();
@@ -2071,7 +2046,7 @@ void kill_screen(const char* lcd_msg) {
2071
2046
*
2072
2047
*/
2073
2048
static void lcd_info_thermistors_menu () {
2074
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
2049
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
2075
2050
START_SCREEN ();
2076
2051
#define THERMISTOR_ID TEMP_SENSOR_0
2077
2052
#include " thermistornames.h"
@@ -2123,7 +2098,7 @@ void kill_screen(const char* lcd_msg) {
2123
2098
*
2124
2099
*/
2125
2100
static void lcd_info_board_menu () {
2126
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
2101
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
2127
2102
START_SCREEN ();
2128
2103
STATIC_ITEM (BOARD_NAME, true , true ); // MyPrinterController
2129
2104
STATIC_ITEM (MSG_INFO_BAUDRATE " : " STRINGIFY (BAUDRATE), true ); // Baud: 250000
@@ -2144,7 +2119,7 @@ void kill_screen(const char* lcd_msg) {
2144
2119
*
2145
2120
*/
2146
2121
static void lcd_info_printer_menu () {
2147
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
2122
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
2148
2123
START_SCREEN ();
2149
2124
STATIC_ITEM (MSG_MARLIN, true , true ); // Marlin
2150
2125
STATIC_ITEM (SHORT_BUILD_VERSION, true ); // x.x.x-Branch
@@ -2334,16 +2309,15 @@ void kill_screen(const char* lcd_msg) {
2334
2309
#define menu_edit_type (_type, _name, _strFunc, scale ) \
2335
2310
bool _menu_edit_ ## _name () { \
2336
2311
ENCODER_DIRECTION_NORMAL (); \
2337
- bool isClicked = LCD_CLICKED; \
2338
2312
if ((int32_t )encoderPosition < 0 ) encoderPosition = 0 ; \
2339
2313
if ((int32_t )encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
2340
2314
if (lcdDrawUpdate) \
2341
2315
lcd_implementation_drawedit (editLabel, _strFunc (((_type)((int32_t )encoderPosition + minEditValue)) / scale)); \
2342
- if (isClicked ) { \
2316
+ if (lcd_clicked ) { \
2343
2317
*((_type*)editValue) = ((_type)((int32_t )encoderPosition + minEditValue)) / scale; \
2344
2318
lcd_goto_previous_menu (true ); \
2345
2319
} \
2346
- return isClicked ; \
2320
+ return lcd_clicked ; \
2347
2321
} \
2348
2322
void menu_edit_ ## _name () { _menu_edit_ ## _name (); } \
2349
2323
void menu_edit_callback_ ## _name () { if (_menu_edit_ ## _name ()) (*callbackFunc)(); } \
@@ -2622,6 +2596,17 @@ void lcd_update() {
2622
2596
2623
2597
lcd_buttons_update ();
2624
2598
2599
+ // If the action button is pressed...
2600
+ if (LCD_CLICKED) {
2601
+ if (!wait_for_unclick) { // If not waiting for a debounce release:
2602
+ wait_for_unclick = true ; // Set debounce flag to ignore continous clicks
2603
+ lcd_clicked = !wait_for_user; // Any click clears wait for user
2604
+ wait_for_user = false ; // Keep the click if not waiting for a user-click
2605
+ lcd_quick_feedback (); // Always make a click sound
2606
+ }
2607
+ }
2608
+ else if (wait_for_unclick) wait_for_unclick = false ;
2609
+
2625
2610
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
2626
2611
2627
2612
bool sd_status = IS_SD_INSERTED;
@@ -2695,7 +2680,7 @@ void lcd_update() {
2695
2680
#endif // REPRAPWORLD_KEYPAD
2696
2681
2697
2682
bool encoderPastThreshold = (abs (encoderDiff) >= ENCODER_PULSES_PER_STEP);
2698
- if (encoderPastThreshold || LCD_CLICKED ) {
2683
+ if (encoderPastThreshold || lcd_clicked ) {
2699
2684
if (encoderPastThreshold) {
2700
2685
int32_t encoderMultiplier = 1 ;
2701
2686
@@ -2781,6 +2766,9 @@ void lcd_update() {
2781
2766
#else
2782
2767
CURRENTSCREEN ();
2783
2768
#endif
2769
+
2770
+ // The previous click was used. Clear until the next one.
2771
+ lcd_clicked = false ;
2784
2772
}
2785
2773
2786
2774
#if ENABLED(ULTIPANEL)
@@ -3024,8 +3012,6 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
3024
3012
#endif
3025
3013
}
3026
3014
3027
- bool lcd_clicked () { return LCD_CLICKED; }
3028
-
3029
3015
#endif // ULTIPANEL
3030
3016
3031
3017
#endif // ULTRA_LCD
0 commit comments