mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-02-18 07:10:58 +00:00
🚸 Ignore first click on asleep LCD
This commit is contained in:
parent
5de9fc556f
commit
282f90c1b3
5 changed files with 13 additions and 5 deletions
|
@ -390,8 +390,9 @@ void MarlinUI::clear_for_drawing() {
|
|||
}
|
||||
|
||||
#if HAS_DISPLAY_SLEEP
|
||||
static bool asleep = false;
|
||||
bool MarlinUI::display_is_asleep() { return asleep; }
|
||||
void MarlinUI::sleep_display(const bool sleep/*=true*/) {
|
||||
static bool asleep = false;
|
||||
if (asleep != sleep) {
|
||||
sleep ? u8g.sleepOn() : u8g.sleepOff();
|
||||
asleep = sleep;
|
||||
|
|
|
@ -957,11 +957,13 @@ void MarlinUI::init() {
|
|||
// If the action button is pressed...
|
||||
static bool wait_for_unclick; // = false
|
||||
|
||||
// Set lcd_clicked for most clicks.
|
||||
// Ignore the click when clearing wait_for_user or waking the screen.
|
||||
auto do_click = [&]{
|
||||
wait_for_unclick = true; // - Set debounce flag to ignore continuous clicks
|
||||
lcd_clicked = !wait_for_user; // - Keep the click if not waiting for a user-click
|
||||
wait_for_user = false; // - Any click clears wait for user
|
||||
quick_feedback(); // - Always make a click sound
|
||||
wait_for_unclick = true;
|
||||
lcd_clicked = !wait_for_user && !display_is_asleep();
|
||||
wait_for_user = false;
|
||||
quick_feedback();
|
||||
};
|
||||
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
|
|
|
@ -305,6 +305,7 @@ public:
|
|||
#endif
|
||||
|
||||
// Sleep or wake the display (e.g., by turning the backlight off/on).
|
||||
static bool display_is_asleep() IF_DISABLED(HAS_DISPLAY_SLEEP, { return false; });
|
||||
static void sleep_display(const bool=true) IF_DISABLED(HAS_DISPLAY_SLEEP, {});
|
||||
static void wake_display() { sleep_display(false); }
|
||||
|
||||
|
|
|
@ -313,6 +313,7 @@ bool Touch::get_point(int16_t * const x, int16_t * const y) {
|
|||
next_sleep_ms = ui.sleep_timeout_minutes ? millis() + MIN_TO_MS(ui.sleep_timeout_minutes) : 0;
|
||||
}
|
||||
|
||||
bool MarlinUI::display_is_asleep() { return touch.isSleeping(); }
|
||||
void MarlinUI::sleep_display(const bool sleep/*=true*/) {
|
||||
if (!sleep) touch.wakeUp();
|
||||
}
|
||||
|
|
|
@ -153,6 +153,9 @@ uint8_t TouchButtons::read_buttons() {
|
|||
next_sleep_ms = ui.sleep_timeout_minutes ? millis() + MIN_TO_MS(ui.sleep_timeout_minutes) : 0;
|
||||
}
|
||||
|
||||
bool MarlinUI::display_is_asleep() {
|
||||
return touchBt.isSleeping();
|
||||
}
|
||||
void MarlinUI::sleep_display(const bool sleep/*=true*/) {
|
||||
if (!sleep) touchBt.wakeUp();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue