Skip to content

Commit 469f227

Browse files
Support 8-bit boards like Mega2560 (#404)
- Changed frequency from int to long - Change constructor argument names (remove leading underscores)
1 parent eaafa0c commit 469f227

File tree

7 files changed

+31
-31
lines changed

7 files changed

+31
-31
lines changed

src/SH1106Brzo.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ class SH1106Brzo : public OLEDDisplay {
4747
uint8_t _scl;
4848

4949
public:
50-
SH1106Brzo(uint8_t _address, uint8_t _sda, uint8_t _scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
50+
SH1106Brzo(uint8_t address, uint8_t sda, uint8_t scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
5151
setGeometry(g);
5252

53-
this->_address = _address;
54-
this->_sda = _sda;
55-
this->_scl = _scl;
53+
this->_address = address;
54+
this->_sda = sda;
55+
this->_scl = scl;
5656
}
5757

5858
bool connect(){

src/SH1106Spi.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ class SH1106Spi : public OLEDDisplay {
4242

4343
public:
4444
/* pass _cs as -1 to indicate "do not use CS pin", for cases where it is hard wired low */
45-
SH1106Spi(uint8_t _rst, uint8_t _dc, uint8_t _cs, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
45+
SH1106Spi(uint8_t rst, uint8_t dc, uint8_t cs, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
4646
setGeometry(g);
4747

48-
this->_rst = _rst;
49-
this->_dc = _dc;
50-
this->_cs = _cs;
48+
this->_rst = rst;
49+
this->_dc = dc;
50+
this->_cs = cs;
5151
}
5252

5353
bool connect(){

src/SH1106Wire.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class SH1106Wire : public OLEDDisplay {
5353
int _scl;
5454
bool _doI2cAutoInit = false;
5555
TwoWire* _wire = NULL;
56-
int _frequency;
56+
long _frequency;
5757

5858
public:
5959
/**
@@ -71,18 +71,18 @@ class SH1106Wire : public OLEDDisplay {
7171
* @param _i2cBus on ESP32 with 2 I2C HW buses, I2C_ONE for 1st Bus, I2C_TWO fot 2nd bus, default I2C_ONE
7272
* @param _frequency for Frequency by default Let's use ~700khz if ESP8266 is in 160Mhz mode, this will be limited to ~400khz if the ESP8266 in 80Mhz mode
7373
*/
74-
SH1106Wire(uint8_t _address, int _sda = -1, int _scl = -1, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64, HW_I2C _i2cBus = I2C_ONE, int _frequency = 700000) {
74+
SH1106Wire(uint8_t address, int sda = -1, int scl = -1, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64, HW_I2C i2cBus = I2C_ONE, long frequency = 700000) {
7575
setGeometry(g);
7676

77-
this->_address = _address;
78-
this->_sda = _sda;
79-
this->_scl = _scl;
77+
this->_address = address;
78+
this->_sda = sda;
79+
this->_scl = scl;
8080
#if !defined(ARDUINO_ARCH_ESP32)
8181
this->_wire = &Wire;
8282
#else
83-
this->_wire = (_i2cBus==I2C_ONE) ? &Wire : &Wire1;
83+
this->_wire = (i2cBus==I2C_ONE) ? &Wire : &Wire1;
8484
#endif
85-
this->_frequency = _frequency;
85+
this->_frequency = frequency;
8686
}
8787

8888
bool connect() {

src/SSD1306Brzo.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ class SSD1306Brzo : public OLEDDisplay {
4747
uint8_t _scl;
4848

4949
public:
50-
SSD1306Brzo(uint8_t _address, uint8_t _sda, uint8_t _scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
50+
SSD1306Brzo(uint8_t address, uint8_t sda, uint8_t scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
5151
setGeometry(g);
5252

53-
this->_address = _address;
54-
this->_sda = _sda;
55-
this->_scl = _scl;
53+
this->_address = address;
54+
this->_sda = sda;
55+
this->_scl = scl;
5656
}
5757

5858
bool connect(){

src/SSD1306I2C.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242

4343
class SSD1306I2C : public OLEDDisplay {
4444
public:
45-
SSD1306I2C(uint8_t _address, PinName _sda, PinName _scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
45+
SSD1306I2C(uint8_t address, PinName sda, PinName scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
4646
setGeometry(g);
4747

48-
this->_address = _address << 1; // convert from 7 to 8 bit for mbed.
49-
this->_sda = _sda;
50-
this->_scl = _scl;
51-
_i2c = new I2C(_sda, _scl);
48+
this->_address = address << 1; // convert from 7 to 8 bit for mbed.
49+
this->_sda = sda;
50+
this->_scl = scl;
51+
_i2c = new I2C(sda, scl);
5252
}
5353

5454
bool connect() {

src/SSD1306Spi.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ class SSD1306Spi : public OLEDDisplay {
4848

4949
public:
5050
/* pass _cs as -1 to indicate "do not use CS pin", for cases where it is hard wired low */
51-
SSD1306Spi(uint8_t _rst, uint8_t _dc, uint8_t _cs, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
51+
SSD1306Spi(uint8_t rst, uint8_t dc, uint8_t cs, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
5252
setGeometry(g);
5353

54-
this->_rst = _rst;
55-
this->_dc = _dc;
56-
this->_cs = _cs;
54+
this->_rst = rst;
55+
this->_dc = dc;
56+
this->_cs = cs;
5757
}
5858

5959
bool connect(){

src/SSD1306Wire.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class SSD1306Wire : public OLEDDisplay {
5353
int _scl;
5454
bool _doI2cAutoInit = false;
5555
TwoWire* _wire = NULL;
56-
int _frequency;
56+
long _frequency;
5757

5858
public:
5959

@@ -72,7 +72,7 @@ class SSD1306Wire : public OLEDDisplay {
7272
* @param _i2cBus on ESP32 with 2 I2C HW buses, I2C_ONE for 1st Bus, I2C_TWO fot 2nd bus, default I2C_ONE
7373
* @param _frequency for Frequency by default Let's use ~700khz if ESP8266 is in 160Mhz mode, this will be limited to ~400khz if the ESP8266 in 80Mhz mode
7474
*/
75-
SSD1306Wire(uint8_t _address, int _sda = -1, int _scl = -1, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64, HW_I2C _i2cBus = I2C_ONE, int _frequency = 700000) {
75+
SSD1306Wire(uint8_t address, int sda = -1, int scl = -1, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64, HW_I2C i2cBus = I2C_ONE, long frequency = 700000) {
7676
setGeometry(g);
7777

7878
this->_address = _address;
@@ -81,7 +81,7 @@ class SSD1306Wire : public OLEDDisplay {
8181
#if !defined(ARDUINO_ARCH_ESP32)
8282
this->_wire = &Wire;
8383
#else
84-
this->_wire = (_i2cBus==I2C_ONE) ? &Wire : &Wire1;
84+
this->_wire = (i2cBus == I2C_ONE) ? &Wire : &Wire1;
8585
#endif
8686
this->_frequency = _frequency;
8787
}

0 commit comments

Comments
 (0)