Hi. I'm in the process of building a multi-display device. I have hooked up two SSD1325-displays over SPI on my ESP8266 (NodeMCU V1.0). Eventually I will use four displays, but let's get two working first
Both displays are sharing all pins except the CS (Chip select) pin.
When initialising the displays I only assign the reset-pin for the first display so they can share this pin, as described here and I save one GPIO. This works well.
I'm having this issue that even though I am instantiating two different displays, they share the same buffer in memory. Is there any workaround for this?
An example of the problem I am seeing:
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1325.h>
#define OLED_CS D4
#define OLED_CS2 D0
#define OLED_RESET D3
#define OLED_DC D2
Adafruit_SSD1325 display(OLED_DC, OLED_RESET, OLED_CS); // Instantiate first display
Adafruit_SSD1325 display2(OLED_DC, -1, OLED_CS2); // Instantiate the second display
void setup() {
display.begin(); //Init display1
display2.begin(); //Init display2
display.clearDisplay(); //We need to run this to clear the Adafruit-splashscreen. This affects both displays, no matter if I call display or display2, this already indicates that they are sharing memory
//Display1 section start
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("Display1");
display.display();
//Display1 section end
//Display2 section start
display2.setTextColor(WHITE);
display2.setCursor(0, 10);
display2.print("Display2");
display2.display();
//Display1 section end
}
void loop() {
}
Running this code prints Display1 on the first display and both Display1 as well as Display2 on the second display.
This should not happen as the buffer was already cleared on line 17 (why doesn't the forum show line numbers?!) just after display2.begin().
If I call display.cleardisplay() or display2.cleardisplay() between writing to the two displays, then it works percetly, but the buffer is now lost. This means that jumping between the two displays, I need to clear the buffer completely and re-draw all elements. This is slow and cumbersome. I would like to be able to update/redraw elements as needed by the program.
Any nice workaround or should I choose another display library that doesn't have this quirk?