Use standard timeout checker for Heatmap

Also, change timestamp from four bytes to two.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/642/head
Michael Richters 6 years ago
parent f62c0f631b
commit 2c75dceedf

@ -38,8 +38,8 @@ Heatmap::TransientLEDMode::TransientLEDMode(const Heatmap *parent)
heatmap_{}, heatmap_{},
// max of heatmap_ (we divide by it so we start at 1) // max of heatmap_ (we divide by it so we start at 1)
highest_(1), highest_(1),
// next heatmap computation time // last heatmap computation time
next_heatmap_comp_time_(0) last_heatmap_comp_time_(Kaleidoscope.millisAtCycleStart())
{} {}
cRGB Heatmap::TransientLEDMode::computeColor(float v) { cRGB Heatmap::TransientLEDMode::computeColor(float v) {
@ -211,14 +211,14 @@ void Heatmap::TransientLEDMode::update(void) {
// this methode is called frequently by the LEDControl::loopHook // this methode is called frequently by the LEDControl::loopHook
// do nothing if we didn't reach next_heatmap_comp_time_ yet // do nothing if the update interval hasn't elapsed since the previous update
if (next_heatmap_comp_time_ && (millis() < next_heatmap_comp_time_)) if (!Kaleidoscope.hasTimeExpired(last_heatmap_comp_time_, update_delay))
return; return;
// do the heatmap computing // do the heatmap computing
// (we reach next_heatmap_comp_time_ or next_heatmap_comp_time_ was never scheduled) // (update_delay milliseconds elapsed since last_heatmap_comp_time)
// schedule the next heatmap computing // schedule the next heatmap computing
next_heatmap_comp_time_ = millis() + update_delay; last_heatmap_comp_time_ = Kaleidoscope.millisAtCycleStart();
// for each key // for each key
for (uint8_t r = 0; r < ROWS; r++) { for (uint8_t r = 0; r < ROWS; r++) {

@ -61,7 +61,7 @@ class Heatmap : public Plugin,
uint16_t heatmap_[ROWS][COLS]; uint16_t heatmap_[ROWS][COLS];
uint16_t highest_; uint16_t highest_;
uint32_t next_heatmap_comp_time_; uint16_t last_heatmap_comp_time_;
void shiftStats(void); void shiftStats(void);
cRGB computeColor(float v); cRGB computeColor(float v);

Loading…
Cancel
Save