You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
3.6 KiB
118 lines
3.6 KiB
6 years ago
|
# Kaleidoscope-IdleLEDs
|
||
|
|
||
|
Having LED effects on the keyboard can be exceptionally helpful. However, having
|
||
|
the effects - or lights, in general - on all the time, even when the keyboard is
|
||
|
otherwise idle, is perhaps not the best. When one leaves the keyboard, locks the
|
||
|
computer, what use are the LED effects then?
|
||
|
|
||
|
One could turn them off manually, but... that's too easy to forget, and why do
|
||
|
something the firmware could do for us anyway? What if the LEDs turned
|
||
|
themselves off after some configurable idle time? Say, if one did not press any
|
||
|
keys for the past ten minutes, just shut 'em off.
|
||
|
|
||
|
This is exactly what the `IdleLEDs` plugin does.
|
||
|
|
||
|
## Using the plugin
|
||
|
|
||
|
The plugin comes with reasonable defaults (see below), and can be used out of
|
||
|
the box, without any further configuration:
|
||
|
|
||
|
```c++
|
||
|
#include <Kaleidoscope.h>
|
||
|
#include <Kaleidoscope-LEDControl.h>
|
||
|
#include <Kaleidoscope-LEDEffect-Rainbow.h>
|
||
|
#include <Kaleidoscope-IdleLEDs.h>
|
||
|
|
||
|
KALEIDOSCOPE_INIT_PLUGINS(LEDControl, IdleLEDs, LEDEffectRainbowWave);
|
||
|
|
||
|
void setup (void) {
|
||
|
Kaleidoscope.setup ();
|
||
|
}
|
||
|
```
|
||
|
|
||
|
Because the plugin needs to know about key events, it is best to make it one of
|
||
|
the first plugins, so it can catch all of them, before any other plugin would
|
||
|
have a chance to consume key events.
|
||
|
|
||
5 years ago
|
It is also possible to enable run-time configuration via he `Focus` plugin, and
|
||
|
persistent storage of such settings. To do that, one has to use the
|
||
|
`PersistentIdleLEDs` object instead, provided by the plugin:
|
||
|
|
||
|
```c++
|
||
|
#include <Kaleidoscope.h>
|
||
|
#include <Kaleidoscope-LEDControl.h>
|
||
|
#include <Kaleidoscope-LEDEffect-Rainbow.h>
|
||
|
#include <Kaleidoscope-EEPROM-Settings.h>
|
||
|
#include <Kaleidoscope-FocusSerial.h>
|
||
|
#include <Kaleidoscope-IdleLEDs.h>
|
||
|
|
||
|
KALEIDOSCOPE_INIT_PLUGINS(
|
||
|
EEPROMSettings,
|
||
|
Focus,
|
||
|
LEDControl,
|
||
|
PersistentIdleLEDs,
|
||
|
LEDEffectRainbowWave
|
||
|
);
|
||
|
|
||
|
void setup (void) {
|
||
|
Kaleidoscope.setup ();
|
||
|
}
|
||
|
```
|
||
|
|
||
5 years ago
|
## Plugin Properties
|
||
6 years ago
|
|
||
5 years ago
|
The plugin provides two objects, `IdleLEDs`, and `PersistentIdleLEDs`, both with
|
||
|
the following properties and methods.
|
||
6 years ago
|
|
||
5 years ago
|
### `.idle_time_limit`
|
||
6 years ago
|
|
||
5 years ago
|
> Property storing the amount of time that can pass without a single key being
|
||
|
> pressed before the plugin considers the keyboard idle and turns off the LEDs.
|
||
|
> Value is expressed in milliseconds.
|
||
6 years ago
|
|
||
5 years ago
|
> Defaults to 600000 milliseconds (10 minutes).
|
||
6 years ago
|
|
||
5 years ago
|
> Provided for compatibility reasons. It is recommended to use one of the
|
||
5 years ago
|
> methods below instead of setting this property directly. If using
|
||
|
> `PersistentIdleLEDs`, setting this property will not persist the value to
|
||
5 years ago
|
> storage. Use `.setIdleTimeoutSeconds()` if persistence is desired.
|
||
5 years ago
|
|
||
|
### `.idleTimeoutSeconds()`
|
||
|
|
||
|
> Returns 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.
|
||
|
|
||
|
### `.setIdleTimeoutSeconds(uint32_t new_limit)`
|
||
|
|
||
|
> 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.
|
||
6 years ago
|
|
||
5 years ago
|
## Focus commands
|
||
|
|
||
|
The plugin provides a single [Focus][FocusSerial] command, but only when using
|
||
|
the `PersistentIdleLEDs` variant:
|
||
|
|
||
|
[FocusSerial]: FocusSerial.md
|
||
|
|
||
|
### `idleleds.time_limit [seconds]`
|
||
|
|
||
|
> Sets the idle time limit to `seconds`, when called with an argument. Returns
|
||
|
> the current limit (in seconds) when called without any.
|
||
|
|
||
6 years ago
|
## Dependencies
|
||
|
|
||
|
* [Kaleidoscope-LEDControl](LEDControl.md)
|
||
|
|
||
5 years ago
|
### Optional dependencies
|
||
|
|
||
|
* [Kaleidoscope-EEPROM-Settings](EEPROM-Settings.md)
|
||
|
* [FocusSerial](FocusSerial.md)
|
||
|
|
||
6 years ago
|
## Further reading
|
||
|
|
||
|
Starting from the [example][plugin:example] is the recommended way of getting
|
||
|
started with the plugin.
|
||
|
|
||
6 years ago
|
[plugin:example]: ../../examples/LEDs/IdleLEDs/IdleLEDs.ino
|