Convert the plugin to a LEDMode

Fixes #3.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago committed by Gergely Nagy
parent 1dcccb0e37
commit b1c0f1fc1b

@ -22,10 +22,11 @@ To use the plugin, one needs to include the header, and select the effect.
#include <Kaleidoscope-LED-Stalker.h> #include <Kaleidoscope-LED-Stalker.h>
void setup () { void setup () {
Kaleidoscope.setup (KEYMAP_SIZE); Kaleidoscope.setup ();
StalkerEffect.configure (STALKER (Haunt, {0xff, 0, 0})); StalkerEffect.configure (STALKER (Haunt, {0xff, 0, 0}));
Kaleidoscope.use (&StalkerEffect, NULL); USE_PLUGINS (&StalkerEffect);
StalkerEffect.activate ();
} }
``` ```

@ -41,10 +41,12 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
}; };
void setup () { void setup () {
Kaleidoscope.setup (KEYMAP_SIZE); Kaleidoscope.setup ();
StalkerEffect.configure (STALKER (BlazingTrail, NULL)); StalkerEffect.configure (STALKER (BlazingTrail, NULL));
Kaleidoscope.use (&LEDControl, &StalkerEffect, NULL); USE_PLUGINS (&StalkerEffect);
StalkerEffect.activate ();
} }
void loop () { void loop () {

@ -36,7 +36,7 @@ namespace KaleidoscopePlugins {
void void
StalkerEffect::begin (void) { StalkerEffect::begin (void) {
event_handler_hook_use (eventHandlerHook); event_handler_hook_use (eventHandlerHook);
loop_hook_use (loopHook); LEDMode::begin ();
} }
Key Key
@ -52,10 +52,7 @@ namespace KaleidoscopePlugins {
} }
void void
StalkerEffect::loopHook (bool postClear) { StalkerEffect::update (void) {
if (postClear)
return;
if (!colorComputer) if (!colorComputer)
return; return;

@ -23,7 +23,7 @@
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
namespace LEDEffects { namespace LEDEffects {
class StalkerEffect : public KaleidoscopePlugin { class StalkerEffect : public LEDMode {
public: public:
class ColorComputer { class ColorComputer {
public: public:
@ -33,6 +33,8 @@ namespace KaleidoscopePlugins {
StalkerEffect (void); StalkerEffect (void);
virtual void begin (void) final; virtual void begin (void) final;
virtual void update (void) final;
static void configure (ColorComputer *colorComputer); static void configure (ColorComputer *colorComputer);
static uint16_t stepLength; static uint16_t stepLength;
@ -42,7 +44,6 @@ namespace KaleidoscopePlugins {
static uint8_t map[ROWS][COLS]; static uint8_t map[ROWS][COLS];
static Key eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState); static Key eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState);
static void loopHook (bool postClear);
}; };
namespace Stalker { namespace Stalker {

Loading…
Cancel
Save