Refactored ledstripanimationactions, ledstripactions, bmsdisplay, accesspointwifisettingsmenu, feedbackdebugmenu, ledstripmenu, ledstripselectblinkmenu, ledstripselectotamode, mosfetsmenu
This commit is contained in:
@@ -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<uint16_t type>
|
||||
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
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
|
||||
@@ -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<SwitchScreenAction<MainMenu>>, 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<Label, 12> 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<espgui::Label, 12> 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<MetersDisplay>();
|
||||
else if (offset > 0)
|
||||
switchScreen<StatusDisplay>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -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>();
|
||||
}
|
||||
|
@@ -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<TEXT_ACCESSPOINTWIFISETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<WifiSettingsMenu>>
|
||||
public espgui::MenuDisplay,
|
||||
public espgui::StaticText<TEXT_ACCESSPOINTWIFISETTINGS>
|
||||
{
|
||||
public:
|
||||
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>>>();
|
||||
}
|
||||
AccessPointWifiSettingsMenu();
|
||||
void back() override;
|
||||
};
|
||||
} // namespace
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include "texts.h"
|
||||
#include "debugtexthelpers.h"
|
||||
#include "debugcolorhelpers.h"
|
||||
#include "displays/menus/debugmenu.h"
|
||||
|
||||
using namespace espgui;
|
||||
|
||||
|
@@ -1,28 +1,30 @@
|
||||
#include "ledstripmenu.h"
|
||||
|
||||
#ifdef FEATURE_LEDSTRIP
|
||||
// 3rdparty lib includes
|
||||
#include <FastLED.h>
|
||||
#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 <actioninterface.h>
|
||||
#include <actions/switchscreenaction.h>
|
||||
#include <actions/toggleboolaction.h>
|
||||
#include <changevaluedisplay.h>
|
||||
#include <checkboxicon.h>
|
||||
#include <icons/back.h>
|
||||
#include <menuitem.h>
|
||||
|
||||
// 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<int16_t>,
|
||||
@@ -109,8 +111,6 @@ public:
|
||||
};
|
||||
} // namespace
|
||||
|
||||
using namespace espgui;
|
||||
|
||||
LedstripMenu::LedstripMenu()
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIPCOLORMENU>, SwitchScreenAction<LedstripColorsDisplay>>>();
|
||||
|
@@ -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
|
||||
|
@@ -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<TEXT_BLINKANIMATION>,
|
||||
public BackActionInterface<SwitchScreenAction<LedstripMenu>>
|
||||
{
|
||||
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
|
||||
class LedstripSelectBlinkMenu :
|
||||
public espgui::MenuDisplay,
|
||||
public espgui::StaticText<TEXT_BLINKANIMATION>
|
||||
{
|
||||
public:
|
||||
LedstripSelectBlinkMenu();
|
||||
void back() override;
|
||||
};
|
||||
#endif
|
||||
|
@@ -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
|
||||
|
@@ -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 <OtaAnimationModes mode>
|
||||
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<TEXT_BLINKANIMATION>,
|
||||
public BackActionInterface<SwitchScreenAction<LedstripMenu>>
|
||||
{
|
||||
public:
|
||||
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
|
||||
class ledstripOtaAnimationChangeMenu :
|
||||
public espgui::MenuDisplay,
|
||||
public espgui::StaticText<TEXT_BLINKANIMATION>
|
||||
{
|
||||
public:
|
||||
ledstripOtaAnimationChangeMenu();
|
||||
void back() override;
|
||||
};
|
||||
#endif
|
||||
|
@@ -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
|
||||
|
@@ -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<pin_t PIN>
|
||||
class GPIOAccessor : public virtual AccessorInterface<bool>
|
||||
class GPIOAccessor : public virtual espgui::AccessorInterface<bool>
|
||||
{
|
||||
public:
|
||||
bool getValue() const override { return digitalRead(PIN); }
|
||||
@@ -28,18 +19,11 @@ using Mosfet1Accessor = GPIOAccessor<PINS_MOSFET1>;
|
||||
using Mosfet2Accessor = GPIOAccessor<PINS_MOSFET2>;
|
||||
|
||||
class MosfetsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_MOSFETS>,
|
||||
public BackActionInterface<SwitchScreenAction<MainMenu>>
|
||||
public espgui::MenuDisplay,
|
||||
public espgui::StaticText<TEXT_MOSFETS>
|
||||
{
|
||||
public:
|
||||
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>>>();
|
||||
}
|
||||
MosfetsMenu();
|
||||
void back() override;
|
||||
};
|
||||
#endif
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user