Merge pull request #90 from bobbycar-graz/feature_ledstrip_brightness_blinker
Feature ledstrip brightness + blinker
This commit is contained in:
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
node: [feedc0de, comred]
|
node: [feedc0de, comred, peter]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout (without submodules)
|
- name: Checkout (without submodules)
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
@ -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
|
||||||
)
|
)
|
||||||
|
@ -81,14 +81,15 @@ set(BOBBYCAR_BUILDFLAGS
|
|||||||
# -DDEFAULT_GAMETRAKDISTMIN=0
|
# -DDEFAULT_GAMETRAKDISTMIN=0
|
||||||
# -DDEFAULT_GAMETRAKDISTMAX=4095
|
# -DDEFAULT_GAMETRAKDISTMAX=4095
|
||||||
# -DFEATURE_POWERSUPPLY
|
# -DFEATURE_POWERSUPPLY
|
||||||
# -DFEATURE_CLOUD
|
-DFEATURE_CLOUD
|
||||||
-DFEATURE_LEDBACKLIGHT
|
-DFEATURE_LEDBACKLIGHT
|
||||||
-DPINS_LEDBACKLIGHT=23
|
-DPINS_LEDBACKLIGHT=23
|
||||||
-DLEDBACKLIGHT_INVERTED
|
-DLEDBACKLIGHT_INVERTED
|
||||||
# -DFEATURE_GARAGE
|
-DFEATURE_GARAGE
|
||||||
# -DFEATURE_NTP
|
-DFEATURE_NTP
|
||||||
-DFEATURE_WIRELESS_CONFIG
|
-DFEATURE_WIRELESS_CONFIG
|
||||||
-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; } };
|
||||||
|
@ -12,7 +12,7 @@ namespace {
|
|||||||
class LedstripAnimationDefaultRainbowAction : public virtual ActionInterface
|
class LedstripAnimationDefaultRainbowAction : public virtual ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_DEFAULTRAINBOW; }
|
void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_DEFAULT; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class LedstripAnimationBlinkLeftAction : public virtual ActionInterface
|
class LedstripAnimationBlinkLeftAction : public virtual ActionInterface
|
||||||
|
@ -8,6 +8,11 @@
|
|||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "settingsutils.h"
|
#include "settingsutils.h"
|
||||||
|
#include "ledstripdefines.h"
|
||||||
|
|
||||||
|
#ifdef FEATURE_LEDSTRIP
|
||||||
|
#include "ledstrip.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -133,5 +138,44 @@ public:
|
|||||||
|
|
||||||
switchProfile(index);
|
switchProfile(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void blinkLeftButton(bool pressed){
|
||||||
|
if(!pressed)return;
|
||||||
|
|
||||||
|
#ifdef FEATURE_LEDSTRIP
|
||||||
|
if(blinkAnimation == LEDSTRIP_ANIMATION_DEFAULT){ //transition from off to left
|
||||||
|
blinkAnimation = LEDSTRIP_ANIMATION_BLINKLEFT;
|
||||||
|
}
|
||||||
|
else if(blinkAnimation == LEDSTRIP_ANIMATION_BLINKRIGHT){ // transition to warning
|
||||||
|
blinkAnimation = LEDSTRIP_ANIMATION_BLINKBOTH;
|
||||||
|
}
|
||||||
|
else{ // transition to off
|
||||||
|
blinkAnimation = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void blinkRightButton(bool pressed){
|
||||||
|
if(!pressed)return;
|
||||||
|
#ifdef FEATURE_LEDSTRIP
|
||||||
|
if(blinkAnimation == LEDSTRIP_ANIMATION_DEFAULT){ //transition from off to right
|
||||||
|
blinkAnimation = LEDSTRIP_ANIMATION_BLINKRIGHT;
|
||||||
|
}
|
||||||
|
else if(blinkAnimation == LEDSTRIP_ANIMATION_BLINKLEFT){ // transition to warning
|
||||||
|
blinkAnimation = LEDSTRIP_ANIMATION_BLINKBOTH;
|
||||||
|
}
|
||||||
|
else{ // transition to off
|
||||||
|
blinkAnimation = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void quickActionButtonDown(bool pressed){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void quickActionButtonUp(bool pressed){
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,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>,
|
||||||
@ -86,6 +94,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,14 @@ void updateLedStrip()
|
|||||||
auto color = CRGB{255, 255, 0};
|
auto color = CRGB{255, 255, 0};
|
||||||
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
|
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
|
||||||
|
|
||||||
|
#ifdef LEDSTRIP_WRONG_DIRECTION
|
||||||
|
if(blinkAnimation == LEDSTRIP_ANIMATION_BLINKLEFT){
|
||||||
|
blinkAnimation = LEDSTRIP_ANIMATION_BLINKRIGHT;
|
||||||
|
} else if(blinkAnimation == LEDSTRIP_ANIMATION_BLINKRIGHT){
|
||||||
|
blinkAnimation = LEDSTRIP_ANIMATION_BLINKLEFT;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKLEFT)
|
if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKLEFT)
|
||||||
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
|
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
|
||||||
if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKRIGHT)
|
if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKRIGHT)
|
||||||
@ -78,6 +86,7 @@ void updateLedStrip()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FastLED.setMaxPowerInVoltsAndMilliamps(5,settings.ledstrip.deziampere * 100);
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file contains a few defines, so you don't have to remember which ledstrip animation is which number
|
* This file contains a few defines, so you don't have to remember which ledstrip animation is which number
|
||||||
*/
|
*/
|
||||||
#define LEDSTRIP_ANIMATION_DEFAULTRAINBOW 0
|
#define LEDSTRIP_ANIMATION_DEFAULT 0
|
||||||
#define LEDSTRIP_ANIMATION_BLINKLEFT 1
|
#define LEDSTRIP_ANIMATION_BLINKLEFT 1
|
||||||
#define LEDSTRIP_ANIMATION_BLINKRIGHT 2
|
#define LEDSTRIP_ANIMATION_BLINKRIGHT 2
|
||||||
#define LEDSTRIP_ANIMATION_BLINKBOTH 3
|
#define LEDSTRIP_ANIMATION_BLINKBOTH 3
|
||||||
|
|
||||||
#define LEDSTRIP_ANIMATION_DEFAULT LEDSTRIP_ANIMATION_DEFAULTRAINBOW
|
|
||||||
|
@ -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";
|
||||||
|
|
||||||
//LedstripSelectAnimationMenu
|
//LedstripSelectAnimationMenu
|
||||||
|
Reference in New Issue
Block a user