From ec326e9679d1c41113e579e60024c55df88ce683 Mon Sep 17 00:00:00 2001 From: Peter Poetzi Date: Sat, 9 Oct 2021 16:19:24 +0200 Subject: [PATCH 1/3] street lightning --- main/accessors/settingsaccessors.h | 3 +++ main/displays/menus/ledstripmenu.h | 21 +++++++++++++++++++++ main/ledstrip.h | 15 +++++++++++++++ main/presets.h | 5 ++++- main/settings.h | 6 ++++++ main/texts.h | 3 +++ 6 files changed, 52 insertions(+), 1 deletion(-) diff --git a/main/accessors/settingsaccessors.h b/main/accessors/settingsaccessors.h index 3e640c0..4a2d488 100644 --- a/main/accessors/settingsaccessors.h +++ b/main/accessors/settingsaccessors.h @@ -160,6 +160,9 @@ struct BigOffsetAccessor : public RefAccessorSaveSettings { int16_t &ge struct DeziampereAccessor : public RefAccessorSaveSettings { int16_t &getRef() const override { return settings.ledstrip.deziampere; } }; struct EnableBeepWhenBlinkAccessor : public RefAccessorSaveSettings { bool &getRef() const override { return settings.ledstrip.enableBeepWhenBlink; } }; struct EnableFullBlinkAccessor : public RefAccessorSaveSettings { bool &getRef() const override { return settings.ledstrip.enableFullBlink; } }; +struct EnableLedstripStVOAccessor : public RefAccessorSaveSettings { bool &getRef() const override { return settings.ledstrip.enableStVO; } }; +struct LedsStVOFrontOffsetAccessor : public RefAccessorSaveSettings { int16_t &getRef() const override { return settings.ledstrip.stvoFrontOffset; } }; +struct LedsStVOFrontLengthAccessor : public RefAccessorSaveSettings { int16_t &getRef() const override { return settings.ledstrip.stvoFrontLength; } }; #endif struct LockscreenAllowPresetSwitchAccessor : public RefAccessorSaveSettings { bool &getRef() const override { return settings.lockscreen.allowPresetSwitch; } }; diff --git a/main/displays/menus/ledstripmenu.h b/main/displays/menus/ledstripmenu.h index 17d7dc8..45dc742 100644 --- a/main/displays/menus/ledstripmenu.h +++ b/main/displays/menus/ledstripmenu.h @@ -68,6 +68,22 @@ using DeziampereChangeScreen = makeComponent< SwitchScreenAction >; +using StVOOffsetChangeScreen = makeComponent< + ChangeValueDisplay, + StaticText, + LedsStVOFrontOffsetAccessor, + BackActionInterface>, + SwitchScreenAction +>; + +using StVOLengthChangeScreen = makeComponent< + ChangeValueDisplay, + StaticText, + LedsStVOFrontLengthAccessor, + BackActionInterface>, + SwitchScreenAction +>; + class LedstripMenu : public MenuDisplay, public StaticText, @@ -80,6 +96,11 @@ public: constructMenuItem, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>(); constructMenuItem, ToggleBoolAction, CheckboxIcon, EnableBeepWhenBlinkAccessor>>(); constructMenuItem, ToggleBoolAction, CheckboxIcon, EnableFullBlinkAccessor>>(); + + constructMenuItem, ToggleBoolAction, CheckboxIcon, EnableLedstripStVOAccessor>>(); + constructMenuItem, SwitchScreenAction>>(); + constructMenuItem, SwitchScreenAction>>(); + constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction>>(); if (!simplified) { constructMenuItem, SwitchScreenAction>>(); } diff --git a/main/ledstrip.h b/main/ledstrip.h index 9a5e273..42d81a5 100644 --- a/main/ledstrip.h +++ b/main/ledstrip.h @@ -1,4 +1,5 @@ #pragma once +#define FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP // 3rdparty lib includes #include @@ -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(); } diff --git a/main/presets.h b/main/presets.h index fe0640f..0859553 100644 --- a/main/presets.h +++ b/main/presets.h @@ -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 diff --git a/main/settings.h b/main/settings.h index 3424252..4b1af21 100644 --- a/main/settings.h +++ b/main/settings.h @@ -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); diff --git a/main/texts.h b/main/texts.h index 10f6cbc..889f5c0 100644 --- a/main/texts.h +++ b/main/texts.h @@ -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 From 2c77b55275299729c374284b4bee5880b3292a14 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Sat, 9 Oct 2021 20:57:06 +0200 Subject: [PATCH 2/3] Added led brightness and animation speed --- main/accessors/settingsaccessors.h | 3 +++ main/displays/menus/ledstripmenu.h | 18 ++++++++++++++++++ main/ledstrip.h | 21 +++++++++++++++------ main/presets.h | 5 ++++- main/settings.h | 9 +++++++++ main/settingsutils.h | 1 + main/texts.h | 3 +++ 7 files changed, 53 insertions(+), 7 deletions(-) diff --git a/main/accessors/settingsaccessors.h b/main/accessors/settingsaccessors.h index 4a2d488..4bb5e4e 100644 --- a/main/accessors/settingsaccessors.h +++ b/main/accessors/settingsaccessors.h @@ -163,6 +163,9 @@ struct EnableFullBlinkAccessor : public RefAccessorSaveSettings { bool &ge struct EnableLedstripStVOAccessor : public RefAccessorSaveSettings { bool &getRef() const override { return settings.ledstrip.enableStVO; } }; struct LedsStVOFrontOffsetAccessor : public RefAccessorSaveSettings { int16_t &getRef() const override { return settings.ledstrip.stvoFrontOffset; } }; struct LedsStVOFrontLengthAccessor : public RefAccessorSaveSettings { int16_t &getRef() const override { return settings.ledstrip.stvoFrontLength; } }; +struct EnableLedstripStVOFrontlight : public RefAccessorSaveSettings { bool &getRef() const override { return settings.ledstrip.stvoFrontEnable; } }; +struct AnimationMultiplierAccessor : public RefAccessorSaveSettings { int16_t &getRef() const override { return settings.ledstrip.animationMultiplier; } }; +struct LedstripBrightnessAccessor : public RefAccessorSaveSettings { uint8_t &getRef() const override { return settings.ledstrip.brightness; } }; #endif struct LockscreenAllowPresetSwitchAccessor : public RefAccessorSaveSettings { bool &getRef() const override { return settings.lockscreen.allowPresetSwitch; } }; diff --git a/main/displays/menus/ledstripmenu.h b/main/displays/menus/ledstripmenu.h index 45dc742..a85a0fb 100644 --- a/main/displays/menus/ledstripmenu.h +++ b/main/displays/menus/ledstripmenu.h @@ -84,6 +84,22 @@ using StVOLengthChangeScreen = makeComponent< SwitchScreenAction >; +using animationMultiplierChangeScreen = makeComponent< + ChangeValueDisplay, + StaticText, + AnimationMultiplierAccessor, + BackActionInterface>, + SwitchScreenAction +>; + +using ledstripBrightnessChangeScreen = makeComponent< + ChangeValueDisplay, + StaticText, + LedstripBrightnessAccessor, + BackActionInterface>, + SwitchScreenAction +>; + class LedstripMenu : public MenuDisplay, public StaticText, @@ -103,10 +119,12 @@ public: constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction>>(); + constructMenuItem, SwitchScreenAction>>(); if (!simplified) { constructMenuItem, SwitchScreenAction>>(); } if (!simplified) { constructMenuItem, SwitchScreenAction>>(); } if (!simplified) { constructMenuItem, SwitchScreenAction>>(); } if (!simplified) { constructMenuItem, SwitchScreenAction>>(); } + if (!simplified) { constructMenuItem, SwitchScreenAction>>(); } if (!simplified) { constructMenuItem, SwitchScreenAction>>(); } constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); } diff --git a/main/ledstrip.h b/main/ledstrip.h index 42d81a5..6f2b430 100644 --- a/main/ledstrip.h +++ b/main/ledstrip.h @@ -126,17 +126,26 @@ void updateLedStrip() { 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}); + 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.bigOffset, center - settings.ledstrip.smallOffset, CRGB{0, 0, 0}); + std::fill(center - settings.ledstrip.bigOffset - 1U, center - settings.ledstrip.smallOffset - 1U, CRGB{255, 0, 0}); // Right + } + 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::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.setBrightness(settings.ledstrip.brightness); FastLED.show(); } @@ -190,7 +199,7 @@ void showSpeedSyncAnimation() { 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 leds_per_second = meter_per_second * leds_per_meter; const float hue_per_second = leds_per_second * hue_per_led; diff --git a/main/presets.h b/main/presets.h index 0859553..d75cc85 100644 --- a/main/presets.h +++ b/main/presets.h @@ -241,7 +241,10 @@ constexpr Settings::Ledstrip defaultLedstrip { .enableFullBlink = false, .enableStVO = false, .stvoFrontOffset = 0, - .stvoFrontLength = 10 + .stvoFrontLength = 10, + .stvoFrontEnable = false, + .animationMultiplier = 10, + .brightness = 255 }; #endif diff --git a/main/settings.h b/main/settings.h index 4b1af21..c7fc85f 100644 --- a/main/settings.h +++ b/main/settings.h @@ -166,6 +166,12 @@ struct Settings bool enableStVO; int16_t stvoFrontOffset; int16_t stvoFrontLength; +<<<<<<< HEAD +======= + bool stvoFrontEnable; + int16_t animationMultiplier; + uint8_t brightness; +>>>>>>> 3dff172 (Added led brightness and animation speed) } ledstrip; #endif @@ -271,6 +277,9 @@ void Settings::executeForEveryCommonSetting(T &&callable) callable("ledstvo", ledstrip.enableStVO); callable("ledstvofoff", ledstrip.stvoFrontOffset); callable("ledstvoflen", ledstrip.stvoFrontLength); + callable("ledstvoen", ledstrip.stvoFrontEnable); + callable("ledAnimMultiplier", ledstrip.animationMultiplier); + callable("ledbrightness", ledstrip.brightness); #endif callable("lockAlwPresetSw", lockscreen.allowPresetSwitch); diff --git a/main/settingsutils.h b/main/settingsutils.h index c06e19f..96bcb5e 100644 --- a/main/settingsutils.h +++ b/main/settingsutils.h @@ -17,6 +17,7 @@ void switchProfile(uint8_t index) if (index == SIMPLIFIED_TRIGGER_TRIGGERONPRESET) { simplified = true; + return; } #endif diff --git a/main/texts.h b/main/texts.h index 889f5c0..383719c 100644 --- a/main/texts.h +++ b/main/texts.h @@ -254,6 +254,9 @@ 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_STVO_ENABLEFRONTLIGHT[] = "StVO Front Enable"; +constexpr char TEXT_ANIMATION_MULTIPLIER[] = "Animation Multiplier"; +constexpr char TEXT_LEDSTRIP_BRIGHTNESS[] = "Ledstrip Brightness"; //constexpr char TEXT_BACK[] = "Back"; //LedstripSelectAnimationMenu From 8dc5665d5d1e58fb6847438dc73c6a12e33d7c08 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Sun, 10 Oct 2021 00:30:06 +0200 Subject: [PATCH 3/3] Forgot merge thingy --- main/settings.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/main/settings.h b/main/settings.h index c7fc85f..6d92256 100644 --- a/main/settings.h +++ b/main/settings.h @@ -166,12 +166,9 @@ struct Settings bool enableStVO; int16_t stvoFrontOffset; int16_t stvoFrontLength; -<<<<<<< HEAD -======= bool stvoFrontEnable; int16_t animationMultiplier; uint8_t brightness; ->>>>>>> 3dff172 (Added led brightness and animation speed) } ledstrip; #endif