Updated to use the new LEDMode/LEDControl API

Signed-off-by: Gergely Nagy <kaleidoscope@gergo.csillger.hu>
pull/389/head
Gergely Nagy 7 years ago
parent c263665f3e
commit dc0b2a2b91

@ -66,10 +66,9 @@ cRGB Heatmap::computeColor(float v) {
Heatmap::Heatmap(void) {
}
void Heatmap::begin(void) {
LEDControl.mode_add(this);
event_handler_hook_use(eventHook);
loop_hook_use(loopHook);
void Heatmap::setup(void) {
Kaleidoscope.useEventHandlerHook(eventHook);
Kaleidoscope.useLoopHook(loopHook);
}
Key Heatmap::eventHook(Key mapped_key, byte row, byte col, uint8_t key_state) {
@ -106,7 +105,7 @@ Heatmap::update(void) {
for (uint8_t c = 0; c < COLS; c++) {
uint8_t cap = max(total_keys_, 1);
float v = static_cast<float>(heatmap_[r][c]) / cap;
LEDControl.setCrgbAt(r, c, computeColor(v));
::LEDControl.setCrgbAt(r, c, computeColor(v));
}
}
}

@ -28,8 +28,10 @@ class Heatmap : public LEDMode {
static uint16_t update_delay;
void begin(void) final;
protected:
void setup(void) final;
void update(void) final;
private:
static uint8_t heatmap_[ROWS][COLS];
static uint16_t total_keys_;

Loading…
Cancel
Save