From 99796ab6ac2d13397354cc63476dd775e760fd7b Mon Sep 17 00:00:00 2001 From: Peter Poetzi Date: Thu, 30 Sep 2021 21:56:45 +0200 Subject: [PATCH] impove led animation switch --- config_comred.cmake | 2 +- config_peter.cmake | 4 ++-- main/dpad5wire_2out.h | 4 ++-- main/ledstrip.h | 3 ++- main/presets.h | 9 ++++++++- main/settings.h | 4 +++- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/config_comred.cmake b/config_comred.cmake index 37392a9..2026453 100644 --- a/config_comred.cmake +++ b/config_comred.cmake @@ -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 ) diff --git a/config_peter.cmake b/config_peter.cmake index 957f7a8..ff8db9e 100644 --- a/config_peter.cmake +++ b/config_peter.cmake @@ -92,5 +92,5 @@ set(BOBBYCAR_BUILDFLAGS -DPINS_LEDSTRIP=33 -DLEDSTRIP_LENGTH=288 # -DLEDSTRIP_WRONG_DIRECTION - # -DLEDSTRIP_ANIMATION_DEFAULT=0 - ) + -DLEDSTRIP_ANIMATION_DEFAULT=1 +) diff --git a/main/dpad5wire_2out.h b/main/dpad5wire_2out.h index 968f0ec..96e870b 100644 --- a/main/dpad5wire_2out.h +++ b/main/dpad5wire_2out.h @@ -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)}; }; diff --git a/main/ledstrip.h b/main/ledstrip.h index 992709b..4e8aca1 100644 --- a/main/ledstrip.h +++ b/main/ledstrip.h @@ -23,6 +23,7 @@ void showSpeedSyncAnimation(); void initLedStrip() { + animation_type = settings.ledstrip.animationType; leds.resize(settings.ledstrip.ledsCount); FastLED.addLeds(&*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) diff --git a/main/presets.h b/main/presets.h index fdf29fb..460a290 100644 --- a/main/presets.h +++ b/main/presets.h @@ -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 diff --git a/main/settings.h b/main/settings.h index 1d331c7..d7936dd 100644 --- a/main/settings.h +++ b/main/settings.h @@ -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);