Merge pull request #67 from bobbycar-graz/2-calibrate-wizard
Refactored calibrate screen layout
This commit is contained in:
@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "actioninterface.h"
|
||||
#include "display.h"
|
||||
|
||||
namespace {
|
||||
class DemoDisplay : public Display, public virtual ActionInterface
|
||||
{
|
||||
public:
|
||||
void confirm() override;
|
||||
};
|
||||
|
||||
void DemoDisplay::confirm()
|
||||
{
|
||||
triggered();
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "demodisplay.h"
|
||||
#include "display.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "globals.h"
|
||||
#include "bmsutils.h"
|
||||
@ -15,7 +15,7 @@ class StatusDisplay;
|
||||
}
|
||||
namespace {
|
||||
#ifdef FEATURE_BMS
|
||||
class BmsDisplay : public DemoDisplay, public SwitchScreenAction<MainMenu>
|
||||
class BmsDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<MainMenu>>
|
||||
{
|
||||
public:
|
||||
void initScreen() override;
|
||||
|
@ -4,9 +4,10 @@
|
||||
|
||||
#include <WString.h>
|
||||
|
||||
#include "demodisplay.h"
|
||||
#include "display.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
#include "texts.h"
|
||||
#include "widgets/label.h"
|
||||
#include "widgets/progressbar.h"
|
||||
@ -18,39 +19,68 @@ class BoardcomputerHardwareSettingsMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class CalibrateDisplay : public DemoDisplay
|
||||
class CalibrateDisplay : public Display
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
public:
|
||||
CalibrateDisplay() = default;
|
||||
CalibrateDisplay(bool bootup);
|
||||
|
||||
void start() override;
|
||||
void initScreen() override;
|
||||
void update() override;
|
||||
void redraw() override;
|
||||
void stop() override;
|
||||
|
||||
void rotate(int offset) override;
|
||||
|
||||
void back() override;
|
||||
|
||||
void triggered() override;
|
||||
void confirm() override;
|
||||
|
||||
private:
|
||||
void copyFromSettings();
|
||||
void copyToSettings();
|
||||
|
||||
const bool m_bootup{false};
|
||||
ModeInterface *m_oldMode;
|
||||
IgnoreInputMode m_mode{0, ControlType::FieldOrientedControl, ControlMode::Torque};
|
||||
|
||||
std::array<Label, 4> m_labels {{
|
||||
Label{25, 50}, // 100, 23
|
||||
Label{25, 75}, // 100, 23
|
||||
Label{25, 100}, // 100, 23
|
||||
Label{25, 125} // 100, 23
|
||||
std::array<Label, 11> m_labels {{
|
||||
Label{25, 72}, // 100, 23
|
||||
Label{145, 72}, // 100, 23
|
||||
Label{25, 97}, // 100, 23
|
||||
Label{145, 97}, // 100, 23
|
||||
|
||||
Label{25, 172}, // 100, 23
|
||||
Label{145, 172}, // 100, 23
|
||||
Label{25, 197}, // 100, 23
|
||||
Label{145, 197}, // 100, 23
|
||||
|
||||
Label{25, 247}, // 190, 23
|
||||
|
||||
Label{25, 277}, // 100, 23
|
||||
Label{145, 277}, // 100, 23
|
||||
}};
|
||||
|
||||
std::array<ProgressBar, 2> m_progressBars {{
|
||||
ProgressBar{20, 200, 200, 10, 0, 1000},
|
||||
ProgressBar{20, 230, 200, 10, 0, 1000}
|
||||
ProgressBar{20, 129, 200, 10, 0, 1000},
|
||||
ProgressBar{20, 229, 200, 10, 0, 1000}
|
||||
}};
|
||||
|
||||
enum Status {
|
||||
Begin,
|
||||
GasMin,
|
||||
GasMax,
|
||||
BremsMin,
|
||||
BremsMax,
|
||||
Confirm
|
||||
};
|
||||
|
||||
int8_t m_selectedButton, m_renderedButton;
|
||||
|
||||
Status m_status;
|
||||
int16_t m_gasMin, m_gasMax, m_bremsMin, m_bremsMax;
|
||||
float m_gas, m_brems;
|
||||
};
|
||||
|
||||
CalibrateDisplay::CalibrateDisplay(bool bootup) :
|
||||
@ -62,6 +92,11 @@ void CalibrateDisplay::start()
|
||||
{
|
||||
m_oldMode = currentMode;
|
||||
currentMode = &m_mode;
|
||||
m_selectedButton = 0;
|
||||
m_status = Status::Begin;
|
||||
copyFromSettings();
|
||||
m_gas = 0.f;
|
||||
m_brems = 0.f;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::initScreen()
|
||||
@ -76,23 +111,107 @@ void CalibrateDisplay::initScreen()
|
||||
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
tft.drawString("gas:", 25, 47);
|
||||
tft.drawString("brems:", 25, 147);
|
||||
|
||||
for (auto &label : m_labels)
|
||||
label.start();
|
||||
|
||||
for (auto &progressBar : m_progressBars)
|
||||
progressBar.start();
|
||||
|
||||
m_renderedButton = -1;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::update()
|
||||
{
|
||||
m_gas = scaleBetween<float>(raw_gas, m_gasMin, m_gasMax, 0., 1000.);
|
||||
m_brems = scaleBetween<float>(raw_brems, m_bremsMin, m_bremsMax, 0., 1000.);
|
||||
}
|
||||
|
||||
void CalibrateDisplay::redraw()
|
||||
{
|
||||
m_labels[0].redraw(String{gas});
|
||||
m_labels[1].redraw(String{raw_gas});
|
||||
m_labels[0].redraw(toString(m_gas));
|
||||
m_labels[1].redraw(toString(raw_gas));
|
||||
if (m_status == Status::GasMin)
|
||||
tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
m_labels[2].redraw(toString(m_gasMin));
|
||||
if (m_status == Status::GasMin)
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
if (m_status == Status::GasMax)
|
||||
tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
m_labels[3].redraw(toString(m_gasMax));
|
||||
if (m_status == Status::GasMax)
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
m_labels[2].redraw(String{brems});
|
||||
m_labels[3].redraw(String{raw_brems});
|
||||
m_progressBars[0].redraw(m_gas);
|
||||
|
||||
m_progressBars[0].redraw(gas);
|
||||
m_progressBars[1].redraw(brems);
|
||||
m_labels[4].redraw(toString(m_brems));
|
||||
m_labels[5].redraw(toString(raw_brems));
|
||||
if (m_status == Status::BremsMin)
|
||||
tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
m_labels[6].redraw(toString(m_bremsMin));
|
||||
if (m_status == Status::BremsMin)
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
if (m_status == Status::BremsMax)
|
||||
tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
m_labels[7].redraw(toString(m_bremsMax));
|
||||
if (m_status == Status::BremsMax)
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
m_progressBars[1].redraw(m_brems);
|
||||
|
||||
m_labels[8].redraw([&](){
|
||||
switch (m_status)
|
||||
{
|
||||
case Status::Begin: return "Start calibrating?";
|
||||
case Status::GasMin: return "Release gas";
|
||||
case Status::GasMax: return "Press gas";
|
||||
case Status::BremsMin: return "Release brems";
|
||||
case Status::BremsMax: return "Press brems";
|
||||
case Status::Confirm: return "Verify";
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}());
|
||||
|
||||
{
|
||||
const auto color = m_status == Status::Confirm && (m_gas > 100 || m_brems > 100) ? TFT_DARKGREY : TFT_WHITE;
|
||||
tft.setTextColor(color, TFT_BLACK);
|
||||
m_labels[9].redraw([&](){
|
||||
switch (m_status)
|
||||
{
|
||||
case Status::Begin: return "Yes";
|
||||
case Status::GasMin:
|
||||
case Status::GasMax:
|
||||
case Status::BremsMin:
|
||||
case Status::BremsMax: return "Next";
|
||||
case Status::Confirm: return "Save";
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}());
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
if (m_selectedButton != m_renderedButton && (m_selectedButton == 0 || m_renderedButton == 0))
|
||||
tft.drawRect(23, 275, 100, 27, m_selectedButton == 0 ? color : TFT_BLACK);
|
||||
}
|
||||
|
||||
m_labels[10].redraw([&](){
|
||||
switch (m_status)
|
||||
{
|
||||
case Status::Begin: return "No";
|
||||
case Status::GasMin:
|
||||
case Status::GasMax:
|
||||
case Status::BremsMin:
|
||||
case Status::BremsMax:
|
||||
case Status::Confirm: return "Restart";
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}());
|
||||
|
||||
if (m_selectedButton != m_renderedButton && (m_selectedButton == 1 || m_renderedButton == 1))
|
||||
tft.drawRect(143, 275, 100, 27, m_selectedButton == 1 ? TFT_WHITE : TFT_BLACK);
|
||||
|
||||
m_renderedButton = m_selectedButton;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::stop()
|
||||
@ -101,17 +220,102 @@ void CalibrateDisplay::stop()
|
||||
currentMode = m_oldMode;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::back()
|
||||
void CalibrateDisplay::rotate(int offset)
|
||||
{
|
||||
if (!m_bootup)
|
||||
switchScreen<BoardcomputerHardwareSettingsMenu>();
|
||||
m_selectedButton += offset;
|
||||
|
||||
if (m_selectedButton < 0)
|
||||
m_selectedButton = 1;
|
||||
if (m_selectedButton > 1)
|
||||
m_selectedButton = 0;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::triggered()
|
||||
void CalibrateDisplay::back()
|
||||
{
|
||||
if (m_bootup)
|
||||
switchScreen<StatusDisplay>();
|
||||
else
|
||||
switchScreen<BoardcomputerHardwareSettingsMenu>();
|
||||
switch (m_status)
|
||||
{
|
||||
case Status::Begin:
|
||||
if (m_bootup)
|
||||
switchScreen<StatusDisplay>();
|
||||
else
|
||||
switchScreen<BoardcomputerHardwareSettingsMenu>();
|
||||
break;
|
||||
case Status::GasMin:
|
||||
case Status::GasMax:
|
||||
case Status::BremsMin:
|
||||
case Status::BremsMax:
|
||||
case Status::Confirm:
|
||||
m_selectedButton = 0;
|
||||
m_status = Status::Begin;
|
||||
copyFromSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void CalibrateDisplay::confirm()
|
||||
{
|
||||
switch (m_selectedButton)
|
||||
{
|
||||
case 0: // left button pressed
|
||||
switch (m_status)
|
||||
{
|
||||
case Status::Begin:
|
||||
m_status = Status::GasMin;
|
||||
break;
|
||||
case Status::GasMin:
|
||||
m_gasMin = raw_gas;
|
||||
m_status = Status::GasMax;
|
||||
break;
|
||||
case Status::GasMax:
|
||||
m_gasMax = raw_gas;
|
||||
m_status = Status::BremsMin;
|
||||
{
|
||||
const auto dead = (m_gasMax - m_gasMin)/20;
|
||||
m_gasMin += dead;
|
||||
m_gasMax -= dead;
|
||||
}
|
||||
break;
|
||||
case Status::BremsMin:
|
||||
m_bremsMin = raw_brems;
|
||||
m_status = Status::BremsMax;
|
||||
break;
|
||||
case Status::BremsMax:
|
||||
m_bremsMax = raw_brems;
|
||||
m_status = Status::Confirm;
|
||||
{
|
||||
const auto dead = (m_bremsMax - m_bremsMin)/20;
|
||||
m_bremsMin += dead;
|
||||
m_bremsMax -= dead;
|
||||
}
|
||||
break;
|
||||
case Status::Confirm:
|
||||
if (m_gas > 100 || m_brems > 100)
|
||||
return;
|
||||
copyToSettings();
|
||||
saveSettings();
|
||||
if (m_bootup)
|
||||
switchScreen<StatusDisplay>();
|
||||
else
|
||||
switchScreen<BoardcomputerHardwareSettingsMenu>();
|
||||
}
|
||||
break;
|
||||
case 1: // right button pressed
|
||||
back();
|
||||
}
|
||||
}
|
||||
|
||||
void CalibrateDisplay::copyFromSettings()
|
||||
{
|
||||
m_gasMin = settings.boardcomputerHardware.gasMin;
|
||||
m_gasMax = settings.boardcomputerHardware.gasMax;
|
||||
m_bremsMin = settings.boardcomputerHardware.bremsMin;
|
||||
m_bremsMax = settings.boardcomputerHardware.bremsMax;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::copyToSettings()
|
||||
{
|
||||
settings.boardcomputerHardware.gasMin = m_gasMin;
|
||||
settings.boardcomputerHardware.gasMax = m_gasMax;
|
||||
settings.boardcomputerHardware.bremsMin = m_bremsMin;
|
||||
settings.boardcomputerHardware.bremsMax = m_bremsMax;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "demodisplay.h"
|
||||
#include "display.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "textinterface.h"
|
||||
#include "widgets/label.h"
|
||||
@ -13,10 +13,8 @@ class GraphsMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class DualGraphDisplay : public DemoDisplay, public SwitchScreenAction<GraphsMenu>, public BackActionInterface<SwitchScreenAction<GraphsMenu>>
|
||||
class DualGraphDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>, public BackActionInterface<SwitchScreenAction<GraphsMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
public:
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <Arduino.h>
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include "demodisplay.h"
|
||||
#include "display.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
|
||||
namespace {
|
||||
@ -14,10 +14,8 @@ class DemosMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class GameOfLifeDisplay : public DemoDisplay, public SwitchScreenAction<DemosMenu>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
|
||||
class GameOfLifeDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<DemosMenu>>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
public:
|
||||
void start() override;
|
||||
void initScreen() override;
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <WString.h>
|
||||
|
||||
#include "demodisplay.h"
|
||||
#include "display.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "globals.h"
|
||||
#include "texts.h"
|
||||
@ -19,10 +19,8 @@ class BoardcomputerHardwareSettingsMenu;
|
||||
|
||||
namespace {
|
||||
#ifdef FEATURE_GAMETRAK
|
||||
class GametrakCalibrateDisplay : public DemoDisplay, public SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, public BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>
|
||||
class GametrakCalibrateDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>, public BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
public:
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "demodisplay.h"
|
||||
#include "display.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "textinterface.h"
|
||||
#include "widgets/label.h"
|
||||
@ -30,10 +30,13 @@ public:
|
||||
};
|
||||
|
||||
template<size_t COUNT>
|
||||
class GraphDisplay : public DemoDisplay, public SwitchScreenAction<GraphsMenu>, public virtual TextInterface, public BackActionInterface<SwitchScreenAction<GraphsMenu>>, public virtual MultiStatisticsInterface<COUNT>
|
||||
class GraphDisplay :
|
||||
public Display,
|
||||
public virtual TextInterface,
|
||||
public ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
|
||||
public BackActionInterface<SwitchScreenAction<GraphsMenu>>,
|
||||
public virtual MultiStatisticsInterface<COUNT>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
public:
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
|
@ -16,6 +16,7 @@ namespace {
|
||||
class BoardcomputerHardwareSettingsMenu;
|
||||
class CalibrateDisplay;
|
||||
class GametrakCalibrateDisplay;
|
||||
class TimersMenu;
|
||||
class SettingsMenu;
|
||||
}
|
||||
|
||||
@ -164,6 +165,7 @@ class BoardcomputerHardwareSettingsMenu :
|
||||
#endif
|
||||
makeComponent<MenuItem, StaticText<nullptr>, DummyAction>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_SWAPSCREENBYTES>, ToggleBoolAction, CheckboxIcon, SwapScreenBytesAccessor>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_TIMERS>, SwitchScreenAction<TimersMenu>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&icons::back>>
|
||||
>
|
||||
{};
|
||||
|
72
src/displays/menus/timersmenu.h
Normal file
72
src/displays/menus/timersmenu.h
Normal file
@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
#include "changevaluedisplay.h"
|
||||
#include "menudisplay.h"
|
||||
#include "staticmenudefinition.h"
|
||||
#include "utils.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "settingsaccessors.h"
|
||||
|
||||
namespace {
|
||||
class BoardcomputerHardwareSettingsMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class TimersMenu;
|
||||
|
||||
using PotiReadRateChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_POTIREADRATE>,
|
||||
PotiReadRateAccessor,
|
||||
BackActionInterface<SwitchScreenAction<TimersMenu>>,
|
||||
SwitchScreenAction<TimersMenu>
|
||||
>;
|
||||
|
||||
using ModeUpdateRateChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_MODEUPDATERATE>,
|
||||
ModeUpdateRateAccessor,
|
||||
BackActionInterface<SwitchScreenAction<TimersMenu>>,
|
||||
SwitchScreenAction<TimersMenu>
|
||||
>;
|
||||
|
||||
using StatsUpdateRateChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_STATSUPDATERATE>,
|
||||
StatsUpdateRateAccessor,
|
||||
BackActionInterface<SwitchScreenAction<TimersMenu>>,
|
||||
SwitchScreenAction<TimersMenu>
|
||||
>;
|
||||
|
||||
using DisplayUpdateRateChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_DISPLAYUPDATERATE>,
|
||||
DisplayUpdateRateAccessor,
|
||||
BackActionInterface<SwitchScreenAction<TimersMenu>>,
|
||||
SwitchScreenAction<TimersMenu>
|
||||
>;
|
||||
|
||||
using DisplayRedrawRateChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_DISPLAYREDRAWRATE>,
|
||||
DisplayRedrawRateAccessor,
|
||||
BackActionInterface<SwitchScreenAction<TimersMenu>>,
|
||||
SwitchScreenAction<TimersMenu>
|
||||
>;
|
||||
|
||||
class TimersMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_TIMERS>,
|
||||
public BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
|
||||
public StaticMenuDefinition<
|
||||
makeComponent<MenuItem, StaticText<TEXT_POTIREADRATE>, SwitchScreenAction<PotiReadRateChangeDisplay>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_MODEUPDATERATE>, SwitchScreenAction<ModeUpdateRateChangeDisplay>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_STATSUPDATERATE>, SwitchScreenAction<StatsUpdateRateChangeDisplay>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_DISPLAYUPDATERATE>, SwitchScreenAction<DisplayUpdateRateChangeDisplay>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_DISPLAYREDRAWRATE>, SwitchScreenAction<DisplayRedrawRateChangeDisplay>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::back>>
|
||||
>
|
||||
{};
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "demodisplay.h"
|
||||
#include "display.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
@ -16,10 +16,8 @@ class BmsDisplay;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class MetersDisplay : public DemoDisplay, public SwitchScreenAction<MainMenu>, public BackActionInterface<SwitchScreenAction<MainMenu>>
|
||||
class MetersDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<MainMenu>>, public BackActionInterface<SwitchScreenAction<MainMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
public:
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <Arduino.h>
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include "demodisplay.h"
|
||||
#include "display.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
|
||||
namespace {
|
||||
@ -13,10 +13,8 @@ class DemosMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class PingPongDisplay : public DemoDisplay, public SwitchScreenAction<DemosMenu>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
|
||||
class PingPongDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<DemosMenu>>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
public:
|
||||
PingPongDisplay();
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <Arduino.h>
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include "demodisplay.h"
|
||||
#include "display.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
|
||||
namespace {
|
||||
@ -13,10 +13,8 @@ class DemosMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class SpiroDisplay : public DemoDisplay, public SwitchScreenAction<DemosMenu>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
|
||||
class SpiroDisplay : public Display, public SwitchScreenAction<DemosMenu>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
public:
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "demodisplay.h"
|
||||
#include "display.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "globals.h"
|
||||
|
||||
@ -13,10 +13,8 @@ class DemosMenu;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class StarfieldDisplay : public DemoDisplay, public SwitchScreenAction<DemosMenu>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
|
||||
class StarfieldDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<DemosMenu>>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
public:
|
||||
StarfieldDisplay();
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <HardwareSerial.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
#include "demodisplay.h"
|
||||
#include "display.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
|
||||
#include "modeinterface.h"
|
||||
@ -20,10 +20,8 @@ class MetersDisplay;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class StatusDisplay : public DemoDisplay, public SwitchScreenAction<MainMenu>
|
||||
class StatusDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<MainMenu>>
|
||||
{
|
||||
using Base = DemoDisplay;
|
||||
|
||||
public:
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
|
28
src/main.cpp
28
src/main.cpp
@ -29,13 +29,11 @@
|
||||
|
||||
namespace {
|
||||
ModeInterface *lastMode{};
|
||||
millis_t lastPotiRead{};
|
||||
millis_t lastModeUpdate{};
|
||||
millis_t lastStatsUpdate{};
|
||||
millis_t lastDisplayUpdate{};
|
||||
millis_t lastDisplayRedraw{};
|
||||
|
||||
constexpr auto modeUpdateRate = 50;
|
||||
constexpr auto statsUpdateRate = 50;
|
||||
constexpr auto displayRedrawRate = 50;
|
||||
}
|
||||
|
||||
void setup()
|
||||
@ -148,12 +146,15 @@ void loop()
|
||||
dpad3wire::update();
|
||||
#endif
|
||||
|
||||
if (!lastModeUpdate)
|
||||
lastModeUpdate = now;
|
||||
else if (now - lastModeUpdate >= 1000/modeUpdateRate)
|
||||
if (!lastPotiRead || now - lastPotiRead >= 1000/settings.boardcomputerHardware.timersSettings.potiReadRate)
|
||||
{
|
||||
readPotis();
|
||||
|
||||
lastPotiRead = now;
|
||||
}
|
||||
|
||||
if (!lastModeUpdate || now - lastModeUpdate >= 1000/settings.boardcomputerHardware.timersSettings.modeUpdateRate)
|
||||
{
|
||||
if (lastMode != currentMode)
|
||||
{
|
||||
if (lastMode)
|
||||
@ -171,18 +172,21 @@ void loop()
|
||||
performance.current++;
|
||||
}
|
||||
|
||||
if (!lastStatsUpdate)
|
||||
lastStatsUpdate = now;
|
||||
else if (now - lastStatsUpdate >= 1000/statsUpdateRate)
|
||||
if (!lastStatsUpdate || now - lastStatsUpdate >= 1000/settings.boardcomputerHardware.timersSettings.statsUpdateRate)
|
||||
{
|
||||
updateAccumulators();
|
||||
pushStats();
|
||||
lastStatsUpdate = now;
|
||||
}
|
||||
|
||||
updateDisplay();
|
||||
if (!lastDisplayUpdate || now - lastDisplayUpdate >= 1000/settings.boardcomputerHardware.timersSettings.displayUpdateRate)
|
||||
{
|
||||
updateDisplay();
|
||||
|
||||
if (!lastDisplayRedraw || now - lastDisplayRedraw >= 1000/displayRedrawRate)
|
||||
lastDisplayUpdate = now;
|
||||
}
|
||||
|
||||
if (!lastDisplayRedraw || now - lastDisplayRedraw >= 1000/settings.boardcomputerHardware.timersSettings.displayRedrawRate)
|
||||
{
|
||||
redrawDisplay();
|
||||
|
||||
|
@ -76,6 +76,14 @@ constexpr Settings::ControllerHardware spinnerControllerHardware {
|
||||
.swapFrontBack = false
|
||||
};
|
||||
|
||||
constexpr Settings::BoardcomputerHardware::TimersSettings defaultTimersSettings {
|
||||
.potiReadRate = 50,
|
||||
.modeUpdateRate = 50,
|
||||
.statsUpdateRate = 50,
|
||||
.displayUpdateRate = 50,
|
||||
.displayRedrawRate = 50
|
||||
};
|
||||
|
||||
constexpr Settings::BoardcomputerHardware defaultBoardcomputerHardware {
|
||||
.sampleCount = 100,
|
||||
.gasMin = DEFAULT_GASMIN,
|
||||
@ -93,7 +101,8 @@ constexpr Settings::BoardcomputerHardware defaultBoardcomputerHardware {
|
||||
.gametrakDistMin = DEFAULT_GAMETRAKDISTMIN,
|
||||
.gametrakDistMax = DEFAULT_GAMETRAKDISTMAX,
|
||||
#endif
|
||||
.swapScreenBytes = DEFAULT_SWAPSCREENBYTES
|
||||
.swapScreenBytes = DEFAULT_SWAPSCREENBYTES,
|
||||
.timersSettings = defaultTimersSettings
|
||||
};
|
||||
|
||||
constexpr Settings::DefaultMode defaultDefaultMode {
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "displays/menus/selectmodemenu.h"
|
||||
#include "displays/menus/settingsmenu.h"
|
||||
#include "displays/menus/stationwifisettingsmenu.h"
|
||||
#include "displays/menus/timersmenu.h"
|
||||
#include "displays/menus/wifiscanmenu.h"
|
||||
#include "displays/menus/wifisettingsmenu.h"
|
||||
#include "displays/bmsdisplay.h"
|
||||
@ -99,6 +100,7 @@ union X {
|
||||
SelectModeMenu selectModeMenu;
|
||||
SettingsMenu settingsMenu;
|
||||
StationWifiSettingsMenu stationWifiSettingsMenu;
|
||||
TimersMenu timersMenu;
|
||||
WifiScanMenu wifiScanMenu;
|
||||
WifiSettingsMenu wifiSettingsMenu;
|
||||
|
||||
@ -179,6 +181,12 @@ union X {
|
||||
GametrakDistMaxChangeScreen changeGametrakDistMax;
|
||||
#endif
|
||||
|
||||
PotiReadRateChangeDisplay potiReadRateChangeDisplay;
|
||||
ModeUpdateRateChangeDisplay modeUpdateRateChangeDisplay;
|
||||
StatsUpdateRateChangeDisplay statsUpdateRateChangeDisplay;
|
||||
DisplayUpdateRateChangeDisplay displayUpdateRateChangeDisplay;
|
||||
DisplayRedrawRateChangeDisplay displayRedrawRateChangeDisplay;
|
||||
|
||||
WifiModeChangeScreen wifiModeChangeScreen;
|
||||
WifiTxPowerChangeScreen wifiTxPowerChangeScreen;
|
||||
|
||||
@ -244,6 +252,8 @@ template<> decltype(displays.presetsMenu) &
|
||||
template<> decltype(displays.selectModeMenu) &getRefByType<decltype(displays.selectModeMenu)>() { return displays.selectModeMenu; }
|
||||
template<> decltype(displays.settingsMenu) &getRefByType<decltype(displays.settingsMenu)>() { return displays.settingsMenu; }
|
||||
template<> decltype(displays.stationWifiSettingsMenu) &getRefByType<decltype(displays.stationWifiSettingsMenu)>() { return displays.stationWifiSettingsMenu; }
|
||||
|
||||
template<> decltype(displays.timersMenu) &getRefByType<decltype(displays.timersMenu)>() { return displays.timersMenu; }
|
||||
template<> decltype(displays.wifiScanMenu) &getRefByType<decltype(displays.wifiScanMenu)>() { return displays.wifiScanMenu; }
|
||||
template<> decltype(displays.wifiSettingsMenu) &getRefByType<decltype(displays.wifiSettingsMenu)>() { return displays.wifiSettingsMenu; }
|
||||
|
||||
@ -324,6 +334,12 @@ template<> decltype(displays.changeGametrakDistMin) &
|
||||
template<> decltype(displays.changeGametrakDistMax) &getRefByType<decltype(displays.changeGametrakDistMax)>() { return displays.changeGametrakDistMax; }
|
||||
#endif
|
||||
|
||||
template<> decltype(displays.potiReadRateChangeDisplay) &getRefByType<decltype(displays.potiReadRateChangeDisplay)>() { return displays.potiReadRateChangeDisplay; }
|
||||
template<> decltype(displays.modeUpdateRateChangeDisplay) &getRefByType<decltype(displays.modeUpdateRateChangeDisplay)>() { return displays.modeUpdateRateChangeDisplay; }
|
||||
template<> decltype(displays.statsUpdateRateChangeDisplay) &getRefByType<decltype(displays.statsUpdateRateChangeDisplay)>() { return displays.statsUpdateRateChangeDisplay; }
|
||||
template<> decltype(displays.displayUpdateRateChangeDisplay) &getRefByType<decltype(displays.displayUpdateRateChangeDisplay)>() { return displays.displayUpdateRateChangeDisplay; }
|
||||
template<> decltype(displays.displayRedrawRateChangeDisplay) &getRefByType<decltype(displays.displayRedrawRateChangeDisplay)>() { return displays.displayRedrawRateChangeDisplay; }
|
||||
|
||||
template<> decltype(displays.wifiModeChangeScreen) &getRefByType<decltype(displays.wifiModeChangeScreen)>() { return displays.wifiModeChangeScreen; }
|
||||
template<> decltype(displays.wifiTxPowerChangeScreen) &getRefByType<decltype(displays.wifiTxPowerChangeScreen)>() { return displays.wifiTxPowerChangeScreen; }
|
||||
|
||||
|
@ -60,6 +60,14 @@ struct Settings
|
||||
int16_t gametrakXMin, gametrakXMax, gametrakYMin, gametrakYMax, gametrakDistMin, gametrakDistMax;
|
||||
#endif
|
||||
bool swapScreenBytes;
|
||||
|
||||
struct TimersSettings {
|
||||
int16_t potiReadRate;
|
||||
int16_t modeUpdateRate;
|
||||
int16_t statsUpdateRate;
|
||||
int16_t displayUpdateRate;
|
||||
int16_t displayRedrawRate;
|
||||
} timersSettings;
|
||||
} boardcomputerHardware;
|
||||
|
||||
struct DefaultMode {
|
||||
@ -143,6 +151,11 @@ void Settings::executeForEverySetting(T &&callable)
|
||||
callable("gametrakDistMax", boardcomputerHardware.gametrakDistMax);
|
||||
#endif
|
||||
callable("swapScreenBytes", boardcomputerHardware.swapScreenBytes);
|
||||
callable("potiReadRate", boardcomputerHardware.timersSettings.potiReadRate);
|
||||
callable("modeUpdateRate", boardcomputerHardware.timersSettings.modeUpdateRate);
|
||||
callable("statsUpdateRate", boardcomputerHardware.timersSettings.statsUpdateRate);
|
||||
callable("displayUpdateRa", boardcomputerHardware.timersSettings.displayUpdateRate);
|
||||
callable("displayRedrawRa", boardcomputerHardware.timersSettings.displayRedrawRate);
|
||||
|
||||
callable("default.modelMo", defaultMode.modelMode);
|
||||
callable("default.enableS", defaultMode.enableSmoothing);
|
||||
|
@ -76,6 +76,11 @@ struct GametrakDistMinAccessor : public RefAccessorSaveSettings<int16_t> { int16
|
||||
struct GametrakDistMaxAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.gametrakDistMax; } };
|
||||
#endif
|
||||
struct SwapScreenBytesAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.boardcomputerHardware.swapScreenBytes; } };
|
||||
struct PotiReadRateAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.timersSettings.potiReadRate; } };
|
||||
struct ModeUpdateRateAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.timersSettings.modeUpdateRate; } };
|
||||
struct StatsUpdateRateAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.timersSettings.statsUpdateRate; } };
|
||||
struct DisplayUpdateRateAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.timersSettings.displayUpdateRate; } };
|
||||
struct DisplayRedrawRateAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.timersSettings.displayRedrawRate; } };
|
||||
|
||||
struct DefaultModeModelModeAccessor : public RefAccessorSaveSettings<UnifiedModelMode> { UnifiedModelMode &getRef() const override { return settings.defaultMode.modelMode; } };
|
||||
struct DefaultModeEnableSmoothingAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.defaultMode.enableSmoothing; } };
|
||||
|
10
src/texts.h
10
src/texts.h
@ -248,6 +248,7 @@ constexpr char TEXT_SETGAMETRAKYMAX[] = "Set gametrakYMax";
|
||||
constexpr char TEXT_SETGAMETRAKDISTMIN[] = "Set gametrakDistMin";
|
||||
constexpr char TEXT_SETGAMETRAKDISTMAX[] = "Set gametrakDistMax";
|
||||
constexpr char TEXT_SWAPSCREENBYTES[] = "Swap screen bytes";
|
||||
constexpr char TEXT_TIMERS[] = "Timers";
|
||||
//constexpr char TEXT_BACK[] = "Back";
|
||||
|
||||
//PresetsMenu
|
||||
@ -277,6 +278,15 @@ constexpr char TEXT_LARSM[] = "Larsm";
|
||||
constexpr char TEXT_GAMETRAK[] = "Gametrak";
|
||||
//constexpr char TEXT_BACK[] = "Back";
|
||||
|
||||
//TimersMenu
|
||||
//constexpr char TEXT_TIMERS[] = "Timers";
|
||||
constexpr char TEXT_POTIREADRATE[] = "Poti read rate";
|
||||
constexpr char TEXT_MODEUPDATERATE[] = "Mode update rate";
|
||||
constexpr char TEXT_STATSUPDATERATE[] = "Stats update rate";
|
||||
constexpr char TEXT_DISPLAYUPDATERATE[] = "Display update rate";
|
||||
constexpr char TEXT_DISPLAYREDRAWRATE[] = "Display redraw rate";
|
||||
//constexpr char TEXT_BACK[] = "Back";
|
||||
|
||||
//ChangeValueDisplay<BluetoothMode>
|
||||
constexpr char TEXT_OFF[] = "Off";
|
||||
constexpr char TEXT_MASTER[] = "Master";
|
||||
|
Reference in New Issue
Block a user