From ae55135001f36abc772c119de2de4ec76e9b2a56 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Sat, 11 May 2024 15:28:08 -0500 Subject: [PATCH 1/4] Added auto shutoff --- Helios/Helios.cpp | 3 +++ Helios/HeliosConfig.h | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/Helios/Helios.cpp b/Helios/Helios.cpp index 732a19c6..807efb71 100644 --- a/Helios/Helios.cpp +++ b/Helios/Helios.cpp @@ -207,6 +207,9 @@ void Helios::set_mode_index(uint8_t mode_index) void Helios::handle_state() { + if (Time::getCurtime() > AUTO_SLEEP_TIME) { + enter_sleep(); + } // check for the force sleep button hold regardless of which state we're in if (Button::holdDuration() > FORCE_SLEEP_TIME) { // when released the device will just sleep diff --git a/Helios/HeliosConfig.h b/Helios/HeliosConfig.h index 73c7ed7c..86217c31 100644 --- a/Helios/HeliosConfig.h +++ b/Helios/HeliosConfig.h @@ -63,6 +63,12 @@ // sleep at any location in the menus #define FORCE_SLEEP_TIME 7000 +// Auto Sleep Time +// +// The duration in ms/ticks to hold the button to force the chip to +// sleep at any location in the menus +#define AUTO_SLEEP_TIME 1800000 + // Delete Color Time // // How long to hold button on a color to start the delete color flash From 93c6d298bca5daab039364f921c79476114247a5 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Sat, 11 May 2024 16:05:26 -0500 Subject: [PATCH 2/4] Added ESD button protection logic --- Helios/Helios.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Helios/Helios.cpp b/Helios/Helios.cpp index 807efb71..3808e3bc 100644 --- a/Helios/Helios.cpp +++ b/Helios/Helios.cpp @@ -209,6 +209,17 @@ void Helios::handle_state() { if (Time::getCurtime() > AUTO_SLEEP_TIME) { enter_sleep(); + return; + } + + static uint32_t lastClickTime = 0; + // ESD protection: Ignore button clicks that occur faster than a single tick + if (Button::onRelease()) { + if (Time::getCurtime() - lastClickTime < TICKRATE) { + // Ignore the click + return; + } + lastClickTime = Time::getCurtime(); } // check for the force sleep button hold regardless of which state we're in if (Button::holdDuration() > FORCE_SLEEP_TIME) { From e0b798decb528e9aee28230da4a0b80a12f87440 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Sat, 11 May 2024 16:08:18 -0500 Subject: [PATCH 3/4] Removed the auto sleep --- Helios/Helios.cpp | 5 ----- Helios/HeliosConfig.h | 6 ------ 2 files changed, 11 deletions(-) diff --git a/Helios/Helios.cpp b/Helios/Helios.cpp index 3808e3bc..36fc93af 100644 --- a/Helios/Helios.cpp +++ b/Helios/Helios.cpp @@ -207,11 +207,6 @@ void Helios::set_mode_index(uint8_t mode_index) void Helios::handle_state() { - if (Time::getCurtime() > AUTO_SLEEP_TIME) { - enter_sleep(); - return; - } - static uint32_t lastClickTime = 0; // ESD protection: Ignore button clicks that occur faster than a single tick if (Button::onRelease()) { diff --git a/Helios/HeliosConfig.h b/Helios/HeliosConfig.h index 86217c31..73c7ed7c 100644 --- a/Helios/HeliosConfig.h +++ b/Helios/HeliosConfig.h @@ -63,12 +63,6 @@ // sleep at any location in the menus #define FORCE_SLEEP_TIME 7000 -// Auto Sleep Time -// -// The duration in ms/ticks to hold the button to force the chip to -// sleep at any location in the menus -#define AUTO_SLEEP_TIME 1800000 - // Delete Color Time // // How long to hold button on a color to start the delete color flash From 2ec251012cc2a842b3d12d3fc299b34dd3473ce7 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Sat, 11 May 2024 16:28:47 -0500 Subject: [PATCH 4/4] Fixed the ESD Protection --- Helios/Helios.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Helios/Helios.cpp b/Helios/Helios.cpp index 36fc93af..b09c33c3 100644 --- a/Helios/Helios.cpp +++ b/Helios/Helios.cpp @@ -207,15 +207,6 @@ void Helios::set_mode_index(uint8_t mode_index) void Helios::handle_state() { - static uint32_t lastClickTime = 0; - // ESD protection: Ignore button clicks that occur faster than a single tick - if (Button::onRelease()) { - if (Time::getCurtime() - lastClickTime < TICKRATE) { - // Ignore the click - return; - } - lastClickTime = Time::getCurtime(); - } // check for the force sleep button hold regardless of which state we're in if (Button::holdDuration() > FORCE_SLEEP_TIME) { // when released the device will just sleep @@ -279,6 +270,12 @@ void Helios::handle_state_modes() // whether they have released the button since turning on bool hasReleased = (Button::releaseCount() > 0); + // ESD protection: Ignore button clicks that occur faster than a single tick + if (hasReleased && Time::getCurtime() < 2) { + enter_sleep(); + return; + } + if (Button::releaseCount() > 1 && Button::onShortClick()) { if (has_flag(FLAG_CONJURE)) { enter_sleep();