Adafuit Display size and TCA9548A

Hi,

I'm using an Arduino Uno with a TCA9548A to run two OLED displays.

The following command works:

define OLED_RESET 4 // Reset pin

Adafruit_SSD1306 display1(OLED_RESET); Adafruit_SSD1306 display2(OLED_RESET);

The following command does not work with two displays,

define SCREEN_WIDTH 128 // OLED display width

define SCREEN_HEIGHT 64 // OLED display height

define OLED_RESET 4 // Reset pin

Adafruit_SSD1306 display1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); Adafruit_SSD1306 display2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

But works with a single display and no TCA9548A

I'm trying to get both displays to show at the higher resolution for my project.

Would appreciate any insights into the issue?

Thanks

S

Go on. It is simple maths. Your Uno has 2048 bytes of SRAM. Each 128x64 requires a separate 1024 byte buffer.

Either buy a bigger Arduino or write to a single display buffer. Concentrate on the current OLED. e.g. clear buffer and create a fresh picture each time you want to update the other physical OLED. Use the TCA9548A to select the physical OLED before display.display().

David.

Paul,

Thanks for the note, but that is what I'm doing (I think).

tcaselect(0); // Screen // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally if(!display1.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); }

display1.clearDisplay(); display1.setTextSize(2); display1.setTextColor(WHITE); display1.setCursor(0,0); display1.println("OpenIQ\n"); display1.setTextSize(2); display1.println("Ready\n"); display1.display();

tcaselect(1); // Screen //SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally if(!display2.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); } display2.clearDisplay(); display2.setTextSize(2); display2.setTextColor(WHITE); display2.setCursor(0,0); display2.println("OpenIQ\n"); display2.setTextSize(2); display2.println("Ready\n"); display2.display();

Am I missing a trick here?

All the Best

S

No, you should use something like this:

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire); //omit RESET arg
...
void setup()
{
  Serial.begin(9600);   //so we can see allocation message  
  // Screen
  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  tcaselect(0);
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
  }
  tcaselect(1);
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("Second SSD1306 allocation failed"));
  }
}
... 
  display.clearDisplay();
  display.setTextSize(2);                 
  display.setTextColor(WHITE);             
  display.setCursor(0,0);                 
  display.println("OpenIQ\n");       
  display.setTextSize(2);                 
  display.println("Ready\n");
  tcaselect(0);
  display.display(); //send buffer contents to OLED #1

  display.clearDisplay();
  display.setTextSize(2);                 
  display.setTextColor(WHITE);             
  display.setCursor(0,0);                 
  display.println("OLED  #2\n");       
  display.setTextSize(2);                 
  display.println("Ready\n");
  tcaselect(1);
  display.display(); //send buffer contents to OLED #2
...

I have not checked the library code. I hope that a second call to display.begin() would send the initialisation sequence again. But not attempt a fresh buffer allocation because it already has a buffer.

Easy enough to try for yourself.

David.