@@ -257,8 +257,8 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
257
257
if (encoderLine >= encoderTopLine + LCD_HEIGHT) { \
258
258
encoderTopLine = encoderLine - (LCD_HEIGHT - 1 ); \
259
259
} \
260
- bool wasClicked = LCD_CLICKED; \
261
- bool _skipStatic = true ; \
260
+ bool wasClicked = lcd_clicked, \
261
+ _skipStatic = true ; \
262
262
SCREEN_OR_MENU_LOOP ()
263
263
264
264
/* *
@@ -381,9 +381,8 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
381
381
menuPosition screen_history[10 ];
382
382
uint8_t screen_history_depth = 0 ;
383
383
384
- bool ignore_click = false ;
385
- bool wait_for_unclick;
386
- bool defer_return_to_status = false ;
384
+ // LCD and menu clicks
385
+ bool lcd_clicked, ignore_click, wait_for_unclick, defer_return_to_status;
387
386
388
387
// Variables used when editing values.
389
388
const char * editLabel;
@@ -437,7 +436,7 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
437
436
438
437
void lcd_ignore_click (bool b) {
439
438
ignore_click = b;
440
- wait_for_unclick = false ;
439
+ lcd_clicked = wait_for_unclick = false ;
441
440
}
442
441
443
442
#endif // ULTIPANEL
@@ -493,23 +492,23 @@ static void lcd_status_screen() {
493
492
494
493
#if ENABLED(ULTIPANEL)
495
494
496
- bool current_click = LCD_CLICKED;
495
+ lcd_clicked = LCD_CLICKED;
497
496
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
- }
497
+ // Might be waiting for unclick
498
+ if (wait_for_unclick) {
499
+ if (!lcd_clicked) ignore_click = wait_for_unclick = false ;
500
+ lcd_clicked = false ;
510
501
}
511
502
512
- if (current_click) {
503
+ // If ignoring the click or using it for something else, swallow it
504
+ if (lcd_clicked && (ignore_click || wait_for_user)) {
505
+ lcd_quick_feedback ();
506
+ wait_for_unclick = true ;
507
+ wait_for_user = false ;
508
+ lcd_clicked = false ;
509
+ }
510
+
511
+ if (lcd_clicked) {
513
512
#if ENABLED(FILAMENT_LCD_DISPLAY)
514
513
previous_lcd_status_ms = millis (); // get status message to show up for a while
515
514
#endif
@@ -676,7 +675,7 @@ void kill_screen(const char* lcd_msg) {
676
675
long babysteps_done = 0 ;
677
676
678
677
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 ; }
678
+ if (lcd_clicked ) { defer_return_to_status = false ; return lcd_goto_previous_menu (true ); }
680
679
ENCODER_DIRECTION_NORMAL ();
681
680
if (encoderPosition) {
682
681
int babystep_increment = (int32_t )encoderPosition * BABYSTEP_MULTIPLICATOR;
@@ -1092,7 +1091,7 @@ void kill_screen(const char* lcd_msg) {
1092
1091
}
1093
1092
1094
1093
static bool debounce_click = false ;
1095
- if (LCD_CLICKED ) {
1094
+ if (lcd_clicked ) {
1096
1095
if (!debounce_click) {
1097
1096
debounce_click = true ; // ignore multiple "clicks" in a row
1098
1097
mbl.set_zigzag_z (_lcd_level_bed_position++, current_position[Z_AXIS]);
@@ -1171,7 +1170,7 @@ void kill_screen(const char* lcd_msg) {
1171
1170
*/
1172
1171
static void _lcd_level_bed_homing_done () {
1173
1172
if (lcdDrawUpdate) lcd_implementation_drawedit (PSTR (MSG_LEVEL_BED_WAITING));
1174
- if (LCD_CLICKED ) {
1173
+ if (lcd_clicked ) {
1175
1174
_lcd_level_bed_position = 0 ;
1176
1175
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
1177
1176
#if Z_HOME_DIR > 0
@@ -1385,7 +1384,7 @@ void kill_screen(const char* lcd_msg) {
1385
1384
*/
1386
1385
1387
1386
static void _lcd_move_xyz (const char * name, AxisEnum axis) {
1388
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
1387
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
1389
1388
ENCODER_DIRECTION_NORMAL ();
1390
1389
if (encoderPosition) {
1391
1390
refresh_cmd_timeout ();
@@ -1425,7 +1424,7 @@ void kill_screen(const char* lcd_msg) {
1425
1424
int8_t eindex=-1
1426
1425
#endif
1427
1426
) {
1428
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
1427
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
1429
1428
ENCODER_DIRECTION_NORMAL ();
1430
1429
if (encoderPosition) {
1431
1430
current_position[E_AXIS] += float ((int32_t )encoderPosition) * move_menu_scale;
@@ -1924,7 +1923,7 @@ void kill_screen(const char* lcd_msg) {
1924
1923
*/
1925
1924
#if HAS_LCD_CONTRAST
1926
1925
static void lcd_set_contrast () {
1927
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
1926
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
1928
1927
ENCODER_DIRECTION_NORMAL ();
1929
1928
if (encoderPosition) {
1930
1929
set_lcd_contrast (lcd_contrast + encoderPosition);
@@ -1991,7 +1990,7 @@ void kill_screen(const char* lcd_msg) {
1991
1990
*/
1992
1991
void lcd_sdcard_menu () {
1993
1992
ENCODER_DIRECTION_MENUS ();
1994
- if (lcdDrawUpdate == 0 && LCD_CLICKED == 0 ) return ; // nothing to do (so don't thrash the SD card)
1993
+ if (! lcdDrawUpdate && !lcd_clicked ) return ; // nothing to do (so don't thrash the SD card)
1995
1994
uint16_t fileCnt = card.getnrfilenames ();
1996
1995
START_MENU ();
1997
1996
MENU_BACK (MSG_MAIN);
@@ -2037,7 +2036,7 @@ void kill_screen(const char* lcd_msg) {
2037
2036
*
2038
2037
*/
2039
2038
static void lcd_info_stats_menu () {
2040
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
2039
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
2041
2040
2042
2041
char buffer[21 ];
2043
2042
printStatistics stats = print_job_timer.getStats ();
@@ -2071,7 +2070,7 @@ void kill_screen(const char* lcd_msg) {
2071
2070
*
2072
2071
*/
2073
2072
static void lcd_info_thermistors_menu () {
2074
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
2073
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
2075
2074
START_SCREEN ();
2076
2075
#define THERMISTOR_ID TEMP_SENSOR_0
2077
2076
#include " thermistornames.h"
@@ -2123,7 +2122,7 @@ void kill_screen(const char* lcd_msg) {
2123
2122
*
2124
2123
*/
2125
2124
static void lcd_info_board_menu () {
2126
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
2125
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
2127
2126
START_SCREEN ();
2128
2127
STATIC_ITEM (BOARD_NAME, true , true ); // MyPrinterController
2129
2128
STATIC_ITEM (MSG_INFO_BAUDRATE " : " STRINGIFY (BAUDRATE), true ); // Baud: 250000
@@ -2144,7 +2143,7 @@ void kill_screen(const char* lcd_msg) {
2144
2143
*
2145
2144
*/
2146
2145
static void lcd_info_printer_menu () {
2147
- if (LCD_CLICKED ) { lcd_goto_previous_menu (true ); return ; }
2146
+ if (lcd_clicked ) { return lcd_goto_previous_menu (true ); }
2148
2147
START_SCREEN ();
2149
2148
STATIC_ITEM (MSG_MARLIN, true , true ); // Marlin
2150
2149
STATIC_ITEM (SHORT_BUILD_VERSION, true ); // x.x.x-Branch
@@ -2334,7 +2333,7 @@ void kill_screen(const char* lcd_msg) {
2334
2333
#define menu_edit_type (_type, _name, _strFunc, scale ) \
2335
2334
bool _menu_edit_ ## _name () { \
2336
2335
ENCODER_DIRECTION_NORMAL (); \
2337
- bool isClicked = LCD_CLICKED ; \
2336
+ bool isClicked = lcd_clicked ; \
2338
2337
if ((int32_t )encoderPosition < 0 ) encoderPosition = 0 ; \
2339
2338
if ((int32_t )encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
2340
2339
if (lcdDrawUpdate) \
@@ -2695,7 +2694,7 @@ void lcd_update() {
2695
2694
#endif // REPRAPWORLD_KEYPAD
2696
2695
2697
2696
bool encoderPastThreshold = (abs (encoderDiff) >= ENCODER_PULSES_PER_STEP);
2698
- if (encoderPastThreshold || LCD_CLICKED ) {
2697
+ if (encoderPastThreshold || lcd_clicked ) {
2699
2698
if (encoderPastThreshold) {
2700
2699
int32_t encoderMultiplier = 1 ;
2701
2700
@@ -3024,8 +3023,6 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
3024
3023
#endif
3025
3024
}
3026
3025
3027
- bool lcd_clicked () { return LCD_CLICKED; }
3028
-
3029
3026
#endif // ULTIPANEL
3030
3027
3031
3028
#endif // ULTRA_LCD
0 commit comments