Files
bobbycar-boardcomputer-firm…/main/displays/menus/ledstripselectblinkmenu.cpp
2021-12-30 03:17:30 +01:00

85 lines
2.8 KiB
C++

#include "ledstripselectblinkmenu.h"
#ifdef FEATURE_LEDSTRIP
// 3rdparty lib includes
#include "actions/dummyaction.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
// local includes
#include "accessors/settingsaccessors.h"
#include "actions/ledstripblinkactions.h"
#include "displays/menus/ledstripmenu.h"
#include "ledstrip.h"
#include "ledstripdefines.h"
#include "bobbycheckbox.h"
namespace {
constexpr char TEXT_BLINKANIMATION[] = "Blink animation";
constexpr char TEXT_ANIMATION_BLINKNONE[] = "Blink Off";
constexpr char TEXT_ANIMATION_BLINKLEFT[] = "Blink Left";
constexpr char TEXT_ANIMATION_BLINKRIGHT[] = "Blink Right";
constexpr char TEXT_ANIMATION_BLINKBOTH[] = "Blink Both";
constexpr char TEXT_LEDSTRIP_EN_BLINK_ANIM[] = "Animated Blink";
constexpr char TEXT_BACK[] = "Back";
class CurrentSelectedBlinkAnimationText : public virtual espgui::TextInterface
{
public:
std::string text() const override;
};
} // namespace
LedstripSelectBlinkMenu::LedstripSelectBlinkMenu()
{
using namespace espgui;
constructMenuItem<makeComponent<MenuItem, CurrentSelectedBlinkAnimationText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKNONE>, LedstripAnimationBlinkNoneAction>>();
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_LEDSTRIP_EN_BLINK_ANIM>, BobbyCheckbox, LedstripEnableBlinkAnimationAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
std::string LedstripSelectBlinkMenu::text() const
{
return TEXT_BLINKANIMATION;
}
void LedstripSelectBlinkMenu::back()
{
espgui::switchScreen<LedstripMenu>();
}
namespace {
std::string CurrentSelectedBlinkAnimationText::text() const
{
switch (blinkAnimation)
{
case LEDSTRIP_OVERWRITE_BLINKLEFT:
#ifndef LEDSTRIP_WRONG_DIRECTION
return TEXT_ANIMATION_BLINKLEFT;
#else
return TEXT_ANIMATION_BLINKRIGHT;
#endif
case LEDSTRIP_OVERWRITE_BLINKRIGHT:
#ifndef LEDSTRIP_WRONG_DIRECTION
return TEXT_ANIMATION_BLINKRIGHT;
#else
return TEXT_ANIMATION_BLINKLEFT;
#endif
case LEDSTRIP_OVERWRITE_BLINKBOTH:
return TEXT_ANIMATION_BLINKBOTH;
default:
return TEXT_ANIMATION_BLINKNONE;
}
}
} // namespace
#endif