From e7e4ba0690b1203b939e4bc42608719eb7c0be82 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 10 Feb 2017 09:10:36 +0100 Subject: [PATCH] Move the static globals into the Heatmap object Fixes #3. Signed-off-by: Gergely Nagy --- src/Akela/Heatmap.cpp | 20 ++++++++++---------- src/Akela/Heatmap.h | 11 +++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/Akela/Heatmap.cpp b/src/Akela/Heatmap.cpp index 5b1d0d46..e067af27 100644 --- a/src/Akela/Heatmap.cpp +++ b/src/Akela/Heatmap.cpp @@ -19,16 +19,16 @@ #include namespace Akela { - static uint8_t heatmap[ROWS][COLS]; - static uint16_t totalKeys; - static uint8_t highestCount; - static uint16_t updateFrequency = 50; - static uint16_t loopCount; + uint8_t Heatmap::heatmap[ROWS][COLS]; + uint16_t Heatmap::totalKeys; + uint8_t Heatmap::highestCount; + uint16_t Heatmap::updateFrequency = 50; + uint16_t Heatmap::loopCount; - static const float 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}}; - static void - 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++) { @@ -40,8 +40,8 @@ namespace Akela { } } - static cRGB - computeColor (float v) { + cRGB + Heatmap::computeColor (float v) { float fb = 0; uint8_t idx1, idx2; diff --git a/src/Akela/Heatmap.h b/src/Akela/Heatmap.h index 2ba1952f..789e1e19 100644 --- a/src/Akela/Heatmap.h +++ b/src/Akela/Heatmap.h @@ -32,6 +32,17 @@ namespace Akela { virtual void update (void) final; private: + static uint8_t heatmap[ROWS][COLS]; + static uint16_t totalKeys; + static uint8_t highestCount; + static uint16_t updateFrequency; + static uint16_t loopCount; + + static const float heatColors[][3]; + + static void shiftStats (void); + static cRGB computeColor (float v); + static Key eventHook (Key mappedKey, byte row, byte col, uint8_t keyState); static void loopHook (bool postClear); };