street lightning

This commit is contained in:
Peter Poetzi
2021-10-09 16:19:24 +02:00
parent 0b758da0f0
commit ec326e9679
6 changed files with 52 additions and 1 deletions

View File

@ -160,6 +160,9 @@ struct BigOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &ge
struct DeziampereAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.deziampere; } };
struct EnableBeepWhenBlinkAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableBeepWhenBlink; } };
struct EnableFullBlinkAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableFullBlink; } };
struct EnableLedstripStVOAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableStVO; } };
struct LedsStVOFrontOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.stvoFrontOffset; } };
struct LedsStVOFrontLengthAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.stvoFrontLength; } };
#endif
struct LockscreenAllowPresetSwitchAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.lockscreen.allowPresetSwitch; } };

View File

@ -68,6 +68,22 @@ using DeziampereChangeScreen = makeComponent<
SwitchScreenAction<LedstripMenu>
>;
using StVOOffsetChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_STVO_FRONTOFFSET>,
LedsStVOFrontOffsetAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using StVOLengthChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_STVO_FRONTLENGTH>,
LedsStVOFrontLengthAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
class LedstripMenu :
public MenuDisplay,
public StaticText<TEXT_LEDSTRIP>,
@ -80,6 +96,11 @@ public:
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BRAKELIGHTS>, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKBEEP>, ToggleBoolAction, CheckboxIcon, EnableBeepWhenBlinkAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FULLBLINK>, ToggleBoolAction, CheckboxIcon, EnableFullBlinkAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP_STVO>, ToggleBoolAction, CheckboxIcon, EnableLedstripStVOAccessor>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_STVO_FRONTOFFSET, LedsStVOFrontOffsetAccessor>, SwitchScreenAction<StVOOffsetChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_STVO_FRONTLENGTH, LedsStVOFrontLengthAccessor>, SwitchScreenAction<StVOLengthChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKANIMATION>, SwitchScreenAction<LedstripSelectBlinkMenu>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>(); }

View File

@ -1,4 +1,5 @@
#pragma once
#define FEATURE_LEDSTRIP
#ifdef FEATURE_LEDSTRIP
// 3rdparty lib includes
#include <FastLED.h>
@ -121,6 +122,20 @@ void updateLedStrip()
}
else if ((cpputils::is_in(blinkAnimation, LEDSTRIP_OVERWRITE_BLINKLEFT, LEDSTRIP_OVERWRITE_BLINKRIGHT, LEDSTRIP_OVERWRITE_BLINKBOTH)) && settings.ledstrip.enableBeepWhenBlink) have_disabled_beeper = false;
if (simplified || settings.ledstrip.enableStVO)
{
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, CRGB{0, 0, 0});
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, CRGB{0, 0, 0});
std::fill(center - settings.ledstrip.bigOffset - 2U, center - settings.ledstrip.smallOffset - 2U, CRGB{255, 0, 0});
std::fill(center + settings.ledstrip.smallOffset + 2U, center + settings.ledstrip.bigOffset + 2U, CRGB{255, 0, 0});
std::fill(std::begin(leds) + settings.ledstrip.stvoFrontOffset, std::begin(leds) + settings.ledstrip.stvoFrontOffset + settings.ledstrip.stvoFrontLength, CRGB{255, 255, 255});
std::fill(std::end(leds) - settings.ledstrip.stvoFrontOffset - settings.ledstrip.stvoFrontLength, std::end(leds) - settings.ledstrip.stvoFrontOffset, CRGB{255, 255, 255});
}
FastLED.setMaxPowerInVoltsAndMilliamps(5,settings.ledstrip.deziampere * 100);
FastLED.show();
}

View File

@ -238,7 +238,10 @@ constexpr Settings::Ledstrip defaultLedstrip {
#else
.animationType = LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW,
#endif
.enableFullBlink = false
.enableFullBlink = false,
.enableStVO = false,
.stvoFrontOffset = 0,
.stvoFrontLength = 10
};
#endif

View File

@ -163,6 +163,9 @@ struct Settings
bool enableBeepWhenBlink;
int16_t animationType;
bool enableFullBlink;
bool enableStVO;
int16_t stvoFrontOffset;
int16_t stvoFrontLength;
} ledstrip;
#endif
@ -265,6 +268,9 @@ void Settings::executeForEveryCommonSetting(T &&callable)
callable("beeppwhenblink", ledstrip.enableBeepWhenBlink);
// callable("animationType", ledstrip.animationType);
callable("fullblink", ledstrip.enableFullBlink);
callable("ledstvo", ledstrip.enableStVO);
callable("ledstvofoff", ledstrip.stvoFrontOffset);
callable("ledstvoflen", ledstrip.stvoFrontLength);
#endif
callable("lockAlwPresetSw", lockscreen.allowPresetSwitch);

View File

@ -251,6 +251,9 @@ constexpr char TEXT_BIGOFFSET[] = "Big Offset";
constexpr char TEXT_LEDSTRIP_MILLIAMP[] = "Ledstrip 0.1A";
constexpr char TEXT_BLINKBEEP[] = "Blink Beep";
constexpr char TEXT_FULLBLINK[] = "Full blink";
constexpr char TEXT_LEDSTRIP_STVO[] = "Enable StVO";
constexpr char TEXT_STVO_FRONTOFFSET[] = "StVO Front Offset";
constexpr char TEXT_STVO_FRONTLENGTH[] = "StVO Front Length";
//constexpr char TEXT_BACK[] = "Back";
//LedstripSelectAnimationMenu