Do not provide toggleLEDs

As this is a generic plugin, for keyboards that do not have LEDs, don't tie it
to LEDControl, and don't provide a `toggleLEDs` method. Instead, show an example
how to achieve the same thing from the sketch.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/365/head
Gergely Nagy 7 years ago committed by Gergely Nagy
parent 5eca9b9a1f
commit c56c7791ba

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

@ -17,6 +17,7 @@
*/
#include <Kaleidoscope.h>
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-HostPowerManagement.h>
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();

@ -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;

@ -37,8 +37,6 @@ class HostPowerManagement : public KaleidoscopePlugin {
WakeupKeyboard.begin();
};
void toggleLEDs(Event event);
private:
static bool was_suspended_;
static bool initial_suspend_;

Loading…
Cancel
Save