Hi,
I'm wanting to run multiple SSD_1306 OLED displays using the Adafruit TCA9548A. The video below shows 4 screens running from an Arduino Due - seems to run the fastest of my boards.
Usually, the Teensy smashes everything else in terms of speed, but not in this case.
Is there any way to speed up the display re-draw? I'm expecting a new Teensy 3.6 shortly, but apart from getting the fastest board available, is there anything I'm doing in code that is slowing things down?
I realise I'm repeating a lot of calculation, but the code posted is the only way I can seem to get the system to work...
On a slightly different tack, bearing in mind I'd like to use many screens in an installation, I could use a PC or Mac to drive these things - but how? And would it make any difference, or is the bottleneck in the screen re-draw on the SSD 1306s?
Any advice would be gratefully received!
This code is very much mostly written by Hari Wiguna...
Thanks Harry!
/*********************************************************************
This is an example for our Monochrome OLEDs based on SSD1306 drivers
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/ category/63_98
This example is for a 128x64 size display using I2C to communicate
3 pins are required to interface (2 I2C and one reset)
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
int nFrames = 36;
#define TCAADDR 0x70
void tcaselect(uint8_t i) {
if (i > 7) return;
Wire.beginTransmission(TCAADDR);
Wire.write(1 << i);
Wire.endTransmission();
}
void setup() {
Serial.begin(115200);
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3c);
display.clearDisplay();
}
void loop() {
for (int frame = 0; frame < nFrames; frame++)
{
HariChord(frame);
}
for (int frame = (nFrames - 1); frame >= 0; frame--)
{
HariChord(frame);
}
}
void HariChord(int frame)
{
display.clearDisplay();
int n = 7;
int r = frame * 128 / nFrames;
float rot = frame * 2 * PI / nFrames;
tcaselect(3);
for (int i = 0; i < (n - 1); i++)
{
float a = rot + i * 2 * PI / n;
int x1 = 0 + cos(a) * r;
int y1 = 0 + sin(a) * r;
for (int j = i + 1; j < n; j++)
{
a = rot + j * 2 * PI / n;
int x2 = 0 + cos(a) * r;
int y2 = 0 + sin(a) * r;
display.drawLine(x1, y1, x2, y2, WHITE);
}
}
display.display();
display.clearDisplay();
tcaselect(2);
for (int i = 0; i < (n - 1); i++)
{
float a = rot + i * 2 * PI / n;
int x1 = 128 + cos(a) * r;
int y1 = 0 + sin(a) * r;
for (int j = i + 1; j < n; j++)
{
a = rot + j * 2 * PI / n;
int x2 = 128 + cos(a) * r;
int y2 = 0 + sin(a) * r;
display.drawLine(x1, y1, x2, y2, WHITE);
}
}
display.display();
display.clearDisplay();
tcaselect(1);
for (int i = 0; i < (n - 1); i++)
{
float a = rot + i * 2 * PI / n;
int x1 = 0 + cos(a) * r;
int y1 = 64 + sin(a) * r;
for (int j = i + 1; j < n; j++)
{
a = rot + j * 2 * PI / n;
int x2 = 0 + cos(a) * r;
int y2 = 64 + sin(a) * r;
display.drawLine(x1, y1, x2, y2, WHITE);
}
}
display.display();
display.clearDisplay();
tcaselect(0);
for (int i = 0; i < (n - 1); i++)
{
float a = rot + i * 2 * PI / n;
int x1 = 128 + cos(a) * r;
int y1 = 64 + sin(a) * r;
for (int j = i + 1; j < n; j++)
{
a = rot + j * 2 * PI / n;
int x2 = 128 + cos(a) * r;
int y2 = 64 + sin(a) * r;
display.drawLine(x1, y1, x2, y2, WHITE);
}
}
display.display();
display.clearDisplay();
}
Many Thanks.