Merge pull request #95 from bobbycar-graz/more-animations

More animations
This commit is contained in:
Peter Pötzi
2021-09-30 22:30:26 +02:00
committed by GitHub
17 changed files with 261 additions and 151 deletions

View File

@ -89,4 +89,5 @@ set(BOBBYCAR_BUILDFLAGS
-DLEDSTRIP_LENGTH=121 -DLEDSTRIP_LENGTH=121
-DHEAP_LRGST_CRASH_TEXT_FIX -DHEAP_LRGST_CRASH_TEXT_FIX
-DLEDSTRIP_WRONG_DIRECTION -DLEDSTRIP_WRONG_DIRECTION
-DLEDSTRIP_ANIMATION_DEFAULT=1
) )

View File

@ -88,4 +88,5 @@ set(BOBBYCAR_BUILDFLAGS
-DPINS_LEDSTRIP=26 -DPINS_LEDSTRIP=26
-DLEDSTRIP_LENGTH=200 -DLEDSTRIP_LENGTH=200
# -DLEDSTRIP_WRONG_DIRECTION # -DLEDSTRIP_WRONG_DIRECTION
# -DLEDSTRIP_ANIMATION_DEFAULT=0
) )

View File

@ -89,4 +89,5 @@ set(BOBBYCAR_BUILDFLAGS
-DLEDSTRIP_LENGTH=121 -DLEDSTRIP_LENGTH=121
-DLEDSTRIP_DEFAULT_BRIGHTNESS=100 -DLEDSTRIP_DEFAULT_BRIGHTNESS=100
# -DLEDSTRIP_WRONG_DIRECTION # -DLEDSTRIP_WRONG_DIRECTION
# -DLEDSTRIP_ANIMATION_DEFAULT=0
) )

View File

@ -87,4 +87,5 @@ set(BOBBYCAR_BUILDFLAGS
# -DFEATURE_LEDSTRIP # -DFEATURE_LEDSTRIP
# -DPINS_LEDSTRIP=26 # -DPINS_LEDSTRIP=26
# -DLEDSTRIP_WRONG_DIRECTION # -DLEDSTRIP_WRONG_DIRECTION
# -DLEDSTRIP_ANIMATION_DEFAULT=0
) )

View File

@ -1,95 +1,96 @@
set(BOBBY_APP_NAME bobbyquad_peter) set(BOBBY_APP_NAME bobbyquad_peter)
add_definitions( add_definitions(
-DUSER_SETUP_LOADED=1 -DUSER_SETUP_LOADED=1
-DLOAD_GLCD=1 -DLOAD_GLCD=1
-DLOAD_FONT2=1 -DLOAD_FONT2=1
-DLOAD_FONT4=1 -DLOAD_FONT4=1
-DLOAD_FONT7=1 -DLOAD_FONT7=1
-DILI9341_DRIVER=1 -DILI9341_DRIVER=1
-DTFT_MOSI=13 -DTFT_MOSI=13
-DTFT_SCLK=15 -DTFT_SCLK=15
-DTFT_CS=14 -DTFT_CS=14
-DTFT_DC=12 -DTFT_DC=12
-DTFT_RST=2 -DTFT_RST=2
-DSPI_FREQUENCY=27000000 -DSPI_FREQUENCY=27000000
) )
set(BOBBYCAR_BUILDFLAGS set(BOBBYCAR_BUILDFLAGS
-DFEATURE_ADC_IN -DFEATURE_ADC_IN
-DPINS_GAS=34 -DPINS_GAS=34
-DPINS_BREMS=35 -DPINS_BREMS=35
-DDEFAULT_SWAPSCREENBYTES=false -DDEFAULT_SWAPSCREENBYTES=false
-DFEATURE_CAN -DFEATURE_CAN
# -DFEATURE_SERIAL # -DFEATURE_SERIAL
# -DPINS_RX1=4 # -DPINS_RX1=4
# -DPINS_TX1=5 # -DPINS_TX1=5
# -DPINS_RX2=22 # -DPINS_RX2=22
# -DPINS_TX2=23 # -DPINS_TX2=23
-DDEFAULT_INVERTFRONTLEFT=false -DDEFAULT_INVERTFRONTLEFT=false
-DDEFAULT_INVERTFRONTRIGHT=true -DDEFAULT_INVERTFRONTRIGHT=true
-DDEFAULT_INVERTBACKLEFT=false -DDEFAULT_INVERTBACKLEFT=false
-DDEFAULT_INVERTBACKRIGHT=true -DDEFAULT_INVERTBACKRIGHT=true
-DDEFAULT_WHEELDIAMETER=200 -DDEFAULT_WHEELDIAMETER=200
# -DFEATURE_MOSFETS # -DFEATURE_MOSFETS
# -DPINS_MOSFET0=18 # -DPINS_MOSFET0=18
# -DPINS_MOSFET1=19 # -DPINS_MOSFET1=19
# -DPINS_MOSFET2=21 # -DPINS_MOSFET2=21
-DDEFAULT_IMOTMAX=28 -DDEFAULT_IMOTMAX=28
-DDEFAULT_IDCMAX=30 -DDEFAULT_IDCMAX=30
-DDEFAULT_NMOTMAX=2000 -DDEFAULT_NMOTMAX=2000
-DDEFAULT_FIELDWEAKMAX=7 -DDEFAULT_FIELDWEAKMAX=7
-DDEFAULT_FIELDADVMAX=40 -DDEFAULT_FIELDADVMAX=40
-DDEVICE_PREFIX=peter_bobbyquad -DDEVICE_PREFIX=peter_bobbyquad
-DAP_PASSWORD=Passwort_123 -DAP_PASSWORD=Passwort_123
-DFEATURE_WEBSERVER -DFEATURE_WEBSERVER
-DFEATURE_OTA -DFEATURE_OTA
-DFEATURE_DPAD_5WIRESW_2OUT -DFEATURE_DPAD_5WIRESW_2OUT
-DPINS_DPAD_5WIRESW_OUT1=18 -DPINS_DPAD_5WIRESW_OUT1=18
-DPINS_DPAD_5WIRESW_OUT2=19 -DPINS_DPAD_5WIRESW_OUT2=19
-DPINS_DPAD_5WIRESW_IN1=4 -DPINS_DPAD_5WIRESW_IN1=4
-DPINS_DPAD_5WIRESW_IN2=5 -DPINS_DPAD_5WIRESW_IN2=5
-DPINS_DPAD_5WIRESW_IN3=27 -DPINS_DPAD_5WIRESW_IN3=27
-DDPAD_5WIRESW_UP=4 -DDPAD_5WIRESW_UP=4
-DDPAD_5WIRESW_DOWN=7 -DDPAD_5WIRESW_DOWN=7
-DDPAD_5WIRESW_CONFIRM=1 -DDPAD_5WIRESW_CONFIRM=1
-DDPAD_5WIRESW_BACK=10 -DDPAD_5WIRESW_BACK=10
-DDPAD_5WIRESW_PROFILE0=11 -DDPAD_5WIRESW_PROFILE0=11
-DDPAD_5WIRESW_PROFILE1=8 -DDPAD_5WIRESW_PROFILE1=8
-DDPAD_5WIRESW_PROFILE2=5 -DDPAD_5WIRESW_PROFILE2=5
-DDPAD_5WIRESW_PROFILE3=2 -DDPAD_5WIRESW_PROFILE3=2
-DDPAD_5WIRESW_BLINK_LEFT=9 -DDPAD_5WIRESW_BLINK_LEFT=9
-DDPAD_5WIRESW_BLINK_RIGHT=0 -DDPAD_5WIRESW_BLINK_RIGHT=0
-DDPAD_5WIRESW_QUICKACTION_DOWN=3 -DDPAD_5WIRESW_QUICKACTION_DOWN=3
-DDPAD_5WIRESW_QUICKACTION_UP=6 -DDPAD_5WIRESW_QUICKACTION_UP=6
# -DDPAD_5WIRESW_DEBUG # -DDPAD_5WIRESW_DEBUG
-DDEFAULT_GASMIN=842 -DDEFAULT_GASMIN=842
-DDEFAULT_GASMAX=2480 -DDEFAULT_GASMAX=2480
-DDEFAULT_BREMSMIN=826 -DDEFAULT_BREMSMIN=826
-DDEFAULT_BREMSMAX=2502 -DDEFAULT_BREMSMAX=2502
-DFEATURE_BLE -DFEATURE_BLE
# -DFEATURE_BLUETOOTH # -DFEATURE_BLUETOOTH
# -DFEATURE_BMS # -DFEATURE_BMS
# -DFEATURE_GAMETRAK # -DFEATURE_GAMETRAK
# -DPINS_GAMETRAKX=34 # -DPINS_GAMETRAKX=34
# -DPINS_GAMETRAKY=39 # -DPINS_GAMETRAKY=39
# -DPINS_GAMETRAKDIST=36 # -DPINS_GAMETRAKDIST=36
# -DDEFAULT_GAMETRAKXMIN=0 # -DDEFAULT_GAMETRAKXMIN=0
# -DDEFAULT_GAMETRAKXMAX=4095 # -DDEFAULT_GAMETRAKXMAX=4095
# -DDEFAULT_GAMETRAKYMIN=0 # -DDEFAULT_GAMETRAKYMIN=0
# -DDEFAULT_GAMETRAKYMAX=4095 # -DDEFAULT_GAMETRAKYMAX=4095
# -DDEFAULT_GAMETRAKDISTMIN=0 # -DDEFAULT_GAMETRAKDISTMIN=0
# -DDEFAULT_GAMETRAKDISTMAX=4095 # -DDEFAULT_GAMETRAKDISTMAX=4095
# -DFEATURE_POWERSUPPLY # -DFEATURE_POWERSUPPLY
-DFEATURE_CLOUD -DFEATURE_CLOUD
-DFEATURE_LEDBACKLIGHT -DFEATURE_LEDBACKLIGHT
-DPINS_LEDBACKLIGHT=23 -DPINS_LEDBACKLIGHT=23
-DLEDBACKLIGHT_INVERTED -DLEDBACKLIGHT_INVERTED
-DFEATURE_GARAGE -DFEATURE_GARAGE
-DFEATURE_NTP -DFEATURE_NTP
-DFEATURE_WIRELESS_CONFIG -DFEATURE_WIRELESS_CONFIG
-DFEATURE_LEDSTRIP -DFEATURE_LEDSTRIP
-DPINS_LEDSTRIP=33 -DPINS_LEDSTRIP=33
-DLEDSTRIP_LENGTH=288 -DLEDSTRIP_LENGTH=288
# -DLEDSTRIP_WRONG_DIRECTION # -DLEDSTRIP_WRONG_DIRECTION
) -DLEDSTRIP_ANIMATION_DEFAULT=1
)

View File

@ -12,24 +12,18 @@ namespace {
class LedstripAnimationDefaultRainbowAction : public virtual ActionInterface class LedstripAnimationDefaultRainbowAction : public virtual ActionInterface
{ {
public: public:
void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_DEFAULT; } void triggered() override { animation_type = LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW; }
}; };
class LedstripAnimationBlinkLeftAction : public virtual ActionInterface class LedstripAnimationBetterRainbowAction : public virtual ActionInterface
{ {
public: public:
void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_BLINKLEFT; } void triggered() override { animation_type = LEDSTRIP_ANIMATION_TYPE_BETTERRAINBOW; }
}; };
class LedstripAnimationBlinkRightAction : public virtual ActionInterface class LedstripAnimationSyncToSpeedAction : public virtual ActionInterface
{ {
public: public:
void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_BLINKRIGHT; } void triggered() override { animation_type = LEDSTRIP_ANIMATION_TYPE_SPEEDSYNCANIMATION; }
};
class LedstripAnimationBlinkBothAction : public virtual ActionInterface
{
public:
void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_BLINKBOTH; }
}; };
} }

View File

@ -0,0 +1,35 @@
#pragma once
#include "actioninterface.h"
#include "utils.h"
#include "globals.h"
#include "ledstrip.h"
#include "ledstripdefines.h"
using namespace espgui;
namespace {
class LedstripAnimationBlinkNoneAction : public virtual ActionInterface
{
public:
void triggered() override { blinkAnimation = LEDSTRIP_OVERWRITE_NONE; }
};
class LedstripAnimationBlinkLeftAction : public virtual ActionInterface
{
public:
void triggered() override { blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT; }
};
class LedstripAnimationBlinkRightAction : public virtual ActionInterface
{
public:
void triggered() override { blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT; }
};
class LedstripAnimationBlinkBothAction : public virtual ActionInterface
{
public:
void triggered() override { blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH; }
};
}

View File

@ -143,14 +143,14 @@ public:
if(!pressed)return; if(!pressed)return;
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
if(blinkAnimation == LEDSTRIP_ANIMATION_DEFAULT){ //transition from off to left if(blinkAnimation == LEDSTRIP_OVERWRITE_NONE){ //transition from off to left
blinkAnimation = LEDSTRIP_ANIMATION_BLINKLEFT; blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT;
} }
else if(blinkAnimation == LEDSTRIP_ANIMATION_BLINKRIGHT){ // transition to warning else if(blinkAnimation == LEDSTRIP_OVERWRITE_BLINKRIGHT){ // transition to warning
blinkAnimation = LEDSTRIP_ANIMATION_BLINKBOTH; blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH;
} }
else{ // transition to off else{ // transition to off
blinkAnimation = 0; blinkAnimation = LEDSTRIP_OVERWRITE_NONE;
} }
#endif #endif
} }
@ -158,14 +158,14 @@ public:
static void blinkRightButton(bool pressed){ static void blinkRightButton(bool pressed){
if(!pressed)return; if(!pressed)return;
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
if(blinkAnimation == LEDSTRIP_ANIMATION_DEFAULT){ //transition from off to right if(blinkAnimation == LEDSTRIP_OVERWRITE_NONE){ //transition from off to right
blinkAnimation = LEDSTRIP_ANIMATION_BLINKRIGHT; blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT;
} }
else if(blinkAnimation == LEDSTRIP_ANIMATION_BLINKLEFT){ // transition to warning else if(blinkAnimation == LEDSTRIP_OVERWRITE_BLINKLEFT){ // transition to warning
blinkAnimation = LEDSTRIP_ANIMATION_BLINKBOTH; blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH;
} }
else{ // transition to off else{ // transition to off
blinkAnimation = 0; blinkAnimation = LEDSTRIP_OVERWRITE_NONE;
} }
#endif #endif
} }

View File

@ -6,6 +6,7 @@
#include "actions/toggleboolaction.h" #include "actions/toggleboolaction.h"
#include "actions/switchscreenaction.h" #include "actions/switchscreenaction.h"
#include "ledstripselectanimationmenu.h" #include "ledstripselectanimationmenu.h"
#include "ledstripselectblinkmenu.h"
#include "texts.h" #include "texts.h"
#include "icons/back.h" #include "icons/back.h"
#include "checkboxicon.h" #include "checkboxicon.h"
@ -28,16 +29,6 @@ namespace {
class LedstripMenu; class LedstripMenu;
class LedstripSelectAnimationMenu; class LedstripSelectAnimationMenu;
struct BlinkAnimationAccessor : public RefAccessor<int16_t> { int16_t &getRef() const override { return blinkAnimation; } };
using BlinkAnimationChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_BLINKANIMATION>,
BlinkAnimationAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using LedsCountChangeScreen = makeComponent< using LedsCountChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>, ChangeValueDisplay<int16_t>,
StaticText<TEXT_LEDSCOUNT>, StaticText<TEXT_LEDSCOUNT>,
@ -86,10 +77,10 @@ class LedstripMenu :
public: public:
LedstripMenu() LedstripMenu()
{ {
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDANIMATION>, ToggleBoolAction, CheckboxIcon, EnableLedAnimationAccessor>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDANIMATION>, ToggleBoolAction, CheckboxIcon, EnableLedAnimationAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BRAKELIGHTS>, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BRAKELIGHTS>, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>();
// constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BLINKANIMATION, BlinkAnimationAccessor>, SwitchScreenAction<BlinkAnimationChangeScreen>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKANIMATION>, SwitchScreenAction<LedstripSelectBlinkMenu>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>(); constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>(); constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>(); constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>();

View File

@ -27,11 +27,10 @@ namespace {
public: public:
LedstripSelectAnimationMenu() LedstripSelectAnimationMenu()
{ {
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_DEFAULTRAINBOW>, LedstripAnimationDefaultRainbowAction>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_DEFAULTRAINBOW>, LedstripAnimationDefaultRainbowAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKLEFT>, LedstripAnimationBlinkLeftAction>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BETTERRAINBOW>, LedstripAnimationBetterRainbowAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKRIGHT>, LedstripAnimationBlinkRightAction>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_SPEEDSYNCANIMATION>, LedstripAnimationSyncToSpeedAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKBOTH>, LedstripAnimationBlinkBothAction>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
} }
}; };
} // Namespace } // Namespace

View File

@ -0,0 +1,37 @@
#pragma once
// Local includes
#include "menudisplay.h"
#include "utils.h"
#include "menuitem.h"
#include "ledstrip.h"
#include "ledstripselectanimationmenu.h"
#include "icons/back.h"
#include "texts.h"
#include "actions/dummyaction.h"
#include "actions/ledstripblinkactions.h"
#include "actions/switchscreenaction.h"
using namespace espgui;
namespace {
class LedstripMenu;
}
namespace {
class LedstripSelectBlinkMenu :
public MenuDisplay,
public StaticText<TEXT_BLINKANIMATION>,
public BackActionInterface<SwitchScreenAction<LedstripMenu>>
{
public:
LedstripSelectBlinkMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKNONE>, LedstripAnimationBlinkNoneAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKLEFT>, LedstripAnimationBlinkLeftAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKRIGHT>, LedstripAnimationBlinkRightAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKBOTH>, LedstripAnimationBlinkBothAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
};
} // Namespace

View File

@ -45,8 +45,8 @@ public:
bool &profile2{this->at(DPAD_5WIRESW_PROFILE2)}; bool &profile2{this->at(DPAD_5WIRESW_PROFILE2)};
bool &profile3{this->at(DPAD_5WIRESW_PROFILE3)}; bool &profile3{this->at(DPAD_5WIRESW_PROFILE3)};
bool &blink_left{this->at(DPAD_5WIRESW_BLINK_RIGHT)}; bool &blink_left{this->at(DPAD_5WIRESW_BLINK_LEFT)};
bool &blink_right{this->at(DPAD_5WIRESW_BLINK_LEFT)}; bool &blink_right{this->at(DPAD_5WIRESW_BLINK_RIGHT)};
bool &quickaction_down{this->at(DPAD_5WIRESW_QUICKACTION_DOWN)}; bool &quickaction_down{this->at(DPAD_5WIRESW_QUICKACTION_DOWN)};
bool &quickaction_up{this->at(DPAD_5WIRESW_QUICKACTION_UP)}; bool &quickaction_up{this->at(DPAD_5WIRESW_QUICKACTION_UP)};
}; };

View File

@ -1,5 +1,4 @@
#pragma once #pragma once
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
// 3rdparty lib includes // 3rdparty lib includes
#include <FastLED.h> #include <FastLED.h>
@ -14,12 +13,17 @@ namespace {
std::vector<CRGB> leds; std::vector<CRGB> leds;
uint8_t gHue = 0; uint8_t gHue = 0;
int16_t blinkAnimation = LEDSTRIP_ANIMATION_DEFAULT; int16_t blinkAnimation = LEDSTRIP_OVERWRITE_NONE;
int16_t animation_type = LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW;
void showDefaultLedstrip(); void showDefaultLedstrip();
void showAnimation();
void showBetterRainbow();
void showSpeedSyncAnimation();
void initLedStrip() void initLedStrip()
{ {
animation_type = settings.ledstrip.animationType;
leds.resize(settings.ledstrip.ledsCount); leds.resize(settings.ledstrip.ledsCount);
FastLED.addLeds<NEOPIXEL, PINS_LEDSTRIP>(&*std::begin(leds), leds.size()) FastLED.addLeds<NEOPIXEL, PINS_LEDSTRIP>(&*std::begin(leds), leds.size())
.setCorrection(TypicalSMD5050); .setCorrection(TypicalSMD5050);
@ -29,7 +33,7 @@ void updateLedStrip()
{ {
EVERY_N_MILLISECONDS( 20 ) { gHue++; } EVERY_N_MILLISECONDS( 20 ) { gHue++; }
if (cpputils::is_in(blinkAnimation, LEDSTRIP_ANIMATION_BLINKLEFT, LEDSTRIP_ANIMATION_BLINKRIGHT, LEDSTRIP_ANIMATION_BLINKBOTH)) if (cpputils::is_in(blinkAnimation, LEDSTRIP_OVERWRITE_BLINKLEFT, LEDSTRIP_OVERWRITE_BLINKRIGHT, LEDSTRIP_OVERWRITE_BLINKBOTH))
{ {
std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0}); std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
@ -38,18 +42,17 @@ void updateLedStrip()
auto color = CRGB{255, 255, 0}; auto color = CRGB{255, 255, 0};
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset); const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
#ifdef LEDSTRIP_WRONG_DIRECTION #ifndef LEDSTRIP_WRONG_DIRECTION
if(blinkAnimation == LEDSTRIP_ANIMATION_BLINKLEFT){ if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKRIGHT)
blinkAnimation = LEDSTRIP_ANIMATION_BLINKRIGHT;
} else if(blinkAnimation == LEDSTRIP_ANIMATION_BLINKRIGHT){
blinkAnimation = LEDSTRIP_ANIMATION_BLINKLEFT;
}
#endif
if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKLEFT)
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color); std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKRIGHT) if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKLEFT)
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color); std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
#else
if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKLEFT)
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKRIGHT)
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
#endif
} }
} }
else else
@ -77,12 +80,12 @@ void updateLedStrip()
} }
else else
{ {
showDefaultLedstrip(); showAnimation();
} }
} }
else else
{ {
showDefaultLedstrip(); showAnimation();
} }
} }
@ -90,6 +93,31 @@ void updateLedStrip()
FastLED.show(); FastLED.show();
} }
void showAnimation() {
if (animation_type == LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW) showDefaultLedstrip();
else if (animation_type == LEDSTRIP_ANIMATION_TYPE_BETTERRAINBOW) showBetterRainbow();
else if (animation_type == LEDSTRIP_ANIMATION_TYPE_SPEEDSYNCANIMATION) showSpeedSyncAnimation();
else showDefaultLedstrip();
}
void showBetterRainbow() {
if (settings.ledstrip.enableLedAnimation)
{
fill_rainbow(&*std::begin(leds), leds.size(), gHue);
}
else
std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
}
void showSpeedSyncAnimation() {
if (settings.ledstrip.enableLedAnimation)
{
// Code that shows static animation relative to the ground
}
else
std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
}
void showDefaultLedstrip() void showDefaultLedstrip()
{ {
if (settings.ledstrip.enableLedAnimation) if (settings.ledstrip.enableLedAnimation)

View File

@ -2,7 +2,13 @@
/* /*
* This file contains a few defines, so you don't have to remember which ledstrip animation is which number * This file contains a few defines, so you don't have to remember which ledstrip animation is which number
*/ */
#define LEDSTRIP_ANIMATION_DEFAULT 0
#define LEDSTRIP_ANIMATION_BLINKLEFT 1 #define LEDSTRIP_OVERWRITE_NONE 0
#define LEDSTRIP_ANIMATION_BLINKRIGHT 2 #define LEDSTRIP_OVERWRITE_BLINKLEFT 1
#define LEDSTRIP_ANIMATION_BLINKBOTH 3 #define LEDSTRIP_OVERWRITE_BLINKRIGHT 2
#define LEDSTRIP_OVERWRITE_BLINKBOTH 3
#define LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW 0
#define LEDSTRIP_ANIMATION_TYPE_BETTERRAINBOW 1
#define LEDSTRIP_ANIMATION_TYPE_SPEEDSYNCANIMATION 2

View File

@ -12,6 +12,7 @@
// local includes // local includes
#include "settings.h" #include "settings.h"
#include "stringsettings.h" #include "stringsettings.h"
#include "ledstripdefines.h"
using namespace std::chrono_literals; using namespace std::chrono_literals;
@ -230,7 +231,13 @@ constexpr Settings::Ledstrip defaultLedstrip {
.centerOffset = 1, .centerOffset = 1,
.smallOffset = 4, .smallOffset = 4,
.bigOffset = 10, .bigOffset = 10,
.deziampere = 30 .deziampere = 30,
#ifdef LEDSTRIP_ANIMATION_DEFAULT
.animationType = LEDSTRIP_ANIMATION_DEFAULT
#else
.animationType = LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW
#endif
}; };
#endif #endif

View File

@ -161,6 +161,7 @@ struct Settings
int16_t smallOffset; int16_t smallOffset;
int16_t bigOffset; int16_t bigOffset;
int16_t deziampere; int16_t deziampere;
int16_t animationType;
} ledstrip; } ledstrip;
#endif #endif
@ -259,7 +260,8 @@ void Settings::executeForEveryCommonSetting(T &&callable)
callable("centerOffset", ledstrip.centerOffset); callable("centerOffset", ledstrip.centerOffset);
callable("smallOffset", ledstrip.smallOffset); callable("smallOffset", ledstrip.smallOffset);
callable("bigOffset", ledstrip.bigOffset); callable("bigOffset", ledstrip.bigOffset);
callable("deziampere", ledstrip.deziampere); //callable("deziampere", ledstrip.deziampere);
callable("animationType", ledstrip.animationType);
#endif #endif
callable("lockAlwPresetSw", lockscreen.allowPresetSwitch); callable("lockAlwPresetSw", lockscreen.allowPresetSwitch);

View File

@ -243,6 +243,7 @@ constexpr char TEXT_LEDSTRIP[] = "Ledstrip";
constexpr char TEXT_LEDANIMATION[] = "LED Animation"; constexpr char TEXT_LEDANIMATION[] = "LED Animation";
constexpr char TEXT_BRAKELIGHTS[] = "Brake Lights"; constexpr char TEXT_BRAKELIGHTS[] = "Brake Lights";
constexpr char TEXT_BLINKANIMATION[] = "Blink animation"; constexpr char TEXT_BLINKANIMATION[] = "Blink animation";
constexpr char TEXT_ANIMATION_TYPE[] = "Blink animation";
constexpr char TEXT_LEDSCOUNT[] = "LEDs Count"; constexpr char TEXT_LEDSCOUNT[] = "LEDs Count";
constexpr char TEXT_CENTEROFFSET[] = "Center Offset"; constexpr char TEXT_CENTEROFFSET[] = "Center Offset";
constexpr char TEXT_SMALLOFFSET[] = "Small Offset"; constexpr char TEXT_SMALLOFFSET[] = "Small Offset";
@ -253,6 +254,11 @@ constexpr char TEXT_LEDSTRIP_MILLIAMP[] = "Ledstrip 0.1A";
//LedstripSelectAnimationMenu //LedstripSelectAnimationMenu
constexpr char TEXT_SELECTANIMATION[] = "Select Animation"; constexpr char TEXT_SELECTANIMATION[] = "Select Animation";
constexpr char TEXT_ANIMATION_DEFAULTRAINBOW[] = "Default Rainbow"; constexpr char TEXT_ANIMATION_DEFAULTRAINBOW[] = "Default Rainbow";
constexpr char TEXT_ANIMATION_BETTERRAINBOW[] = "Better Rainbow";
constexpr char TEXT_ANIMATION_SPEEDSYNCANIMATION[] = "Speed Sync";
//LedstripSelectBlinkMenu
constexpr char TEXT_ANIMATION_BLINKNONE[] = "Blink Off";
constexpr char TEXT_ANIMATION_BLINKLEFT[] = "Blink Left"; constexpr char TEXT_ANIMATION_BLINKLEFT[] = "Blink Left";
constexpr char TEXT_ANIMATION_BLINKRIGHT[] = "Blink Right"; constexpr char TEXT_ANIMATION_BLINKRIGHT[] = "Blink Right";
constexpr char TEXT_ANIMATION_BLINKBOTH[] = "Blink Both"; constexpr char TEXT_ANIMATION_BLINKBOTH[] = "Blink Both";