Merge pull request #791 from keyboardio/idleleds/smarter-idling

IdleLEDs: Be smarter about re-enabling LEDs
pull/796/head
Gergely Nagy 5 years ago committed by GitHub
commit a9087a8811
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,6 +26,7 @@ namespace plugin {
uint32_t IdleLEDs::idle_time_limit = 600000; // 10 minutes
uint32_t IdleLEDs::start_time_ = 0;
bool IdleLEDs::idle_;
uint32_t IdleLEDs::idleTimeoutSeconds() {
return idle_time_limit / 1000;
@ -39,6 +40,7 @@ EventHandlerResult IdleLEDs::beforeEachCycle() {
if (::LEDControl.isEnabled() &&
Runtime.hasTimeExpired(start_time_, idle_time_limit)) {
::LEDControl.disable();
idle_ = true;
}
return EventHandlerResult::OK;
@ -46,8 +48,9 @@ EventHandlerResult IdleLEDs::beforeEachCycle() {
EventHandlerResult IdleLEDs::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state) {
if (!::LEDControl.isEnabled()) {
if (idle_) {
::LEDControl.enable();
idle_ = false;
}
start_time_ = Runtime.millisAtCycleStart();

@ -36,6 +36,7 @@ class IdleLEDs: public kaleidoscope::Plugin {
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state);
private:
static bool idle_;
static uint32_t start_time_;
};

Loading…
Cancel
Save