Skip to content

Commit

Permalink
Support 8-bit boards like Mega2560 (#404)
Browse files Browse the repository at this point in the history
- Changed frequency from int to long
- Change constructor argument names (remove leading underscores)
  • Loading branch information
ClutchplateDude authored May 24, 2024
1 parent eaafa0c commit 469f227
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
8 changes: 4 additions & 4 deletions src/SH1106Brzo.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ class SH1106Brzo : public OLEDDisplay {
uint8_t _scl;

public:
SH1106Brzo(uint8_t _address, uint8_t _sda, uint8_t _scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
SH1106Brzo(uint8_t address, uint8_t sda, uint8_t scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
setGeometry(g);

this->_address = _address;
this->_sda = _sda;
this->_scl = _scl;
this->_address = address;
this->_sda = sda;
this->_scl = scl;
}

bool connect(){
Expand Down
8 changes: 4 additions & 4 deletions src/SH1106Spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class SH1106Spi : public OLEDDisplay {

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

this->_rst = _rst;
this->_dc = _dc;
this->_cs = _cs;
this->_rst = rst;
this->_dc = dc;
this->_cs = cs;
}

bool connect(){
Expand Down
14 changes: 7 additions & 7 deletions src/SH1106Wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SH1106Wire : public OLEDDisplay {
int _scl;
bool _doI2cAutoInit = false;
TwoWire* _wire = NULL;
int _frequency;
long _frequency;

public:
/**
Expand All @@ -71,18 +71,18 @@ class SH1106Wire : public OLEDDisplay {
* @param _i2cBus on ESP32 with 2 I2C HW buses, I2C_ONE for 1st Bus, I2C_TWO fot 2nd bus, default I2C_ONE
* @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
*/
SH1106Wire(uint8_t _address, int _sda = -1, int _scl = -1, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64, HW_I2C _i2cBus = I2C_ONE, int _frequency = 700000) {
SH1106Wire(uint8_t address, int sda = -1, int scl = -1, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64, HW_I2C i2cBus = I2C_ONE, long frequency = 700000) {
setGeometry(g);

this->_address = _address;
this->_sda = _sda;
this->_scl = _scl;
this->_address = address;
this->_sda = sda;
this->_scl = scl;
#if !defined(ARDUINO_ARCH_ESP32)
this->_wire = &Wire;
#else
this->_wire = (_i2cBus==I2C_ONE) ? &Wire : &Wire1;
this->_wire = (i2cBus==I2C_ONE) ? &Wire : &Wire1;
#endif
this->_frequency = _frequency;
this->_frequency = frequency;
}

bool connect() {
Expand Down
8 changes: 4 additions & 4 deletions src/SSD1306Brzo.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ class SSD1306Brzo : public OLEDDisplay {
uint8_t _scl;

public:
SSD1306Brzo(uint8_t _address, uint8_t _sda, uint8_t _scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
SSD1306Brzo(uint8_t address, uint8_t sda, uint8_t scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
setGeometry(g);

this->_address = _address;
this->_sda = _sda;
this->_scl = _scl;
this->_address = address;
this->_sda = sda;
this->_scl = scl;
}

bool connect(){
Expand Down
10 changes: 5 additions & 5 deletions src/SSD1306I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@

class SSD1306I2C : public OLEDDisplay {
public:
SSD1306I2C(uint8_t _address, PinName _sda, PinName _scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
SSD1306I2C(uint8_t address, PinName sda, PinName scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64) {
setGeometry(g);

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

bool connect() {
Expand Down
8 changes: 4 additions & 4 deletions src/SSD1306Spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ class SSD1306Spi : public OLEDDisplay {

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

this->_rst = _rst;
this->_dc = _dc;
this->_cs = _cs;
this->_rst = rst;
this->_dc = dc;
this->_cs = cs;
}

bool connect(){
Expand Down
6 changes: 3 additions & 3 deletions src/SSD1306Wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SSD1306Wire : public OLEDDisplay {
int _scl;
bool _doI2cAutoInit = false;
TwoWire* _wire = NULL;
int _frequency;
long _frequency;

public:

Expand All @@ -72,7 +72,7 @@ class SSD1306Wire : public OLEDDisplay {
* @param _i2cBus on ESP32 with 2 I2C HW buses, I2C_ONE for 1st Bus, I2C_TWO fot 2nd bus, default I2C_ONE
* @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
*/
SSD1306Wire(uint8_t _address, int _sda = -1, int _scl = -1, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64, HW_I2C _i2cBus = I2C_ONE, int _frequency = 700000) {
SSD1306Wire(uint8_t address, int sda = -1, int scl = -1, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64, HW_I2C i2cBus = I2C_ONE, long frequency = 700000) {
setGeometry(g);

this->_address = _address;
Expand All @@ -81,7 +81,7 @@ class SSD1306Wire : public OLEDDisplay {
#if !defined(ARDUINO_ARCH_ESP32)
this->_wire = &Wire;
#else
this->_wire = (_i2cBus==I2C_ONE) ? &Wire : &Wire1;
this->_wire = (i2cBus == I2C_ONE) ? &Wire : &Wire1;
#endif
this->_frequency = _frequency;
}
Expand Down

0 comments on commit 469f227

Please sign in to comment.