Skip to content

Commit 282f90c

Browse files
committed
🚸 Ignore first click on asleep LCD
1 parent 5de9fc5 commit 282f90c

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

Marlin/src/lcd/dogm/marlinui_DOGM.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,9 @@ void MarlinUI::clear_for_drawing() {
390390
}
391391

392392
#if HAS_DISPLAY_SLEEP
393+
static bool asleep = false;
394+
bool MarlinUI::display_is_asleep() { return asleep; }
393395
void MarlinUI::sleep_display(const bool sleep/*=true*/) {
394-
static bool asleep = false;
395396
if (asleep != sleep) {
396397
sleep ? u8g.sleepOn() : u8g.sleepOff();
397398
asleep = sleep;

Marlin/src/lcd/marlinui.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -957,11 +957,13 @@ void MarlinUI::init() {
957957
// If the action button is pressed...
958958
static bool wait_for_unclick; // = false
959959

960+
// Set lcd_clicked for most clicks.
961+
// Ignore the click when clearing wait_for_user or waking the screen.
960962
auto do_click = [&]{
961-
wait_for_unclick = true; // - Set debounce flag to ignore continuous clicks
962-
lcd_clicked = !wait_for_user; // - Keep the click if not waiting for a user-click
963-
wait_for_user = false; // - Any click clears wait for user
964-
quick_feedback(); // - Always make a click sound
963+
wait_for_unclick = true;
964+
lcd_clicked = !wait_for_user && !display_is_asleep();
965+
wait_for_user = false;
966+
quick_feedback();
965967
};
966968

967969
#if HAS_TOUCH_BUTTONS

Marlin/src/lcd/marlinui.h

+1
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ class MarlinUI {
305305
#endif
306306

307307
// Sleep or wake the display (e.g., by turning the backlight off/on).
308+
static bool display_is_asleep() IF_DISABLED(HAS_DISPLAY_SLEEP, { return false; });
308309
static void sleep_display(const bool=true) IF_DISABLED(HAS_DISPLAY_SLEEP, {});
309310
static void wake_display() { sleep_display(false); }
310311

Marlin/src/lcd/tft/touch.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ bool Touch::get_point(int16_t * const x, int16_t * const y) {
313313
next_sleep_ms = ui.sleep_timeout_minutes ? millis() + MIN_TO_MS(ui.sleep_timeout_minutes) : 0;
314314
}
315315

316+
bool MarlinUI::display_is_asleep() { return touch.isSleeping(); }
316317
void MarlinUI::sleep_display(const bool sleep/*=true*/) {
317318
if (!sleep) touch.wakeUp();
318319
}

Marlin/src/lcd/touch/touch_buttons.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ uint8_t TouchButtons::read_buttons() {
153153
next_sleep_ms = ui.sleep_timeout_minutes ? millis() + MIN_TO_MS(ui.sleep_timeout_minutes) : 0;
154154
}
155155

156+
bool MarlinUI::display_is_asleep() {
157+
return touchBt.isSleeping();
158+
}
156159
void MarlinUI::sleep_display(const bool sleep/*=true*/) {
157160
if (!sleep) touchBt.wakeUp();
158161
}

0 commit comments

Comments
 (0)