Skip to content

Commit 9790e13

Browse files
committed
Add constructor overloading for backwards compatibility
1 parent 19b07d8 commit 9790e13

File tree

6 files changed

+35
-12
lines changed

6 files changed

+35
-12
lines changed

SH1106Brzo.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class SH1106Brzo : public OLEDDisplay {
4444
uint8_t _scl;
4545

4646
public:
47+
SH1106Brzo(uint8_t _address, uint8_t _sda, uint8_t _scl) : SH1106Brzo(GEOMETRY_128_64, _address, _sda, _scl) {
48+
49+
}
50+
4751
SH1106Brzo(OLEDDISPLAY_GEOMETRY g, uint8_t _address, uint8_t _sda, uint8_t _scl) {
4852
this->geometry = g;
4953
if (g == GEOMETRY_128_64) {
@@ -53,7 +57,7 @@ class SH1106Brzo : public OLEDDisplay {
5357
} else if (g == GEOMETRY_128_32) {
5458
this->displayWidth = 128;
5559
this->displayHeight = 32;
56-
this->displayBufferSize = 512;
60+
this->displayBufferSize = 512;
5761
}
5862

5963
this->_address = _address;
@@ -100,7 +104,7 @@ class SH1106Brzo : public OLEDDisplay {
100104
uint8_t sendBuffer[17];
101105
sendBuffer[0] = 0x40;
102106

103-
// Calculate the colum offset
107+
// Calculate the colum offset
104108
uint8_t minBoundXp2H = (minBoundX + 2) & 0x0F;
105109
uint8_t minBoundXp2L = 0x10 | ((minBoundX + 2) >> 4 );
106110

SH1106Spi.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ class SH1106Spi : public OLEDDisplay {
3737
uint8_t _dc;
3838

3939
public:
40+
SH1106Spi(uint8_t _rst, uint8_t _dc) : SH1106Spi(GEOMETRY_128_64, _rst, _dc) {
4041

41-
SH1106Spi(OLEDDISPLAY_GEOMETRY g, uint8_t _rst, uint8_t _dc) {
42+
}
43+
44+
SH1106Spi(OLEDDISPLAY_GEOMETRY g, uint8_t _rst, uint8_t _dc) {
4245
this->geometry = g;
4346
if (g == GEOMETRY_128_64) {
4447
this->displayWidth = 128;
@@ -47,7 +50,7 @@ class SH1106Spi : public OLEDDisplay {
4750
} else if (g == GEOMETRY_128_32) {
4851
this->displayWidth = 128;
4952
this->displayHeight = 32;
50-
this->displayBufferSize = 512;
53+
this->displayBufferSize = 512;
5154
}
5255

5356
this->_rst = _rst;

SH1106Wire.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ class SH1106Wire : public OLEDDisplay {
4444
uint8_t _scl;
4545

4646
public:
47-
SH1106Wire(OLEDDISPLAY_GEOMETRY g, uint8_t _address, uint8_t _sda, uint8_t _scl) {
47+
SH1106Wire(uint8_t _address, uint8_t _sda, uint8_t _scl) : SH1106Wire(GEOMETRY_128_64, _address, _sda, _scl) {
48+
49+
}
50+
51+
SH1106Wire(OLEDDISPLAY_GEOMETRY g, uint8_t _address, uint8_t _sda, uint8_t _scl) {
4852
this->geometry = g;
4953
if (g == GEOMETRY_128_64) {
5054
this->displayWidth = 128;
@@ -53,7 +57,7 @@ class SH1106Wire : public OLEDDisplay {
5357
} else if (g == GEOMETRY_128_32) {
5458
this->displayWidth = 128;
5559
this->displayHeight = 32;
56-
this->displayBufferSize = 512;
60+
this->displayBufferSize = 512;
5761
}
5862

5963
this->_address = _address;

SSD1306Brzo.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class SSD1306Brzo : public OLEDDisplay {
4444
uint8_t _scl;
4545

4646
public:
47+
SSD1306Brzo(uint8_t _address, uint8_t _sda, uint8_t _scl) : SSD1306Brzo(GEOMETRY_128_64, _address, _sda, _scl) {
48+
49+
}
50+
4751
SSD1306Brzo(OLEDDISPLAY_GEOMETRY g, uint8_t _address, uint8_t _sda, uint8_t _scl) {
4852
this->geometry = g;
4953
if (g == GEOMETRY_128_64) {
@@ -53,7 +57,7 @@ class SSD1306Brzo : public OLEDDisplay {
5357
} else if (g == GEOMETRY_128_32) {
5458
this->displayWidth = 128;
5559
this->displayHeight = 32;
56-
this->displayBufferSize = 512;
60+
this->displayBufferSize = 512;
5761
}
5862

5963
this->_address = _address;
@@ -130,7 +134,7 @@ class SSD1306Brzo : public OLEDDisplay {
130134

131135
sendCommand(PAGEADDR);
132136
sendCommand(0x0);
133-
137+
134138
if (geometry == GEOMETRY_128_64) {
135139
sendCommand(0x7);
136140
} else if (geometry == GEOMETRY_128_32) {

SSD1306Spi.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class SSD1306Spi : public OLEDDisplay {
4444
uint8_t _cs;
4545

4646
public:
47+
SSD1306Spi(uint8_t _rst, uint8_t _dc, uint8_t _cs) : SSD1306Spi(GEOMETRY_128_64, _rst, _dc, _cs) {
48+
49+
}
50+
4751
SSD1306Spi(OLEDDISPLAY_GEOMETRY g, uint8_t _rst, uint8_t _dc, uint8_t _cs) {
4852
this->geometry = g;
4953
if (g == GEOMETRY_128_64) {
@@ -53,9 +57,9 @@ class SSD1306Spi : public OLEDDisplay {
5357
} else if (g == GEOMETRY_128_32) {
5458
this->displayWidth = 128;
5559
this->displayHeight = 32;
56-
this->displayBufferSize = 512;
60+
this->displayBufferSize = 512;
5761
}
58-
62+
5963
this->_rst = _rst;
6064
this->_dc = _dc;
6165
this->_cs = _cs;

SSD1306Wire.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ class SSD1306Wire : public OLEDDisplay {
3838
uint8_t _scl;
3939

4040
public:
41+
SSD1306Wire(uint8_t _address, uint8_t _sda, uint8_t _scl) : SSD1306Wire(GEOMETRY_128_64, _address, _sda, _scl) {
42+
43+
}
44+
4145
SSD1306Wire(OLEDDISPLAY_GEOMETRY g, uint8_t _address, uint8_t _sda, uint8_t _scl) {
4246
this->geometry = g;
4347
if (g == GEOMETRY_128_64) {
@@ -47,7 +51,7 @@ class SSD1306Wire : public OLEDDisplay {
4751
} else if (g == GEOMETRY_128_32) {
4852
this->displayWidth = 128;
4953
this->displayHeight = 32;
50-
this->displayBufferSize = 512;
54+
this->displayBufferSize = 512;
5155
}
5256

5357
this->_address = _address;
@@ -129,7 +133,7 @@ class SSD1306Wire : public OLEDDisplay {
129133

130134
sendCommand(PAGEADDR);
131135
sendCommand(0x0);
132-
136+
133137
if (geometry == GEOMETRY_128_64) {
134138
sendCommand(0x7);
135139
} else if (geometry == GEOMETRY_128_32) {

0 commit comments

Comments
 (0)