#pragma once // 3rdparty lib includes #include // local includes #include "displaywithtitle.h" #include "textinterface.h" #include "widgets/label.h" #include "widgets/graph.h" #include "tftinstance.h" namespace espgui { template class GraphAccessorInterface { public: virtual std::array>, COUNT> getBuffers() const = 0; }; template class SingleGraphAccessor : public virtual GraphAccessorInterface<1> { public: Graph<200, 1>::Container getBuffers() const { return {T{}.getBuffer()}; } }; template class DualGraphAccessor : public virtual GraphAccessorInterface<2> { public: Graph<200, 2>::Container getBuffers() const { return {T1{}.getBuffer(), T2{}.getBuffer()}; } }; template class GraphDisplay : public DisplayWithTitle, public virtual GraphAccessorInterface { using Base = DisplayWithTitle; public: void initScreen() override; void redraw() override; private: static constexpr int screenHeight = 320, topMargin = 40, bottomMargin = 10, labelOffset = -5; static constexpr int graphHeight = screenHeight-topMargin-bottomMargin; Graph<200, COUNT> m_graph{0, 40, 270}; }; template void GraphDisplay::initScreen() { Base::initScreen(); m_graph.start(static_cast &>(*this).getBuffers()); } template void GraphDisplay::redraw() { Base::redraw(); m_graph.redraw(static_cast &>(*this).getBuffers()); } }