diff --git a/config_comred.cmake b/config_comred.cmake index 8b47ba7..ed4ee8a 100644 --- a/config_comred.cmake +++ b/config_comred.cmake @@ -88,4 +88,5 @@ set(BOBBYCAR_BUILDFLAGS -DPINS_LEDSTRIP=33 -DLEDSTRIP_LENGTH=121 -DHEAP_LRGST_CRASH_TEXT_FIX + -DLEDSTRIP_WRONG_DIRECTION ) diff --git a/config_feedc0de.cmake b/config_feedc0de.cmake index 5075ca9..afaa1e8 100644 --- a/config_feedc0de.cmake +++ b/config_feedc0de.cmake @@ -87,4 +87,5 @@ set(BOBBYCAR_BUILDFLAGS -DFEATURE_LEDSTRIP -DPINS_LEDSTRIP=26 -DLEDSTRIP_LENGTH=200 +# -DLEDSTRIP_WRONG_DIRECTION ) diff --git a/config_greyhash.cmake b/config_greyhash.cmake index 3c7b912..edddb12 100644 --- a/config_greyhash.cmake +++ b/config_greyhash.cmake @@ -88,4 +88,5 @@ set(BOBBYCAR_BUILDFLAGS -DPINS_LEDSTRIP=33 -DLEDSTRIP_LENGTH=121 -DLEDSTRIP_DEFAULT_BRIGHTNESS=100 +# -DLEDSTRIP_WRONG_DIRECTION ) diff --git a/config_mick.cmake b/config_mick.cmake index 24dd97d..2c9b451 100644 --- a/config_mick.cmake +++ b/config_mick.cmake @@ -86,4 +86,5 @@ set(BOBBYCAR_BUILDFLAGS -DFEATURE_WIRELESS_CONFIG # -DFEATURE_LEDSTRIP # -DPINS_LEDSTRIP=26 +# -DLEDSTRIP_WRONG_DIRECTION ) diff --git a/config_peter.cmake b/config_peter.cmake index 0618d86..b191378 100644 --- a/config_peter.cmake +++ b/config_peter.cmake @@ -91,4 +91,5 @@ set(BOBBYCAR_BUILDFLAGS -DFEATURE_LEDSTRIP -DPINS_LEDSTRIP=33 -DLEDSTRIP_LENGTH=288 + # -DLEDSTRIP_WRONG_DIRECTION ) diff --git a/main/accessors/settingsaccessors.h b/main/accessors/settingsaccessors.h index 9676250..2a7efd5 100644 --- a/main/accessors/settingsaccessors.h +++ b/main/accessors/settingsaccessors.h @@ -157,6 +157,7 @@ struct LedsCountAccessor : public RefAccessorSaveSettings { int16_t &ge struct CenterOffsetAccessor : public RefAccessorSaveSettings { int16_t &getRef() const override { return settings.ledstrip.centerOffset; } }; struct SmallOffsetAccessor : public RefAccessorSaveSettings { int16_t &getRef() const override { return settings.ledstrip.smallOffset; } }; struct BigOffsetAccessor : public RefAccessorSaveSettings { int16_t &getRef() const override { return settings.ledstrip.bigOffset; } }; +struct DeziampereAccessor : public RefAccessorSaveSettings { int16_t &getRef() const override { return settings.ledstrip.deziampere; } }; #endif struct LockscreenAllowPresetSwitchAccessor : public RefAccessorSaveSettings { bool &getRef() const override { return settings.lockscreen.allowPresetSwitch; } }; diff --git a/main/buttons.h b/main/buttons.h index 2188b53..44d7aa0 100644 --- a/main/buttons.h +++ b/main/buttons.h @@ -9,6 +9,10 @@ // local includes #include "settingsutils.h" +#ifdef FEATURE_LEDSTRIP +#include "ledstrip.h" +#endif + namespace { int rotated{}; @@ -133,5 +137,56 @@ public: switchProfile(index); } + + static void blinkLeftButton(bool pressed){ + if(!pressed)return; + +#ifdef FEATURE_LEDSTRIP + +#ifdef LEDSTRIP_WRONG_DIRECTION + const auto target_blinkAnimation = 1; +#else + const auto target_blinkAnimation = 2; +#endif + if(blinkAnimation == 0){ //transition from off to left + blinkAnimation = target_blinkAnimation; + } + else if(blinkAnimation == 3 - target_blinkAnimation){ // transition to warning + blinkAnimation = 3; + } + else{ // transition to off + blinkAnimation = 0; + } +#endif + } + + static void blinkRightButton(bool pressed){ + if(!pressed)return; +#ifdef FEATURE_LEDSTRIP + + #ifdef LEDSTRIP_WRONG_DIRECTION + const auto target_blinkAnimation = 2; +#else + const auto target_blinkAnimation = 1; +#endif + if(blinkAnimation == 0){ //transition from off to left + blinkAnimation = target_blinkAnimation; + } + else if(blinkAnimation == 3 - target_blinkAnimation){ // transition to warning + blinkAnimation = 3; + } + else{ // transition to off + blinkAnimation = 0; + } +#endif + } + + static void quickActionButtonDown(bool pressed){ + + } + + static void quickActionButtonUp(bool pressed){ + + } }; } diff --git a/main/displays/menus/ledstripmenu.h b/main/displays/menus/ledstripmenu.h index b56fb9a..23e0ace 100644 --- a/main/displays/menus/ledstripmenu.h +++ b/main/displays/menus/ledstripmenu.h @@ -68,6 +68,14 @@ using BigOffsetChangeScreen = makeComponent< SwitchScreenAction >; +using DeziampereChangeScreen = makeComponent< + ChangeValueDisplay, + StaticText, + DeziampereAccessor, + BackActionInterface>, + SwitchScreenAction +>; + class LedstripMenu : public MenuDisplay, public StaticText, @@ -83,6 +91,7 @@ public: constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction>>(); + constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); } }; diff --git a/main/dpad5wire_2out.h b/main/dpad5wire_2out.h index 9b6702d..968f0ec 100644 --- a/main/dpad5wire_2out.h +++ b/main/dpad5wire_2out.h @@ -227,24 +227,28 @@ void update() if (lastState.blink_left != newState.blink_left && now - debounceBlinkLeft > dpadDebounce) { lastState.blink_left = newState.blink_left; + InputDispatcher::blinkLeftButton(newState.blink_left); debounceBlinkLeft = now; } if (lastState.blink_right != newState.blink_right && now - debounceBlinkRight > dpadDebounce) { lastState.blink_right = newState.blink_right; + InputDispatcher::blinkRightButton(newState.blink_right); debounceBlinkRight = now; } if (lastState.quickaction_down != newState.quickaction_down && now - debounceQuickactionDown > dpadDebounce) { lastState.quickaction_down = newState.quickaction_down; + InputDispatcher::quickActionButtonDown(newState.quickaction_down); debounceQuickactionDown = now; } if (lastState.quickaction_up != newState.quickaction_up && now - debounceQuickactionUp > dpadDebounce) { lastState.quickaction_up = newState.quickaction_up; + InputDispatcher::quickActionButtonUp(newState.quickaction_up); debounceQuickactionUp = now; } } diff --git a/main/ledstrip.h b/main/ledstrip.h index 4951ce0..a9ca8d4 100644 --- a/main/ledstrip.h +++ b/main/ledstrip.h @@ -77,6 +77,7 @@ void updateLedStrip() } } + FastLED.setMaxPowerInVoltsAndMilliamps(5,settings.ledstrip.deziampere * 100); FastLED.show(); } diff --git a/main/presets.h b/main/presets.h index 1622dc1..fdf29fb 100644 --- a/main/presets.h +++ b/main/presets.h @@ -229,7 +229,8 @@ constexpr Settings::Ledstrip defaultLedstrip { .ledsCount = LEDSTRIP_LENGTH, .centerOffset = 1, .smallOffset = 4, - .bigOffset = 10 + .bigOffset = 10, + .deziampere = 30 }; #endif diff --git a/main/settings.h b/main/settings.h index 3a9aa99..1d331c7 100644 --- a/main/settings.h +++ b/main/settings.h @@ -160,6 +160,7 @@ struct Settings int16_t centerOffset; int16_t smallOffset; int16_t bigOffset; + int16_t deziampere; } ledstrip; #endif @@ -258,6 +259,7 @@ void Settings::executeForEveryCommonSetting(T &&callable) callable("centerOffset", ledstrip.centerOffset); callable("smallOffset", ledstrip.smallOffset); callable("bigOffset", ledstrip.bigOffset); + callable("deziampere", ledstrip.deziampere); #endif callable("lockAlwPresetSw", lockscreen.allowPresetSwitch); diff --git a/main/texts.h b/main/texts.h index 262c8df..a2aab9b 100644 --- a/main/texts.h +++ b/main/texts.h @@ -247,6 +247,7 @@ constexpr char TEXT_LEDSCOUNT[] = "LEDs Count"; constexpr char TEXT_CENTEROFFSET[] = "Center Offset"; constexpr char TEXT_SMALLOFFSET[] = "Small Offset"; constexpr char TEXT_BIGOFFSET[] = "Big Offset"; +constexpr char TEXT_LEDSTRIP_MILLIAMP[] = "Ledstrip 0.1A"; //constexpr char TEXT_BACK[] = "Back"; //LockscreenSettingsMenu