Merge pull request #24 from 0xFEEDC0DE64/update
This commit is contained in:
@ -67,7 +67,7 @@ void GraphDisplay<COUNT>::initScreen(TftInterface &tft)
|
||||
{
|
||||
Base::initScreen(tft);
|
||||
|
||||
m_graph.start(static_cast<const GraphAccessorInterface<COUNT> &>(*this).getBuffers());
|
||||
m_graph.start(tft, static_cast<const GraphAccessorInterface<COUNT> &>(*this).getBuffers());
|
||||
}
|
||||
|
||||
template<size_t COUNT>
|
||||
@ -75,7 +75,7 @@ void GraphDisplay<COUNT>::redraw(TftInterface &tft)
|
||||
{
|
||||
Base::redraw(tft);
|
||||
|
||||
m_graph.redraw(static_cast<const GraphAccessorInterface<COUNT> &>(*this).getBuffers());
|
||||
m_graph.redraw(tft, static_cast<const GraphAccessorInterface<COUNT> &>(*this).getBuffers());
|
||||
}
|
||||
|
||||
template<size_t COUNT>
|
||||
|
@ -75,22 +75,20 @@ void SplitGraphDisplay<COUNT0, COUNT1>::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<const TopGraphAccessorInterface<COUNT0>&>(*this).getTopBuffers());
|
||||
m_graph1.start(static_cast<const BottomGraphAccessorInterface<COUNT1>&>(*this).getBottomBuffers());
|
||||
m_graph0.start(tft, static_cast<const TopGraphAccessorInterface<COUNT0>&>(*this).getTopBuffers());
|
||||
m_graph1.start(tft, static_cast<const BottomGraphAccessorInterface<COUNT1>&>(*this).getBottomBuffers());
|
||||
}
|
||||
|
||||
template<std::size_t COUNT0, std::size_t COUNT1>
|
||||
void SplitGraphDisplay<COUNT0, COUNT1>::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<const TopGraphAccessorInterface<COUNT0>&>(*this).getTopBuffers());
|
||||
m_graph1.redraw(static_cast<const BottomGraphAccessorInterface<COUNT1>&>(*this).getBottomBuffers());
|
||||
m_graph0.redraw(tft, static_cast<const TopGraphAccessorInterface<COUNT0>&>(*this).getTopBuffers());
|
||||
m_graph1.redraw(tft, static_cast<const BottomGraphAccessorInterface<COUNT1>&>(*this).getBottomBuffers());
|
||||
}
|
||||
|
||||
template<std::size_t COUNT0, std::size_t COUNT1>
|
||||
|
@ -73,6 +73,19 @@ public:
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data) { m_tft.pushImage(x, y, w, h, data); }
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data, uint16_t transparent) { m_tft.pushImage(x, y, w, h, data, transparent); }
|
||||
|
||||
uint16_t decodeUTF8(const uint8_t *buf, uint16_t *index, uint16_t remaining) override { return m_tft.decodeUTF8(buf, index, remaining); }
|
||||
uint16_t decodeUTF8(uint8_t c) override { return m_tft.decodeUTF8(c); }
|
||||
|
||||
void setSwapBytes(bool swap) override { m_tft.setSwapBytes(swap); }
|
||||
bool getSwapBytes(void) const override { return m_tft.getSwapBytes(); }
|
||||
|
||||
void startWrite(void) override { m_tft.startWrite(); }
|
||||
void writeColor(uint16_t color, uint32_t len) override { m_tft.writeColor(color, len); }
|
||||
void endWrite(void) override { m_tft.endWrite(); }
|
||||
|
||||
void pushColor(uint16_t color, uint32_t len) override { m_tft.pushColor(color, len); }
|
||||
|
||||
void setAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h) override { m_tft.setAddrWindow(xs, ys, w, h); }
|
||||
private:
|
||||
TFT_eSPI m_tft;
|
||||
};
|
||||
|
@ -84,6 +84,25 @@ public:
|
||||
// These are used to render images or sprites stored in RAM arrays (used by Sprite class for 16bpp Sprites)
|
||||
virtual void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data) = 0;
|
||||
virtual void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data, uint16_t transparent) = 0;
|
||||
|
||||
// Used by library and Smooth font class to extract Unicode point codes from a UTF8 encoded string
|
||||
virtual uint16_t decodeUTF8(const uint8_t *buf, uint16_t *index, uint16_t remaining) = 0;
|
||||
virtual uint16_t decodeUTF8(uint8_t c) = 0;
|
||||
|
||||
// Swap the byte order for pushImage() and pushPixels() - corrects endianness
|
||||
virtual void setSwapBytes(bool swap) = 0;
|
||||
virtual bool getSwapBytes(void) const = 0;
|
||||
|
||||
// Bare metal functions
|
||||
virtual void startWrite(void) = 0;
|
||||
virtual void writeColor(uint16_t color, uint32_t len) = 0;
|
||||
virtual void endWrite(void) = 0;
|
||||
|
||||
// Push (aka write pixel) colours to the set window
|
||||
virtual void pushColor(uint16_t color, uint32_t len) = 0;
|
||||
|
||||
// The TFT_eSprite class inherits the following functions (not all are useful to Sprite class
|
||||
virtual void setAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h) = 0;
|
||||
};
|
||||
|
||||
inline bool isLandscape(const TftInterface &tft)
|
||||
|
@ -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<LENGTH, COUNT>::Graph(int x, int y, int height) :
|
||||
}
|
||||
|
||||
template<size_t LENGTH, size_t COUNT>
|
||||
void Graph<LENGTH, COUNT>::start(const Container &buffers)
|
||||
void Graph<LENGTH, COUNT>::start(TftInterface &tft, const Container &buffers)
|
||||
{
|
||||
m_min = 0.f;
|
||||
m_max = 10.f;
|
||||
@ -66,20 +66,20 @@ void Graph<LENGTH, COUNT>::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<size_t LENGTH, size_t COUNT>
|
||||
void Graph<LENGTH, COUNT>::redraw(const Container &buffers)
|
||||
void Graph<LENGTH, COUNT>::redraw(TftInterface &tft, const Container &buffers)
|
||||
{
|
||||
render(buffers, true);
|
||||
render(tft, buffers, true);
|
||||
}
|
||||
|
||||
template<size_t LENGTH, size_t COUNT>
|
||||
void Graph<LENGTH, COUNT>::render(const Container &buffers, bool delta)
|
||||
void Graph<LENGTH, COUNT>::render(TftInterface &tft, const Container &buffers, bool delta)
|
||||
{
|
||||
float min{std::numeric_limits<float>::quiet_NaN()}, max{std::numeric_limits<float>::quiet_NaN()};
|
||||
bool first{true};
|
||||
@ -115,10 +115,8 @@ void Graph<LENGTH, COUNT>::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++)
|
||||
|
Reference in New Issue
Block a user