diff --git a/README.md b/README.md index 17b1610e..52b82866 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ [st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52 Support performing custom actions whenever the host suspends, resumes, or is -sleeping. By default, the LEDs will be turned off on suspend, and the previous -LED mode restored on resume. +sleeping. Additionally, this plugin provides optional support for the keyboard +to wake the host up from suspend. ## Using the plugin @@ -41,11 +41,6 @@ The plugin provides the `HostPowerManagement` object, which has the following me > > Once enabled, it **cannot** be disabled again. -### `.toggleLEDs(event)` - -> Turns LEDs off on suspend, restores the previous LED mode on resume. This is -> called by `hostPowerManagementEventHandler()` by default. - ## Overrideable methods ### `hostPowerManagementEventHandler(event)` @@ -58,12 +53,7 @@ The plugin provides the `HostPowerManagement` object, which has the following me > cycle while the host is suspended; `kaleidoscope::HostPowerManagement::Resume` is > fired once when the host wakes up. > -> The default implementation calls `HostPowerManagement.toggleLEDs`. When overriding the -> function, the default is lost. - -## Dependencies - -* [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl) +> The default implementation is empty. ## Further reading diff --git a/examples/HostPowerManagement/HostPowerManagement.ino b/examples/HostPowerManagement/HostPowerManagement.ino index be96b3ce..0c498931 100644 --- a/examples/HostPowerManagement/HostPowerManagement.ino +++ b/examples/HostPowerManagement/HostPowerManagement.ino @@ -17,6 +17,7 @@ */ #include +#include #include const Key keymaps[][ROWS][COLS] PROGMEM = { @@ -41,6 +42,22 @@ const Key keymaps[][ROWS][COLS] PROGMEM = { }; +void hostPowerManagementEventHandler(kaleidoscope::HostPowerManagement::Event event) { + switch (event) { + case kaleidoscope::HostPowerManagement::Suspend: + LEDControl.paused = true; + LEDControl.set_all_leds_to({0, 0, 0}); + LEDControl.syncLeds(); + break; + case kaleidoscope::HostPowerManagement::Resume: + LEDControl.paused = false; + LEDControl.refreshAll(); + break; + case kaleidoscope::HostPowerManagement::Sleep: + break; + } +} + void setup() { Kaleidoscope.setup(); diff --git a/src/Kaleidoscope/HostPowerManagement.cpp b/src/Kaleidoscope/HostPowerManagement.cpp index 2b4ee255..d91ddbf9 100644 --- a/src/Kaleidoscope/HostPowerManagement.cpp +++ b/src/Kaleidoscope/HostPowerManagement.cpp @@ -33,22 +33,6 @@ void HostPowerManagement::begin(void) { Kaleidoscope.useLoopHook(loopHook); } -void HostPowerManagement::toggleLEDs(HostPowerManagement::Event event) { - switch (event) { - case Suspend: - ::LEDControl.paused = true; - ::LEDControl.set_all_leds_to({0, 0, 0}); - ::LEDControl.syncLeds(); - break; - case Resume: - ::LEDControl.paused = false; - ::LEDControl.refreshAll(); - break; - case Sleep: - break; - } -} - void HostPowerManagement::loopHook(bool post_clear) { if (post_clear) return; @@ -75,7 +59,6 @@ void HostPowerManagement::loopHook(bool post_clear) { } __attribute__((weak)) void hostPowerManagementEventHandler(kaleidoscope::HostPowerManagement::Event event) { - HostPowerManagement.toggleLEDs(event); } kaleidoscope::HostPowerManagement HostPowerManagement; diff --git a/src/Kaleidoscope/HostPowerManagement.h b/src/Kaleidoscope/HostPowerManagement.h index de3c827b..79e321f1 100644 --- a/src/Kaleidoscope/HostPowerManagement.h +++ b/src/Kaleidoscope/HostPowerManagement.h @@ -37,8 +37,6 @@ class HostPowerManagement : public KaleidoscopePlugin { WakeupKeyboard.begin(); }; - void toggleLEDs(Event event); - private: static bool was_suspended_; static bool initial_suspend_;