Kaleidoscope Style Guide conformance

Rearranged both in style, and in naming conventions to match the Kaleidoscope
Style Guide, and please the linter too.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/389/head
Gergely Nagy 7 years ago
parent 947019733d
commit 3e982ba5f6

@ -12,34 +12,32 @@
The `Colormap` extension provides an easier way to set up a different - static -
color map per-layer. This means that we can set up a map of colors for each key,
on a per-layer basis, and whenever a layer becomes active, the color map for
that layer is applied on top of everything else. The extension supports
transparent colors, to make things easier.
Both the palette and the color map is stored in EEPROM, and the palette is
limited to 15 colors (with the 16th being the transparent color). The plugin can
work together with the [Focus][plugin:focus] plugin, to make it easier to update
the palette or the color map itself.
that layer is applied on top of everything else. Colors are picked from a
15-color palette (or 16, if we disable transparency), provided by
the [LED-Palette-Theme][plugin:l-p-t] plugin. The color map is stored in
`EEPROM`, and can be easily changed via the [Focus][plugin:focus] plugin, which
also provides palette editing capabilities.
[plugin:focus]: https://github.com/keyboardio/Kaleidoscope-Focus
[plugin:l-p-t]: https://github.com/keyboardio/Kaleidoscope-LED-Palette-Theme
## Using the extension
To use the extension, include the header, tell it the number of layers you have,
and it will do the rest.
register the `Focus` hooks, and it will do the rest.
```c++
#include <Kaleidoscope.h>
#include <Kaleidoscope-LED-Palette-Theme.h>
#include <Kaleidoscope-Colormap.h>
#include <Kaleidoscope-Focus.h>
void setup (void) {
Kaleidoscope.setup ();
USE_PLUGINS (&ColormapEffect, &Focus);
void setup(void) {
Kaleidoscope.setup();
USE_PLUGINS(&ColormapEffect, &Focus);
ColormapEffect.configure (1);
Focus.addHook (FOCUS_HOOK_LEDPALETTETHEME);
Focus.addHook (FOCUS_HOOK_COLORMAP);
ColormapEffect.max_layers(1);
Focus.addHook(FOCUS_HOOK_LEDPALETTETHEME);
Focus.addHook(FOCUS_HOOK_COLORMAP);
}
```
@ -47,9 +45,10 @@ void setup (void) {
The extension provides an `ColormapEffect` singleton object, with a single method:
### `.configure(maxLayers)`
### `.max_layers(max)`
> Tells the extension to reserve space in EEPROM for up to `maxLayers` layers.
> Tells the extension to reserve space in EEPROM for up to `max` layers. Can
> only be called once, any subsequent call will be a no-op.
## Dependencies

@ -21,8 +21,7 @@
const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED
(
Key_LEDEffectNext, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
(Key_LEDEffectNext, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
@ -36,18 +35,17 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey
),
Key_NoKey),
};
void setup () {
Kaleidoscope.use (&ColormapEffect, NULL);
void setup() {
USE_PLUGINS(&ColormapEffect);
Kaleidoscope.setup ();
ColormapEffect.configure (1);
ColormapEffect.activate ();
Kaleidoscope.setup();
ColormapEffect.max_layers(1);
ColormapEffect.activate();
}
void loop () {
Kaleidoscope.loop ();
void loop() {
Kaleidoscope.loop();
}

@ -16,42 +16,53 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Kaleidoscope-Colormap.h>
#include <EEPROM.h>
#include <Kaleidoscope-EEPROM-Settings.h>
#include <Kaleidoscope-Focus.h>
#include <EEPROM.h>
namespace KaleidoscopePlugins {
namespace kaleidoscope {
uint16_t ColormapEffect::mapBase;
uint8_t ColormapEffect::maxLayers;
uint16_t ColormapEffect::map_base_;
uint8_t ColormapEffect::max_layers_;
ColormapEffect::ColormapEffect(void) {
}
void
ColormapEffect::begin(void) {
LEDMode::begin();
ColormapEffect::ColormapEffect (void) {
USE_PLUGINS(&::EEPROMSettings, &::LEDPaletteTheme);
}
void
ColormapEffect::configure (uint8_t maxLayers_) {
USE_PLUGINS (&::EEPROMSettings, &::LEDPaletteTheme);
ColormapEffect::max_layers(uint8_t max_) {
if (map_base_ != 0)
return;
maxLayers = maxLayers_;
mapBase = ::LEDPaletteTheme.reserveThemes (maxLayers);
max_layers_ = max_;
map_base_ = ::LEDPaletteTheme.reserveThemes(max_layers_);
}
void
ColormapEffect::update (void) {
ColormapEffect::update(void) {
for (uint8_t l = 0; l < 32; l++) {
if (!Layer.isOn (l))
if (!Layer.isOn(l))
continue;
::LEDPaletteTheme.update (mapBase, l);
::LEDPaletteTheme.update(map_base_, l);
}
}
bool
ColormapEffect::focusHook (const char *command) {
return ::LEDPaletteTheme.themeFocusHandler (command, PSTR("colormap.map"), mapBase, maxLayers);
ColormapEffect::focusHook(const char *command) {
return ::LEDPaletteTheme.themeFocusHandler(command, PSTR("colormap.map"), map_base_, max_layers_);
}
};
} // namespace kaleidoscope
KaleidoscopePlugins::ColormapEffect ColormapEffect;
kaleidoscope::ColormapEffect ColormapEffect;

@ -21,23 +21,25 @@
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-LED-Palette-Theme.h>
namespace KaleidoscopePlugins {
namespace kaleidoscope {
class ColormapEffect : public LEDMode {
public:
ColormapEffect (void);
ColormapEffect(void);
virtual void update (void) final;
void configure (uint8_t maxLayers);
void begin(void) final;
void update(void) final;
static bool focusHook (const char *command);
void max_layers(uint8_t max_);
static bool focusHook(const char *command);
private:
static uint8_t maxLayers;
static uint16_t mapBase;
};
static uint8_t max_layers_;
static uint16_t map_base_;
};
} // namespace kaleidoscope
extern KaleidoscopePlugins::ColormapEffect ColormapEffect;
extern kaleidoscope::ColormapEffect ColormapEffect;
#define FOCUS_HOOK_COLORMAP FOCUS_HOOK(ColormapEffect.focusHook, \
"colormap.map")

Loading…
Cancel
Save