Improved animation selection

This commit is contained in:
CommanderRedYT
2021-09-30 14:08:38 +02:00
parent 5e355feea9
commit 0529c85151
6 changed files with 86 additions and 1 deletions

View File

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

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

View File

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

View 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

0
main/ledstripdefines.h Normal file
View File

View File

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