Hello, I have 2 Breakout OLED boards connected to a ESP32 using SPI
I cannot get the 2nd board to work even though I get a clean compile.
The 2nd chip connected to PIN 13 doesn’t work (CS)
Any help is appreciated
// Ramesh 05312019 changes for removing I2C
#include “HyperDisplay_UG2856KLBAG01.h”
// User Setup //
//////////////////////////
#define SERIAL_PORT Serial
#define WIRE_PORT Wire // Used if USE_SPI == 0
#define SPI_PORT SPI // Used if USE_SPI == 1
#define RES_PIN 2 // Optional
#define CS_PIN 14 // Used only if USE_SPI == 1
#define DC_PIN 15 // Used only if USE_SPI == 1
#define CS2_PIN 13 // Ramesh - for 2nd board
// Ramesh set USE_SPI to 1 for Serial peripheral interface
#define USE_SPI 1 // Choose your interface. 0 = I2C, 1 = SPI
// END USER SETUP
// Object Declaration. A class exists for each interface option
UG2856KLBAG01_SPI myTOLED; // Declare a SPI-based Transparent OLED object called myTOLED
UG2856KLBAG01_SPI myTOLED2; // Declare a SPI-based Transparent OLED object called myTOLED
void setup() {
Serial.begin(9600);
Serial.println(“Example2_DrawingBasics: Transparent Graphical OLED”);
SPI_PORT.begin();
myTOLED.begin(CS_PIN, DC_PIN, SPI_PORT); // Begin for SPI requires that you provide the CS and DC pin numbers
// for 2nd board
myTOLED2.begin(CS2_PIN, DC_PIN, SPI_PORT);
/*
-
Drawing with the Transparent Graphical OLED
-
The TOLED display is a 1-bit per pixel display, meaning that each pixel can either be on or off. It is also possible to
-
raise/lower the contrast of the entire display, but not any pixel individually.
-
This simplicity allows the TOLED HyperDisplay driver not to worry about color, instead each HyperDisplay function is
-
given two variants - one to ‘Set’ the pixels and one to ‘Clear’ the pixels. In th following code block we will try
-
out a few of those functions. Note, all the ‘Set’ functions have a ‘Clear’ counterpart that turns off pixels, but we
-
will only show those in comments to avoid redundancy
*/
//uint8_t x1 = 0;
// myTOLED.pixelSet(x0, y0); // Provide the X and Y locations of the single pixel to set or clear
// myTOLED.pixelClear(x0, y0); //
// myTOLED.circleSet(x0, y1, r); // Outline circle centered at (x0, y0) with radius r
// myTOLED.circleSet(x0, y1, r-4, true); // Filled in
// myTOLED.circleSet(x0, y1, r);
// myTOLED.circleSet(x0, y1, r-4, true);
}
void loop() {
uint8_t x0 = 10;
uint8_t y0 = 20;
uint8_t y1 = 0;
uint8_t r = 0;
// Changed from 122, since it is moving far to the right
uint8_t HORZ = 138;
//myTOLED.pixelSet(x0, y0); // Provide the X and Y locations of the single pixel to set or clear
//myTOLED.pixelClear(x0, y0);
x0 = 108;
y1 = 24;
r = 14;
//myTOLED.circleSet(x0, y1, r); // Outline circle centered at (x0, y0) with radius r
//myTOLED.circleSet(x0, y1, r-4, true); // Filled in
// Loop to move the circle
for (uint32_t i=5; i<HORZ; i++) {
myTOLED.circleSet(i, y0, r-4, true);
myTOLED.circleClear(i, y0, r-4, false);
}
for (uint32_t i=5; i<HORZ; i++) {
myTOLED2.circleSet(i, y0, r-4, true);
myTOLED2.circleClear(i, y0, r-4, false);
}
myTOLED.pixelSet(126,2);
delay(100);
myTOLED.pixelClear(126,2);
delay(100);
}