From c9351447b3f4e94f78a1c79ce5b0b9f1c321518d Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 10 Jan 2020 10:41:56 +0100 Subject: [PATCH] IdleLEDs: Allow temporarily disabling the functionality When setting the idle timeout to zero, stop checking for idleness, and never turn the LEDs off. Setting the timeout to a higher value again will resume the plugin's functionality. Signed-off-by: Gergely Nagy --- docs/plugins/IdleLEDs.md | 6 ++++++ src/kaleidoscope/plugin/IdleLEDs.cpp | 3 +++ 2 files changed, 9 insertions(+) diff --git a/docs/plugins/IdleLEDs.md b/docs/plugins/IdleLEDs.md index ae38b9b2..7bf86754 100644 --- a/docs/plugins/IdleLEDs.md +++ b/docs/plugins/IdleLEDs.md @@ -87,6 +87,9 @@ the following properties and methods. > Sets the amount of time (in seconds) that can pass without a single key being > pressed before the plugin considers the keyboard idle and turns off the LEDs. +> +> Setting the timeout to 0 will disable the plugin until it is set to a higher +> value. ## Focus commands @@ -99,6 +102,9 @@ the `PersistentIdleLEDs` variant: > Sets the idle time limit to `seconds`, when called with an argument. Returns > the current limit (in seconds) when called without any. +> +> Setting the timeout to 0 will disable the plugin until it is set to a higher +> value. ## Dependencies diff --git a/src/kaleidoscope/plugin/IdleLEDs.cpp b/src/kaleidoscope/plugin/IdleLEDs.cpp index a2424861..b22d452e 100644 --- a/src/kaleidoscope/plugin/IdleLEDs.cpp +++ b/src/kaleidoscope/plugin/IdleLEDs.cpp @@ -37,6 +37,9 @@ void IdleLEDs::setIdleTimeoutSeconds(uint32_t new_limit) { } EventHandlerResult IdleLEDs::beforeEachCycle() { + if (idle_time_limit == 0) + return EventHandlerResult::OK; + if (::LEDControl.isEnabled() && Runtime.hasTimeExpired(start_time_, idle_time_limit)) { ::LEDControl.disable();