SparkFun Forums 

Where electronics enthusiasts find answers.

Questions &/or issues related to products in the LCDs and OLEDs category should be posted in this forum.
#205013
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);

}
#205080
Hello, I changed the code to mimic the structure of the volumetric display . I get a clean compile, but nothing happening in the displays.

Please...help!


https://github.com/sparkfun/HyperDispla ... splays.ino

// Ramesh changes for SPI
// Ramesh 05312019 changes for removing I2C

#include "HyperDisplay_UG2856KLBAG01.h" // Your library can be installed here: http://librarymanager/All#SparkFun_Tran ... hical_OLED
// The rest of the Layer Cake: http://librarymanager/All#SparkFun_HyperDisplay_SSD1309
// http://librarymanager/All#SparkFun_HyperDisplay
//////////////////////////
// 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 DC_PIN 15 // Used only if USE_SPI == 1




// Ramesh set USE_SPI to 1 for Serial peripheral interface
#define USE_SPI 1 // Choose your interface. 0 = I2C, 1 = SPI






// Object Declaration. A class exists for each interface option

UG2856KLBAG01_SPI myTOLED0; // Declare a SPI-based Transparent OLED object called myTOLED
UG2856KLBAG01_SPI myTOLED1; // Declare a SPI-based Transparent OLED object called myTOLED

UG2856KLBAG01_SPI oleds[] = {
myTOLED0,
myTOLED1,
};

uint8_t cs[] = {
14,
13
};

uint8_t numLayers = 2;


void setup() {


SERIAL_PORT.begin(9600);

SERIAL_PORT.println(F("Example: Move circle thru 2 boards"));
SERIAL_PORT.println(numLayers);

SPI_PORT.begin();

for(uint8_t indi = 0; indi < numLayers; indi++){
oleds[indi].begin(cs[indi], DC_PIN, SPI_PORT); // Begin for SPI requires that you provide the CS and DC pin numbers
}




}

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++) {

myTOLED0.circleSet(i, y0, r-4, true);
myTOLED0.circleClear(i, y0, r-4, false);


}

for (uint32_t i=5; i<HORZ; i++) {

myTOLED1.circleSet(i, y0, r-4, true);
myTOLED1.circleClear(i, y0, r-4, false);


}



myTOLED0.pixelSet(126,2);
delay(100);

myTOLED0.pixelClear(126,2);
delay(100);

}
#205084
Unfortunately we can't help with your code.
Have you tried swapping the CS line for the displays to see if the second display works then? Have you tried each display with our example code? If you can get both displays to work individually with our example code, the problem would have to be somewhere in your code.
#205120
Thanks for your reply Chris, it turns out the CS I was using for the 2nd board - pin 12 wasn't working.

I switched to PIN 27 and wrote the below code with CS being in an array (like Volumetric display) and it is working


But I am dissapointed the circle is moving very slowly. I am using ESP32 Thing Plus.

> Is there a more efficient way to write this code to move a circle faster across the board?
> how can I use other PINS for CS ? Say A0 thru A5 for example?

ANy suggestions welcome!



#include "HyperDisplay_UG2856KLBAG01.h"

#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 CS_PIN2 27 // Used only if USE_SPI == 1, 27 works

#define DC_PIN 15 // Used only if USE_SPI == 1

// 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 myTOLED0; // Declare a SPI-based Transparent OLED object called myTOLED

UG2856KLBAG01_SPI myTOLED1;

void setup() {
Serial.begin(9600);

Serial.println("Example2_DrawingBasics: Transparent Graphical OLED");

SPI_PORT.begin();
myTOLED0.begin(CS_PIN, DC_PIN, SPI_PORT); // Begin for SPI requires that you provide the CS and DC pin numbers

myTOLED1.begin(CS_PIN2, DC_PIN, SPI_PORT); // 2nd board


/*
* 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
*/



}

void loop() {

uint8_t x0 = 10;
uint8_t y0 = 20;

uint8_t r = 0;

uint8_t HORZ = 138; // Changed from 122, since it is moving far to the right



x0 = 108;
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++) {

myTOLED0.circleSet(i, y0, r-4, true);
myTOLED0.circleClear(i, y0, r-4, false);

}

for (uint32_t i=5; i<HORZ; i++) {

myTOLED1.circleSet(i, y0, r-4, true);
myTOLED1.circleClear(i, y0, r-4, false);


}



}