Skip to content

Commit

Permalink
Merge pull request #796 from keyboardio/idleleds/disable-on-0
Browse files Browse the repository at this point in the history
IdleLEDs: Allow temporarily disabling the functionality
  • Loading branch information
obra committed Jan 13, 2020
2 parents 579cd56 + c935144 commit 58bd7ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/plugins/IdleLEDs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/kaleidoscope/plugin/IdleLEDs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 58bd7ec

Please sign in to comment.