implement LED strip brightness and blinker
This commit is contained in:
@ -88,4 +88,5 @@ set(BOBBYCAR_BUILDFLAGS
|
|||||||
-DPINS_LEDSTRIP=33
|
-DPINS_LEDSTRIP=33
|
||||||
-DLEDSTRIP_LENGTH=121
|
-DLEDSTRIP_LENGTH=121
|
||||||
-DHEAP_LRGST_CRASH_TEXT_FIX
|
-DHEAP_LRGST_CRASH_TEXT_FIX
|
||||||
|
-DLEDSTRIP_WRONG_DIRECTION
|
||||||
)
|
)
|
||||||
|
@ -87,4 +87,5 @@ set(BOBBYCAR_BUILDFLAGS
|
|||||||
-DFEATURE_LEDSTRIP
|
-DFEATURE_LEDSTRIP
|
||||||
-DPINS_LEDSTRIP=26
|
-DPINS_LEDSTRIP=26
|
||||||
-DLEDSTRIP_LENGTH=200
|
-DLEDSTRIP_LENGTH=200
|
||||||
|
# -DLEDSTRIP_WRONG_DIRECTION
|
||||||
)
|
)
|
||||||
|
@ -88,4 +88,5 @@ set(BOBBYCAR_BUILDFLAGS
|
|||||||
-DPINS_LEDSTRIP=33
|
-DPINS_LEDSTRIP=33
|
||||||
-DLEDSTRIP_LENGTH=121
|
-DLEDSTRIP_LENGTH=121
|
||||||
-DLEDSTRIP_DEFAULT_BRIGHTNESS=100
|
-DLEDSTRIP_DEFAULT_BRIGHTNESS=100
|
||||||
|
# -DLEDSTRIP_WRONG_DIRECTION
|
||||||
)
|
)
|
||||||
|
@ -86,4 +86,5 @@ set(BOBBYCAR_BUILDFLAGS
|
|||||||
-DFEATURE_WIRELESS_CONFIG
|
-DFEATURE_WIRELESS_CONFIG
|
||||||
# -DFEATURE_LEDSTRIP
|
# -DFEATURE_LEDSTRIP
|
||||||
# -DPINS_LEDSTRIP=26
|
# -DPINS_LEDSTRIP=26
|
||||||
|
# -DLEDSTRIP_WRONG_DIRECTION
|
||||||
)
|
)
|
||||||
|
@ -91,4 +91,5 @@ set(BOBBYCAR_BUILDFLAGS
|
|||||||
-DFEATURE_LEDSTRIP
|
-DFEATURE_LEDSTRIP
|
||||||
-DPINS_LEDSTRIP=33
|
-DPINS_LEDSTRIP=33
|
||||||
-DLEDSTRIP_LENGTH=288
|
-DLEDSTRIP_LENGTH=288
|
||||||
|
# -DLEDSTRIP_WRONG_DIRECTION
|
||||||
)
|
)
|
||||||
|
@ -157,6 +157,7 @@ struct LedsCountAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &ge
|
|||||||
struct CenterOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.centerOffset; } };
|
struct CenterOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.centerOffset; } };
|
||||||
struct SmallOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.smallOffset; } };
|
struct SmallOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.smallOffset; } };
|
||||||
struct BigOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.bigOffset; } };
|
struct BigOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.bigOffset; } };
|
||||||
|
struct DeziampereAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.deziampere; } };
|
||||||
#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; } };
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
// local includes
|
// local includes
|
||||||
#include "settingsutils.h"
|
#include "settingsutils.h"
|
||||||
|
|
||||||
|
#ifdef FEATURE_LEDSTRIP
|
||||||
|
#include "ledstrip.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int rotated{};
|
int rotated{};
|
||||||
@ -133,5 +137,56 @@ public:
|
|||||||
|
|
||||||
switchProfile(index);
|
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){
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,14 @@ using BigOffsetChangeScreen = makeComponent<
|
|||||||
SwitchScreenAction<LedstripMenu>
|
SwitchScreenAction<LedstripMenu>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
using DeziampereChangeScreen = makeComponent<
|
||||||
|
ChangeValueDisplay<int16_t>,
|
||||||
|
StaticText<TEXT_LEDSTRIP_MILLIAMP>,
|
||||||
|
DeziampereAccessor,
|
||||||
|
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
|
||||||
|
SwitchScreenAction<LedstripMenu>
|
||||||
|
>;
|
||||||
|
|
||||||
class LedstripMenu :
|
class LedstripMenu :
|
||||||
public MenuDisplay,
|
public MenuDisplay,
|
||||||
public StaticText<TEXT_LEDSTRIP>,
|
public StaticText<TEXT_LEDSTRIP>,
|
||||||
@ -83,6 +91,7 @@ public:
|
|||||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>();
|
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>();
|
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BIGOFFSET, BigOffsetAccessor>, SwitchScreenAction<BigOffsetChangeScreen>>>();
|
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BIGOFFSET, BigOffsetAccessor>, SwitchScreenAction<BigOffsetChangeScreen>>>();
|
||||||
|
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>>>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -227,24 +227,28 @@ void update()
|
|||||||
if (lastState.blink_left != newState.blink_left && now - debounceBlinkLeft > dpadDebounce)
|
if (lastState.blink_left != newState.blink_left && now - debounceBlinkLeft > dpadDebounce)
|
||||||
{
|
{
|
||||||
lastState.blink_left = newState.blink_left;
|
lastState.blink_left = newState.blink_left;
|
||||||
|
InputDispatcher::blinkLeftButton(newState.blink_left);
|
||||||
debounceBlinkLeft = now;
|
debounceBlinkLeft = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastState.blink_right != newState.blink_right && now - debounceBlinkRight > dpadDebounce)
|
if (lastState.blink_right != newState.blink_right && now - debounceBlinkRight > dpadDebounce)
|
||||||
{
|
{
|
||||||
lastState.blink_right = newState.blink_right;
|
lastState.blink_right = newState.blink_right;
|
||||||
|
InputDispatcher::blinkRightButton(newState.blink_right);
|
||||||
debounceBlinkRight = now;
|
debounceBlinkRight = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastState.quickaction_down != newState.quickaction_down && now - debounceQuickactionDown > dpadDebounce)
|
if (lastState.quickaction_down != newState.quickaction_down && now - debounceQuickactionDown > dpadDebounce)
|
||||||
{
|
{
|
||||||
lastState.quickaction_down = newState.quickaction_down;
|
lastState.quickaction_down = newState.quickaction_down;
|
||||||
|
InputDispatcher::quickActionButtonDown(newState.quickaction_down);
|
||||||
debounceQuickactionDown = now;
|
debounceQuickactionDown = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastState.quickaction_up != newState.quickaction_up && now - debounceQuickactionUp > dpadDebounce)
|
if (lastState.quickaction_up != newState.quickaction_up && now - debounceQuickactionUp > dpadDebounce)
|
||||||
{
|
{
|
||||||
lastState.quickaction_up = newState.quickaction_up;
|
lastState.quickaction_up = newState.quickaction_up;
|
||||||
|
InputDispatcher::quickActionButtonUp(newState.quickaction_up);
|
||||||
debounceQuickactionUp = now;
|
debounceQuickactionUp = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,7 @@ void updateLedStrip()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FastLED.setMaxPowerInVoltsAndMilliamps(5,settings.ledstrip.deziampere * 100);
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +229,8 @@ constexpr Settings::Ledstrip defaultLedstrip {
|
|||||||
.ledsCount = LEDSTRIP_LENGTH,
|
.ledsCount = LEDSTRIP_LENGTH,
|
||||||
.centerOffset = 1,
|
.centerOffset = 1,
|
||||||
.smallOffset = 4,
|
.smallOffset = 4,
|
||||||
.bigOffset = 10
|
.bigOffset = 10,
|
||||||
|
.deziampere = 30
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -160,6 +160,7 @@ struct Settings
|
|||||||
int16_t centerOffset;
|
int16_t centerOffset;
|
||||||
int16_t smallOffset;
|
int16_t smallOffset;
|
||||||
int16_t bigOffset;
|
int16_t bigOffset;
|
||||||
|
int16_t deziampere;
|
||||||
} ledstrip;
|
} ledstrip;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -258,6 +259,7 @@ void Settings::executeForEveryCommonSetting(T &&callable)
|
|||||||
callable("centerOffset", ledstrip.centerOffset);
|
callable("centerOffset", ledstrip.centerOffset);
|
||||||
callable("smallOffset", ledstrip.smallOffset);
|
callable("smallOffset", ledstrip.smallOffset);
|
||||||
callable("bigOffset", ledstrip.bigOffset);
|
callable("bigOffset", ledstrip.bigOffset);
|
||||||
|
callable("deziampere", ledstrip.deziampere);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
callable("lockAlwPresetSw", lockscreen.allowPresetSwitch);
|
callable("lockAlwPresetSw", lockscreen.allowPresetSwitch);
|
||||||
|
@ -247,6 +247,7 @@ constexpr char TEXT_LEDSCOUNT[] = "LEDs Count";
|
|||||||
constexpr char TEXT_CENTEROFFSET[] = "Center Offset";
|
constexpr char TEXT_CENTEROFFSET[] = "Center Offset";
|
||||||
constexpr char TEXT_SMALLOFFSET[] = "Small Offset";
|
constexpr char TEXT_SMALLOFFSET[] = "Small Offset";
|
||||||
constexpr char TEXT_BIGOFFSET[] = "Big Offset";
|
constexpr char TEXT_BIGOFFSET[] = "Big Offset";
|
||||||
|
constexpr char TEXT_LEDSTRIP_MILLIAMP[] = "Ledstrip 0.1A";
|
||||||
//constexpr char TEXT_BACK[] = "Back";
|
//constexpr char TEXT_BACK[] = "Back";
|
||||||
|
|
||||||
//LockscreenSettingsMenu
|
//LockscreenSettingsMenu
|
||||||
|
Reference in New Issue
Block a user