From 936408a17a6ee549591c676bf45c36f4c54ebefe Mon Sep 17 00:00:00 2001 From: greyhash Date: Mon, 18 Apr 2022 16:39:47 +0200 Subject: [PATCH] Fixed snake animation --- main/ledstrip.cpp | 4 ++-- main/ledstrip.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main/ledstrip.cpp b/main/ledstrip.cpp index 0d82946..905619e 100644 --- a/main/ledstrip.cpp +++ b/main/ledstrip.cpp @@ -17,7 +17,7 @@ using namespace std::chrono_literals; std::vector leds; uint8_t gHue = 0; -int16_t gLedPosition = 0; +float gLedPosition = 0; // yes, this is intendet as a float value! Do NOT change! uint16_t blinkAnimation = LEDSTRIP_OVERWRITE_NONE; @@ -333,7 +333,7 @@ void showDefaultLedstrip() void showSnakeAnimation() { - const int16_t leds_per_cycle = floor(1. / std::max(1, configs.ledstrip.animationMultiplier.value)) * (avgSpeedKmh + 1); + const float leds_per_cycle = (1. / std::max(1, configs.ledstrip.animationMultiplier.value)) * (avgSpeedKmh + 1); // yes, this is intendet as a float value! Do NOT change! fadeToBlackBy(&*std::begin(leds), leds.size(), floor(20*leds_per_cycle)); if (gLedPosition >= leds.size()) { diff --git a/main/ledstrip.h b/main/ledstrip.h index cf9e328..467f484 100644 --- a/main/ledstrip.h +++ b/main/ledstrip.h @@ -39,7 +39,7 @@ enum Bobbycar_Side extern std::vector leds; extern uint8_t gHue; -extern int16_t gLedPosition; +extern float gLedPosition; // yes, this is intendet as a float value! Do NOT change! extern uint16_t blinkAnimation;