Merge pull request #90 from bobbycar-graz/feature_ledstrip_brightness_blinker

Feature ledstrip brightness + blinker
This commit is contained in:
Peter Pötzi
2021-09-30 14:41:43 +02:00
committed by GitHub
16 changed files with 83 additions and 9 deletions

View File

@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [feedc0de, comred]
node: [feedc0de, comred, peter]
steps:
- name: Checkout (without submodules)
uses: actions/checkout@v2

View File

@ -88,4 +88,5 @@ set(BOBBYCAR_BUILDFLAGS
-DPINS_LEDSTRIP=33
-DLEDSTRIP_LENGTH=121
-DHEAP_LRGST_CRASH_TEXT_FIX
-DLEDSTRIP_WRONG_DIRECTION
)

View File

@ -87,4 +87,5 @@ set(BOBBYCAR_BUILDFLAGS
-DFEATURE_LEDSTRIP
-DPINS_LEDSTRIP=26
-DLEDSTRIP_LENGTH=200
# -DLEDSTRIP_WRONG_DIRECTION
)

View File

@ -88,4 +88,5 @@ set(BOBBYCAR_BUILDFLAGS
-DPINS_LEDSTRIP=33
-DLEDSTRIP_LENGTH=121
-DLEDSTRIP_DEFAULT_BRIGHTNESS=100
# -DLEDSTRIP_WRONG_DIRECTION
)

View File

@ -86,4 +86,5 @@ set(BOBBYCAR_BUILDFLAGS
-DFEATURE_WIRELESS_CONFIG
# -DFEATURE_LEDSTRIP
# -DPINS_LEDSTRIP=26
# -DLEDSTRIP_WRONG_DIRECTION
)

View File

@ -81,14 +81,15 @@ set(BOBBYCAR_BUILDFLAGS
# -DDEFAULT_GAMETRAKDISTMIN=0
# -DDEFAULT_GAMETRAKDISTMAX=4095
# -DFEATURE_POWERSUPPLY
# -DFEATURE_CLOUD
-DFEATURE_CLOUD
-DFEATURE_LEDBACKLIGHT
-DPINS_LEDBACKLIGHT=23
-DLEDBACKLIGHT_INVERTED
# -DFEATURE_GARAGE
# -DFEATURE_NTP
-DFEATURE_GARAGE
-DFEATURE_NTP
-DFEATURE_WIRELESS_CONFIG
-DFEATURE_LEDSTRIP
-DPINS_LEDSTRIP=33
-DLEDSTRIP_LENGTH=288
# -DLEDSTRIP_WRONG_DIRECTION
)

View File

@ -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 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 DeziampereAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.deziampere; } };
#endif
struct LockscreenAllowPresetSwitchAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.lockscreen.allowPresetSwitch; } };

View File

@ -12,7 +12,7 @@ namespace {
class LedstripAnimationDefaultRainbowAction : public virtual ActionInterface
{
public:
void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_DEFAULTRAINBOW; }
void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_DEFAULT; }
};
class LedstripAnimationBlinkLeftAction : public virtual ActionInterface

View File

@ -8,6 +8,11 @@
// local includes
#include "settingsutils.h"
#include "ledstripdefines.h"
#ifdef FEATURE_LEDSTRIP
#include "ledstrip.h"
#endif
namespace {
@ -133,5 +138,44 @@ public:
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){
}
};
}

View File

@ -70,6 +70,14 @@ using BigOffsetChangeScreen = makeComponent<
SwitchScreenAction<LedstripMenu>
>;
using DeziampereChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_LEDSTRIP_MILLIAMP>,
DeziampereAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
class LedstripMenu :
public MenuDisplay,
public StaticText<TEXT_LEDSTRIP>,
@ -86,6 +94,7 @@ public:
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>();
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>>>();
}
};

View File

@ -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;
}
}

View File

@ -38,6 +38,14 @@ void updateLedStrip()
auto color = CRGB{255, 255, 0};
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)
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKRIGHT)
@ -78,6 +86,7 @@ void updateLedStrip()
}
}
FastLED.setMaxPowerInVoltsAndMilliamps(5,settings.ledstrip.deziampere * 100);
FastLED.show();
}

View File

@ -2,9 +2,7 @@
/*
* 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_BLINKRIGHT 2
#define LEDSTRIP_ANIMATION_BLINKBOTH 3
#define LEDSTRIP_ANIMATION_DEFAULT LEDSTRIP_ANIMATION_DEFAULTRAINBOW

View File

@ -229,7 +229,8 @@ constexpr Settings::Ledstrip defaultLedstrip {
.ledsCount = LEDSTRIP_LENGTH,
.centerOffset = 1,
.smallOffset = 4,
.bigOffset = 10
.bigOffset = 10,
.deziampere = 30
};
#endif

View File

@ -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);

View File

@ -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";
//LedstripSelectAnimationMenu