From c33ec4ba7e52159fd6dd032d82400869690b35ec Mon Sep 17 00:00:00 2001 From: UniversalTimeCodeGit <39132717+UniversalTimeCodeGit@users.noreply.github.com> Date: Thu, 10 May 2018 17:16:24 -0400 Subject: [PATCH] Implement Heatmap Reset Method This commit includes the resetMap method which is used to start the heatmap from 0. I also use it as a workaround for my map starting up with an "infinitely hot" key --- src/Kaleidoscope/Heatmap.cpp | 12 ++++++++++++ src/Kaleidoscope/Heatmap.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/Kaleidoscope/Heatmap.cpp b/src/Kaleidoscope/Heatmap.cpp index 23727206..eed703ba 100644 --- a/src/Kaleidoscope/Heatmap.cpp +++ b/src/Kaleidoscope/Heatmap.cpp @@ -111,6 +111,18 @@ void Heatmap::shiftStats(void) { highest_ = highest_ >> 1; } +void Heatmap::resetMap(void) { + // this method can be used as a way to work around an existing bug with a single key + // getting special attention or if the user just wants a button to reset the map + for (uint8_t r = 0; r < ROWS; r++) { + for (uint8_t c = 0; c < COLS; c++) { + heatmap_[r][c] = 0; + } + } + + highest_ = 1; +} + void Heatmap::setup(void) { Kaleidoscope.useEventHandlerHook(eventHook); Kaleidoscope.useLoopHook(loopHook); diff --git a/src/Kaleidoscope/Heatmap.h b/src/Kaleidoscope/Heatmap.h index fba0a51e..7d7b6639 100644 --- a/src/Kaleidoscope/Heatmap.h +++ b/src/Kaleidoscope/Heatmap.h @@ -29,6 +29,7 @@ class Heatmap : public LEDMode { static uint16_t update_delay; static const cRGB *heat_colors; static uint8_t heat_colors_length; + void resetMap(void); protected: void setup(void) final;