|
|
|
@ -20,16 +20,16 @@
|
|
|
|
|
#include <Kaleidoscope-Heatmap.h>
|
|
|
|
|
|
|
|
|
|
namespace KaleidoscopePlugins {
|
|
|
|
|
uint8_t Heatmap::heatmap[ROWS][COLS];
|
|
|
|
|
uint16_t Heatmap::totalKeys;
|
|
|
|
|
uint8_t Heatmap::highestCount;
|
|
|
|
|
uint16_t Heatmap::updateDelay = 500;
|
|
|
|
|
uint32_t Heatmap::endTime;
|
|
|
|
|
uint8_t Heatmap::heatmap[ROWS][COLS];
|
|
|
|
|
uint16_t Heatmap::totalKeys;
|
|
|
|
|
uint8_t Heatmap::highestCount;
|
|
|
|
|
uint16_t Heatmap::updateDelay = 500;
|
|
|
|
|
uint32_t Heatmap::endTime;
|
|
|
|
|
|
|
|
|
|
const float Heatmap::heatColors[][3] = {{0.0, 0.0, 0.0}, {0.1, 1, 0.1}, {1, 1, 0.1}, {1, 0.1, 0.1}};
|
|
|
|
|
const float Heatmap::heatColors[][3] = {{0.0, 0.0, 0.0}, {0.1, 1, 0.1}, {1, 1, 0.1}, {1, 0.1, 0.1}};
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Heatmap::shiftStats (void) {
|
|
|
|
|
void
|
|
|
|
|
Heatmap::shiftStats (void) {
|
|
|
|
|
highestCount = totalKeys = 0;
|
|
|
|
|
for (uint8_t r = 0; r < ROWS; r++) {
|
|
|
|
|
for (uint8_t c = 0; c < COLS; c++) {
|
|
|
|
@ -39,10 +39,10 @@ namespace KaleidoscopePlugins {
|
|
|
|
|
highestCount = heatmap[r][c];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cRGB
|
|
|
|
|
Heatmap::computeColor (float v) {
|
|
|
|
|
cRGB
|
|
|
|
|
Heatmap::computeColor (float v) {
|
|
|
|
|
float fb = 0;
|
|
|
|
|
uint8_t idx1, idx2;
|
|
|
|
|
|
|
|
|
@ -62,20 +62,20 @@ namespace KaleidoscopePlugins {
|
|
|
|
|
uint8_t b = (int)(((heatColors[idx2][2] - heatColors[idx1][2]) * fb + heatColors[idx1][2]) * 255);
|
|
|
|
|
|
|
|
|
|
return {b, g, r};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Heatmap::Heatmap (void) {
|
|
|
|
|
}
|
|
|
|
|
Heatmap::Heatmap (void) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Heatmap::begin (void) {
|
|
|
|
|
void
|
|
|
|
|
Heatmap::begin (void) {
|
|
|
|
|
LEDControl.mode_add (this);
|
|
|
|
|
event_handler_hook_use (this->eventHook);
|
|
|
|
|
loop_hook_use (this->loopHook);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Key
|
|
|
|
|
Heatmap::eventHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
|
Key
|
|
|
|
|
Heatmap::eventHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
|
// if it is a synthetic key, skip it.
|
|
|
|
|
if (keyState & INJECTED)
|
|
|
|
|
return mappedKey;
|
|
|
|
@ -90,16 +90,16 @@ namespace KaleidoscopePlugins {
|
|
|
|
|
highestCount = heatmap[row][col];
|
|
|
|
|
|
|
|
|
|
return mappedKey;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Heatmap::loopHook (bool postClear) {
|
|
|
|
|
void
|
|
|
|
|
Heatmap::loopHook (bool postClear) {
|
|
|
|
|
if (highestCount > 191 || totalKeys > 16000)
|
|
|
|
|
shiftStats();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Heatmap::update (void) {
|
|
|
|
|
void
|
|
|
|
|
Heatmap::update (void) {
|
|
|
|
|
if (endTime && (millis () > endTime))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@ -112,7 +112,7 @@ namespace KaleidoscopePlugins {
|
|
|
|
|
LEDControl.led_set_crgb_at (r, c, computeColor (v));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
KaleidoscopePlugins::Heatmap HeatmapEffect;
|
|
|
|
|