|
|
|
@ -29,7 +29,7 @@ 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}};
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Heatmap::shiftStats (void) {
|
|
|
|
|
Heatmap::shiftStats(void) {
|
|
|
|
|
highestCount = totalKeys = 0;
|
|
|
|
|
for (uint8_t r = 0; r < ROWS; r++) {
|
|
|
|
|
for (uint8_t c = 0; c < COLS; c++) {
|
|
|
|
@ -42,7 +42,7 @@ Heatmap::shiftStats (void) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cRGB
|
|
|
|
|
Heatmap::computeColor (float v) {
|
|
|
|
|
Heatmap::computeColor(float v) {
|
|
|
|
|
float fb = 0;
|
|
|
|
|
uint8_t idx1, idx2;
|
|
|
|
|
|
|
|
|
@ -64,24 +64,24 @@ Heatmap::computeColor (float v) {
|
|
|
|
|
return {b, g, r};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Heatmap::Heatmap (void) {
|
|
|
|
|
Heatmap::Heatmap(void) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Heatmap::begin (void) {
|
|
|
|
|
LEDControl.mode_add (this);
|
|
|
|
|
event_handler_hook_use (this->eventHook);
|
|
|
|
|
loop_hook_use (this->loopHook);
|
|
|
|
|
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) {
|
|
|
|
|
Heatmap::eventHook(Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
|
// if it is a synthetic key, skip it.
|
|
|
|
|
if (keyState & INJECTED)
|
|
|
|
|
return mappedKey;
|
|
|
|
|
|
|
|
|
|
// if the key is not toggled on, return.
|
|
|
|
|
if (!key_toggled_on (keyState))
|
|
|
|
|
if (!key_toggled_on(keyState))
|
|
|
|
|
return mappedKey;
|
|
|
|
|
|
|
|
|
|
totalKeys++;
|
|
|
|
@ -93,23 +93,23 @@ Heatmap::eventHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Heatmap::loopHook (bool postClear) {
|
|
|
|
|
Heatmap::loopHook(bool postClear) {
|
|
|
|
|
if (highestCount > 191 || totalKeys > 16000)
|
|
|
|
|
shiftStats();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Heatmap::update (void) {
|
|
|
|
|
if (endTime && (millis () > endTime))
|
|
|
|
|
Heatmap::update(void) {
|
|
|
|
|
if (endTime && (millis() > endTime))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
endTime = millis () + updateDelay;
|
|
|
|
|
endTime = millis() + updateDelay;
|
|
|
|
|
|
|
|
|
|
for (uint8_t r = 0; r < ROWS; r++) {
|
|
|
|
|
for (uint8_t c = 0; c < COLS; c++) {
|
|
|
|
|
uint8_t cap = max(totalKeys, 1);
|
|
|
|
|
float v = float(heatmap[r][c]) / cap;
|
|
|
|
|
LEDControl.led_set_crgb_at (r, c, computeColor (v));
|
|
|
|
|
LEDControl.led_set_crgb_at(r, c, computeColor(v));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|