Merge pull request #98 from bobbycar-graz/blink-styles
Added beep-blink, 6Wire and more
This commit is contained in:
@ -159,6 +159,7 @@ struct SmallOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &
|
|||||||
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; } };
|
struct DeziampereAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.deziampere; } };
|
||||||
struct EnableBeepWhenBlinkAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableBeepWhenBlink; } };
|
struct EnableBeepWhenBlinkAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableBeepWhenBlink; } };
|
||||||
|
struct EnableFullBlinkAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableFullBlink; } };
|
||||||
#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; } };
|
||||||
|
@ -18,13 +18,29 @@ public:
|
|||||||
class LedstripAnimationBlinkLeftAction : public virtual ActionInterface
|
class LedstripAnimationBlinkLeftAction : public virtual ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void triggered() override { blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT; }
|
#ifndef LEDSTRIP_WRONG_DIRECTION
|
||||||
|
void triggered() override {
|
||||||
|
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void triggered() override {
|
||||||
|
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class LedstripAnimationBlinkRightAction : public virtual ActionInterface
|
class LedstripAnimationBlinkRightAction : public virtual ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void triggered() override { blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT; }
|
#ifndef LEDSTRIP_WRONG_DIRECTION
|
||||||
|
void triggered() override {
|
||||||
|
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void triggered() override {
|
||||||
|
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class LedstripAnimationBlinkBothAction : public virtual ActionInterface
|
class LedstripAnimationBlinkBothAction : public virtual ActionInterface
|
||||||
|
@ -78,6 +78,8 @@ public:
|
|||||||
{
|
{
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDANIMATION>, ToggleBoolAction, CheckboxIcon, EnableLedAnimationAccessor>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDANIMATION>, ToggleBoolAction, CheckboxIcon, EnableLedAnimationAccessor>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BRAKELIGHTS>, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BRAKELIGHTS>, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKBEEP>, ToggleBoolAction, CheckboxIcon, EnableBeepWhenBlinkAccessor>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FULLBLINK>, ToggleBoolAction, CheckboxIcon, EnableFullBlinkAccessor>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKANIMATION>, SwitchScreenAction<LedstripSelectBlinkMenu>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKANIMATION>, SwitchScreenAction<LedstripSelectBlinkMenu>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>();
|
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>();
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#define FEATURE_DPAD_6WIRESW
|
|
||||||
// system includes
|
// system includes
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#define FEATURE_LEDSTRIP
|
||||||
#ifdef FEATURE_LEDSTRIP
|
#ifdef FEATURE_LEDSTRIP
|
||||||
// 3rdparty lib includes
|
// 3rdparty lib includes
|
||||||
#include <FastLED.h>
|
#include <FastLED.h>
|
||||||
@ -32,37 +33,43 @@ void initLedStrip()
|
|||||||
void updateLedStrip()
|
void updateLedStrip()
|
||||||
{
|
{
|
||||||
EVERY_N_MILLISECONDS( 20 ) { gHue++; }
|
EVERY_N_MILLISECONDS( 20 ) { gHue++; }
|
||||||
|
static bool have_disabled_beeper = false;
|
||||||
|
|
||||||
if (cpputils::is_in(blinkAnimation, LEDSTRIP_OVERWRITE_BLINKLEFT, LEDSTRIP_OVERWRITE_BLINKRIGHT, LEDSTRIP_OVERWRITE_BLINKBOTH))
|
if (cpputils::is_in(blinkAnimation, LEDSTRIP_OVERWRITE_BLINKLEFT, LEDSTRIP_OVERWRITE_BLINKRIGHT, LEDSTRIP_OVERWRITE_BLINKBOTH))
|
||||||
{
|
{
|
||||||
std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
|
std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
|
||||||
|
|
||||||
if (espchrono::millis_clock::now().time_since_epoch() % 750ms < 375ms)
|
if (espchrono::millis_clock::now().time_since_epoch() % 750ms < 375ms)
|
||||||
{
|
{
|
||||||
if (settings.ledstrip.enableBeepWhenBlink)
|
if (settings.ledstrip.enableBeepWhenBlink)
|
||||||
{
|
{
|
||||||
for (Controller &controller : controllers)
|
for (Controller &controller : controllers)
|
||||||
controller.command.buzzer.freq = 3;
|
controller.command.buzzer.freq = 3;
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
|
||||||
#ifndef LEDSTRIP_WRONG_DIRECTION
|
if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKRIGHT && !settings.ledstrip.enableFullBlink)
|
||||||
if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKRIGHT)
|
{
|
||||||
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_OVERWRITE_BLINKLEFT)
|
}
|
||||||
|
else if(blinkAnimation != LEDSTRIP_OVERWRITE_BLINKRIGHT && settings.ledstrip.enableFullBlink)
|
||||||
|
{
|
||||||
|
std::fill(std::begin(leds), center, color);
|
||||||
|
}
|
||||||
|
if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKLEFT && !settings.ledstrip.enableFullBlink)
|
||||||
|
{
|
||||||
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
|
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
|
||||||
#else
|
}
|
||||||
if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKLEFT)
|
else if(blinkAnimation != LEDSTRIP_OVERWRITE_BLINKLEFT && settings.ledstrip.enableFullBlink)
|
||||||
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
|
{
|
||||||
if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKRIGHT)
|
std::fill(center, std::end(leds), color);
|
||||||
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
|
}
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
if (settings.ledstrip.enableBeepWhenBlink)
|
if (settings.ledstrip.enableBeepWhenBlink)
|
||||||
{
|
{
|
||||||
for (Controller &controller : controllers)
|
for (Controller &controller : controllers)
|
||||||
controller.command.buzzer.freq = 0;
|
controller.command.buzzer.freq = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,8 +93,15 @@ void updateLedStrip()
|
|||||||
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
|
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
|
||||||
|
|
||||||
std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
|
std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
|
||||||
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
|
if (settings.ledstrip.enableFullBlink)
|
||||||
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
|
{
|
||||||
|
std::fill(std::begin(leds), std::end(leds), color);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
|
||||||
|
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -100,6 +114,14 @@ void updateLedStrip()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (have_disabled_beeper == false && (!(cpputils::is_in(blinkAnimation, LEDSTRIP_OVERWRITE_BLINKLEFT, LEDSTRIP_OVERWRITE_BLINKRIGHT, LEDSTRIP_OVERWRITE_BLINKBOTH)) || !settings.ledstrip.enableBeepWhenBlink))
|
||||||
|
{
|
||||||
|
for (Controller &controller : controllers)
|
||||||
|
controller.command.buzzer.freq = 0;
|
||||||
|
have_disabled_beeper = true;
|
||||||
|
}
|
||||||
|
else if ((cpputils::is_in(blinkAnimation, LEDSTRIP_OVERWRITE_BLINKLEFT, LEDSTRIP_OVERWRITE_BLINKRIGHT, LEDSTRIP_OVERWRITE_BLINKBOTH)) && settings.ledstrip.enableBeepWhenBlink) have_disabled_beeper = false;
|
||||||
|
|
||||||
FastLED.setMaxPowerInVoltsAndMilliamps(5,settings.ledstrip.deziampere * 100);
|
FastLED.setMaxPowerInVoltsAndMilliamps(5,settings.ledstrip.deziampere * 100);
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define LEDSTRIP_OVERWRITE_NONE 0
|
#define LEDSTRIP_OVERWRITE_NONE 0
|
||||||
#define LEDSTRIP_OVERWRITE_BLINKLEFT 1
|
#ifndef LEDSTRIP_WRONG_DIRECTION
|
||||||
|
#define LEDSTRIP_OVERWRITE_BLINKLEFT 1
|
||||||
#define LEDSTRIP_OVERWRITE_BLINKRIGHT 2
|
#define LEDSTRIP_OVERWRITE_BLINKRIGHT 2
|
||||||
#define LEDSTRIP_OVERWRITE_BLINKBOTH 3
|
#else
|
||||||
|
#define LEDSTRIP_OVERWRITE_BLINKLEFT 2
|
||||||
|
#define LEDSTRIP_OVERWRITE_BLINKRIGHT 1
|
||||||
|
#endif
|
||||||
|
#define LEDSTRIP_OVERWRITE_BLINKBOTH 3
|
||||||
|
|
||||||
|
|
||||||
#define LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW 0
|
#define LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW 0
|
||||||
|
@ -234,10 +234,11 @@ constexpr Settings::Ledstrip defaultLedstrip {
|
|||||||
.deziampere = 30,
|
.deziampere = 30,
|
||||||
.enableBeepWhenBlink = false,
|
.enableBeepWhenBlink = false,
|
||||||
#ifdef LEDSTRIP_ANIMATION_DEFAULT
|
#ifdef LEDSTRIP_ANIMATION_DEFAULT
|
||||||
.animationType = LEDSTRIP_ANIMATION_DEFAULT
|
.animationType = LEDSTRIP_ANIMATION_DEFAULT,
|
||||||
#else
|
#else
|
||||||
.animationType = LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW
|
.animationType = LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW,
|
||||||
#endif
|
#endif
|
||||||
|
.enableFullBlink = false
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -163,6 +163,7 @@ struct Settings
|
|||||||
int16_t deziampere;
|
int16_t deziampere;
|
||||||
bool enableBeepWhenBlink;
|
bool enableBeepWhenBlink;
|
||||||
int16_t animationType;
|
int16_t animationType;
|
||||||
|
bool enableFullBlink;
|
||||||
} ledstrip;
|
} ledstrip;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -264,6 +265,7 @@ void Settings::executeForEveryCommonSetting(T &&callable)
|
|||||||
callable("deziampere", ledstrip.deziampere);
|
callable("deziampere", ledstrip.deziampere);
|
||||||
callable("beeppwhenblink", ledstrip.enableBeepWhenBlink);
|
callable("beeppwhenblink", ledstrip.enableBeepWhenBlink);
|
||||||
// callable("animationType", ledstrip.animationType);
|
// callable("animationType", ledstrip.animationType);
|
||||||
|
callable("fullblink", ledstrip.enableFullBlink);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
callable("lockAlwPresetSw", lockscreen.allowPresetSwitch);
|
callable("lockAlwPresetSw", lockscreen.allowPresetSwitch);
|
||||||
|
@ -250,6 +250,7 @@ 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_LEDSTRIP_MILLIAMP[] = "Ledstrip 0.1A";
|
||||||
constexpr char TEXT_BLINKBEEP[] = "Blink Beep";
|
constexpr char TEXT_BLINKBEEP[] = "Blink Beep";
|
||||||
|
constexpr char TEXT_FULLBLINK[] = "Full blink";
|
||||||
//constexpr char TEXT_BACK[] = "Back";
|
//constexpr char TEXT_BACK[] = "Back";
|
||||||
|
|
||||||
//LedstripSelectAnimationMenu
|
//LedstripSelectAnimationMenu
|
||||||
|
Reference in New Issue
Block a user