diff --git a/SSD1306/SSD1306Ascii.cpp b/SSD1306/SSD1306Ascii.cpp index dc7f078..0a436b2 100644 --- a/SSD1306/SSD1306Ascii.cpp +++ b/SSD1306/SSD1306Ascii.cpp @@ -121,7 +121,6 @@ size_t SSD1306Ascii::write(uint8_t ch) { // Fixed width font. base += nr*w*ch; uint8_t scol = m_col; - uint8_t srow = m_row; for (uint8_t r = 0; r < nr; r++) { if (r) { setCursor(scol, m_row + 1); @@ -134,6 +133,6 @@ size_t SSD1306Ascii::write(uint8_t ch) { ssd1306WriteRamBuf(0); } } - setRow(srow); + flushDisplay(); return 1; } diff --git a/SSD1306/SSD1306Ascii.h b/SSD1306/SSD1306Ascii.h index efe7109..6225efe 100644 --- a/SSD1306/SSD1306Ascii.h +++ b/SSD1306/SSD1306Ascii.h @@ -224,7 +224,7 @@ class SSD1306Ascii : public Print { * * @param[in] c The data byte. * @note The byte may be buffered until a call to ssd1306WriteCmd - * or ssd1306WriteRam. + * or ssd1306WriteRam or endWrite. */ void ssd1306WriteRamBuf(uint8_t c); /** @@ -235,8 +235,11 @@ class SSD1306Ascii : public Print { */ size_t write(uint8_t c); + + protected: virtual void writeDisplay(uint8_t b, uint8_t mode) = 0; + virtual void flushDisplay() = 0; uint8_t m_col; // Cursor column. uint8_t m_row; // Cursor RAM row. uint8_t m_displayWidth; // Display width. diff --git a/SSD1306/SSD1306AsciiWire.h b/SSD1306/SSD1306AsciiWire.h index 6c8159d..e1a6938 100644 --- a/SSD1306/SSD1306AsciiWire.h +++ b/SSD1306/SSD1306AsciiWire.h @@ -90,6 +90,15 @@ class SSD1306AsciiWire : public SSD1306Ascii { #endif // OPTIMIZE_I2C } + void flushDisplay() { +#if OPTIMIZE_I2C + if (m_nData) { + m_oledWire.endTransmission(); + m_nData = 0; + } +#endif // OPTIMIZE_I2C + } + protected: uint8_t m_i2cAddr; #if OPTIMIZE_I2C