@@ -23,8 +23,6 @@ public:
|
||||
virtual int shownValue() const = 0;
|
||||
virtual void setShownValue(int value) = 0;
|
||||
|
||||
virtual void confirm() = 0;
|
||||
|
||||
protected:
|
||||
Label m_titleLabel{5, 5}; // 230, 25
|
||||
Label m_valueLabel{26, 81}; // 188, 53
|
||||
@@ -55,13 +53,11 @@ public:
|
||||
void redraw() override;
|
||||
|
||||
void rotate(int offset) override;
|
||||
void button() override;
|
||||
void confirm() override;
|
||||
|
||||
int shownValue() const { return m_value; }
|
||||
void setShownValue(int value) { m_value = value; }
|
||||
|
||||
void confirm() override;
|
||||
|
||||
private:
|
||||
Tvalue m_value{};
|
||||
|
||||
@@ -132,12 +128,6 @@ void ChangeValueDisplay<Tvalue>::rotate(int offset)
|
||||
m_rotateOffset += offset;
|
||||
}
|
||||
|
||||
template<typename Tvalue>
|
||||
void ChangeValueDisplay<Tvalue>::button()
|
||||
{
|
||||
m_pressed = true;
|
||||
}
|
||||
|
||||
template<typename Tvalue>
|
||||
void ChangeValueDisplay<Tvalue>::confirm()
|
||||
{
|
||||
|
@@ -7,10 +7,10 @@ namespace {
|
||||
class DemoDisplay : public Display, public virtual ActionInterface
|
||||
{
|
||||
public:
|
||||
void button() override;
|
||||
void confirm() override;
|
||||
};
|
||||
|
||||
void DemoDisplay::button()
|
||||
void DemoDisplay::confirm()
|
||||
{
|
||||
triggered();
|
||||
}
|
||||
|
@@ -9,7 +9,35 @@ class ChangeValueDisplayInterface;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class Display {
|
||||
class ConfirmInterface {
|
||||
public:
|
||||
virtual void confirm() {}
|
||||
};
|
||||
|
||||
class BackInterface {
|
||||
public:
|
||||
virtual void back() {}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class ConfirmActionInterface : public virtual ConfirmInterface
|
||||
{
|
||||
T m_action;
|
||||
|
||||
public:
|
||||
void confirm() override { m_action.triggered(); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class BackActionInterface : public virtual BackInterface
|
||||
{
|
||||
T m_action;
|
||||
|
||||
public:
|
||||
void back() override { m_action.triggered(); }
|
||||
};
|
||||
|
||||
class Display : public virtual ConfirmInterface, public virtual BackInterface {
|
||||
public:
|
||||
virtual ~Display() = default;
|
||||
|
||||
@@ -20,7 +48,6 @@ public:
|
||||
virtual void stop() {}
|
||||
|
||||
virtual void rotate(int offset) {}
|
||||
virtual void button() {}
|
||||
|
||||
virtual TextInterface *asTextInterface() { return nullptr; }
|
||||
virtual const TextInterface *asTextInterface() const { return nullptr; }
|
||||
|
@@ -31,6 +31,8 @@ public:
|
||||
void redraw() override;
|
||||
void stop() override;
|
||||
|
||||
void back() override;
|
||||
|
||||
void triggered() override;
|
||||
|
||||
private:
|
||||
@@ -97,6 +99,12 @@ void CalibrateDisplay::stop()
|
||||
currentMode = m_oldMode;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::back()
|
||||
{
|
||||
if (!m_bootup)
|
||||
switchScreen<BoardcomputerHardwareSettingsMenu>();
|
||||
}
|
||||
|
||||
void CalibrateDisplay::triggered()
|
||||
{
|
||||
if (m_bootup)
|
||||
|
@@ -13,7 +13,7 @@ class GraphsMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class DualGraphDisplay : public DemoDisplay, public SwitchScreenAction<GraphsMenu>
|
||||
class DualGraphDisplay : public DemoDisplay, public SwitchScreenAction<GraphsMenu>, public BackActionInterface<SwitchScreenAction<GraphsMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
|
@@ -14,7 +14,7 @@ class DemosMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class GameOfLifeDisplay : public DemoDisplay, public SwitchScreenAction<DemosMenu>
|
||||
class GameOfLifeDisplay : public DemoDisplay, public SwitchScreenAction<DemosMenu>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
|
@@ -30,7 +30,7 @@ public:
|
||||
};
|
||||
|
||||
template<size_t COUNT>
|
||||
class GraphDisplay : public DemoDisplay, public SwitchScreenAction<GraphsMenu>, public virtual TextInterface, public virtual MultiStatisticsInterface<COUNT>
|
||||
class GraphDisplay : public DemoDisplay, public SwitchScreenAction<GraphsMenu>, public virtual TextInterface, public BackActionInterface<SwitchScreenAction<GraphsMenu>>, public virtual MultiStatisticsInterface<COUNT>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
|
@@ -29,7 +29,7 @@ public:
|
||||
void redraw() override;
|
||||
void stop() override;
|
||||
|
||||
void button() override;
|
||||
void confirm() override;
|
||||
void rotate(int offset) override;
|
||||
|
||||
private:
|
||||
@@ -146,7 +146,7 @@ void Lockscreen::stop()
|
||||
currentMode = m_oldMode;
|
||||
}
|
||||
|
||||
void Lockscreen::button()
|
||||
void Lockscreen::confirm()
|
||||
{
|
||||
m_pressed = true;
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ constexpr char TEXT_ESPINFO[] = "ESP info:";
|
||||
class AboutMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_ABOUT>,
|
||||
public BackActionInterface<SwitchScreenAction<SettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_VERSION>, DummyAction>,
|
||||
makeComponent<MenuItem, StaticText<nullptr>, DummyAction>,
|
||||
|
@@ -50,6 +50,7 @@ public:
|
||||
class AccessPointWifiSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_ACCESSPOINTWIFISETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<WifiSettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, WifiSoftApGetStationNumText, StaticFont<2>, DisabledColor, DummyAction>,
|
||||
makeComponent<MenuItem, WifiSoftApIpText, StaticFont<2>, DisabledColor, DummyAction>,
|
||||
|
@@ -22,6 +22,7 @@ namespace {
|
||||
class BluetoothSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_BLUETOOTHSETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<SettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, BluetoothAvailableText, DisabledColor, DummyAction>,
|
||||
makeComponent<MenuItem, BluetoothHasClientText, DisabledColor, DummyAction>,
|
||||
|
@@ -24,6 +24,7 @@ namespace {
|
||||
class BmsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_BMS>,
|
||||
public BackActionInterface<SwitchScreenAction<MainMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_CONNECTBMS>, BluetoothConnectBmsAction>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_DISCONNECTBMS>, BluetoothDisconnectAction>,
|
||||
|
@@ -28,15 +28,46 @@ public:
|
||||
String text() const override { return String{"brems: "} + raw_brems + ": " + brems; }
|
||||
};
|
||||
|
||||
using SampleCountChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETSAMPLECOUNT>, SampleCountAccessor, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>;
|
||||
using GasMinChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETGASMIN>, GasMinAccessor, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>;
|
||||
using GasMaxChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETGASMAX>, GasMaxAccessor, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>;
|
||||
using BremsMinChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETBREMSMIN>, BremsMinAccessor, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>;
|
||||
using BremsMaxChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETBREMSMAX>, BremsMaxAccessor, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>;
|
||||
using SampleCountChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETSAMPLECOUNT>,
|
||||
SampleCountAccessor,
|
||||
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
|
||||
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
|
||||
>;
|
||||
using GasMinChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETGASMIN>,
|
||||
GasMinAccessor,
|
||||
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
|
||||
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
|
||||
>;
|
||||
using GasMaxChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETGASMAX>,
|
||||
GasMaxAccessor,
|
||||
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
|
||||
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
|
||||
>;
|
||||
using BremsMinChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETBREMSMIN>,
|
||||
BremsMinAccessor,
|
||||
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
|
||||
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
|
||||
>;
|
||||
using BremsMaxChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETBREMSMAX>,
|
||||
BremsMaxAccessor,
|
||||
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
|
||||
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
|
||||
>;
|
||||
|
||||
class BoardcomputerHardwareSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_BOARDCOMPUTERHARDWARESETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<SettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, GasText, DisabledColor, StaticFont<2>, DummyAction>,
|
||||
makeComponent<MenuItem, BremsText, DisabledColor, StaticFont<2>, DummyAction>,
|
||||
|
@@ -20,25 +20,74 @@ class SettingsMenu;
|
||||
|
||||
namespace {
|
||||
struct FrontFreqAccessor : public RefAccessor<uint8_t> { uint8_t &getRef() const override { return front.command.buzzer.freq; } };
|
||||
using FrontFreqChangeScreen = makeComponent<ChangeValueDisplay<uint8_t>, StaticText<TEXT_FRONTFREQ>, FrontFreqAccessor, SwitchScreenAction<BuzzerMenu>>;
|
||||
using FrontFreqChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<uint8_t>,
|
||||
StaticText<TEXT_FRONTFREQ>,
|
||||
FrontFreqAccessor,
|
||||
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
|
||||
SwitchScreenAction<BuzzerMenu>
|
||||
>;
|
||||
|
||||
struct FrontPatternAccessor : public RefAccessor<uint8_t> { uint8_t &getRef() const override { return front.command.buzzer.pattern; } };
|
||||
using FrontPatternChangeScreen = makeComponent<ChangeValueDisplay<uint8_t>, StaticText<TEXT_FRONTPATTERN>, FrontPatternAccessor, SwitchScreenAction<BuzzerMenu>>;
|
||||
using FrontPatternChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<uint8_t>,
|
||||
StaticText<TEXT_FRONTPATTERN>,
|
||||
FrontPatternAccessor,
|
||||
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
|
||||
SwitchScreenAction<BuzzerMenu>
|
||||
>;
|
||||
|
||||
struct BackFreqAccessor : public RefAccessor<uint8_t> { uint8_t &getRef() const override { return back.command.buzzer.freq; } };
|
||||
using BackFreqChangeScreen = makeComponent<ChangeValueDisplay<uint8_t>, StaticText<TEXT_BACKFREQ>, BackFreqAccessor, SwitchScreenAction<BuzzerMenu>>;
|
||||
using BackFreqChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<uint8_t>,
|
||||
StaticText<TEXT_BACKFREQ>,
|
||||
BackFreqAccessor,
|
||||
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
|
||||
SwitchScreenAction<BuzzerMenu>
|
||||
>;
|
||||
|
||||
struct BackPatternAccessor : public RefAccessor<uint8_t> { uint8_t &getRef() const override { return back.command.buzzer.pattern; } };
|
||||
using BackPatternChangeScreen = makeComponent<ChangeValueDisplay<uint8_t>, StaticText<TEXT_BACKPATTERN>, BackPatternAccessor, SwitchScreenAction<BuzzerMenu>>;
|
||||
using BackPatternChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<uint8_t>,
|
||||
StaticText<TEXT_BACKPATTERN>,
|
||||
BackPatternAccessor,
|
||||
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
|
||||
SwitchScreenAction<BuzzerMenu>
|
||||
>;
|
||||
|
||||
using ReverseBeepFreq0ChangeScreen = makeComponent<ChangeValueDisplay<uint8_t>, StaticText<TEXT_REVERSEBEEPFREQ0>, ReverseBeepFreq0Accessor, SwitchScreenAction<BuzzerMenu>>;
|
||||
using ReverseBeepFreq1ChangeScreen = makeComponent<ChangeValueDisplay<uint8_t>, StaticText<TEXT_REVERSEBEEPFREQ1>, ReverseBeepFreq1Accessor, SwitchScreenAction<BuzzerMenu>>;
|
||||
using ReverseBeepDuration0ChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_REVERSEBEEPDURATION0>, ReverseBeepDuration0Accessor, SwitchScreenAction<BuzzerMenu>>;
|
||||
using ReverseBeepDuration1ChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_REVERSEBEEPDURATION1>, ReverseBeepDuration1Accessor, SwitchScreenAction<BuzzerMenu>>;
|
||||
using ReverseBeepFreq0ChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<uint8_t>,
|
||||
StaticText<TEXT_REVERSEBEEPFREQ0>,
|
||||
ReverseBeepFreq0Accessor,
|
||||
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
|
||||
SwitchScreenAction<BuzzerMenu>
|
||||
>;
|
||||
using ReverseBeepFreq1ChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<uint8_t>,
|
||||
StaticText<TEXT_REVERSEBEEPFREQ1>,
|
||||
ReverseBeepFreq1Accessor,
|
||||
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
|
||||
SwitchScreenAction<BuzzerMenu>
|
||||
>;
|
||||
using ReverseBeepDuration0ChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_REVERSEBEEPDURATION0>,
|
||||
ReverseBeepDuration0Accessor,
|
||||
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
|
||||
SwitchScreenAction<BuzzerMenu>
|
||||
>;
|
||||
using ReverseBeepDuration1ChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_REVERSEBEEPDURATION1>,
|
||||
ReverseBeepDuration1Accessor,
|
||||
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
|
||||
SwitchScreenAction<BuzzerMenu>
|
||||
>;
|
||||
|
||||
class BuzzerMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_BUZZER>,
|
||||
public BackActionInterface<SwitchScreenAction<SettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_FRONTFREQ>, SwitchScreenAction<FrontFreqChangeScreen>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_FRONTPATTERN>, SwitchScreenAction<FrontPatternChangeScreen>>,
|
||||
|
@@ -19,6 +19,7 @@ template<const char *Ttext, typename Ttexts>
|
||||
class CommandDebugMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<Ttext>,
|
||||
public BackActionInterface<SwitchScreenAction<DebugMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, typename Ttexts::BuzzerFreqText, DisabledColor, DummyAction>,
|
||||
makeComponent<MenuItem, typename Ttexts::BuzzerPatternText, DisabledColor, DummyAction>,
|
||||
|
@@ -23,13 +23,33 @@ class SettingsMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
using WheelDiameterMmChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_WHEELDIAMETERMM>, WheelDiameterMmAccessor, SwitchScreenAction<ControllerHardwareSettingsMenu>>;
|
||||
using WheelDiameterInchChangeScreen = makeComponent<ChangeValueDisplay<float>, StaticText<TEXT_WHEELDIAMETERINCH>, WheelDiameterInchAccessor, RatioNumberStep<float, std::ratio<1,10>>, SwitchScreenAction<ControllerHardwareSettingsMenu>>;
|
||||
using NumMagnetPolesChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_NUMMAGNETPOLES>, NumMagnetPolesAccessor, SwitchScreenAction<ControllerHardwareSettingsMenu>>;
|
||||
using WheelDiameterMmChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_WHEELDIAMETERMM>,
|
||||
WheelDiameterMmAccessor,
|
||||
BackActionInterface<SwitchScreenAction<ControllerHardwareSettingsMenu>>,
|
||||
SwitchScreenAction<ControllerHardwareSettingsMenu>
|
||||
>;
|
||||
using WheelDiameterInchChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<float>,
|
||||
StaticText<TEXT_WHEELDIAMETERINCH>,
|
||||
WheelDiameterInchAccessor,
|
||||
RatioNumberStep<float, std::ratio<1,10>>,
|
||||
BackActionInterface<SwitchScreenAction<ControllerHardwareSettingsMenu>>,
|
||||
SwitchScreenAction<ControllerHardwareSettingsMenu>
|
||||
>;
|
||||
using NumMagnetPolesChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_NUMMAGNETPOLES>,
|
||||
NumMagnetPolesAccessor,
|
||||
BackActionInterface<SwitchScreenAction<ControllerHardwareSettingsMenu>>,
|
||||
SwitchScreenAction<ControllerHardwareSettingsMenu>
|
||||
>;
|
||||
|
||||
class ControllerHardwareSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_CONTROLLERHARDWARESETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<SettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_SETENABLED>, SwitchScreenAction<EnableMenu>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_SETINVERTED>, SwitchScreenAction<InvertMenu>>,
|
||||
|
@@ -36,6 +36,7 @@ namespace {
|
||||
class DebugMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_DEBUG>,
|
||||
public BackActionInterface<SwitchScreenAction<MainMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_LOADSETTINGS>, LoadSettingsAction>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_SAVESETTINGS>, SaveSettingsAction>,
|
||||
|
@@ -18,20 +18,81 @@ class ModesSettingsMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
using DefaultModeCtrlTypChangeDisplay = makeComponent<ChangeValueDisplay<ControlType>, StaticText<TEXT_SETCONTROLTYPE>, DefaultModeCtrlTypAccessor, SwitchScreenAction<DefaultModeSettingsMenu>>;
|
||||
using DefaultModeCtrlModChangeDisplay = makeComponent<ChangeValueDisplay<ControlMode>, StaticText<TEXT_SETCONTROLMODE>, DefaultModeCtrlModAccessor, SwitchScreenAction<DefaultModeSettingsMenu>>;
|
||||
using DefaultModeSmoothingChangeDisplay = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETSMOOTHING>, DefaultModeSmoothingAccessor, SwitchScreenAction<DefaultModeSettingsMenu>>;
|
||||
using DefaultModeFrontPercentageChangeDisplay = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETFRONTPERCENTAGE>, DefaultModeFrontPercentageAccessor, SwitchScreenAction<DefaultModeSettingsMenu>>;
|
||||
using DefaultModeBackPercentageChangeDisplay = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETBACKPERCENTAGE>, DefaultModeBackPercentageAccessor, SwitchScreenAction<DefaultModeSettingsMenu>>;
|
||||
using DefaultModeAddSchwelleChangeDisplay = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETADDSCHWELLE>, DefaultModeAddSchwelleAccessor, SwitchScreenAction<DefaultModeSettingsMenu>>;
|
||||
using DefaultModeGas1WertChangeDisplay = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETGAS1WERT>, DefaultModeGas1WertAccessor, SwitchScreenAction<DefaultModeSettingsMenu>>;
|
||||
using DefaultModeGas2WertChangeDisplay = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETGAS2WERT>, DefaultModeGas2WertAccessor, SwitchScreenAction<DefaultModeSettingsMenu>>;
|
||||
using DefaultModeBrems1WertChangeDisplay = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETBREMS1WERT>, DefaultModeBrems1WertAccessor, SwitchScreenAction<DefaultModeSettingsMenu>>;
|
||||
using DefaultModeBrems2WertChangeDisplay = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETBREMS2WERT>, DefaultModeBrems2WertAccessor, SwitchScreenAction<DefaultModeSettingsMenu>>;
|
||||
using DefaultModeCtrlTypChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<ControlType>,
|
||||
StaticText<TEXT_SETCONTROLTYPE>,
|
||||
DefaultModeCtrlTypAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeCtrlModChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<ControlMode>,
|
||||
StaticText<TEXT_SETCONTROLMODE>,
|
||||
DefaultModeCtrlModAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeSmoothingChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETSMOOTHING>,
|
||||
DefaultModeSmoothingAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeFrontPercentageChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETFRONTPERCENTAGE>,
|
||||
DefaultModeFrontPercentageAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeBackPercentageChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETBACKPERCENTAGE>,
|
||||
DefaultModeBackPercentageAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeAddSchwelleChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETADDSCHWELLE>,
|
||||
DefaultModeAddSchwelleAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeGas1WertChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETGAS1WERT>,
|
||||
DefaultModeGas1WertAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeGas2WertChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETGAS2WERT>,
|
||||
DefaultModeGas2WertAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeBrems1WertChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETBREMS1WERT>,
|
||||
DefaultModeBrems1WertAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeBrems2WertChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETBREMS2WERT>,
|
||||
DefaultModeBrems2WertAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
|
||||
class DefaultModeSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_DEFAULTMODESETTIGNS>,
|
||||
public BackActionInterface<SwitchScreenAction<ModesSettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_SETCONTROLTYPE>, SwitchScreenAction<DefaultModeCtrlTypChangeDisplay>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_SETCONTROLMODE>, SwitchScreenAction<DefaultModeCtrlModChangeDisplay>>,
|
||||
|
@@ -20,6 +20,7 @@ namespace {
|
||||
class DemosMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_DEMOS>,
|
||||
public BackActionInterface<SwitchScreenAction<MainMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_STARFIELD>, SwitchScreenAction<StarfieldDisplay>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_PINGPONG>, SwitchScreenAction<PingPongDisplay>>,
|
||||
|
@@ -121,6 +121,7 @@ constexpr char TEXT_DEBUGTOGGLE[] = "Toggle";
|
||||
class DynamicDebugMenu :
|
||||
public MenuDisplay,
|
||||
public RandomText,
|
||||
public BackActionInterface<SwitchScreenAction<DebugMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
// dummy items to allow for scrolling
|
||||
makeComponent<MenuItem, StaticText<TEXT_DUMMYITEM>, DummyAction>,
|
||||
|
@@ -19,6 +19,7 @@ namespace {
|
||||
class EnableMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_SETENABLED>,
|
||||
public BackActionInterface<SwitchScreenAction<ControllerHardwareSettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_ENABLEFRONTLEFT>, ToggleBoolAction, CheckboxIcon, FrontLeftEnabledAccessor>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_ENABLEFRONTRIGHT>, ToggleBoolAction, CheckboxIcon, FrontRightEnabledAccessor>,
|
||||
|
@@ -20,6 +20,7 @@ template<const char *Ttext, typename Ttexts, template<int> class ColorInterface>
|
||||
class FeedbackDebugMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<Ttext>,
|
||||
public BackActionInterface<SwitchScreenAction<DebugMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, typename Ttexts::BatVoltageText, ColorInterface<TFT_DARKGREY>, DummyAction>,
|
||||
makeComponent<MenuItem, typename Ttexts::BatVoltageFixedText, ColorInterface<TFT_DARKGREY>, DummyAction>,
|
||||
|
@@ -39,7 +39,13 @@ struct WifiModeAccessor : public virtual AccessorInterface<wifi_mode_t>
|
||||
// TODO: better error handling
|
||||
}
|
||||
};
|
||||
using WifiModeChangeScreen = makeComponent<ChangeValueDisplay<wifi_mode_t>, StaticText<TEXT_WIFICHANGEMODE>, WifiModeAccessor, SwitchScreenAction<GenericWifiSettingsMenu>>;
|
||||
using WifiModeChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<wifi_mode_t>,
|
||||
StaticText<TEXT_WIFICHANGEMODE>,
|
||||
WifiModeAccessor,
|
||||
BackActionInterface<SwitchScreenAction<GenericWifiSettingsMenu>>,
|
||||
SwitchScreenAction<GenericWifiSettingsMenu>
|
||||
>;
|
||||
|
||||
struct WifiSleepAccessor : public virtual AccessorInterface<bool>
|
||||
{
|
||||
@@ -62,11 +68,18 @@ struct WifiTxPowerAccessor : public virtual AccessorInterface<wifi_power_t>
|
||||
// TODO: better error handling
|
||||
}
|
||||
};
|
||||
using WifiTxPowerChangeScreen = makeComponent<ChangeValueDisplay<wifi_power_t>, StaticText<TEXT_WIFICHANGETXPOWER>, WifiTxPowerAccessor, SwitchScreenAction<GenericWifiSettingsMenu>>;
|
||||
using WifiTxPowerChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<wifi_power_t>,
|
||||
StaticText<TEXT_WIFICHANGETXPOWER>,
|
||||
WifiTxPowerAccessor,
|
||||
BackActionInterface<SwitchScreenAction<GenericWifiSettingsMenu>>,
|
||||
SwitchScreenAction<GenericWifiSettingsMenu>
|
||||
>;
|
||||
|
||||
class GenericWifiSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_GENERICWIFISETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<WifiSettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, WifiStatusBitsText, DisabledColor, DummyAction>,
|
||||
makeComponent<MenuItem, WifiChannelText, DisabledColor, DummyAction>,
|
||||
|
@@ -48,6 +48,7 @@ using MotorCurrentsGraphDisplay = makeComponent<GraphDisplay<4>, StaticText<TEXT
|
||||
class GraphsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_GRAPHS>,
|
||||
public BackActionInterface<SwitchScreenAction<MainMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_GAS>, SwitchScreenAction<GasGraphDisplay>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_BREMS>, SwitchScreenAction<BremsGraphDisplay>>,
|
||||
|
@@ -19,6 +19,7 @@ namespace {
|
||||
class InvertMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_SETINVERTED>,
|
||||
public BackActionInterface<SwitchScreenAction<ControllerHardwareSettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_INVERTFRONTLEFT>, ToggleBoolAction, CheckboxIcon, FrontLeftInvertedAccessor>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_INVERTFRONTRIGHT>, ToggleBoolAction, CheckboxIcon, FrontRightInvertedAccessor>,
|
||||
|
@@ -16,12 +16,25 @@ class ModesSettingsMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
using LarsmModeModeChangeDisplay = makeComponent<ChangeValueDisplay<LarsmModeMode>, StaticText<TEXT_LARSMMODECHANGEMODE>, LarsmModeModeAccessor, SwitchScreenAction<LarsmModeSettingsMenu>>;
|
||||
using LarsmModeIterationsChangeDisplay = makeComponent<ChangeValueDisplay<uint8_t>, StaticText<TEXT_LARSMMODECHANGEITERATIONS>, LarsmModeIterationsAccessor, SwitchScreenAction<LarsmModeSettingsMenu>>;
|
||||
using LarsmModeModeChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<LarsmModeMode>,
|
||||
StaticText<TEXT_LARSMMODECHANGEMODE>,
|
||||
LarsmModeModeAccessor,
|
||||
BackActionInterface<SwitchScreenAction<LarsmModeSettingsMenu>>,
|
||||
SwitchScreenAction<LarsmModeSettingsMenu>
|
||||
>;
|
||||
using LarsmModeIterationsChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<uint8_t>,
|
||||
StaticText<TEXT_LARSMMODECHANGEITERATIONS>,
|
||||
LarsmModeIterationsAccessor,
|
||||
BackActionInterface<SwitchScreenAction<LarsmModeSettingsMenu>>,
|
||||
SwitchScreenAction<LarsmModeSettingsMenu>
|
||||
>;
|
||||
|
||||
class LarsmModeSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_LARSMMODESETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<ModesSettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_LARSMMODECHANGEMODE>, SwitchScreenAction<LarsmModeModeChangeDisplay>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_LARSMMODECHANGEITERATIONS>, SwitchScreenAction<LarsmModeIterationsChangeDisplay>>,
|
||||
|
@@ -16,16 +16,53 @@ class SettingsMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
using IMotMaxChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETIMOTMAX>, IMotMaxAccessor, SwitchScreenAction<LimitsSettingsMenu>>;
|
||||
using IDcMaxChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETIDCMAX>, IDcMaxAccessor, SwitchScreenAction<LimitsSettingsMenu>>;
|
||||
using NMotMaxKmhChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETNMOTMAXKMH>, NMotMaxKmhAccessor, SwitchScreenAction<LimitsSettingsMenu>>;
|
||||
using NMotMaxRpmChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETNMOTMAX>, NMotMaxRpmAccessor, SwitchScreenAction<LimitsSettingsMenu>>;
|
||||
using FieldWeakMaxChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETFIELDWEAKMAX>, FieldWeakMaxAccessor, SwitchScreenAction<LimitsSettingsMenu>>;
|
||||
using PhaseAdvMaxChangeScreen = makeComponent<ChangeValueDisplay<int16_t>, StaticText<TEXT_SETPHASEADVMAX>, PhaseAdvMaxAccessor, SwitchScreenAction<LimitsSettingsMenu>>;
|
||||
using IMotMaxChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETIMOTMAX>,
|
||||
IMotMaxAccessor,
|
||||
BackActionInterface<SwitchScreenAction<LimitsSettingsMenu>>,
|
||||
SwitchScreenAction<LimitsSettingsMenu>
|
||||
>;
|
||||
using IDcMaxChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETIDCMAX>,
|
||||
IDcMaxAccessor,
|
||||
BackActionInterface<SwitchScreenAction<LimitsSettingsMenu>>,
|
||||
SwitchScreenAction<LimitsSettingsMenu>
|
||||
>;
|
||||
using NMotMaxKmhChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETNMOTMAXKMH>,
|
||||
NMotMaxKmhAccessor,
|
||||
BackActionInterface<SwitchScreenAction<LimitsSettingsMenu>>,
|
||||
SwitchScreenAction<LimitsSettingsMenu>
|
||||
>;
|
||||
using NMotMaxRpmChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETNMOTMAX>,
|
||||
NMotMaxRpmAccessor,
|
||||
BackActionInterface<SwitchScreenAction<LimitsSettingsMenu>>,
|
||||
SwitchScreenAction<LimitsSettingsMenu>
|
||||
>;
|
||||
using FieldWeakMaxChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETFIELDWEAKMAX>,
|
||||
FieldWeakMaxAccessor,
|
||||
BackActionInterface<SwitchScreenAction<LimitsSettingsMenu>>,
|
||||
SwitchScreenAction<LimitsSettingsMenu>
|
||||
>;
|
||||
using PhaseAdvMaxChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETPHASEADVMAX>,
|
||||
PhaseAdvMaxAccessor,
|
||||
BackActionInterface<SwitchScreenAction<LimitsSettingsMenu>>,
|
||||
SwitchScreenAction<LimitsSettingsMenu>
|
||||
>;
|
||||
|
||||
class LimitsSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_LIMITSSETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<SettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_SETIMOTMAX>, SwitchScreenAction<IMotMaxChangeScreen>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_SETIDCMAX>, SwitchScreenAction<IDcMaxChangeScreen>>,
|
||||
|
@@ -34,6 +34,7 @@ namespace {
|
||||
class MainMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_MAINMENU>,
|
||||
public BackActionInterface<SwitchScreenAction<StatusDisplay>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_STATUS>, SwitchScreenAction<StatusDisplay>, StaticMenuItemIcon<&icons::back>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_SELECTMODE>, SwitchScreenAction<SelectModeMenu>, StaticMenuItemIcon<&icons::modes>>,
|
||||
|
@@ -18,6 +18,7 @@ namespace {
|
||||
class ModesSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_MODESSETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<SettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_DEFAULTMODESETTIGNS>, SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_TEMPOMATMODESETTINGS>, SwitchScreenAction<TempomatModeSettingsMenu>>,
|
||||
|
@@ -20,6 +20,7 @@ template<const char *Ttext, typename Ttexts, template<int> class ColorInterface>
|
||||
class MotorFeedbackDebugMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<Ttext>,
|
||||
public BackActionInterface<SwitchScreenAction<DebugMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, typename Ttexts::AngleText, ColorInterface<TFT_DARKGREY>, DummyAction>,
|
||||
makeComponent<MenuItem, typename Ttexts::SpeedText, ColorInterface<TFT_DARKGREY>, DummyAction>,
|
||||
|
@@ -19,6 +19,7 @@ template<const char *Ttext, typename Ttexts>
|
||||
class MotorStateDebugMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<Ttext>,
|
||||
public BackActionInterface<SwitchScreenAction<DebugMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, typename Ttexts::EnableText, DisabledColor, DummyAction>,
|
||||
makeComponent<MenuItem, typename Ttexts::PwmText, DisabledColor, DummyAction>,
|
||||
|
@@ -18,20 +18,37 @@ class MainMenu;
|
||||
|
||||
namespace {
|
||||
template<const Settings *preset>
|
||||
class ApplyPresetAction : public virtual ActionInterface {public: void triggered() override { settings = *preset; saveSettings(); } };
|
||||
class ApplyPresetAction : public virtual ActionInterface
|
||||
{
|
||||
public:
|
||||
void triggered() override { settings = *preset; saveSettings(); }
|
||||
};
|
||||
|
||||
template<const Settings::Limits *preset>
|
||||
class ApplyLimitsPresetAction : public virtual ActionInterface {public: void triggered() override { settings.limits = *preset; saveSettings(); } };
|
||||
class ApplyLimitsPresetAction : public virtual ActionInterface
|
||||
{
|
||||
public:
|
||||
void triggered() override { settings.limits = *preset; saveSettings(); }
|
||||
};
|
||||
|
||||
template<const Settings::ControllerHardware *preset>
|
||||
class ApplyControllerHardwarePresetAction : public virtual ActionInterface {public: void triggered() override { settings.controllerHardware = *preset; saveSettings(); } };
|
||||
class ApplyControllerHardwarePresetAction : public virtual ActionInterface
|
||||
{
|
||||
public:
|
||||
void triggered() override { settings.controllerHardware = *preset; saveSettings(); }
|
||||
};
|
||||
|
||||
template<const Settings::BoardcomputerHardware *preset>
|
||||
class ApplyBoardcomputerHardwarePresetAction : public virtual ActionInterface {public: void triggered() override { settings.boardcomputerHardware = *preset; saveSettings(); } };
|
||||
class ApplyBoardcomputerHardwarePresetAction : public virtual ActionInterface
|
||||
{
|
||||
public:
|
||||
void triggered() override { settings.boardcomputerHardware = *preset; saveSettings(); }
|
||||
};
|
||||
|
||||
class PresetsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_PRESETS>,
|
||||
public BackActionInterface<SwitchScreenAction<MainMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_DEFAULTEVERYTHING>, ApplyPresetAction<&presets::defaultSettings>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_DEFAULTLIMITS>, ApplyLimitsPresetAction<&presets::defaultLimits>>,
|
||||
|
@@ -31,6 +31,7 @@ using SetLarsmModeAction = SetterAction<ModeInterface*, currentMode, LarsmMode*,
|
||||
class SelectModeMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_SELECTMODE>,
|
||||
public BackActionInterface<SwitchScreenAction<MainMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_DEFAULT>, MultiAction<SetDefaultModeAction, SwitchScreenAction<MainMenu>>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_TEMPOMAT>, MultiAction<SetTempomatModeAction, SwitchScreenAction<MainMenu>>>,
|
||||
|
@@ -37,6 +37,7 @@ struct BackLedAccessor : public RefAccessor<bool> { bool &getRef() const overrid
|
||||
class SettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_SETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<MainMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_LIMITSSETTINGS>, SwitchScreenAction<LimitsSettingsMenu>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_WIFISETTINGS>, SwitchScreenAction<WifiSettingsMenu>, StaticMenuItemIcon<&icons::wifi>>,
|
||||
|
@@ -112,6 +112,7 @@ public:
|
||||
class StationWifiSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_STATIONWIFISETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<WifiSettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_WIFIRECONNECT>, WifiReconnectAction>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_WIFIDISCONNECT>, WifiDisconnectAction>,
|
||||
|
@@ -16,12 +16,25 @@ class ModesSettingsMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
using TempomatModeCtrlTypChangeScreen = makeComponent<ChangeValueDisplay<ControlType>, StaticText<TEXT_SETCONTROLMODE>, TempomatModeCtrlTypAccessor, SwitchScreenAction<TempomatModeSettingsMenu>>;
|
||||
using TempomatModeCtrlModChangeScreen = makeComponent<ChangeValueDisplay<ControlMode>, StaticText<TEXT_SETCONTROLMODE>, TempomatModeCtrlModAccessor, SwitchScreenAction<TempomatModeSettingsMenu>>;
|
||||
using TempomatModeCtrlTypChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<ControlType>,
|
||||
StaticText<TEXT_SETCONTROLMODE>,
|
||||
TempomatModeCtrlTypAccessor,
|
||||
BackActionInterface<SwitchScreenAction<TempomatModeSettingsMenu>>,
|
||||
SwitchScreenAction<TempomatModeSettingsMenu>
|
||||
>;
|
||||
using TempomatModeCtrlModChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<ControlMode>,
|
||||
StaticText<TEXT_SETCONTROLMODE>,
|
||||
TempomatModeCtrlModAccessor,
|
||||
BackActionInterface<SwitchScreenAction<TempomatModeSettingsMenu>>,
|
||||
SwitchScreenAction<TempomatModeSettingsMenu>
|
||||
>;
|
||||
|
||||
class TempomatModeSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_TEMPOMATMODESETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<ModesSettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_SETCONTROLTYPE>, SwitchScreenAction<TempomatModeCtrlTypChangeScreen>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_SETCONTROLMODE>, SwitchScreenAction<TempomatModeCtrlModChangeScreen>>,
|
||||
|
@@ -18,7 +18,7 @@ class WifiSettingsMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class WifiScanMenu : public MenuDisplay
|
||||
class WifiScanMenu : public MenuDisplay, public BackActionInterface<SwitchScreenAction<WifiSettingsMenu>>
|
||||
{
|
||||
using Base = MenuDisplay;
|
||||
|
||||
|
@@ -20,6 +20,7 @@ namespace {
|
||||
class WifiSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_WIFISETTINGS>,
|
||||
public BackActionInterface<SwitchScreenAction<SettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_GENERICWIFISETTINGS>, SwitchScreenAction<GenericWifiSettingsMenu>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_STATIONWIFISETTINGS>, SwitchScreenAction<StationWifiSettingsMenu>>,
|
||||
|
@@ -16,7 +16,7 @@ class BmsDisplay;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class MetersDisplay : public DemoDisplay, public SwitchScreenAction<MainMenu>
|
||||
class MetersDisplay : public DemoDisplay, public SwitchScreenAction<MainMenu>, public BackActionInterface<SwitchScreenAction<MainMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
|
@@ -13,7 +13,7 @@ class DemosMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class PingPongDisplay : public DemoDisplay, public SwitchScreenAction<DemosMenu>
|
||||
class PingPongDisplay : public DemoDisplay, public SwitchScreenAction<DemosMenu>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
|
@@ -13,7 +13,7 @@ class DemosMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class SpiroDisplay : public DemoDisplay, public SwitchScreenAction<DemosMenu>
|
||||
class SpiroDisplay : public DemoDisplay, public SwitchScreenAction<DemosMenu>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
|
@@ -13,7 +13,7 @@ class DemosMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class StarfieldDisplay : public DemoDisplay, public SwitchScreenAction<DemosMenu>
|
||||
class StarfieldDisplay : public DemoDisplay, public SwitchScreenAction<DemosMenu>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
|
@@ -148,8 +148,8 @@ void StatusDisplay::redraw()
|
||||
m_labelBrems.redraw(String{brems});
|
||||
m_progressBarBrems.redraw(brems);
|
||||
|
||||
m_frontStatus.redraw(front);
|
||||
m_backStatus.redraw(back);
|
||||
m_frontStatus.redraw(::front);
|
||||
m_backStatus.redraw(::back);
|
||||
|
||||
tft.setTextFont(2);
|
||||
m_labelWifiStatus.redraw(toString(WiFi.status()));
|
||||
|
@@ -27,7 +27,7 @@ public:
|
||||
void start() override;
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
void button() override;
|
||||
void confirm() override;
|
||||
|
||||
public:
|
||||
bool m_finished;
|
||||
@@ -85,7 +85,7 @@ void UpdateDisplay::redraw()
|
||||
m_progressBar.redraw(float(m_progress) / m_total * 100.f);
|
||||
}
|
||||
|
||||
void UpdateDisplay::button()
|
||||
void UpdateDisplay::confirm()
|
||||
{
|
||||
if (m_finished)
|
||||
switchScreen<StatusDisplay>();
|
||||
|
@@ -58,7 +58,9 @@ void updateDpad()
|
||||
if (!std::get<ButtonDown>(lastState) && std::get<ButtonDown>(state))
|
||||
InputDispatcher::rotate(1);
|
||||
if (std::get<ButtonConfirm>(lastState) != std::get<ButtonConfirm>(state))
|
||||
InputDispatcher::button(std::get<ButtonConfirm>(state));
|
||||
InputDispatcher::confirmButton(std::get<ButtonConfirm>(state));
|
||||
if (std::get<ButtonBack>(lastState) != std::get<ButtonBack>(state))
|
||||
InputDispatcher::backButton(std::get<ButtonBack>(state));
|
||||
|
||||
lastState = state;
|
||||
}
|
||||
|
@@ -75,7 +75,9 @@ void updateDpadHack()
|
||||
if (!std::get<ButtonDown>(lastState) && std::get<ButtonDown>(state))
|
||||
InputDispatcher::rotate(1);
|
||||
if (std::get<ButtonConfirm>(lastState) != std::get<ButtonConfirm>(state))
|
||||
InputDispatcher::button(std::get<ButtonConfirm>(state));
|
||||
InputDispatcher::confirmButton(std::get<ButtonConfirm>(state));
|
||||
if (std::get<ButtonBack>(lastState) != std::get<ButtonBack>(state))
|
||||
InputDispatcher::backButton(std::get<ButtonBack>(state));
|
||||
|
||||
lastState = state;
|
||||
}
|
||||
|
@@ -42,8 +42,10 @@ Display *currentDisplay{};
|
||||
|
||||
int rotated{};
|
||||
bool requestFullRedraw{};
|
||||
bool buttonLongPressed{};
|
||||
bool buttonPressed{};
|
||||
bool confirmButtonPressed{};
|
||||
bool confirmButtonLongPressed{};
|
||||
bool backButtonPressed{};
|
||||
bool backButtonLongPressed{};
|
||||
|
||||
class InputDispatcher
|
||||
{
|
||||
@@ -53,7 +55,7 @@ public:
|
||||
rotated += offset;
|
||||
}
|
||||
|
||||
static void button(bool pressed)
|
||||
static void confirmButton(bool pressed)
|
||||
{
|
||||
static unsigned long pressBegin = 0;
|
||||
|
||||
@@ -65,15 +67,36 @@ public:
|
||||
{
|
||||
const auto duration = now - pressBegin;
|
||||
|
||||
if (duration < 1000)
|
||||
buttonPressed = true;
|
||||
else if (duration < 3000)
|
||||
buttonLongPressed = true;
|
||||
if (duration < 500)
|
||||
confirmButtonPressed = true;
|
||||
else if (duration < 2000)
|
||||
confirmButtonLongPressed = true;
|
||||
else
|
||||
requestFullRedraw = true;
|
||||
|
||||
pressBegin = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void backButton(bool pressed)
|
||||
{
|
||||
static unsigned long pressBegin = 0;
|
||||
|
||||
const auto now = millis();
|
||||
|
||||
if (pressed)
|
||||
pressBegin = now;
|
||||
else
|
||||
{
|
||||
const auto duration = now - pressBegin;
|
||||
|
||||
if (duration < 500)
|
||||
backButtonPressed = true;
|
||||
else
|
||||
backButtonLongPressed = true;
|
||||
|
||||
pressBegin = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ public:
|
||||
void stop() override;
|
||||
|
||||
void rotate(int offset) override;
|
||||
void button() override;
|
||||
void confirm() override;
|
||||
|
||||
virtual void itemPressed(int index);
|
||||
|
||||
@@ -241,7 +241,7 @@ void MenuDisplay::rotate(int offset)
|
||||
m_rotateOffset += offset;
|
||||
}
|
||||
|
||||
void MenuDisplay::button()
|
||||
void MenuDisplay::confirm()
|
||||
{
|
||||
m_pressed = true;
|
||||
}
|
||||
|
@@ -345,18 +345,32 @@ void updateDisplay()
|
||||
currentDisplay->initScreen();
|
||||
}
|
||||
|
||||
if (buttonLongPressed)
|
||||
if (confirmButtonPressed)
|
||||
{
|
||||
buttonLongPressed = false;
|
||||
Serial.println("todo: implement long press");
|
||||
}
|
||||
|
||||
if (buttonPressed)
|
||||
{
|
||||
buttonPressed = false;
|
||||
confirmButtonPressed = false;
|
||||
|
||||
if (currentDisplay)
|
||||
currentDisplay->button();
|
||||
currentDisplay->confirm();
|
||||
}
|
||||
|
||||
if (confirmButtonLongPressed)
|
||||
{
|
||||
confirmButtonLongPressed = false;
|
||||
Serial.println("todo: implement long press for confirm");
|
||||
}
|
||||
|
||||
if (backButtonPressed)
|
||||
{
|
||||
backButtonPressed = false;
|
||||
|
||||
if (currentDisplay)
|
||||
currentDisplay->back();
|
||||
}
|
||||
|
||||
if (backButtonLongPressed)
|
||||
{
|
||||
backButtonLongPressed = false;
|
||||
Serial.println("todo: implement long press for back");
|
||||
}
|
||||
|
||||
if (currentDisplay)
|
||||
|
@@ -83,8 +83,12 @@ void handleSerial()
|
||||
InputDispatcher::rotate(1);
|
||||
break;
|
||||
case 'C':
|
||||
InputDispatcher::button(true);
|
||||
InputDispatcher::button(false);
|
||||
InputDispatcher::confirmButton(true);
|
||||
InputDispatcher::confirmButton(false);
|
||||
break;
|
||||
case 'D':
|
||||
InputDispatcher::backButton(true);
|
||||
InputDispatcher::backButton(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ void initWebserver()
|
||||
{
|
||||
HtmlTag pTag{"p", content};
|
||||
|
||||
content += "<a href=\"/up\">Up</a> <a href=\"/down\">Down</a> <a href=\"/confirm\">Confirm</a>";
|
||||
content += "<a href=\"/up\">Up</a> <a href=\"/down\">Down</a> <a href=\"/confirm\">Confirm</a> <a href=\"/back\">Back</a>";
|
||||
}
|
||||
|
||||
if (auto constCurrentDisplay = static_cast<const Display *>(currentDisplay))
|
||||
@@ -117,8 +117,17 @@ void initWebserver()
|
||||
});
|
||||
|
||||
webServer.on("/confirm", HTTP_GET, [](){
|
||||
InputDispatcher::button(true);
|
||||
InputDispatcher::button(false);
|
||||
InputDispatcher::confirmButton(true);
|
||||
InputDispatcher::confirmButton(false);
|
||||
|
||||
webServer.sendHeader("Connection", "close");
|
||||
webServer.sendHeader("Location", "/");
|
||||
webServer.send(302, "text/html", "ok");
|
||||
});
|
||||
|
||||
webServer.on("/back", HTTP_GET, [](){
|
||||
InputDispatcher::backButton(true);
|
||||
InputDispatcher::backButton(false);
|
||||
|
||||
webServer.sendHeader("Connection", "close");
|
||||
webServer.sendHeader("Location", "/");
|
||||
|
Reference in New Issue
Block a user