Merge pull request #91 from bobbycar-graz/ledstrip-menu-improvement
Ledstrip menu improvement
This commit is contained in:
@ -13,6 +13,7 @@ set(headers
|
||||
actions/bmsturnonchargeaction.h
|
||||
actions/bmsturnondischargeaction.h
|
||||
actions/erasenvsaction.h
|
||||
actions/ledstripanimationactions.h
|
||||
actions/loadsettingsaction.h
|
||||
actions/modesettingsaction.h
|
||||
actions/multiaction.h
|
||||
@ -55,6 +56,7 @@ set(headers
|
||||
displays/menus/invertmenu.h
|
||||
displays/menus/larsmmodesettingsmenu.h
|
||||
displays/menus/ledstripmenu.h
|
||||
displays/menus/ledstripselectanimationmenu.h
|
||||
displays/menus/modessettingsmenu.h
|
||||
displays/menus/mosfetsmenu.h
|
||||
displays/menus/motorstatedebugmenu.h
|
||||
@ -111,6 +113,7 @@ set(headers
|
||||
icons/update.h
|
||||
icons/wifi.h
|
||||
ledstrip.h
|
||||
ledstripdefines.h
|
||||
modes/defaultmode.h
|
||||
modes/gametrakmode.h
|
||||
modes/ignoreinputmode.h
|
||||
|
35
main/actions/ledstripanimationactions.h
Normal file
35
main/actions/ledstripanimationactions.h
Normal file
@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "actioninterface.h"
|
||||
#include "utils.h"
|
||||
#include "globals.h"
|
||||
#include "ledstrip.h"
|
||||
#include "ledstripdefines.h"
|
||||
|
||||
using namespace espgui;
|
||||
|
||||
namespace {
|
||||
class LedstripAnimationDefaultRainbowAction : public virtual ActionInterface
|
||||
{
|
||||
public:
|
||||
void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_DEFAULTRAINBOW; }
|
||||
};
|
||||
|
||||
class LedstripAnimationBlinkLeftAction : public virtual ActionInterface
|
||||
{
|
||||
public:
|
||||
void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_BLINKLEFT; }
|
||||
};
|
||||
|
||||
class LedstripAnimationBlinkRightAction : public virtual ActionInterface
|
||||
{
|
||||
public:
|
||||
void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_BLINKRIGHT; }
|
||||
};
|
||||
|
||||
class LedstripAnimationBlinkBothAction : public virtual ActionInterface
|
||||
{
|
||||
public:
|
||||
void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_BLINKBOTH; }
|
||||
};
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
#include "menuitem.h"
|
||||
#include "actions/toggleboolaction.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "ledstripselectanimationmenu.h"
|
||||
#include "texts.h"
|
||||
#include "icons/back.h"
|
||||
#include "checkboxicon.h"
|
||||
@ -25,6 +26,7 @@ using namespace espgui;
|
||||
namespace {
|
||||
#ifdef FEATURE_LEDSTRIP
|
||||
class LedstripMenu;
|
||||
class LedstripSelectAnimationMenu;
|
||||
|
||||
struct BlinkAnimationAccessor : public RefAccessor<int16_t> { int16_t &getRef() const override { return blinkAnimation; } };
|
||||
|
||||
@ -78,7 +80,8 @@ public:
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDANIMATION>, ToggleBoolAction, CheckboxIcon, EnableLedAnimationAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BRAKELIGHTS>, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BLINKANIMATION, BlinkAnimationAccessor>, SwitchScreenAction<BlinkAnimationChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>();
|
||||
// constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BLINKANIMATION, BlinkAnimationAccessor>, SwitchScreenAction<BlinkAnimationChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>();
|
||||
|
37
main/displays/menus/ledstripselectanimationmenu.h
Normal file
37
main/displays/menus/ledstripselectanimationmenu.h
Normal file
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
// Local includes
|
||||
#include "menudisplay.h"
|
||||
#include "utils.h"
|
||||
#include "menuitem.h"
|
||||
#include "ledstrip.h"
|
||||
#include "ledstripselectanimationmenu.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "actions/dummyaction.h"
|
||||
#include "actions/ledstripanimationactions.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
|
||||
using namespace espgui;
|
||||
|
||||
namespace {
|
||||
class LedstripMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class LedstripSelectAnimationMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_SELECTANIMATION>,
|
||||
public BackActionInterface<SwitchScreenAction<LedstripMenu>>
|
||||
{
|
||||
public:
|
||||
LedstripSelectAnimationMenu()
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_DEFAULTRAINBOW>, LedstripAnimationDefaultRainbowAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKLEFT>, LedstripAnimationBlinkLeftAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKRIGHT>, LedstripAnimationBlinkRightAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKBOTH>, LedstripAnimationBlinkBothAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
};
|
||||
} // Namespace
|
@ -8,12 +8,13 @@
|
||||
#include "globals.h"
|
||||
#include "cpputils.h"
|
||||
#include "espchrono.h"
|
||||
#include "ledstripdefines.h"
|
||||
|
||||
namespace {
|
||||
std::vector<CRGB> leds;
|
||||
uint8_t gHue = 0;
|
||||
|
||||
int16_t blinkAnimation = 0;
|
||||
int16_t blinkAnimation = LEDSTRIP_ANIMATION_DEFAULT;
|
||||
|
||||
void showDefaultLedstrip();
|
||||
|
||||
@ -28,7 +29,7 @@ void updateLedStrip()
|
||||
{
|
||||
EVERY_N_MILLISECONDS( 20 ) { gHue++; }
|
||||
|
||||
if (cpputils::is_in(blinkAnimation, 1, 2, 3))
|
||||
if (cpputils::is_in(blinkAnimation, LEDSTRIP_ANIMATION_BLINKLEFT, LEDSTRIP_ANIMATION_BLINKRIGHT, LEDSTRIP_ANIMATION_BLINKBOTH))
|
||||
{
|
||||
std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
|
||||
|
||||
@ -37,9 +38,9 @@ void updateLedStrip()
|
||||
auto color = CRGB{255, 255, 0};
|
||||
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
|
||||
|
||||
if (blinkAnimation != 2)
|
||||
if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKLEFT)
|
||||
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
|
||||
if (blinkAnimation != 1)
|
||||
if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKRIGHT)
|
||||
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
|
||||
}
|
||||
}
|
||||
|
10
main/ledstripdefines.h
Normal file
10
main/ledstripdefines.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
/*
|
||||
* 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_BLINKLEFT 1
|
||||
#define LEDSTRIP_ANIMATION_BLINKRIGHT 2
|
||||
#define LEDSTRIP_ANIMATION_BLINKBOTH 3
|
||||
|
||||
#define LEDSTRIP_ANIMATION_DEFAULT LEDSTRIP_ANIMATION_DEFAULTRAINBOW
|
@ -249,6 +249,13 @@ constexpr char TEXT_SMALLOFFSET[] = "Small Offset";
|
||||
constexpr char TEXT_BIGOFFSET[] = "Big Offset";
|
||||
//constexpr char TEXT_BACK[] = "Back";
|
||||
|
||||
//LedstripSelectAnimationMenu
|
||||
constexpr char TEXT_SELECTANIMATION[] = "Select Animation";
|
||||
constexpr char TEXT_ANIMATION_DEFAULTRAINBOW[] = "Default Rainbow";
|
||||
constexpr char TEXT_ANIMATION_BLINKLEFT[] = "Blink Left";
|
||||
constexpr char TEXT_ANIMATION_BLINKRIGHT[] = "Blink Right";
|
||||
constexpr char TEXT_ANIMATION_BLINKBOTH[] = "Blink Both";
|
||||
|
||||
//LockscreenSettingsMenu
|
||||
constexpr char TEXT_LOCKSCREENSETTINGS[] = "Lockscreen Settings";
|
||||
constexpr char TEXT_ALLOWPRESETSWITCH[] = "Allow preset switch";
|
||||
|
Reference in New Issue
Block a user