diff --git a/src/actions/multiaction.h b/src/actions/multiaction.h index 3ab4d48..1975335 100644 --- a/src/actions/multiaction.h +++ b/src/actions/multiaction.h @@ -12,11 +12,8 @@ class MultiAction : public virtual ActionInterface public: void triggered() override { - m_action.triggered(); + T{}.triggered(); } - -private: - T m_action; }; template @@ -25,11 +22,8 @@ class MultiAction : public virtual MultiAction public: void triggered() override { - m_action.triggered(); + T{}.triggered(); MultiAction::triggered(); } - -private: - T m_action; }; } diff --git a/src/display.h b/src/display.h index c6dd14d..a68cdb4 100644 --- a/src/display.h +++ b/src/display.h @@ -11,30 +11,38 @@ class ChangeValueDisplayInterface; namespace { class ConfirmInterface { public: - virtual void confirm() {} + virtual void confirm() = 0; }; class BackInterface { public: - virtual void back() {} + virtual void back() = 0; }; template class ConfirmActionInterface : public virtual ConfirmInterface { - T m_action; - public: - void confirm() override { m_action.triggered(); } + void confirm() override { T{}.triggered(); } +}; + +class DummyConfirm : public virtual ConfirmInterface +{ +public: + void confirm() override {} }; template class BackActionInterface : public virtual BackInterface { - T m_action; - public: - void back() override { m_action.triggered(); } + void back() override { T{}.triggered(); } +}; + +class DummyBack : public virtual BackInterface +{ +public: + void back() override {} }; class Display : public virtual ConfirmInterface, public virtual BackInterface { diff --git a/src/displays/bmsdisplay.h b/src/displays/bmsdisplay.h index a3cc21e..ad39644 100644 --- a/src/displays/bmsdisplay.h +++ b/src/displays/bmsdisplay.h @@ -15,7 +15,7 @@ class StatusDisplay; } namespace { #ifdef FEATURE_BMS -class BmsDisplay : public Display, public ConfirmActionInterface> +class BmsDisplay : public Display, public ConfirmActionInterface>, public DummyBack { public: void initScreen() override; diff --git a/src/displays/calibratedisplay.h b/src/displays/calibratedisplay.h index b4b6b79..0da3fe3 100644 --- a/src/displays/calibratedisplay.h +++ b/src/displays/calibratedisplay.h @@ -189,12 +189,12 @@ void CalibrateDisplay::redraw() } __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); + tft.drawRect(3, 275, 100, 27, m_selectedButton == 0 ? color : TFT_BLACK); } + tft.setTextColor(TFT_WHITE, TFT_BLACK); m_labels[10].redraw([&](){ switch (m_status) { @@ -203,13 +203,13 @@ void CalibrateDisplay::redraw() case Status::GasMax: case Status::BremsMin: case Status::BremsMax: - case Status::Confirm: return "Restart"; + case Status::Confirm: return "Abort"; } __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); + tft.drawRect(123, 275, 100, 27, m_selectedButton == 1 ? TFT_WHITE : TFT_BLACK); m_renderedButton = m_selectedButton; } diff --git a/src/displays/dualgraphdisplay.h b/src/displays/dualgraphdisplay.h deleted file mode 100644 index 1976fb4..0000000 --- a/src/displays/dualgraphdisplay.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#include "display.h" -#include "actions/switchscreenaction.h" -#include "textinterface.h" -#include "widgets/label.h" -#include "widgets/graph.h" -#include "globals.h" -#include "statistics.h" - -namespace { -class GraphsMenu; -} - -namespace { -class DualGraphDisplay : public Display, public ConfirmActionInterface>, public BackActionInterface> -{ -public: - void initScreen() override; - void redraw() override; - -private: - Label m_titleLabel{5, 5}; // 230, 25 - - Graph<200, 1> m_graph0{0, 40, 133}; - Graph<200, 1> m_graph1{0, 179, 133}; -}; - -void DualGraphDisplay::initScreen() -{ - tft.fillScreen(TFT_BLACK); - - m_titleLabel.start(); - tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE); - - m_graph0.start({statistics::gas}); - m_graph1.start({statistics::brems}); -} - -void DualGraphDisplay::redraw() -{ - tft.setTextFont(4); - tft.setTextColor(TFT_YELLOW, TFT_BLACK); - m_titleLabel.redraw("Gas/Brems dual"); - - m_graph0.redraw({statistics::gas}); - m_graph1.redraw({statistics::brems}); -} -} diff --git a/src/displays/graphdisplay.h b/src/displays/graphdisplay.h index dc99b1a..c5ee2db 100644 --- a/src/displays/graphdisplay.h +++ b/src/displays/graphdisplay.h @@ -1,31 +1,37 @@ #pragma once #include "display.h" -#include "actions/switchscreenaction.h" #include "textinterface.h" #include "widgets/label.h" #include "widgets/graph.h" #include "globals.h" #include "statistics.h" -namespace { -class GraphsMenu; -} - namespace { template -class MultiStatisticsInterface +class GraphAccessorInterface { public: virtual std::array, COUNT> getBuffers() const = 0; }; -class MultiStatisticsSingleImpl : public virtual MultiStatisticsInterface<1>, public virtual BufferAccessorInterface +template +class SingleGraphAccessor : public virtual GraphAccessorInterface<1> { public: - std::array, 1> getBuffers() const + Graph<200, 1>::Container getBuffers() const { - return {getBuffer()}; + return {T{}.getBuffer()}; + } +}; + +template +class DualGraphAccessor : public virtual GraphAccessorInterface<2> +{ +public: + Graph<200, 2>::Container getBuffers() const + { + return {T1{}.getBuffer(), T2{}.getBuffer()}; } }; @@ -33,9 +39,7 @@ template class GraphDisplay : public Display, public virtual TextInterface, - public ConfirmActionInterface>, - public BackActionInterface>, - public virtual MultiStatisticsInterface + public virtual GraphAccessorInterface { public: void initScreen() override; @@ -58,7 +62,7 @@ void GraphDisplay::initScreen() m_titleLabel.start(); tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE); - m_graph.start(static_cast &>(*this).getBuffers()); + m_graph.start(static_cast &>(*this).getBuffers()); } template @@ -68,6 +72,6 @@ void GraphDisplay::redraw() tft.setTextColor(TFT_YELLOW, TFT_BLACK); m_titleLabel.redraw(text()); - m_graph.redraw(static_cast &>(*this).getBuffers()); + m_graph.redraw(static_cast &>(*this).getBuffers()); } } diff --git a/src/displays/lockscreen.h b/src/displays/lockscreen.h index ecf241b..68f17d6 100644 --- a/src/displays/lockscreen.h +++ b/src/displays/lockscreen.h @@ -14,7 +14,7 @@ class MainMenu; } namespace { -class Lockscreen : public Display +class Lockscreen : public Display, public DummyBack { using Base = Display; diff --git a/src/displays/menus/graphsmenu.h b/src/displays/menus/graphsmenu.h index a599f31..f77c427 100644 --- a/src/displays/menus/graphsmenu.h +++ b/src/displays/menus/graphsmenu.h @@ -7,44 +7,143 @@ #include "icons/back.h" #include "texts.h" #include "displays/graphdisplay.h" +#include "displays/splitgraphdisplay.h" #include "statistics.h" namespace { class MainMenu; -class DualGraphDisplay; +class GraphsMenu; } namespace { -using GasGraphDisplay = makeComponent, StaticText, MultiStatisticsSingleImpl, GasStatistics>; -using BremsGraphDisplay = makeComponent, StaticText, MultiStatisticsSingleImpl, BremsStatistics>; -using AvgSpeedGraphDisplay = makeComponent, StaticText, MultiStatisticsSingleImpl, AvgSpeedStatistics>; -using AvgSpeedKmhGraphDisplay = makeComponent, StaticText, MultiStatisticsSingleImpl, AvgSpeedKmhStatistics>; -using SumCurrentGraphDisplay = makeComponent, StaticText, MultiStatisticsSingleImpl, SumCurrentStatistics>; -using FrontVoltageGraphDisplay = makeComponent, StaticText, MultiStatisticsSingleImpl, FrontVoltageStatistics>; -using BackVoltageGraphDisplay = makeComponent, StaticText, MultiStatisticsSingleImpl, BackVoltageStatistics>; -#ifdef FEATURE_BMS -using BmsVoltageGraphDisplay = makeComponent, StaticText, MultiStatisticsSingleImpl, BmsVoltageStatistics>; -using BmsCurrentGraphDisplay = makeComponent, StaticText, MultiStatisticsSingleImpl, BmsCurrentStatistics>; -using BmsPowerGraphDisplay = makeComponent, StaticText, MultiStatisticsSingleImpl, BmsPowerStatistics>; +using GasGraphDisplay = makeComponent< + GraphDisplay<1>, + StaticText, + SingleGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; +using BremsGraphDisplay = makeComponent< + GraphDisplay<1>, + StaticText, + SingleGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; +using PotisGraphDisplay = makeComponent< + GraphDisplay<2>, + StaticText, + DualGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; +using PotisSplitGraphDisplay = makeComponent< + SplitGraphDisplay<1, 1>, + StaticText, + SingleTopGraphAccessor, + SingleBottomGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; -class SumCurrentsComparisonStatistics : public virtual MultiStatisticsInterface<2> -{ - std::array, 2> getBuffers() const override - { - return {SumCurrentStatistics{}.getBuffer(), BmsCurrentStatistics{}.getBuffer()}; - } -}; -using SumCurrentsComparisonGraphDisplay = makeComponent, StaticText, SumCurrentsComparisonStatistics>; +using AvgSpeedGraphDisplay = makeComponent< + GraphDisplay<1>, + StaticText, + SingleGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; +using AvgSpeedKmhGraphDisplay = makeComponent< + GraphDisplay<1>, + StaticText, + SingleGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; + +using SumCurrentGraphDisplay = makeComponent< + GraphDisplay<1>, + StaticText, + SingleGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; + +using FrontVoltageGraphDisplay = makeComponent< + GraphDisplay<1>, + StaticText, + SingleGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; +using BackVoltageGraphDisplay = makeComponent< + GraphDisplay<1>, + StaticText, + SingleGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; +using VoltagesGraphDisplay = makeComponent< + GraphDisplay<2>, + StaticText, + DualGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; +using VoltagesSplitGraphDisplay = makeComponent< + SplitGraphDisplay<1, 1>, + StaticText, + SingleTopGraphAccessor, + SingleBottomGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; + +#ifdef FEATURE_BMS +using BmsVoltageGraphDisplay = makeComponent< + GraphDisplay<1>, + StaticText, + SingleGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; +using BmsCurrentGraphDisplay = makeComponent< + GraphDisplay<1>, + StaticText, + SingleGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; +using BmsPowerGraphDisplay = makeComponent< + GraphDisplay<1>, + StaticText, + SingleGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; +using SumCurrentsComparisonGraphDisplay = makeComponent< + GraphDisplay<2>, + StaticText, + DualGraphAccessor, + ConfirmActionInterface>, + BackActionInterface> +>; #endif -class MotorCurrentsStatistics : public virtual MultiStatisticsInterface<4> +class MotorCurrentsStatistics : public virtual GraphAccessorInterface<4> { std::array, 4> getBuffers() const override { return {FrontLeftCurrentStatistics{}.getBuffer(), FrontRightCurrentStatistics{}.getBuffer(), BackLeftCurrentStatistics{}.getBuffer(), BackRightCurrentStatistics{}.getBuffer()}; } }; -using MotorCurrentsGraphDisplay = makeComponent, StaticText, MotorCurrentsStatistics>; +using MotorCurrentsGraphDisplay = makeComponent< + GraphDisplay<4>, + StaticText, + MotorCurrentsStatistics, + ConfirmActionInterface>, + BackActionInterface> +>; class GraphsMenu : public MenuDisplay, @@ -53,11 +152,15 @@ class GraphsMenu : public StaticMenuDefinition< makeComponent, SwitchScreenAction>, makeComponent, SwitchScreenAction>, + makeComponent, SwitchScreenAction>, + makeComponent, SwitchScreenAction>, makeComponent, SwitchScreenAction>, makeComponent, SwitchScreenAction>, makeComponent, SwitchScreenAction>, makeComponent, SwitchScreenAction>, makeComponent, SwitchScreenAction>, + makeComponent, SwitchScreenAction>, + makeComponent, SwitchScreenAction>, #ifdef FEATURE_BMS makeComponent, SwitchScreenAction>, makeComponent, SwitchScreenAction>, @@ -65,7 +168,6 @@ class GraphsMenu : makeComponent, SwitchScreenAction>, #endif makeComponent, SwitchScreenAction>, - makeComponent, SwitchScreenAction>, makeComponent, SwitchScreenAction, StaticMenuItemIcon<&icons::back>> > {}; diff --git a/src/displays/metersdisplay.h b/src/displays/metersdisplay.h index 09285ce..a5e47a9 100644 --- a/src/displays/metersdisplay.h +++ b/src/displays/metersdisplay.h @@ -39,12 +39,12 @@ private: static constexpr auto x = 40; std::array meters{{ - VerticalMeter{"U f", "%.1fV", 0*x, 160}, - VerticalMeter{"U b", "%.1fV", 1*x, 160}, - VerticalMeter{"Ivl", "%.1fA", 2*x, 160}, - VerticalMeter{"Ivr", "%.1fA", 3*x, 160}, - VerticalMeter{"Ihl", "%.1fA", 4*x, 160}, - VerticalMeter{"Ihr", "%.1fA", 5*x, 160} + VerticalMeter{"U f", "%.1f", 0*x, 160}, + VerticalMeter{"U b", "%.1f", 1*x, 160}, + VerticalMeter{"Ibl", "%.1f", 2*x, 160}, + VerticalMeter{"Ibr", "%.1f", 3*x, 160}, + VerticalMeter{"Ihl", "%.1f", 4*x, 160}, + VerticalMeter{"Ihr", "%.1f", 5*x, 160} }}; }; diff --git a/src/displays/poweroffdisplay.h b/src/displays/poweroffdisplay.h index a6f2b2e..759f1ad 100644 --- a/src/displays/poweroffdisplay.h +++ b/src/displays/poweroffdisplay.h @@ -12,7 +12,7 @@ class MainMenu; } namespace { -class PoweroffDisplay : public Display +class PoweroffDisplay : public Display, public DummyConfirm, public DummyBack { public: void start() override; diff --git a/src/displays/spirodisplay.h b/src/displays/spirodisplay.h index 226516f..96a9a31 100644 --- a/src/displays/spirodisplay.h +++ b/src/displays/spirodisplay.h @@ -13,7 +13,7 @@ class DemosMenu; } namespace { -class SpiroDisplay : public Display, public SwitchScreenAction, public BackActionInterface> +class SpiroDisplay : public Display, public SwitchScreenAction, public DummyConfirm, public BackActionInterface> { public: void initScreen() override; diff --git a/src/displays/splitgraphdisplay.h b/src/displays/splitgraphdisplay.h new file mode 100644 index 0000000..32a5a4c --- /dev/null +++ b/src/displays/splitgraphdisplay.h @@ -0,0 +1,85 @@ +#pragma once + +#include "display.h" +#include "textinterface.h" +#include "widgets/label.h" +#include "widgets/graph.h" +#include "globals.h" +#include "statistics.h" + +namespace { +template +class TopGraphAccessorInterface +{ +public: + virtual typename Graph<200, COUNT>::Container getTopBuffers() const = 0; +}; + +template +class SingleTopGraphAccessor : public virtual TopGraphAccessorInterface<1> +{ +public: + typename Graph<200, 1>::Container getTopBuffers() const override + { + return {T{}.getBuffer()}; + } +}; + +template +class BottomGraphAccessorInterface +{ +public: + virtual typename Graph<200, COUNT>::Container getBottomBuffers() const = 0; +}; + +template +class SingleBottomGraphAccessor : public virtual BottomGraphAccessorInterface<1> +{ +public: + typename Graph<200, 1>::Container getBottomBuffers() const override + { + return {T{}.getBuffer()}; + } +}; + +template +class SplitGraphDisplay : + public Display, + public virtual TextInterface, + public virtual TopGraphAccessorInterface, + public virtual BottomGraphAccessorInterface +{ +public: + void initScreen() override; + void redraw() override; + +private: + Label m_titleLabel{5, 5}; // 230, 25 + + Graph<200, COUNT0> m_graph0{0, 40, 133}; + Graph<200, COUNT1> m_graph1{0, 179, 133}; +}; + +template +void SplitGraphDisplay::initScreen() +{ + tft.fillScreen(TFT_BLACK); + + m_titleLabel.start(); + tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE); + + m_graph0.start(static_cast&>(*this).getTopBuffers()); + m_graph1.start(static_cast&>(*this).getBottomBuffers()); +} + +template +void SplitGraphDisplay::redraw() +{ + tft.setTextFont(4); + tft.setTextColor(TFT_YELLOW, TFT_BLACK); + m_titleLabel.redraw(text()); + + m_graph0.redraw(static_cast&>(*this).getTopBuffers()); + m_graph1.redraw(static_cast&>(*this).getBottomBuffers()); +} +} diff --git a/src/displays/statusdisplay.h b/src/displays/statusdisplay.h index 698c538..115dd94 100644 --- a/src/displays/statusdisplay.h +++ b/src/displays/statusdisplay.h @@ -20,7 +20,7 @@ class MetersDisplay; } namespace { -class StatusDisplay : public Display, public ConfirmActionInterface> +class StatusDisplay : public Display, public ConfirmActionInterface>, public DummyBack { public: void initScreen() override; diff --git a/src/displays/updatedisplay.h b/src/displays/updatedisplay.h index 46af5e1..4fd6aeb 100644 --- a/src/displays/updatedisplay.h +++ b/src/displays/updatedisplay.h @@ -19,7 +19,7 @@ class StatusDisplay; namespace { #ifdef FEATURE_OTA -class UpdateDisplay : public Display +class UpdateDisplay : public Display, public DummyBack { public: UpdateDisplay(const String &title); diff --git a/src/screens.h b/src/screens.h index 4fc866b..00e61e9 100644 --- a/src/screens.h +++ b/src/screens.h @@ -35,7 +35,6 @@ #include "displays/menus/wifisettingsmenu.h" #include "displays/bmsdisplay.h" #include "displays/calibratedisplay.h" -#include "displays/dualgraphdisplay.h" #include "displays/gameoflifedisplay.h" #include "displays/gametrakcalibratedisplay.h" #include "displays/lockscreen.h" @@ -108,7 +107,6 @@ union X { BmsDisplay bmsDisplay; #endif CalibrateDisplay calibrateDisplay; - DualGraphDisplay dualGraphDisplay; GameOfLifeDisplay gameOfLifeDisplay; #ifdef FEATURE_GAMETRAK GametrakCalibrateDisplay gametrakCalibrateDisplay; @@ -192,11 +190,15 @@ union X { GasGraphDisplay gasGraphDisplay; BremsGraphDisplay bremsGraphDisplay; + PotisGraphDisplay potisGraphDisplay; + PotisSplitGraphDisplay potisSplitGraphDisplay; AvgSpeedGraphDisplay avgSpeedGraphDisplay; AvgSpeedKmhGraphDisplay avgSpeedKmhGraphDisplay; SumCurrentGraphDisplay sumCurrentGraphDisplay; FrontVoltageGraphDisplay frontVoltageGraphDisplay; BackVoltageGraphDisplay backVoltageGraphDisplay; + VoltagesGraphDisplay voltagesGraphDisplay; + VoltagesSplitGraphDisplay voltagesSplitGraphDisplay; #ifdef FEATURE_BMS BmsVoltageGraphDisplay bmsVoltageGraphDisplay; BmsCurrentGraphDisplay bmsCurrentGraphDisplay; @@ -260,7 +262,6 @@ template<> decltype(displays.wifiSettingsMenu) & template<> decltype(displays.bmsDisplay) &getRefByType() { return displays.bmsDisplay; } #endif template<> decltype(displays.calibrateDisplay) &getRefByType() { return displays.calibrateDisplay; } -template<> decltype(displays.dualGraphDisplay) &getRefByType() { return displays.dualGraphDisplay; } template<> decltype(displays.gameOfLifeDisplay) &getRefByType() { return displays.gameOfLifeDisplay; } #ifdef FEATURE_GAMETRAK template<> decltype(displays.gametrakCalibrateDisplay) &getRefByType() { return displays.gametrakCalibrateDisplay; } @@ -344,11 +345,15 @@ template<> decltype(displays.wifiTxPowerChangeScreen) & template<> decltype(displays.gasGraphDisplay) &getRefByType() { return displays.gasGraphDisplay; } template<> decltype(displays.bremsGraphDisplay) &getRefByType() { return displays.bremsGraphDisplay; } +template<> decltype(displays.potisGraphDisplay) &getRefByType() { return displays.potisGraphDisplay; } +template<> decltype(displays.potisSplitGraphDisplay) &getRefByType() { return displays.potisSplitGraphDisplay; } template<> decltype(displays.avgSpeedGraphDisplay) &getRefByType() { return displays.avgSpeedGraphDisplay; } template<> decltype(displays.avgSpeedKmhGraphDisplay) &getRefByType() { return displays.avgSpeedKmhGraphDisplay; } template<> decltype(displays.sumCurrentGraphDisplay) &getRefByType() { return displays.sumCurrentGraphDisplay; } template<> decltype(displays.frontVoltageGraphDisplay) &getRefByType() { return displays.frontVoltageGraphDisplay; } template<> decltype(displays.backVoltageGraphDisplay) &getRefByType() { return displays.backVoltageGraphDisplay; } +template<> decltype(displays.voltagesGraphDisplay) &getRefByType() { return displays.voltagesGraphDisplay; } +template<> decltype(displays.voltagesSplitGraphDisplay) &getRefByType() { return displays.voltagesSplitGraphDisplay; } #ifdef FEATURE_BMS template<> decltype(displays.bmsVoltageGraphDisplay) &getRefByType() { return displays.bmsVoltageGraphDisplay; } template<> decltype(displays.bmsCurrentGraphDisplay) &getRefByType() { return displays.bmsCurrentGraphDisplay; } diff --git a/src/statistics.h b/src/statistics.h index e21fbc9..d920bd1 100644 --- a/src/statistics.h +++ b/src/statistics.h @@ -42,14 +42,14 @@ void pushStats() #endif } -class BufferAccessorInterface +class StatisticsAccessorInterface { public: virtual const statistics::ContainerType &getBuffer() const = 0; }; template -class BufferAccessorImpl : public virtual BufferAccessorInterface +class BufferAccessorImpl : public virtual StatisticsAccessorInterface { public: const statistics::ContainerType &getBuffer() const override { return T; } diff --git a/src/texts.h b/src/texts.h index b54bf13..f62ea92 100644 --- a/src/texts.h +++ b/src/texts.h @@ -178,17 +178,18 @@ constexpr char TEXT_WIFISCAN[] = "WiFi scan"; //constexpr char TEXT_GRAPHS[] = "Graphs"; constexpr char TEXT_GAS[] = "Gas"; constexpr char TEXT_BREMS[] = "Brems"; +constexpr char TEXT_POTIS[] = "Potis"; constexpr char TEXT_AVGSPEED[] = "Avg. speed"; constexpr char TEXT_AVGSPEEDKMH[] = "Avg. speed KMH"; constexpr char TEXT_SUMCURRENT[] = "Sum current"; constexpr char TEXT_FRONTVOLTAGE[] = "Front voltage"; constexpr char TEXT_BACKVOLTAGE[] = "Back voltage"; +constexpr char TEXT_VOLTAGES[] = "Voltages"; constexpr char TEXT_BMSVOLTAGE[] = "BMS voltage"; constexpr char TEXT_BMSCURRENT[] = "BMS current"; constexpr char TEXT_BMSPOWER[] = "BMS power"; constexpr char TEXT_SUMCURRENTSCOMPARISON[] = "Sum currents comparison"; constexpr char TEXT_MOTORCURRENTS[] = "Motor currents"; -constexpr char TEXT_DUALGRAPHS[] = "Dual graphs"; //constexpr char TEXT_BACK[] = "Back"; //InvertMenu diff --git a/src/widgets/graph.h b/src/widgets/graph.h index 8c816bc..e65d040 100644 --- a/src/widgets/graph.h +++ b/src/widgets/graph.h @@ -15,15 +15,16 @@ class Graph static constexpr int leftMargin = 40; public: + using Container = std::array>, COUNT>; static constexpr int WIDTH = LENGTH+40; Graph(int x, int y, int height); - void start(const std::array>, COUNT> &buffers); - void redraw(const std::array>, COUNT> &buffers); + void start(const Container &buffers); + void redraw(const Container &buffers); private: - void render(const std::array>, COUNT> &buffers, bool delta); + void render(const Container &buffers, bool delta); const int m_x, m_y, m_height; @@ -49,7 +50,7 @@ Graph::Graph(int x, int y, int height) : } template -void Graph::start(const std::array>, COUNT> &buffers) +void Graph::start(const Container &buffers) { m_min = 0.f; m_max = 10.f; @@ -66,13 +67,13 @@ void Graph::start(const std::array -void Graph::redraw(const std::array>, COUNT> &buffers) +void Graph::redraw(const Container &buffers) { render(buffers, true); } template -void Graph::render(const std::array>, COUNT> &buffers, bool delta) +void Graph::render(const Container &buffers, bool delta) { float min{std::numeric_limits::quiet_NaN()}, max{std::numeric_limits::quiet_NaN()}; bool first{true};