diff --git a/src/graphdisplay.h b/src/graphdisplay.h index c5c5301..75cc3b3 100644 --- a/src/graphdisplay.h +++ b/src/graphdisplay.h @@ -67,7 +67,7 @@ void GraphDisplay::initScreen(TftInterface &tft) { Base::initScreen(tft); - m_graph.start(static_cast &>(*this).getBuffers()); + m_graph.start(tft, static_cast &>(*this).getBuffers()); } template @@ -75,7 +75,7 @@ void GraphDisplay::redraw(TftInterface &tft) { Base::redraw(tft); - m_graph.redraw(static_cast &>(*this).getBuffers()); + m_graph.redraw(tft, static_cast &>(*this).getBuffers()); } template diff --git a/src/splitgraphdisplay.h b/src/splitgraphdisplay.h index ca3c734..57a2632 100644 --- a/src/splitgraphdisplay.h +++ b/src/splitgraphdisplay.h @@ -75,22 +75,20 @@ void SplitGraphDisplay::initScreen(TftInterface &tft) { Base::initScreen(tft); - m_titleLabel.start(); + m_titleLabel.start(tft); tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE); - m_graph0.start(static_cast&>(*this).getTopBuffers()); - m_graph1.start(static_cast&>(*this).getBottomBuffers()); + m_graph0.start(tft, static_cast&>(*this).getTopBuffers()); + m_graph1.start(tft, static_cast&>(*this).getBottomBuffers()); } template void SplitGraphDisplay::redraw(TftInterface &tft) { - tft.setTextFont(4); - tft.setTextColor(TFT_YELLOW, TFT_BLACK); - m_titleLabel.redraw(text()); + m_titleLabel.redraw(tft, text(), TFT_YELLOW, TFT_BLACK, 4); - m_graph0.redraw(static_cast&>(*this).getTopBuffers()); - m_graph1.redraw(static_cast&>(*this).getBottomBuffers()); + m_graph0.redraw(tft, static_cast&>(*this).getTopBuffers()); + m_graph1.redraw(tft, static_cast&>(*this).getBottomBuffers()); } template diff --git a/src/widgets/graph.h b/src/widgets/graph.h index 6432445..356793e 100644 --- a/src/widgets/graph.h +++ b/src/widgets/graph.h @@ -26,11 +26,11 @@ public: Graph(int x, int y, int height); - void start(const Container &buffers); - void redraw(const Container &buffers); + void start(TftInterface &tft, const Container &buffers); + void redraw(TftInterface &tft, const Container &buffers); private: - void render(const Container &buffers, bool delta); + void render(TftInterface &tft, const Container &buffers, bool delta); const int m_x, m_y, m_height; @@ -56,7 +56,7 @@ Graph::Graph(int x, int y, int height) : } template -void Graph::start(const Container &buffers) +void Graph::start(TftInterface &tft, const Container &buffers) { m_min = 0.f; m_max = 10.f; @@ -66,20 +66,20 @@ void Graph::start(const Container &buffers) for (auto iter = std::begin(m_labels); iter != std::end(m_labels); iter++) { tft.drawFastHLine(m_x+leftMargin-5, float(m_y)+(float(m_height)/(m_labels.size()-1)*std::distance(std::begin(m_labels), iter)), 4, TFT_WHITE); - iter->start(); + iter->start(tft); } - render(buffers, false); + render(tft, buffers, false); } template -void Graph::redraw(const Container &buffers) +void Graph::redraw(TftInterface &tft, const Container &buffers) { - render(buffers, true); + render(tft, buffers, true); } template -void Graph::render(const Container &buffers, bool delta) +void Graph::render(TftInterface &tft, const Container &buffers, bool delta) { float min{std::numeric_limits::quiet_NaN()}, max{std::numeric_limits::quiet_NaN()}; bool first{true}; @@ -115,10 +115,8 @@ void Graph::render(const Container &buffers, bool delta) if (m_min < 0 && m_max < 0) m_max = 0; - tft.setTextFont(2); - tft.setTextColor(TFT_WHITE, TFT_BLACK); for (auto iter = std::begin(m_labels); iter != std::end(m_labels); iter++) - iter->redraw(std::to_string(int(m_max+((m_min-m_max)/(m_labels.size()-1)*std::distance(std::begin(m_labels), iter))))); + iter->redraw(tft, std::to_string(int(m_max+((m_min-m_max)/(m_labels.size()-1)*std::distance(std::begin(m_labels), iter)))), TFT_WHITE, TFT_BLACK, 2); int x{leftMargin}; for (auto pixelsIter = std::begin(m_lastPixels); pixelsIter!=std::end(m_lastPixels); pixelsIter++)