Rearrange the file layout in preparation of becoming a monorepo

Move the documentation to `doc/plugin/LEDEffect-Rainbow.md`, sources under
`src/kaleidoscope/plugin/` (appropriately namespaced). This is in preparation of
merging plugins into a single monorepo.

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

@ -5,52 +5,4 @@
[travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-LEDEffect-Rainbow.svg?branch=master
[travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-LEDEffect-Rainbow
Two colorful rainbow effects are implemented by this plugin: one where the
rainbow waves through the keys, and another where the LEDs breathe though the
colors of a rainbow. The difference is that in the first case, we have all the
rainbow colors on display, and it waves through the keyboard. In the second
case, we have only one color at a time, for the whole board, and the color
cycles through the rainbow's palette.
## Using the extension
To use the plugin, include the header, and tell the firmware to use either (or
both!) of the effects:
```c++
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-LEDEffect-Rainbow.h>
KALEIDOSCOPE_INIT_PLUGINS(LEDRainbowEffect, LEDRainbowWaveEffect);
void setup() {
Kaleidoscope.setup();
LEDRainbowEffect.brightness(150);
LEDRainbowWaveEffect.brightness(150);
LEDRainbowWaveEffect.update_delay(50);
}
```
## Plugin methods
The plugin provides two objects: `LEDRainbowEffect`, and `LEDRainbowWaveEffect`,
both of which provide the following methods:
### `.brightness([brightness])`
> Sets (or gets, if called without an argument) the LED brightness for the
> effect.
>
> Defaults to 50.
### `.update_delay([delay])`
> Sets (or gets, if called without an argument) the number of milliseconds
> between effect updates. Smaller number results in faster rainbows.
>
> Defaults to 40.
## Dependencies
* [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl)
See [doc/plugin/LEDEffect-Rainbow.md](doc/plugin/LEDEffect-Rainbow.md) for documentation.

@ -0,0 +1,51 @@
# Kaleidoscope-LEDEffect-Rainbow
Two colorful rainbow effects are implemented by this plugin: one where the
rainbow waves through the keys, and another where the LEDs breathe though the
colors of a rainbow. The difference is that in the first case, we have all the
rainbow colors on display, and it waves through the keyboard. In the second
case, we have only one color at a time, for the whole board, and the color
cycles through the rainbow's palette.
## Using the extension
To use the plugin, include the header, and tell the firmware to use either (or
both!) of the effects:
```c++
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-LEDEffect-Rainbow.h>
KALEIDOSCOPE_INIT_PLUGINS(LEDRainbowEffect, LEDRainbowWaveEffect);
void setup() {
Kaleidoscope.setup();
LEDRainbowEffect.brightness(150);
LEDRainbowWaveEffect.brightness(150);
LEDRainbowWaveEffect.update_delay(50);
}
```
## Plugin methods
The plugin provides two objects: `LEDRainbowEffect`, and `LEDRainbowWaveEffect`,
both of which provide the following methods:
### `.brightness([brightness])`
> Sets (or gets, if called without an argument) the LED brightness for the
> effect.
>
> Defaults to 50.
### `.update_delay([delay])`
> Sets (or gets, if called without an argument) the number of milliseconds
> between effect updates. Smaller number results in faster rainbows.
>
> Defaults to 40.
## Dependencies
* [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl)

@ -16,61 +16,4 @@
#pragma once
#include "Kaleidoscope-LEDControl.h"
#include "LEDUtils.h"
namespace kaleidoscope {
class LEDRainbowEffect : public LEDMode {
public:
LEDRainbowEffect(void) {}
void brightness(byte);
byte brightness(void) {
return rainbow_value;
}
void update_delay(byte);
byte update_delay(void) {
return rainbow_update_delay;
}
void update(void) final;
private:
uint16_t rainbow_hue = 0; // stores 0 to 614
uint8_t rainbow_steps = 1; // number of hues we skip in a 360 range per update
uint16_t rainbow_last_update = 0;
uint16_t rainbow_update_delay = 40; // delay between updates (ms)
byte rainbow_saturation = 255;
byte rainbow_value = 50;
};
class LEDRainbowWaveEffect : public LEDMode {
public:
LEDRainbowWaveEffect(void) {}
void brightness(byte);
byte brightness(void) {
return rainbow_value;
}
void update_delay(byte);
byte update_delay(void) {
return rainbow_update_delay;
}
void update(void) final;
private:
uint16_t rainbow_hue = 0; // stores 0 to 614
uint8_t rainbow_wave_steps = 1; // number of hues we skip in a 360 range per update
uint16_t rainbow_last_update = 0;
uint16_t rainbow_update_delay = 40; // delay between updates (ms)
byte rainbow_saturation = 255;
byte rainbow_value = 50;
};
}
extern kaleidoscope::LEDRainbowEffect LEDRainbowEffect;
extern kaleidoscope::LEDRainbowWaveEffect LEDRainbowWaveEffect;
#include "kaleidoscope/plugin/LEDEffect-Rainbow.h"

@ -17,6 +17,7 @@
#include "Kaleidoscope-LEDEffect-Rainbow.h"
namespace kaleidoscope {
namespace plugin {
void LEDRainbowEffect::update(void) {
uint16_t now = millis();
@ -75,7 +76,9 @@ void LEDRainbowWaveEffect::brightness(byte brightness) {
void LEDRainbowWaveEffect::update_delay(byte delay) {
rainbow_update_delay = delay;
}
}
}
kaleidoscope::LEDRainbowEffect LEDRainbowEffect;
kaleidoscope::LEDRainbowWaveEffect LEDRainbowWaveEffect;
kaleidoscope::plugin::LEDRainbowEffect LEDRainbowEffect;
kaleidoscope::plugin::LEDRainbowWaveEffect LEDRainbowWaveEffect;

@ -0,0 +1,77 @@
/* Kaleidoscope-LEDEffect-Rainbow - Rainbow LED effects for Kaleidoscope.
* Copyright (C) 2017-2018 Keyboard.io, Inc.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "Kaleidoscope-LEDControl.h"
namespace kaleidoscope {
namespace plugin {
class LEDRainbowEffect : public LEDMode {
public:
LEDRainbowEffect(void) {}
void brightness(byte);
byte brightness(void) {
return rainbow_value;
}
void update_delay(byte);
byte update_delay(void) {
return rainbow_update_delay;
}
void update(void) final;
private:
uint16_t rainbow_hue = 0; // stores 0 to 614
uint8_t rainbow_steps = 1; // number of hues we skip in a 360 range per update
uint16_t rainbow_last_update = 0;
uint16_t rainbow_update_delay = 40; // delay between updates (ms)
byte rainbow_saturation = 255;
byte rainbow_value = 50;
};
class LEDRainbowWaveEffect : public LEDMode {
public:
LEDRainbowWaveEffect(void) {}
void brightness(byte);
byte brightness(void) {
return rainbow_value;
}
void update_delay(byte);
byte update_delay(void) {
return rainbow_update_delay;
}
void update(void) final;
private:
uint16_t rainbow_hue = 0; // stores 0 to 614
uint8_t rainbow_wave_steps = 1; // number of hues we skip in a 360 range per update
uint16_t rainbow_last_update = 0;
uint16_t rainbow_update_delay = 40; // delay between updates (ms)
byte rainbow_saturation = 255;
byte rainbow_value = 50;
};
}
}
extern kaleidoscope::plugin::LEDRainbowEffect LEDRainbowEffect;
extern kaleidoscope::plugin::LEDRainbowWaveEffect LEDRainbowWaveEffect;
Loading…
Cancel
Save