mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-11 13:21:01 +01:00
Speed up OLED writes
Add new flushDisplay() to end any in-progress I2C transaction. Previously, an redundant command was sent that ended the in-progress transaction but also sent another complete, but unnecessary, transaction.
This commit is contained in:
parent
5e9fb046ab
commit
4685d2b24a
@ -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;
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user