make astyle

pull/365/head
Jesse Vincent 7 years ago
parent 90f5c51386
commit 46d40dd3d5
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -22,35 +22,35 @@
const Key keymaps[][ROWS][COLS] PROGMEM = { const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED [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_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_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, Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
Key_NoKey, Key_NoKey,
Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip, Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip,
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote, Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey Key_NoKey
), ),
}; };
void setup () { void setup () {
Kaleidoscope.setup (); Kaleidoscope.setup ();
StalkerEffect.configure (STALKER (BlazingTrail, NULL)); StalkerEffect.configure (STALKER (BlazingTrail, NULL));
USE_PLUGINS (&LEDOff, &StalkerEffect); USE_PLUGINS (&LEDOff, &StalkerEffect);
StalkerEffect.activate (); StalkerEffect.activate ();
} }
void loop () { void loop () {
Kaleidoscope.loop (); Kaleidoscope.loop ();
} }

@ -20,132 +20,133 @@
#include <LEDUtils.h> #include <LEDUtils.h>
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
namespace LEDEffects { namespace LEDEffects {
uint8_t StalkerEffect::map[ROWS][COLS]; uint8_t StalkerEffect::map[ROWS][COLS];
StalkerEffect::ColorComputer *StalkerEffect::colorComputer; StalkerEffect::ColorComputer *StalkerEffect::colorComputer;
uint16_t StalkerEffect::stepLength = 50; uint16_t StalkerEffect::stepLength = 50;
uint32_t StalkerEffect::stepEndTime; uint32_t StalkerEffect::stepEndTime;
StalkerEffect::StalkerEffect (void) { StalkerEffect::StalkerEffect (void) {
} }
void void
StalkerEffect::configure (ColorComputer *colorComputer_) { StalkerEffect::configure (ColorComputer *colorComputer_) {
colorComputer = colorComputer_; colorComputer = colorComputer_;
} }
void void
StalkerEffect::begin (void) { StalkerEffect::begin (void) {
event_handler_hook_use (eventHandlerHook); event_handler_hook_use (eventHandlerHook);
LEDMode::begin (); LEDMode::begin ();
} }
void void
StalkerEffect::init (void) { StalkerEffect::init (void) {
memset (map, 0, sizeof (map)); memset (map, 0, sizeof (map));
} }
Key Key
StalkerEffect::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) { StalkerEffect::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
if (row >= ROWS || col >= COLS) if (row >= ROWS || col >= COLS)
return mappedKey; return mappedKey;
if (key_is_pressed (keyState)) { if (key_is_pressed (keyState)) {
map[row][col] = 0xff; map[row][col] = 0xff;
}
return mappedKey;
} }
void return mappedKey;
StalkerEffect::update (void) { }
if (!colorComputer)
void
StalkerEffect::update (void) {
if (!colorComputer)
return; return;
bool timeOut = millis () >= stepEndTime; bool timeOut = millis () >= stepEndTime;
for (byte r = 0; r < ROWS; r++) { for (byte r = 0; r < ROWS; r++) {
for (byte c = 0; c < COLS; c++) { for (byte c = 0; c < COLS; c++) {
uint8_t step = map[r][c]; uint8_t step = map[r][c];
if (step) { if (step) {
LEDControl.led_set_crgb_at (r, c, colorComputer->compute (&step)); LEDControl.led_set_crgb_at (r, c, colorComputer->compute (&step));
} }
bool wasZero = (map[r][c] == 0); bool wasZero = (map[r][c] == 0);
if (timeOut) { if (timeOut) {
map[r][c] = step; map[r][c] = step;
} }
if (!wasZero && !map[r][c]) if (!wasZero && !map[r][c])
LEDControl.led_set_crgb_at (r, c, (cRGB){0, 0, 0}); LEDControl.led_set_crgb_at (r, c, (cRGB) {
0, 0, 0
});
} }
} }
if (timeOut) if (timeOut)
stepEndTime = millis () + stepLength; stepEndTime = millis () + stepLength;
}
namespace Stalker {
cRGB Haunt::highlightColor;
// Haunt
Haunt::Haunt (const cRGB highlightColor_) {
highlightColor = highlightColor_;
}
cRGB
Haunt::compute (uint8_t *step) {
cRGB color = CRGB((uint8_t)min(*step * highlightColor.r / 255, 255),
(uint8_t)min(*step * highlightColor.g / 255, 255),
(uint8_t)min(*step * highlightColor.b / 255, 255));
if (*step >= 0xf0)
*step -= 1;
else if (*step >= 0x40)
*step -= 16;
else if (*step >= 32)
*step -= 32;
else
*step = 0;
return color;
}
// BlazingTrail
BlazingTrail::BlazingTrail (...) {
}
cRGB
BlazingTrail::compute (uint8_t *step) {
cRGB color;
if (*step >= 0xff - 30) {
color = hsv_to_rgb (0xff - *step, 255, 255);
} else {
color = hsv_to_rgb (30, 255, 255);
color.r = min(*step * color.r / 255, 255);
color.g = min(*step * color.g / 255, 255);
} }
namespace Stalker { if (*step >= 0xf0 - 30)
*step -= 1;
cRGB Haunt::highlightColor; else if (*step >= 0x40)
*step -= 16;
else if (*step >= 32)
*step -= 32;
else
*step = 0;
// Haunt return color;
Haunt::Haunt (const cRGB highlightColor_) { }
highlightColor = highlightColor_;
}
cRGB };
Haunt::compute (uint8_t *step) {
cRGB color = CRGB((uint8_t)min(*step * highlightColor.r / 255, 255),
(uint8_t)min(*step * highlightColor.g / 255, 255),
(uint8_t)min(*step * highlightColor.b / 255, 255));
if (*step >= 0xf0)
*step -= 1;
else if (*step >= 0x40)
*step -= 16;
else if (*step >= 32)
*step -= 32;
else
*step = 0;
return color;
}
// BlazingTrail
BlazingTrail::BlazingTrail (...) {
}
cRGB
BlazingTrail::compute (uint8_t *step) {
cRGB color;
if (*step >= 0xff - 30) {
color = hsv_to_rgb (0xff - *step, 255, 255);
}
else {
color = hsv_to_rgb (30, 255, 255);
color.r = min(*step * color.r / 255, 255);
color.g = min(*step * color.g / 255, 255);
}
if (*step >= 0xf0 - 30)
*step -= 1;
else if (*step >= 0x40)
*step -= 16;
else if (*step >= 32)
*step -= 32;
else
*step = 0;
return color;
}
};
}; };
}; };
KaleidoscopePlugins::LEDEffects::StalkerEffect StalkerEffect; KaleidoscopePlugins::LEDEffects::StalkerEffect StalkerEffect;

@ -22,54 +22,56 @@
#define STALKER(n, ...) (({static KaleidoscopePlugins::LEDEffects::Stalker::n _effect (__VA_ARGS__); &_effect;})) #define STALKER(n, ...) (({static KaleidoscopePlugins::LEDEffects::Stalker::n _effect (__VA_ARGS__); &_effect;}))
namespace KaleidoscopePlugins { namespace KaleidoscopePlugins {
namespace LEDEffects { namespace LEDEffects {
class StalkerEffect : public LEDMode { class StalkerEffect : public LEDMode {
public: public:
class ColorComputer { class ColorComputer {
public: public:
virtual cRGB compute (uint8_t *step) = 0; virtual cRGB compute (uint8_t *step) = 0;
}; };
StalkerEffect (void); StalkerEffect (void);
virtual void begin (void) final; virtual void begin (void) final;
virtual void init (void) final; virtual void init (void) final;
virtual void update (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;
private: private:
static uint32_t stepEndTime; static uint32_t stepEndTime;
static ColorComputer *colorComputer; static ColorComputer *colorComputer;
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);
}; };
namespace Stalker { namespace Stalker {
class Haunt : public StalkerEffect::ColorComputer { class Haunt : public StalkerEffect::ColorComputer {
public: public:
Haunt (const cRGB highlightColor); Haunt (const cRGB highlightColor);
Haunt (void) : Haunt ({0x40, 0x80, 0x80}) {}; Haunt (void) : Haunt ( {
Haunt (void *) : Haunt () {}; 0x40, 0x80, 0x80
}) {};
Haunt (void *) : Haunt () {};
virtual cRGB compute (uint8_t *step) final; virtual cRGB compute (uint8_t *step) final;
private: private:
static cRGB highlightColor; static cRGB highlightColor;
}; };
class BlazingTrail : public StalkerEffect::ColorComputer { class BlazingTrail : public StalkerEffect::ColorComputer {
public: public:
BlazingTrail (...); BlazingTrail (...);
virtual cRGB compute (uint8_t *step) final; virtual cRGB compute (uint8_t *step) final;
}; };
}; };
}; };
}; };
extern KaleidoscopePlugins::LEDEffects::StalkerEffect StalkerEffect; extern KaleidoscopePlugins::LEDEffects::StalkerEffect StalkerEffect;

Loading…
Cancel
Save