mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-26 17:46:14 +01:00
Update SSD1306Ascii.cpp
Bugfix: Move calculation of m_charsPerColumn and m_charsPerRow into constructors, to avoid incorrect random values being reported.
This commit is contained in:
parent
173676287c
commit
33229b4847
|
@ -143,18 +143,18 @@ const uint8_t FLASH SSD1306AsciiWire::SH1106_132x64init[] = {
|
||||||
// SSD1306AsciiWire Method Definitions
|
// SSD1306AsciiWire Method Definitions
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Constructor
|
// Auto-detect address
|
||||||
SSD1306AsciiWire::SSD1306AsciiWire(int width, int height) {
|
SSD1306AsciiWire::SSD1306AsciiWire(int width, int height)
|
||||||
m_i2cAddr = 0;
|
: SSD1306AsciiWire(0, width, height) { }
|
||||||
m_displayWidth = width;
|
|
||||||
m_displayHeight = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
// CS auto-detect and configure constructor
|
// Constructor with explicit address
|
||||||
SSD1306AsciiWire::SSD1306AsciiWire(I2CAddress address, int width, int height) {
|
SSD1306AsciiWire::SSD1306AsciiWire(I2CAddress address, int width, int height) {
|
||||||
m_i2cAddr = address;
|
m_i2cAddr = address;
|
||||||
m_displayWidth = width;
|
m_displayWidth = width;
|
||||||
m_displayHeight = height;
|
m_displayHeight = height;
|
||||||
|
// Set size in characters
|
||||||
|
m_charsPerColumn = m_displayHeight / fontHeight;
|
||||||
|
m_charsPerRow = (m_displayWidth+fontWidth-1) / fontWidth; // Round up
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SSD1306AsciiWire::begin() {
|
bool SSD1306AsciiWire::begin() {
|
||||||
|
@ -173,9 +173,6 @@ bool SSD1306AsciiWire::begin() {
|
||||||
DIAG(F("OLED display not found"));
|
DIAG(F("OLED display not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set size in characters
|
|
||||||
m_charsPerColumn = m_displayHeight / fontHeight;
|
|
||||||
m_charsPerRow = (m_displayWidth+fontWidth-1) / fontWidth; // Round up
|
|
||||||
m_col = 0;
|
m_col = 0;
|
||||||
m_row = 0;
|
m_row = 0;
|
||||||
m_colOffset = 0;
|
m_colOffset = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user