Hi Guys
I am trying to get 2 x OLED displays to work on separate 12c bus's using the standard SDA0/SCL0 (18,19) and SDA1/SDA2 (16,17) pins
When I compile I get an error
Compilation error: no matching function for call to 'TwoWire::begin(int, int)'
I am trying to get 2 x OLED displays to work on separate 12c bus's using the standard SDA0/SCL0 (18,19) and SDA1/SDA2 (16,17) pins
When I compile I get an error
Compilation error: no matching function for call to 'TwoWire::begin(int, int)'
Code:
/home/stu/Arduino/Dusl_12c_oled/Dusl_12c_oled.ino: In function 'void setup()':
/home/stu/Arduino/Dusl_12c_oled/Dusl_12c_oled.ino:33:14: error: no matching function for call to 'TwoWire::begin(int, int)'
33 | Wire.begin(I2C_A_SDA, I2C_A_SCL); // display 1
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/Wire.h:26,
from /home/stu/Arduino/Dusl_12c_oled/Dusl_12c_oled.ino:1:
/home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/WireIMXRT.h:71:14: note: candidate: 'void TwoWire::begin()'
71 | void begin();
| ^~~~~
/home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/WireIMXRT.h:71:14: note: candidate expects 0 arguments, 2 provided
/home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/WireIMXRT.h:72:14: note: candidate: 'void TwoWire::begin(uint8_t)'
72 | void begin(uint8_t address);
| ^~~~~
/home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/WireIMXRT.h:72:14: note: candidate expects 1 argument, 2 provided
/home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/WireIMXRT.h:73:14: note: candidate: 'void TwoWire::begin(int)'
73 | void begin(int address) {
| ^~~~~
/home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/WireIMXRT.h:73:14: note: candidate expects 1 argument, 2 provided
/home/stu/Arduino/Dusl_12c_oled/Dusl_12c_oled.ino:34:15: error: no matching function for call to 'TwoWire::begin(int, int)'
34 | Wire1.begin(I2C_B_SDA, I2C_B_SCL); // display 2
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/Wire.h:26,
from /home/stu/Arduino/Dusl_12c_oled/Dusl_12c_oled.ino:1:
/home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/WireIMXRT.h:71:14: note: candidate: 'void TwoWire::begin()'
71 | void begin();
| ^~~~~
/home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/WireIMXRT.h:71:14: note: candidate expects 0 arguments, 2 provided
/home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/WireIMXRT.h:72:14: note: candidate: 'void TwoWire::begin(uint8_t)'
72 | void begin(uint8_t address);
| ^~~~~
/home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/WireIMXRT.h:72:14: note: candidate expects 1 argument, 2 provided
/home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/WireIMXRT.h:73:14: note: candidate: 'void TwoWire::begin(int)'
73 | void begin(int address) {
| ^~~~~
/home/stu/.arduino15/packages/teensy/hardware/avr/1.59.0/libraries/Wire/WireIMXRT.h:73:14: note: candidate expects 1 argument, 2 provided
exit status 1
Compilation error: no matching function for call to 'TwoWire::begin(int, int)'
Code:
#include <Wire.h>
#include <WireIMXRT.h>
#include <WireKinetis.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
extern TwoWire Wire1;
// #define Wire Wire
#define WIRE Wire
#define I2C_A_SDA 18 // I2c pins for display 1 on 12c bus A
#define I2C_A_SCL 19 //
#define I2C_B_SDA 16 // i2c pins for display 2 on i2c bus B
#define I2C_B_SCL 17 //
// OLED parameters
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C // Change if required
#define ROTATION 0 // Rotates text on OLED 1=90 degrees, 2=180 degrees
// Define display object
Adafruit_SSD1306 display1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_SSD1306 display2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, OLED_RESET);
void setup() {
Serial.begin(115200);
while (!Serial)
;
Wire.begin(I2C_A_SDA, I2C_A_SCL); // display 1
Wire1.begin(I2C_B_SDA, I2C_B_SCL); // display 2
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if (!display1.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("Display1 SSD1306 allocation failed"));
for (;;)
; // Don't proceed, loop forever
}
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if (!display2.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("Display2 SSD1306 allocation failed"));
for (;;)
; // Don't proceed, loop forever
}
// Show splash screen
display1.display();
display2.display();
delay(2000); // Pause for 2 seconds
// Display settings
display1.clearDisplay();
display1.setTextSize(2); // Normal 1:1 pixel scale
display1.setTextColor(WHITE); // Draw white text
display1.setCursor(0,0); // Start at top-left corner
display1.setRotation(ROTATION); // Set screen rotation
// Display settings
display2.clearDisplay();
display2.setTextSize(2); // Normal 1:1 pixel scale
display2.setTextColor(WHITE); // Draw white text
display2.setCursor(0,0); // Start at top-left corner
display2.setRotation(ROTATION); // Set screen rotation
display1.print("Display1 ");
display2.print("Display2 ");
display1.display();
display2.display();
}
void loop() {
}