Merge pull request #94 from bobbycar-graz/blink-beep

Blink beep
This commit is contained in:
Peter Pötzi
2021-09-30 22:37:45 +02:00
committed by GitHub
6 changed files with 18 additions and 4 deletions

View File

@ -158,6 +158,7 @@ struct CenterOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t
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; } };
struct EnableBeepWhenBlinkAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableBeepWhenBlink; } };
#endif
struct LockscreenAllowPresetSwitchAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.lockscreen.allowPresetSwitch; } };

View File

@ -1,5 +1,4 @@
#pragma once
// local includes
#include "menudisplay.h"
#include "menuitem.h"

View File

@ -39,6 +39,11 @@ void updateLedStrip()
if (espchrono::millis_clock::now().time_since_epoch() % 750ms < 375ms)
{
if (settings.ledstrip.enableBeepWhenBlink)
{
for (Controller &controller : controllers)
controller.command.buzzer.freq = 3;
}
auto color = CRGB{255, 255, 0};
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
@ -53,6 +58,12 @@ void updateLedStrip()
if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKRIGHT)
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
#endif
} else {
if (settings.ledstrip.enableBeepWhenBlink)
{
for (Controller &controller : controllers)
controller.command.buzzer.freq = 0;
}
}
}
else

View File

@ -232,12 +232,12 @@ constexpr Settings::Ledstrip defaultLedstrip {
.smallOffset = 4,
.bigOffset = 10,
.deziampere = 30,
.enableBeepWhenBlink = false,
#ifdef LEDSTRIP_ANIMATION_DEFAULT
.animationType = LEDSTRIP_ANIMATION_DEFAULT
#else
.animationType = LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW
#endif
};
#endif

View File

@ -161,6 +161,7 @@ struct Settings
int16_t smallOffset;
int16_t bigOffset;
int16_t deziampere;
bool enableBeepWhenBlink;
int16_t animationType;
} ledstrip;
#endif
@ -260,8 +261,9 @@ void Settings::executeForEveryCommonSetting(T &&callable)
callable("centerOffset", ledstrip.centerOffset);
callable("smallOffset", ledstrip.smallOffset);
callable("bigOffset", ledstrip.bigOffset);
//callable("deziampere", ledstrip.deziampere);
callable("animationType", ledstrip.animationType);
callable("deziampere", ledstrip.deziampere);
callable("beeppwhenblink", ledstrip.enableBeepWhenBlink);
// callable("animationType", ledstrip.animationType);
#endif
callable("lockAlwPresetSw", lockscreen.allowPresetSwitch);

View File

@ -249,6 +249,7 @@ 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_BLINKBEEP[] = "Blink Beep";
//constexpr char TEXT_BACK[] = "Back";
//LedstripSelectAnimationMenu