New Animations: Snake, Efficiency
This commit is contained in:
@ -11,11 +11,13 @@
|
||||
#include "ota.h"
|
||||
#include "time_bobbycar.h"
|
||||
#include "utils.h"
|
||||
#include "drivingstatistics.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
std::vector<CRGB> leds;
|
||||
uint8_t gHue = 0;
|
||||
uint8_t gLedPosition = 0;
|
||||
|
||||
uint16_t blinkAnimation = LEDSTRIP_OVERWRITE_NONE;
|
||||
|
||||
@ -225,6 +227,8 @@ void showAnimation()
|
||||
case LedstripAnimation::BetterRainbow: showBetterRainbow(); break;
|
||||
case LedstripAnimation::SpeedSync: showSpeedSyncAnimation(); break;
|
||||
case LedstripAnimation::CustomColor: showCustomColor(); break;
|
||||
case LedstripAnimation::SnakeAnimation: showSnakeAnimation(); break;
|
||||
case LedstripAnimation::EfficiencyAnimation: showEfficiencyAnimation(); break;
|
||||
default: showDefaultLedstrip();
|
||||
}
|
||||
}
|
||||
@ -324,6 +328,25 @@ void showDefaultLedstrip()
|
||||
}
|
||||
}
|
||||
|
||||
void showSnakeAnimation()
|
||||
{
|
||||
fadeToBlackBy(&*std::begin(leds), leds.size(), 20);
|
||||
if(gLedPosition == leds.size()){gLedPosition = 0;}
|
||||
uint8_t snake_2_pos = floor(leds.size()/2) + gLedPosition;
|
||||
if(snake_2_pos > leds.size()){snake_2_pos -= leds.size();}
|
||||
if(gHue == 255){gHue = 0;}
|
||||
leds[gLedPosition] |= CHSV(gHue, 255, 255);
|
||||
leds[snake_2_pos] |= CHSV(gHue, 255, 255);
|
||||
gLedPosition += 1;
|
||||
gHue += 5;
|
||||
}
|
||||
|
||||
void showEfficiencyAnimation()
|
||||
{
|
||||
uint16_t color = getEfficiencyClassColor();
|
||||
std::fill(std::begin(leds), std::end(leds), CRGB(((((color >> 11) & 0x1F) * 527) + 23) >> 6, ((((color >> 5) & 0x3F) * 259) + 33) >> 6, (((color & 0x1F) * 527) + 23) >> 6));
|
||||
}
|
||||
|
||||
void showCustomColor()
|
||||
{
|
||||
const auto eighth_length = leds.size() / 8;
|
||||
|
@ -20,7 +20,9 @@ DECLARE_BOBBYTYPESAFE_ENUM(OtaAnimationModes, : uint8_t, OtaAnimationModesValues
|
||||
x(DefaultRainbow) \
|
||||
x(BetterRainbow) \
|
||||
x(SpeedSync) \
|
||||
x(CustomColor)
|
||||
x(CustomColor) \
|
||||
x(SnakeAnimation) \
|
||||
x(EfficiencyAnimation)
|
||||
DECLARE_BOBBYTYPESAFE_ENUM(LedstripAnimation, : uint8_t, LedstripAnimationValues)
|
||||
|
||||
enum Bobbycar_Side
|
||||
@ -45,6 +47,8 @@ void showAnimation();
|
||||
void showBetterRainbow();
|
||||
void showSpeedSyncAnimation();
|
||||
void showCustomColor();
|
||||
void showSnakeAnimation();
|
||||
void showEfficiencyAnimation();
|
||||
void showOtaAnimation();
|
||||
|
||||
void initLedStrip();
|
||||
|
Reference in New Issue
Block a user