impove led animation switch

This commit is contained in:
Peter Poetzi
2021-09-30 21:56:45 +02:00
parent 21ba6b4d97
commit 99796ab6ac
6 changed files with 18 additions and 8 deletions

View File

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

View File

@ -92,5 +92,5 @@ set(BOBBYCAR_BUILDFLAGS
-DPINS_LEDSTRIP=33
-DLEDSTRIP_LENGTH=288
# -DLEDSTRIP_WRONG_DIRECTION
# -DLEDSTRIP_ANIMATION_DEFAULT=0
)
-DLEDSTRIP_ANIMATION_DEFAULT=1
)

View File

@ -45,8 +45,8 @@ public:
bool &profile2{this->at(DPAD_5WIRESW_PROFILE2)};
bool &profile3{this->at(DPAD_5WIRESW_PROFILE3)};
bool &blink_left{this->at(DPAD_5WIRESW_BLINK_RIGHT)};
bool &blink_right{this->at(DPAD_5WIRESW_BLINK_LEFT)};
bool &blink_left{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_up{this->at(DPAD_5WIRESW_QUICKACTION_UP)};
};

View File

@ -23,6 +23,7 @@ void showSpeedSyncAnimation();
void initLedStrip()
{
animation_type = settings.ledstrip.animationType;
leds.resize(settings.ledstrip.ledsCount);
FastLED.addLeds<NEOPIXEL, PINS_LEDSTRIP>(&*std::begin(leds), leds.size())
.setCorrection(TypicalSMD5050);
@ -41,7 +42,7 @@ void updateLedStrip()
auto color = CRGB{255, 255, 0};
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
#ifdef LEDSTRIP_WRONG_DIRECTION
#ifndef LEDSTRIP_WRONG_DIRECTION
if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKRIGHT)
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKLEFT)

View File

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

View File

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