diff --git a/main/actions/ledstripanimationactions.h b/main/actions/ledstripanimationactions.h index d79671e..9f705c5 100644 --- a/main/actions/ledstripanimationactions.h +++ b/main/actions/ledstripanimationactions.h @@ -1,40 +1,14 @@ #pragma once #include "actioninterface.h" -#include "utils.h" -#include "globals.h" #include "ledstrip.h" // #include "ledstripdefines.h" -using namespace espgui; - -namespace { #ifdef FEATURE_LEDSTRIP template -class LedStripSetAnimationAction : public virtual ActionInterface +class LedStripSetAnimationAction : public virtual espgui::ActionInterface { public: 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 -} diff --git a/main/actions/ledstripblinkactions.cpp b/main/actions/ledstripblinkactions.cpp index e69de29..8d903b8 100644 --- a/main/actions/ledstripblinkactions.cpp +++ b/main/actions/ledstripblinkactions.cpp @@ -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 diff --git a/main/actions/ledstripblinkactions.h b/main/actions/ledstripblinkactions.h index f22efa5..4ea7541 100644 --- a/main/actions/ledstripblinkactions.h +++ b/main/actions/ledstripblinkactions.h @@ -1,53 +1,37 @@ #pragma once -#include "actioninterface.h" -#include "utils.h" -#include "globals.h" -#include "ledstrip.h" -#include "ledstripdefines.h" - -using namespace espgui; - #ifdef FEATURE_LEDSTRIP -namespace { -class LedstripAnimationBlinkNoneAction : public virtual ActionInterface +#include "actioninterface.h" + +class LedstripAnimationBlinkNoneAction : public virtual espgui::ActionInterface { public: - void triggered() override { blinkAnimation = LEDSTRIP_OVERWRITE_NONE; } + void triggered() override; }; -class LedstripAnimationBlinkLeftAction : public virtual ActionInterface +class LedstripAnimationBlinkLeftAction : public virtual espgui::ActionInterface { public: #ifndef LEDSTRIP_WRONG_DIRECTION - void triggered() override { - blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT; - } + void triggered() override; #else - void triggered() override { - blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT; - } + void triggered() override; #endif }; -class LedstripAnimationBlinkRightAction : public virtual ActionInterface +class LedstripAnimationBlinkRightAction : public virtual espgui::ActionInterface { public: #ifndef LEDSTRIP_WRONG_DIRECTION - void triggered() override { - blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT; - } + void triggered() override; #else - void triggered() override { - blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT; - } + void triggered() override; #endif }; -class LedstripAnimationBlinkBothAction : public virtual ActionInterface +class LedstripAnimationBlinkBothAction : public virtual espgui::ActionInterface { public: - void triggered() override { blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH; } + void triggered() override; }; -} #endif diff --git a/main/displays/bmsdisplay.cpp b/main/displays/bmsdisplay.cpp index e69de29..bf89591 100644 --- a/main/displays/bmsdisplay.cpp +++ b/main/displays/bmsdisplay.cpp @@ -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(); + else if (offset > 0) + switchScreen(); +} + +void BmsDisplay::confirm() +{ + switchScreen(); +} +#endif diff --git a/main/displays/bmsdisplay.h b/main/displays/bmsdisplay.h index a9b60c2..46701cc 100644 --- a/main/displays/bmsdisplay.h +++ b/main/displays/bmsdisplay.h @@ -1,5 +1,6 @@ #pragma once +#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS) // 3rdparty lib includes #include @@ -11,122 +12,32 @@ #include "widgets/label.h" #include "screenmanager.h" -namespace { -#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS) -class BmsDisplay : public Display, public ConfirmActionInterface>, public DummyBack +class BmsDisplay : + public espgui::Display, + public espgui::DummyBack { public: void initScreen() override; void redraw() override; - + void confirm() override; void rotate(int offset) override; - Label m_statusLabel{200, 0}; + espgui::Label m_statusLabel{200, 0}; - Label m_voltageLabel{107, 0}; - Label m_capacityLabel{107, 25}; - Label m_socLabel{107, 50}; - Label m_powerLabel{107, 75}; - Label m_currentLabel{107, 100}; - Label m_speedLabel{107, 125}; - Label m_powerPerSpeedLabel{107, 150}; + espgui::Label m_voltageLabel{107, 0}; + espgui::Label m_capacityLabel{107, 25}; + espgui::Label m_socLabel{107, 50}; + espgui::Label m_powerLabel{107, 75}; + espgui::Label m_currentLabel{107, 100}; + espgui::Label m_speedLabel{107, 125}; + espgui::Label m_powerPerSpeedLabel{107, 150}; - std::array m_battLabels{{ - Label{0, 225}, Label{60, 225}, Label{120, 225}, Label{180, 225}, - Label{0, 250}, Label{60, 250}, Label{120, 250}, Label{180, 250}, - Label{0, 275}, Label{60, 275}, Label{120, 275}, Label{180, 275} + std::array m_battLabels{{ + espgui::Label{0, 225}, espgui::Label{60, 225}, espgui::Label{120, 225}, espgui::Label{180, 225}, + espgui::Label{0, 250}, espgui::Label{60, 250}, espgui::Label{120, 250}, espgui::Label{180, 250}, + 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(); - else if (offset > 0) - switchScreen(); -} #endif -} diff --git a/main/displays/menus/accesspointwifisettingsmenu.cpp b/main/displays/menus/accesspointwifisettingsmenu.cpp index e69de29..a37981e 100644 --- a/main/displays/menus/accesspointwifisettingsmenu.cpp +++ b/main/displays/menus/accesspointwifisettingsmenu.cpp @@ -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, ToggleBoolAction, CheckboxIcon, WifiApEnabledAccessor>>(); + constructMenuItem, DisabledColor, DummyAction>>(); + constructMenuItem, DisabledColor, DummyAction>>(); + constructMenuItem, DisabledColor, DummyAction>>(); + constructMenuItem, DisabledColor, DummyAction>>(); + constructMenuItem, DisabledColor, DummyAction>>(); + constructMenuItem, DisabledColor, DummyAction>>(); + constructMenuItem, DisabledColor, DummyAction>>(); + constructMenuItem, DisabledColor, DummyAction>>(); + constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); +} + +void AccessPointWifiSettingsMenu::back() +{ + switchScreen(); +} diff --git a/main/displays/menus/accesspointwifisettingsmenu.h b/main/displays/menus/accesspointwifisettingsmenu.h index 11be9f9..49c39f8 100644 --- a/main/displays/menus/accesspointwifisettingsmenu.h +++ b/main/displays/menus/accesspointwifisettingsmenu.h @@ -2,37 +2,13 @@ // local includes #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" -using namespace espgui; - -namespace { class AccessPointWifiSettingsMenu : - public MenuDisplay, - public StaticText, - public BackActionInterface> + public espgui::MenuDisplay, + public espgui::StaticText { public: - AccessPointWifiSettingsMenu() - { - constructMenuItem, ToggleBoolAction, CheckboxIcon, WifiApEnabledAccessor>>(); - constructMenuItem, DisabledColor, DummyAction>>(); - constructMenuItem, DisabledColor, DummyAction>>(); - constructMenuItem, DisabledColor, DummyAction>>(); - constructMenuItem, DisabledColor, DummyAction>>(); - constructMenuItem, DisabledColor, DummyAction>>(); - constructMenuItem, DisabledColor, DummyAction>>(); - constructMenuItem, DisabledColor, DummyAction>>(); - constructMenuItem, DisabledColor, DummyAction>>(); - constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); - } + AccessPointWifiSettingsMenu(); + void back() override; }; -} // namespace diff --git a/main/displays/menus/feedbackdebugmenu.h b/main/displays/menus/feedbackdebugmenu.h index 5e1fb06..92104a6 100644 --- a/main/displays/menus/feedbackdebugmenu.h +++ b/main/displays/menus/feedbackdebugmenu.h @@ -10,6 +10,7 @@ #include "texts.h" #include "debugtexthelpers.h" #include "debugcolorhelpers.h" +#include "displays/menus/debugmenu.h" using namespace espgui; diff --git a/main/displays/menus/ledstripmenu.cpp b/main/displays/menus/ledstripmenu.cpp index cdeba51..e5d99f1 100644 --- a/main/displays/menus/ledstripmenu.cpp +++ b/main/displays/menus/ledstripmenu.cpp @@ -1,28 +1,30 @@ #include "ledstripmenu.h" +#ifdef FEATURE_LEDSTRIP // 3rdparty lib includes #include -#include "menuitem.h" -#include "actions/toggleboolaction.h" -#include "actions/switchscreenaction.h" -#include "icons/back.h" -#include "checkboxicon.h" -#include "changevaluedisplay.h" -#include "actioninterface.h" +#include +#include +#include +#include +#include +#include +#include // 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 "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 { using LedsCountChangeScreen = makeComponent< ChangeValueDisplay, @@ -109,8 +111,6 @@ public: }; } // namespace -using namespace espgui; - LedstripMenu::LedstripMenu() { constructMenuItem, SwitchScreenAction>>(); diff --git a/main/displays/menus/ledstripselectblinkmenu.cpp b/main/displays/menus/ledstripselectblinkmenu.cpp index e69de29..6e44234 100644 --- a/main/displays/menus/ledstripselectblinkmenu.cpp +++ b/main/displays/menus/ledstripselectblinkmenu.cpp @@ -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>(); + constructMenuItem>(); + constructMenuItem, LedstripAnimationBlinkNoneAction>>(); + constructMenuItem, LedstripAnimationBlinkLeftAction>>(); + constructMenuItem, LedstripAnimationBlinkRightAction>>(); + constructMenuItem, LedstripAnimationBlinkBothAction>>(); + constructMenuItem, ToggleBoolAction, CheckboxIcon, LedstripEnableBlinkAnimationAccessor>>(); + constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); +} + +void LedstripSelectBlinkMenu::back() +{ + switchScreen(); +} +#endif diff --git a/main/displays/menus/ledstripselectblinkmenu.h b/main/displays/menus/ledstripselectblinkmenu.h index ca37a95..1819c14 100644 --- a/main/displays/menus/ledstripselectblinkmenu.h +++ b/main/displays/menus/ledstripselectblinkmenu.h @@ -2,64 +2,22 @@ // 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/ledstripblinkactions.h" -#include "actions/switchscreenaction.h" -#include "actions/toggleboolaction.h" -#include "checkboxicon.h" +#include "ledstrip.h" #include "ledstripdefines.h" -#include "accessors/settingsaccessors.h" -#include "ledstripmenu.h" #ifdef FEATURE_LEDSTRIP -class currentSelectedBlinkAnimationText : public virtual TextInterface { public: std::string text() const override { - 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; - } - }; +class currentSelectedBlinkAnimationText : public virtual espgui::TextInterface +{ +public: std::string text() const override; }; -using namespace espgui; - -namespace { - class LedstripSelectBlinkMenu : - public MenuDisplay, - public StaticText, - public BackActionInterface> - { - public: - LedstripSelectBlinkMenu() - { - constructMenuItem>(); - constructMenuItem>(); - constructMenuItem, LedstripAnimationBlinkNoneAction>>(); - constructMenuItem, LedstripAnimationBlinkLeftAction>>(); - constructMenuItem, LedstripAnimationBlinkRightAction>>(); - constructMenuItem, LedstripAnimationBlinkBothAction>>(); - constructMenuItem, ToggleBoolAction, CheckboxIcon, LedstripEnableBlinkAnimationAccessor>>(); - constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); - } - }; -} // Namespace +class LedstripSelectBlinkMenu : + public espgui::MenuDisplay, + public espgui::StaticText +{ +public: + LedstripSelectBlinkMenu(); + void back() override; +}; #endif diff --git a/main/displays/menus/ledstripselectotamode.cpp b/main/displays/menus/ledstripselectotamode.cpp index e69de29..97ce863 100644 --- a/main/displays/menus/ledstripselectotamode.cpp +++ b/main/displays/menus/ledstripselectotamode.cpp @@ -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, LedstripChangeOtaAnimModeAction>>(); + constructMenuItem, LedstripChangeOtaAnimModeAction>>(); + constructMenuItem, LedstripChangeOtaAnimModeAction>>(); + constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); +} + +void ledstripOtaAnimationChangeMenu::back() +{ + switchScreen(); +} +#endif diff --git a/main/displays/menus/ledstripselectotamode.h b/main/displays/menus/ledstripselectotamode.h index f49e54d..02ffc51 100644 --- a/main/displays/menus/ledstripselectotamode.h +++ b/main/displays/menus/ledstripselectotamode.h @@ -2,20 +2,15 @@ // Local includes #include "menudisplay.h" -#include "utils.h" -#include "menuitem.h" -#include "ledstrip.h" -#include "icons/back.h" #include "texts.h" -#include "actions/switchscreenaction.h" -#include "accessors/settingsaccessors.h" -#include "ledstripmenu.h" +#include "ledstrip.h" +#include "globals.h" +#include "utils.h" #if defined(FEATURE_LEDSTRIP) && defined(FEATURE_OTA) -using namespace espgui; template -class LedstripChangeOtaAnimModeAction : public virtual ActionInterface +class LedstripChangeOtaAnimModeAction : public virtual espgui::ActionInterface { public: void triggered() override @@ -25,20 +20,12 @@ public: } }; -namespace { - class ledstripOtaAnimationChangeMenu : - public MenuDisplay, - public StaticText, - public BackActionInterface> - { - public: - ledstripOtaAnimationChangeMenu() - { - constructMenuItem, LedstripChangeOtaAnimModeAction>>(); - constructMenuItem, LedstripChangeOtaAnimModeAction>>(); - constructMenuItem, LedstripChangeOtaAnimModeAction>>(); - constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); - } - }; -} // Namespace +class ledstripOtaAnimationChangeMenu : + public espgui::MenuDisplay, + public espgui::StaticText +{ +public: + ledstripOtaAnimationChangeMenu(); + void back() override; +}; #endif diff --git a/main/displays/menus/mosfetsmenu.cpp b/main/displays/menus/mosfetsmenu.cpp index e69de29..2c2073d 100644 --- a/main/displays/menus/mosfetsmenu.cpp +++ b/main/displays/menus/mosfetsmenu.cpp @@ -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, ToggleBoolAction, CheckboxIcon, Mosfet0Accessor>>(); + constructMenuItem, ToggleBoolAction, CheckboxIcon, Mosfet1Accessor>>(); + constructMenuItem, ToggleBoolAction, CheckboxIcon, Mosfet2Accessor>>(); + constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); +} + +void MosfetsMenu::back() +{ + switchScreen(); +} + +#endif diff --git a/main/displays/menus/mosfetsmenu.h b/main/displays/menus/mosfetsmenu.h index 92e7587..ee1b88b 100644 --- a/main/displays/menus/mosfetsmenu.h +++ b/main/displays/menus/mosfetsmenu.h @@ -1,22 +1,13 @@ #pragma once -// local includes +#ifdef FEATURE_MOSFETS #include "menudisplay.h" -#include "utils.h" -#include "menuitem.h" -#include "actions/toggleboolaction.h" -#include "actions/switchscreenaction.h" -#include "checkboxicon.h" -#include "icons/back.h" +#include "accessorinterface.h" #include "texts.h" #include "types.h" -using namespace espgui; - -namespace { -#ifdef FEATURE_MOSFETS template -class GPIOAccessor : public virtual AccessorInterface +class GPIOAccessor : public virtual espgui::AccessorInterface { public: bool getValue() const override { return digitalRead(PIN); } @@ -28,18 +19,11 @@ using Mosfet1Accessor = GPIOAccessor; using Mosfet2Accessor = GPIOAccessor; class MosfetsMenu : - public MenuDisplay, - public StaticText, - public BackActionInterface> + public espgui::MenuDisplay, + public espgui::StaticText { public: - MosfetsMenu() - { - constructMenuItem, ToggleBoolAction, CheckboxIcon, Mosfet0Accessor>>(); - constructMenuItem, ToggleBoolAction, CheckboxIcon, Mosfet1Accessor>>(); - constructMenuItem, ToggleBoolAction, CheckboxIcon, Mosfet2Accessor>>(); - constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); - } + MosfetsMenu(); + void back() override; }; #endif -} // namespace