From 67262add72e85069bd4ce98f2df4d354998ddb97 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sat, 18 Mar 2017 11:01:23 +0100 Subject: [PATCH] Don't use floats for the Haunt effect Fixes #7. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/LED-Stalker.cpp | 18 +++++++----------- src/Kaleidoscope/LED-Stalker.h | 3 +-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Kaleidoscope/LED-Stalker.cpp b/src/Kaleidoscope/LED-Stalker.cpp index 10ec5486..1f3a7fa6 100644 --- a/src/Kaleidoscope/LED-Stalker.cpp +++ b/src/Kaleidoscope/LED-Stalker.cpp @@ -92,22 +92,18 @@ namespace KaleidoscopePlugins { namespace Stalker { + cRGB Haunt::highlightColor; + // Haunt - float Haunt::mb; - float Haunt::mg; - float Haunt::mr; - - Haunt::Haunt (const cRGB highlightColor) { - mb = highlightColor.b / 255.0; - mg = highlightColor.g / 255.0; - mr = highlightColor.r / 255.0; + Haunt::Haunt (const cRGB highlightColor_) { + highlightColor = highlightColor_; } cRGB Haunt::compute (uint8_t step) { - cRGB color = {(uint8_t)min(step * mb, 255), - (uint8_t)min(step * mg, 255), - (uint8_t)min(step * mr, 255)}; + cRGB color = CRGB((uint8_t)min(step * highlightColor.r / 255, 255), + (uint8_t)min(step * highlightColor.g / 255, 255), + (uint8_t)min(step * highlightColor.b / 255, 255)); return color; } diff --git a/src/Kaleidoscope/LED-Stalker.h b/src/Kaleidoscope/LED-Stalker.h index fdbeace8..b75e28ce 100644 --- a/src/Kaleidoscope/LED-Stalker.h +++ b/src/Kaleidoscope/LED-Stalker.h @@ -56,9 +56,8 @@ namespace KaleidoscopePlugins { Haunt (void *) : Haunt () {}; virtual cRGB compute (uint8_t step) final; - private: - static float mr, mg, mb; + static cRGB highlightColor; }; class BlazingTrail : public StalkerEffect::ColorComputer {