mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-23 12:51:24 +01:00
Refactor SSD1306 initialisation to support different initialisation sequences.
To support a HAL Display driver, the SSD1306 driver can be created (new) and then the I2C address assigned explicitly in the begin() call. The original approach of looking for the I2C device address has also been retained in a different constructor.
This commit is contained in:
parent
9435869ee3
commit
278a9c52a6
@ -144,7 +144,10 @@ const uint8_t FLASH SSD1306AsciiWire::SH1106_132x64init[] = {
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Constructor
|
||||
SSD1306AsciiWire::SSD1306AsciiWire() {}
|
||||
SSD1306AsciiWire::SSD1306AsciiWire() {
|
||||
I2CManager.begin();
|
||||
I2CManager.setClock(400000L); // Set max supported I2C speed
|
||||
}
|
||||
|
||||
// CS auto-detect and configure constructor
|
||||
SSD1306AsciiWire::SSD1306AsciiWire(int width, int height) {
|
||||
@ -193,7 +196,7 @@ bool SSD1306AsciiWire::begin(I2CAddress address, int width, int height) {
|
||||
return false;
|
||||
}
|
||||
// Device found
|
||||
DIAG(F("%dx%d OLED display configured on I2C:x%x"), m_displayWidth, m_displayHeight, (uint8_t)m_i2cAddr);
|
||||
DIAG(F("%dx%d OLED display configured on I2C:x%x"), m_displayWidth, m_displayHeight, (int)m_i2cAddr);
|
||||
clear();
|
||||
return true;
|
||||
}
|
||||
@ -203,8 +206,9 @@ void SSD1306AsciiWire::clearNative() {
|
||||
const int maxBytes = sizeof(blankPixels); // max number of bytes sendable over Wire
|
||||
for (uint8_t r = 0; r <= m_displayHeight/8 - 1; r++) {
|
||||
setRowNative(r); // Position at start of row to be erased
|
||||
for (uint8_t c = 0; c <= m_displayWidth - 1; c += maxBytes-1) {
|
||||
uint8_t len = min(m_displayWidth-c, maxBytes-1) + 1;
|
||||
for (uint8_t c = 0; c <= m_displayWidth - 1; c += maxBytes) {
|
||||
uint8_t len = m_displayWidth-c;
|
||||
if (len > maxBytes) len = maxBytes;
|
||||
I2CManager.write_P(m_i2cAddr, blankPixels, len); // Write a number of blank columns
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user