Refactored ledstripanimationactions, ledstripactions, bmsdisplay, accesspointwifisettingsmenu, feedbackdebugmenu, ledstripmenu, ledstripselectblinkmenu, ledstripselectotamode, mosfetsmenu

This commit is contained in:
CommanderRedYT
2021-12-14 09:56:40 +01:00
parent 27019b7d75
commit 02999bcde1
15 changed files with 368 additions and 310 deletions

View File

@@ -1,40 +1,14 @@
#pragma once #pragma once
#include "actioninterface.h" #include "actioninterface.h"
#include "utils.h"
#include "globals.h"
#include "ledstrip.h" #include "ledstrip.h"
// #include "ledstripdefines.h" // #include "ledstripdefines.h"
using namespace espgui;
namespace {
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
template<uint16_t type> template<uint16_t type>
class LedStripSetAnimationAction : public virtual ActionInterface class LedStripSetAnimationAction : public virtual espgui::ActionInterface
{ {
public: public:
void triggered() override { animation_type = type; } void triggered() override { animation_type = type; }
}; };
/*
class LedstripAnimationDefaultRainbowAction : public virtual ActionInterface
{
public:
void triggered() override { animation_type = LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW; }
};
class LedstripAnimationBetterRainbowAction : public virtual ActionInterface
{
public:
void triggered() override { animation_type = LEDSTRIP_ANIMATION_TYPE_BETTERRAINBOW; }
};
class LedstripAnimationSyncToSpeedAction : public virtual ActionInterface
{
public:
void triggered() override { animation_type = LEDSTRIP_ANIMATION_TYPE_SPEEDSYNCANIMATION; }
};
*/
#endif #endif
}

View File

@@ -0,0 +1,42 @@
#include "ledstripblinkactions.h"
#ifdef FEATURE_LEDSTRIP
#include "ledstrip.h"
#include "ledstripdefines.h"
using namespace espgui;
void LedstripAnimationBlinkNoneAction::triggered()
{
blinkAnimation = LEDSTRIP_OVERWRITE_NONE;
}
#ifndef LEDSTRIP_WRONG_DIRECTION
void LedstripAnimationBlinkLeftAction::triggered()
{
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT;
}
#else
void LedstripAnimationBlinkLeftAction::triggered()
{
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT;
}
#endif
#ifndef LEDSTRIP_WRONG_DIRECTION
void LedstripAnimationBlinkRightAction::triggered()
{
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT;
}
#else
void LedstripAnimationBlinkRightAction::triggered()
{
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT;
}
#endif
void LedstripAnimationBlinkBothAction::triggered()
{
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH;
}
#endif

View File

@@ -1,53 +1,37 @@
#pragma once #pragma once
#include "actioninterface.h"
#include "utils.h"
#include "globals.h"
#include "ledstrip.h"
#include "ledstripdefines.h"
using namespace espgui;
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
namespace { #include "actioninterface.h"
class LedstripAnimationBlinkNoneAction : public virtual ActionInterface
class LedstripAnimationBlinkNoneAction : public virtual espgui::ActionInterface
{ {
public: public:
void triggered() override { blinkAnimation = LEDSTRIP_OVERWRITE_NONE; } void triggered() override;
}; };
class LedstripAnimationBlinkLeftAction : public virtual ActionInterface class LedstripAnimationBlinkLeftAction : public virtual espgui::ActionInterface
{ {
public: public:
#ifndef LEDSTRIP_WRONG_DIRECTION #ifndef LEDSTRIP_WRONG_DIRECTION
void triggered() override { void triggered() override;
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT;
}
#else #else
void triggered() override { void triggered() override;
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT;
}
#endif #endif
}; };
class LedstripAnimationBlinkRightAction : public virtual ActionInterface class LedstripAnimationBlinkRightAction : public virtual espgui::ActionInterface
{ {
public: public:
#ifndef LEDSTRIP_WRONG_DIRECTION #ifndef LEDSTRIP_WRONG_DIRECTION
void triggered() override { void triggered() override;
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT;
}
#else #else
void triggered() override { void triggered() override;
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT;
}
#endif #endif
}; };
class LedstripAnimationBlinkBothAction : public virtual ActionInterface class LedstripAnimationBlinkBothAction : public virtual espgui::ActionInterface
{ {
public: public:
void triggered() override { blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH; } void triggered() override;
}; };
}
#endif #endif

View File

@@ -0,0 +1,105 @@
#include "bmsdisplay.h"
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
#include "displays/menus/mainmenu.h"
#include "displays/metersdisplay.h"
#include "displays/statusdisplay.h"
#include "screenmanager.h"
#include "tftinstance.h"
using namespace espgui;
void BmsDisplay::initScreen()
{
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setTextFont(2);
m_statusLabel.start();
m_statusLabel.redraw("init");
tft.setTextFont(4);
tft.drawString("Voltage:", 0, m_voltageLabel.y());
m_voltageLabel.start();
tft.drawString("Capacity:", 0, m_capacityLabel.y());
m_capacityLabel.start();
tft.drawString("SOC:", 0, m_socLabel.y());
m_socLabel.start();
tft.drawString("Power:", 0, m_powerLabel.y());
m_powerLabel.start();
tft.drawString("Current:", 0, m_currentLabel.y());
m_currentLabel.start();
tft.drawString("Speed:", 0, m_speedLabel.y());
m_speedLabel.start();
tft.drawString("PpS:", 0, m_powerPerSpeedLabel.y());
m_powerPerSpeedLabel.start();
for (auto &label : m_battLabels)
label.start();
tft.drawString("Cycle:", 0, m_cycleLabel.y());
m_cycleLabel.start();
}
void BmsDisplay::redraw()
{
if (bluetoothSerial.hasClient())
tft.setTextColor(TFT_GREEN, TFT_BLACK);
else
{
tft.setTextColor(TFT_RED, TFT_BLACK);
tft.setTextFont(2);
}
m_statusLabel.redraw(bluetoothSerial.hasClient() ? "OK" : "FAIL");
tft.setTextColor(TFT_WHITE, TFT_BLACK);
if (!bluetoothSerial.hasClient())
tft.setTextFont(4);
if (bluetoothSerial.hasClient())
{
m_voltageLabel.redraw(fmt::format("{:.02f}V", bms::voltage));
m_capacityLabel.redraw(fmt::format("{:.02f} mAh", bms::capacity));
m_socLabel.redraw(fmt::format("{:.02f}%", bms::soc));
m_powerLabel.redraw(fmt::format("{:.02f}W", bms::power));
m_currentLabel.redraw(fmt::format("{:.02f}A", bms::current));
}
else
{
m_voltageLabel.clear();
m_capacityLabel.clear();
m_socLabel.clear();
m_powerLabel.clear();
m_currentLabel.clear();
}
m_speedLabel.redraw(fmt::format("{:.02f}kmh", avgSpeedKmh));
if (bluetoothSerial.hasClient())
m_powerPerSpeedLabel.redraw(fmt::format("{:.02f}W/kmh", avgSpeedKmh < 1 ? 0 : bms::power / avgSpeedKmh));
else
m_powerPerSpeedLabel.clear();
for (int i = 0; i < 12; i++)
m_battLabels[i].redraw(fmt::format("{:.02f}", bms::batt[i]));
if (bluetoothSerial.hasClient())
m_cycleLabel.redraw(fmt::format("{:.02f}AH", bms::cycle));
else
m_cycleLabel.clear();
}
void BmsDisplay::rotate(int offset)
{
if (offset < 0)
switchScreen<MetersDisplay>();
else if (offset > 0)
switchScreen<StatusDisplay>();
}
void BmsDisplay::confirm()
{
switchScreen<MainMenu>();
}
#endif

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
// 3rdparty lib includes // 3rdparty lib includes
#include <fmt/core.h> #include <fmt/core.h>
@@ -11,122 +12,32 @@
#include "widgets/label.h" #include "widgets/label.h"
#include "screenmanager.h" #include "screenmanager.h"
namespace { class BmsDisplay :
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS) public espgui::Display,
class BmsDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<MainMenu>>, public DummyBack public espgui::DummyBack
{ {
public: public:
void initScreen() override; void initScreen() override;
void redraw() override; void redraw() override;
void confirm() override;
void rotate(int offset) override; void rotate(int offset) override;
Label m_statusLabel{200, 0}; espgui::Label m_statusLabel{200, 0};
Label m_voltageLabel{107, 0}; espgui::Label m_voltageLabel{107, 0};
Label m_capacityLabel{107, 25}; espgui::Label m_capacityLabel{107, 25};
Label m_socLabel{107, 50}; espgui::Label m_socLabel{107, 50};
Label m_powerLabel{107, 75}; espgui::Label m_powerLabel{107, 75};
Label m_currentLabel{107, 100}; espgui::Label m_currentLabel{107, 100};
Label m_speedLabel{107, 125}; espgui::Label m_speedLabel{107, 125};
Label m_powerPerSpeedLabel{107, 150}; espgui::Label m_powerPerSpeedLabel{107, 150};
std::array<Label, 12> m_battLabels{{ std::array<espgui::Label, 12> m_battLabels{{
Label{0, 225}, Label{60, 225}, Label{120, 225}, Label{180, 225}, espgui::Label{0, 225}, espgui::Label{60, 225}, espgui::Label{120, 225}, espgui::Label{180, 225},
Label{0, 250}, Label{60, 250}, Label{120, 250}, Label{180, 250}, espgui::Label{0, 250}, espgui::Label{60, 250}, espgui::Label{120, 250}, espgui::Label{180, 250},
Label{0, 275}, Label{60, 275}, Label{120, 275}, Label{180, 275} espgui::Label{0, 275}, espgui::Label{60, 275}, espgui::Label{120, 275}, espgui::Label{180, 275}
}}; }};
Label m_cycleLabel{105, 300}; espgui::Label m_cycleLabel{105, 300};
}; };
void BmsDisplay::initScreen()
{
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setTextFont(2);
m_statusLabel.start();
m_statusLabel.redraw("init");
tft.setTextFont(4);
tft.drawString("Voltage:", 0, m_voltageLabel.y());
m_voltageLabel.start();
tft.drawString("Capacity:", 0, m_capacityLabel.y());
m_capacityLabel.start();
tft.drawString("SOC:", 0, m_socLabel.y());
m_socLabel.start();
tft.drawString("Power:", 0, m_powerLabel.y());
m_powerLabel.start();
tft.drawString("Current:", 0, m_currentLabel.y());
m_currentLabel.start();
tft.drawString("Speed:", 0, m_speedLabel.y());
m_speedLabel.start();
tft.drawString("PpS:", 0, m_powerPerSpeedLabel.y());
m_powerPerSpeedLabel.start();
for (auto &label : m_battLabels)
label.start();
tft.drawString("Cycle:", 0, m_cycleLabel.y());
m_cycleLabel.start();
}
void BmsDisplay::redraw()
{
if (bluetoothSerial.hasClient())
tft.setTextColor(TFT_GREEN, TFT_BLACK);
else
{
tft.setTextColor(TFT_RED, TFT_BLACK);
tft.setTextFont(2);
}
m_statusLabel.redraw(bluetoothSerial.hasClient() ? "OK" : "FAIL");
tft.setTextColor(TFT_WHITE, TFT_BLACK);
if (!bluetoothSerial.hasClient())
tft.setTextFont(4);
if (bluetoothSerial.hasClient())
{
m_voltageLabel.redraw(fmt::format("{:.02f}V", bms::voltage));
m_capacityLabel.redraw(fmt::format("{:.02f} mAh", bms::capacity));
m_socLabel.redraw(fmt::format("{:.02f}%", bms::soc));
m_powerLabel.redraw(fmt::format("{:.02f}W", bms::power));
m_currentLabel.redraw(fmt::format("{:.02f}A", bms::current));
}
else
{
m_voltageLabel.clear();
m_capacityLabel.clear();
m_socLabel.clear();
m_powerLabel.clear();
m_currentLabel.clear();
}
m_speedLabel.redraw(fmt::format("{:.02f}kmh", avgSpeedKmh));
if (bluetoothSerial.hasClient())
m_powerPerSpeedLabel.redraw(fmt::format("{:.02f}W/kmh", avgSpeedKmh < 1 ? 0 : bms::power / avgSpeedKmh));
else
m_powerPerSpeedLabel.clear();
for (int i = 0; i < 12; i++)
m_battLabels[i].redraw(fmt::format("{:.02f}", bms::batt[i]));
if (bluetoothSerial.hasClient())
m_cycleLabel.redraw(fmt::format("{:.02f}AH", bms::cycle));
else
m_cycleLabel.clear();
}
void BmsDisplay::rotate(int offset)
{
if (offset < 0)
switchScreen<MetersDisplay>();
else if (offset > 0)
switchScreen<StatusDisplay>();
}
#endif #endif
}

View File

@@ -0,0 +1,33 @@
#include "accesspointwifisettingsmenu.h"
// local includes
#include "accessors/settingsaccessors.h"
#include "actions/dummyaction.h"
#include "actions/switchscreenaction.h"
#include "actions/toggleboolaction.h"
#include "checkboxicon.h"
#include "displays/menus/wifisettingsmenu.h"
#include "icons/back.h"
#include "menuitem.h"
#include "wifitexthelpers.h"
using namespace espgui;
AccessPointWifiSettingsMenu::AccessPointWifiSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_WIFIAPENABLED>, ToggleBoolAction, CheckboxIcon, WifiApEnabledAccessor>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApGetStationNumText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApIpText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApBroadcastIpText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApNetworkIdText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApSubnetCidrText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApIpV6Text, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApHostnameText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApMacAddressText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<WifiSettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void AccessPointWifiSettingsMenu::back()
{
switchScreen<WifiSettingsMenu>();
}

View File

@@ -2,37 +2,13 @@
// local includes // local includes
#include "menudisplay.h" #include "menudisplay.h"
#include "menuitem.h"
#include "actions/dummyaction.h"
#include "actions/switchscreenaction.h"
#include "actions/toggleboolaction.h"
#include "checkboxicon.h"
#include "icons/back.h"
#include "wifitexthelpers.h"
#include "accessors/settingsaccessors.h"
#include "texts.h" #include "texts.h"
using namespace espgui;
namespace {
class AccessPointWifiSettingsMenu : class AccessPointWifiSettingsMenu :
public MenuDisplay, public espgui::MenuDisplay,
public StaticText<TEXT_ACCESSPOINTWIFISETTINGS>, public espgui::StaticText<TEXT_ACCESSPOINTWIFISETTINGS>
public BackActionInterface<SwitchScreenAction<WifiSettingsMenu>>
{ {
public: public:
AccessPointWifiSettingsMenu() AccessPointWifiSettingsMenu();
{ void back() override;
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_WIFIAPENABLED>, ToggleBoolAction, CheckboxIcon, WifiApEnabledAccessor>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApGetStationNumText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApIpText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApBroadcastIpText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApNetworkIdText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApSubnetCidrText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApIpV6Text, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApHostnameText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, WifiSoftApMacAddressText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<WifiSettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
}; };
} // namespace

View File

@@ -10,6 +10,7 @@
#include "texts.h" #include "texts.h"
#include "debugtexthelpers.h" #include "debugtexthelpers.h"
#include "debugcolorhelpers.h" #include "debugcolorhelpers.h"
#include "displays/menus/debugmenu.h"
using namespace espgui; using namespace espgui;

View File

@@ -1,28 +1,30 @@
#include "ledstripmenu.h" #include "ledstripmenu.h"
#ifdef FEATURE_LEDSTRIP
// 3rdparty lib includes // 3rdparty lib includes
#include <FastLED.h> #include <FastLED.h>
#include "menuitem.h" #include <actioninterface.h>
#include "actions/toggleboolaction.h" #include <actions/switchscreenaction.h>
#include "actions/switchscreenaction.h" #include <actions/toggleboolaction.h>
#include "icons/back.h" #include <changevaluedisplay.h>
#include "checkboxicon.h" #include <checkboxicon.h>
#include "changevaluedisplay.h" #include <icons/back.h>
#include "actioninterface.h" #include <menuitem.h>
// local includes // local includes
#include "accessors/settingsaccessors.h"
#include "displays/ledstripcolorsdisplay.h"
#include "displays/menus/ledstripselectotamode.h"
#include "displays/menus/mainmenu.h"
#include "globals.h"
#include "ledstrip.h"
#include "ledstripselectanimationmenu.h" #include "ledstripselectanimationmenu.h"
#include "ledstripselectblinkmenu.h" #include "ledstripselectblinkmenu.h"
#include "globals.h"
#include "accessors/settingsaccessors.h"
#ifdef FEATURE_LEDSTRIP
#include "ledstrip.h"
#include "displays/menus/ledstripselectotamode.h"
#endif
#include "displays/ledstripcolorsdisplay.h"
#include "displays/menus/mainmenu.h"
#ifdef FEATURE_LEDSTRIP // clang-format off
using namespace espgui;
namespace { namespace {
using LedsCountChangeScreen = makeComponent< using LedsCountChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>, ChangeValueDisplay<int16_t>,
@@ -109,8 +111,6 @@ public:
}; };
} // namespace } // namespace
using namespace espgui;
LedstripMenu::LedstripMenu() LedstripMenu::LedstripMenu()
{ {
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIPCOLORMENU>, SwitchScreenAction<LedstripColorsDisplay>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIPCOLORMENU>, SwitchScreenAction<LedstripColorsDisplay>>>();

View File

@@ -0,0 +1,53 @@
#include "ledstripselectblinkmenu.h"
#ifdef FEATURE_LEDSTRIP
// Local includes
#include "accessors/settingsaccessors.h"
#include "actions/dummyaction.h"
#include "actions/ledstripblinkactions.h"
#include "actions/switchscreenaction.h"
#include "actions/toggleboolaction.h"
#include "checkboxicon.h"
#include "displays/menus/ledstripmenu.h"
#include "icons/back.h"
using namespace espgui;
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;
}
}
LedstripSelectBlinkMenu::LedstripSelectBlinkMenu()
{
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>, ToggleBoolAction, CheckboxIcon, LedstripEnableBlinkAnimationAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void LedstripSelectBlinkMenu::back()
{
switchScreen<LedstripMenu>();
}
#endif

View File

@@ -2,64 +2,22 @@
// Local includes // Local includes
#include "menudisplay.h" #include "menudisplay.h"
#include "utils.h"
#include "menuitem.h"
#include "ledstrip.h"
#include "ledstripselectanimationmenu.h"
#include "icons/back.h"
#include "texts.h" #include "texts.h"
#include "actions/dummyaction.h" #include "ledstrip.h"
#include "actions/ledstripblinkactions.h"
#include "actions/switchscreenaction.h"
#include "actions/toggleboolaction.h"
#include "checkboxicon.h"
#include "ledstripdefines.h" #include "ledstripdefines.h"
#include "accessors/settingsaccessors.h"
#include "ledstripmenu.h"
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
class currentSelectedBlinkAnimationText : public virtual TextInterface { public: std::string text() const override { class currentSelectedBlinkAnimationText : public virtual espgui::TextInterface
switch (blinkAnimation) { {
case LEDSTRIP_OVERWRITE_BLINKLEFT: public: std::string text() const override;
#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;
}
};
}; };
using namespace espgui; class LedstripSelectBlinkMenu :
public espgui::MenuDisplay,
namespace { public espgui::StaticText<TEXT_BLINKANIMATION>
class LedstripSelectBlinkMenu : {
public MenuDisplay, public:
public StaticText<TEXT_BLINKANIMATION>, LedstripSelectBlinkMenu();
public BackActionInterface<SwitchScreenAction<LedstripMenu>> void back() override;
{ };
public:
LedstripSelectBlinkMenu()
{
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>, ToggleBoolAction, CheckboxIcon, LedstripEnableBlinkAnimationAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
};
} // Namespace
#endif #endif

View File

@@ -0,0 +1,24 @@
#include "ledstripselectotamode.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
#include "ledstripmenu.h"
// Local includes
#if defined(FEATURE_LEDSTRIP) && defined(FEATURE_OTA)
using namespace espgui;
ledstripOtaAnimationChangeMenu::ledstripOtaAnimationChangeMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_OTAANIM_NONE>, LedstripChangeOtaAnimModeAction<OtaAnimationModes::None>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_OTAANIM_PROGRESS>, LedstripChangeOtaAnimModeAction<OtaAnimationModes::GreenProgressBar>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_OTAANIM_COLOR>, LedstripChangeOtaAnimModeAction<OtaAnimationModes::ColorChangeAll>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void ledstripOtaAnimationChangeMenu::back()
{
switchScreen<LedstripMenu>();
}
#endif

View File

@@ -2,20 +2,15 @@
// Local includes // Local includes
#include "menudisplay.h" #include "menudisplay.h"
#include "utils.h"
#include "menuitem.h"
#include "ledstrip.h"
#include "icons/back.h"
#include "texts.h" #include "texts.h"
#include "actions/switchscreenaction.h" #include "ledstrip.h"
#include "accessors/settingsaccessors.h" #include "globals.h"
#include "ledstripmenu.h" #include "utils.h"
#if defined(FEATURE_LEDSTRIP) && defined(FEATURE_OTA) #if defined(FEATURE_LEDSTRIP) && defined(FEATURE_OTA)
using namespace espgui;
template <OtaAnimationModes mode> template <OtaAnimationModes mode>
class LedstripChangeOtaAnimModeAction : public virtual ActionInterface class LedstripChangeOtaAnimModeAction : public virtual espgui::ActionInterface
{ {
public: public:
void triggered() override void triggered() override
@@ -25,20 +20,12 @@ public:
} }
}; };
namespace { class ledstripOtaAnimationChangeMenu :
class ledstripOtaAnimationChangeMenu : public espgui::MenuDisplay,
public MenuDisplay, public espgui::StaticText<TEXT_BLINKANIMATION>
public StaticText<TEXT_BLINKANIMATION>, {
public BackActionInterface<SwitchScreenAction<LedstripMenu>> public:
{ ledstripOtaAnimationChangeMenu();
public: void back() override;
ledstripOtaAnimationChangeMenu() };
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_OTAANIM_NONE>, LedstripChangeOtaAnimModeAction<OtaAnimationModes::None>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_OTAANIM_PROGRESS>, LedstripChangeOtaAnimModeAction<OtaAnimationModes::GreenProgressBar>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_OTAANIM_COLOR>, LedstripChangeOtaAnimModeAction<OtaAnimationModes::ColorChangeAll>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
};
} // Namespace
#endif #endif

View File

@@ -0,0 +1,26 @@
#include "mosfetsmenu.h"
#ifdef FEATURE_MOSFETS
#include "actions/switchscreenaction.h"
#include "actions/toggleboolaction.h"
#include "checkboxicon.h"
#include "displays/menus/mainmenu.h"
#include "icons/back.h"
using namespace espgui;
MosfetsMenu::MosfetsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOSFET0>, ToggleBoolAction, CheckboxIcon, Mosfet0Accessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOSFET1>, ToggleBoolAction, CheckboxIcon, Mosfet1Accessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOSFET2>, ToggleBoolAction, CheckboxIcon, Mosfet2Accessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void MosfetsMenu::back()
{
switchScreen<MainMenu>();
}
#endif

View File

@@ -1,22 +1,13 @@
#pragma once #pragma once
// local includes #ifdef FEATURE_MOSFETS
#include "menudisplay.h" #include "menudisplay.h"
#include "utils.h" #include "accessorinterface.h"
#include "menuitem.h"
#include "actions/toggleboolaction.h"
#include "actions/switchscreenaction.h"
#include "checkboxicon.h"
#include "icons/back.h"
#include "texts.h" #include "texts.h"
#include "types.h" #include "types.h"
using namespace espgui;
namespace {
#ifdef FEATURE_MOSFETS
template<pin_t PIN> template<pin_t PIN>
class GPIOAccessor : public virtual AccessorInterface<bool> class GPIOAccessor : public virtual espgui::AccessorInterface<bool>
{ {
public: public:
bool getValue() const override { return digitalRead(PIN); } bool getValue() const override { return digitalRead(PIN); }
@@ -28,18 +19,11 @@ using Mosfet1Accessor = GPIOAccessor<PINS_MOSFET1>;
using Mosfet2Accessor = GPIOAccessor<PINS_MOSFET2>; using Mosfet2Accessor = GPIOAccessor<PINS_MOSFET2>;
class MosfetsMenu : class MosfetsMenu :
public MenuDisplay, public espgui::MenuDisplay,
public StaticText<TEXT_MOSFETS>, public espgui::StaticText<TEXT_MOSFETS>
public BackActionInterface<SwitchScreenAction<MainMenu>>
{ {
public: public:
MosfetsMenu() MosfetsMenu();
{ void back() override;
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOSFET0>, ToggleBoolAction, CheckboxIcon, Mosfet0Accessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOSFET1>, ToggleBoolAction, CheckboxIcon, Mosfet1Accessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOSFET2>, ToggleBoolAction, CheckboxIcon, Mosfet2Accessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
}; };
#endif #endif
} // namespace