#pragma once // local includes #include "display.h" #include "tftinterface.h" #include "tftcolors.h" #include "textinterface.h" #include "widgets/label.h" #include "widgets/graph.h" #include "confirminterface.h" #include "backinterface.h" namespace espgui { 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 virtual ConfirmInterface, public virtual BackInterface { using Base = Display; public: void initScreen(TftInterface &tft) override; void redraw(TftInterface &tft) override; void buttonPressed(Button button) 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(TftInterface &tft) { Base::initScreen(tft); m_titleLabel.start(tft); tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE); m_graph0.start(tft, static_cast&>(*this).getTopBuffers()); m_graph1.start(tft, static_cast&>(*this).getBottomBuffers()); } template void SplitGraphDisplay::redraw(TftInterface &tft) { m_titleLabel.redraw(tft, text(), TFT_YELLOW, TFT_BLACK, 4); m_graph0.redraw(tft, static_cast&>(*this).getTopBuffers()); m_graph1.redraw(tft, static_cast&>(*this).getBottomBuffers()); } template void SplitGraphDisplay::buttonPressed(Button button) { //Base::buttonPressed(button); switch (button) { case Button::Left: back(); break; case Button::Right: confirm(); break; default:; } } } // namespace espgui