Added led brightness and animation speed

This commit is contained in:
CommanderRedYT
2021-10-09 20:57:06 +02:00
parent ec326e9679
commit 2c77b55275
7 changed files with 53 additions and 7 deletions

View File

@@ -163,6 +163,9 @@ struct EnableFullBlinkAccessor : public RefAccessorSaveSettings<bool> { bool &ge
struct EnableLedstripStVOAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableStVO; } }; 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 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; } }; struct LedsStVOFrontLengthAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.stvoFrontLength; } };
struct EnableLedstripStVOFrontlight : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.stvoFrontEnable; } };
struct AnimationMultiplierAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.animationMultiplier; } };
struct LedstripBrightnessAccessor : public RefAccessorSaveSettings<uint8_t> { uint8_t &getRef() const override { return settings.ledstrip.brightness; } };
#endif #endif
struct LockscreenAllowPresetSwitchAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.lockscreen.allowPresetSwitch; } }; struct LockscreenAllowPresetSwitchAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.lockscreen.allowPresetSwitch; } };

View File

@@ -84,6 +84,22 @@ using StVOLengthChangeScreen = makeComponent<
SwitchScreenAction<LedstripMenu> SwitchScreenAction<LedstripMenu>
>; >;
using animationMultiplierChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_ANIMATION_MULTIPLIER>,
AnimationMultiplierAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using ledstripBrightnessChangeScreen = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_LEDSTRIP_BRIGHTNESS>,
LedstripBrightnessAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
class LedstripMenu : class LedstripMenu :
public MenuDisplay, public MenuDisplay,
public StaticText<TEXT_LEDSTRIP>, public StaticText<TEXT_LEDSTRIP>,
@@ -103,10 +119,12 @@ public:
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKANIMATION>, SwitchScreenAction<LedstripSelectBlinkMenu>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKANIMATION>, SwitchScreenAction<LedstripSelectBlinkMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_MULTIPLIER>, SwitchScreenAction<animationMultiplierChangeScreen>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>(); } if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>(); } if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>(); } if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BIGOFFSET, BigOffsetAccessor>, SwitchScreenAction<BigOffsetChangeScreen>>>(); } if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BIGOFFSET, BigOffsetAccessor>, SwitchScreenAction<BigOffsetChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP_BRIGHTNESS>, SwitchScreenAction<ledstripBrightnessChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSTRIP_MILLIAMP, DeziampereAccessor>, SwitchScreenAction<DeziampereChangeScreen>>>(); } if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSTRIP_MILLIAMP, DeziampereAccessor>, SwitchScreenAction<DeziampereChangeScreen>>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
} }

View File

@@ -126,17 +126,26 @@ void updateLedStrip()
{ {
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset); 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}); if (!(blinkAnimation == LEDSTRIP_OVERWRITE_BLINKLEFT || blinkAnimation == LEDSTRIP_OVERWRITE_BLINKBOTH) || !(espchrono::millis_clock::now().time_since_epoch() % 750ms < 375ms) || settings.ledstrip.enableFullBlink) // Condition for right
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, CRGB{0, 0, 0}); {
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, 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.bigOffset - 1U, center - settings.ledstrip.smallOffset - 1U, CRGB{255, 0, 0}); // Right
std::fill(center + settings.ledstrip.smallOffset + 2U, center + settings.ledstrip.bigOffset + 2U, CRGB{255, 0, 0}); }
if (!(blinkAnimation == LEDSTRIP_OVERWRITE_BLINKRIGHT || blinkAnimation == LEDSTRIP_OVERWRITE_BLINKBOTH) || !(espchrono::millis_clock::now().time_since_epoch() % 750ms < 375ms) || settings.ledstrip.enableFullBlink) // Condition for left
{
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, CRGB{0, 0, 0});
std::fill(center + settings.ledstrip.smallOffset + 1U, center + settings.ledstrip.bigOffset + 1U, CRGB{255, 0, 0}); // Left
}
if (settings.ledstrip.stvoFrontEnable)
{
std::fill(std::begin(leds) + settings.ledstrip.stvoFrontOffset, std::begin(leds) + settings.ledstrip.stvoFrontOffset + settings.ledstrip.stvoFrontLength, CRGB{255, 255, 255}); 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}); 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.setMaxPowerInVoltsAndMilliamps(5,settings.ledstrip.deziampere * 100);
FastLED.setBrightness(settings.ledstrip.brightness);
FastLED.show(); FastLED.show();
} }
@@ -190,7 +199,7 @@ void showSpeedSyncAnimation() {
static float hue_result = 0; static float hue_result = 0;
const float hue_per_led = .1; const float hue_per_led = 1. / std::max(uint8_t(1), uint8_t(settings.ledstrip.animationMultiplier));
const float meter_per_second = avgSpeedKmh / 3.6; const float meter_per_second = avgSpeedKmh / 3.6;
const float leds_per_second = meter_per_second * leds_per_meter; const float leds_per_second = meter_per_second * leds_per_meter;
const float hue_per_second = leds_per_second * hue_per_led; const float hue_per_second = leds_per_second * hue_per_led;

View File

@@ -241,7 +241,10 @@ constexpr Settings::Ledstrip defaultLedstrip {
.enableFullBlink = false, .enableFullBlink = false,
.enableStVO = false, .enableStVO = false,
.stvoFrontOffset = 0, .stvoFrontOffset = 0,
.stvoFrontLength = 10 .stvoFrontLength = 10,
.stvoFrontEnable = false,
.animationMultiplier = 10,
.brightness = 255
}; };
#endif #endif

View File

@@ -166,6 +166,12 @@ struct Settings
bool enableStVO; bool enableStVO;
int16_t stvoFrontOffset; int16_t stvoFrontOffset;
int16_t stvoFrontLength; int16_t stvoFrontLength;
<<<<<<< HEAD
=======
bool stvoFrontEnable;
int16_t animationMultiplier;
uint8_t brightness;
>>>>>>> 3dff172 (Added led brightness and animation speed)
} ledstrip; } ledstrip;
#endif #endif
@@ -271,6 +277,9 @@ void Settings::executeForEveryCommonSetting(T &&callable)
callable("ledstvo", ledstrip.enableStVO); callable("ledstvo", ledstrip.enableStVO);
callable("ledstvofoff", ledstrip.stvoFrontOffset); callable("ledstvofoff", ledstrip.stvoFrontOffset);
callable("ledstvoflen", ledstrip.stvoFrontLength); callable("ledstvoflen", ledstrip.stvoFrontLength);
callable("ledstvoen", ledstrip.stvoFrontEnable);
callable("ledAnimMultiplier", ledstrip.animationMultiplier);
callable("ledbrightness", ledstrip.brightness);
#endif #endif
callable("lockAlwPresetSw", lockscreen.allowPresetSwitch); callable("lockAlwPresetSw", lockscreen.allowPresetSwitch);

View File

@@ -17,6 +17,7 @@ void switchProfile(uint8_t index)
if (index == SIMPLIFIED_TRIGGER_TRIGGERONPRESET) if (index == SIMPLIFIED_TRIGGER_TRIGGERONPRESET)
{ {
simplified = true; simplified = true;
return;
} }
#endif #endif

View File

@@ -254,6 +254,9 @@ constexpr char TEXT_FULLBLINK[] = "Full blink";
constexpr char TEXT_LEDSTRIP_STVO[] = "Enable StVO"; constexpr char TEXT_LEDSTRIP_STVO[] = "Enable StVO";
constexpr char TEXT_STVO_FRONTOFFSET[] = "StVO Front Offset"; constexpr char TEXT_STVO_FRONTOFFSET[] = "StVO Front Offset";
constexpr char TEXT_STVO_FRONTLENGTH[] = "StVO Front Length"; constexpr char TEXT_STVO_FRONTLENGTH[] = "StVO Front Length";
constexpr char TEXT_STVO_ENABLEFRONTLIGHT[] = "StVO Front Enable";
constexpr char TEXT_ANIMATION_MULTIPLIER[] = "Animation Multiplier";
constexpr char TEXT_LEDSTRIP_BRIGHTNESS[] = "Ledstrip Brightness";
//constexpr char TEXT_BACK[] = "Back"; //constexpr char TEXT_BACK[] = "Back";
//LedstripSelectAnimationMenu //LedstripSelectAnimationMenu