LED-Wavepool: Add a way to use an explicit hue for the animation

While the rainbow colors are great, some may want to restrict the colors to a
single hue. For this purpose, the `ripple_hue` property was introduced. It
defaults to `Wavepool.rainbow_hue` (a special value that tells the plugin to use
multiple hues).

Inspired by @bjc's ToyKeeper/Kaleidoscope-LED-Wavepool#8.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/510/head
Gergely Nagy 6 years ago
parent e4689caf8a
commit cae7048f6a
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -25,7 +25,7 @@ void setup (){
It is recommended to place the activation of the plugin as early as possible, so
the plugin can catch all relevant key presses.
## Plugin methods
## Plugin properties
The plugin provides the `WavepoolEffect` object, which has the following
properties:
@ -39,6 +39,16 @@ properties:
>
> Default is 5000 (5 seconds).
### `.ripple_hue`
> The Hue of the ripple animation. If set, the light splashing across the
> keyboard will use this value instead of all colors of the rainbow.
>
> Setting it to the special value of `Wavepool.rainbow_hue` will cause the
> plugin to use all colors again.
>
> Defaults to `Wavepool.rainbow_hue`.
## Dependencies
* [Kaleidoscope-LEDControl](LEDControl.md)

@ -50,6 +50,7 @@ void setup() {
Kaleidoscope.setup();
WavepoolEffect.idle_timeout = 5000; // 5 seconds
WavepoolEffect.ripple_hue = WavepoolEffect.rainbow_hue;
WavepoolEffect.activate();
}

@ -29,6 +29,7 @@ int8_t WavepoolEffect::surface[2][WP_WID * WP_HGT];
uint8_t WavepoolEffect::page = 0;
uint8_t WavepoolEffect::frames_since_event = 0;
uint16_t WavepoolEffect::idle_timeout = 5000; // 5 seconds
int16_t WavepoolEffect::ripple_hue = WavepoolEffect::rainbow_hue; // automatic hue
// map native keyboard coordinates (16x4) into geometric space (14x5)
PROGMEM const uint8_t WavepoolEffect::rc2pos[ROWS * COLS] = {
@ -189,10 +190,14 @@ void WavepoolEffect::update(void) {
uint8_t intensity = abs(height) * 2;
uint8_t saturation = 0xff - intensity;
// color starts white but gets dimmer and more saturated as it fades,
// with hue wobbling according to height map
int16_t hue = (current_hue + height + (height >> 1)) & 0xff;
uint8_t value = (intensity >= 128) ? 255 : intensity << 1;
int16_t hue = ripple_hue;
if (ripple_hue == rainbow_hue) {
// color starts white but gets dimmer and more saturated as it fades,
// with hue wobbling according to height map
hue = (current_hue + height + (height >> 1)) & 0xff;
}
cRGB color = hsvToRgb(hue, saturation, value);

@ -34,7 +34,9 @@ class WavepoolEffect : public LEDMode {
// ms before idle animation starts after last keypress
static uint16_t idle_timeout;
static int16_t ripple_hue;
static constexpr int16_t rainbow_hue = INT16_MAX;
protected:
void update(void) final;

Loading…
Cancel
Save