Teensy3.5 and SSD1351 128x128 OLED

Status
Not open for further replies.

nemail

Member
Hi

today I got my Teensy 3.5 and so I tried to hook it up to my SSD1351 128x128 RGB OLED Display.

I'm using the SSD1351 Library which comes with the Teensyduino setup (this one: https://github.com/kirberich/teensy_ssd1351).

All I get is this:
Photo-2016-11-30-23-30-40_1453.jpg

This is how I attached it:
Photo-2016-11-30-23-31-29_1454.jpg

This is the code I've uploaded:

Code:
#include <Arduino.h>
#include <SPI.h>
#define SLOW_SPI
#include <ssd1351.h>

// This example is used to illustrate the different color modes. Select a different mode to see
// different amounts of colour banding.

typedef ssd1351::IndexedColor Color;
// typedef ssd1351::LowColor Color;
// typedef ssd1351::HighColor Color;

// Choose display buffering - NoBuffer or SingleBuffer currently supported
// auto display = ssd1351::SSD1351<Color, ssd1351::NoBuffer, 128, 96>();
auto display = ssd1351::SSD1351<Color, ssd1351::NoBuffer, 128, 128>();


void setup() {
	Serial.begin(9600);
	Serial.println("Booting...");
	display.begin();
	display.setCursor(10, 10);
	Serial.println("Display set up.");
	display.println("Hello world");
}

void loop() {
}

Doesn't matter if I define SLOW_SPI or not. Doesn't matter if I use IndexedColor, LowColor or HighColor or SingeBuffer or NoBuffer.
I even tried to set the SPI clock in the SSD1351.h from 20000000 to 12000000.
also going down with the teensy MHz from 120MHz to 8MHz didn't help (I tried all MHz steps between too).

Any idea what the problem could be?

Thanks!
 
Note, that library does not come Teensydunio. So you might ask the provider of the library (kirberich) if there are any fixes.

FWIW, I've been able to run the Adafuit SSD1351 library on the Teensy 3.6 and 3.5 using the uncannyEyes sketch from Adafruit. For the actual Adafruit display, I had to cut the Teensy clock rate down to 24 Mhz in order to get a good display. Using the New Haven display, I was able to bump it up to 48 Mhz (I had bought the New Haven display first, but I miswired it, and then got the Adafruit display -- afterwards, I was able to get the New Haven display working).

The picture of the pinout of the display is kind of weird in that it lists SDA and SCL, which are the names of the 2 i2c wires, but it is a SPI device, and I would expect MOSI and SCLK instead.

Also, I see you are using VIN to provide power. My Adafruit/New Haven OLED displays that use SSD1351 can be powered with VIN. However, my TFT displays that use ST7735 need 3.3v power or else they will not recognize the data signals from the Teensy. Perhaps your display is similar.
 
Last edited:
Note, that library does not come Teensydunio. So you might ask the provider of the library (kirberich) if there are any fixes.

FWIW, I've been able to run the Adafuit SSD1351 library on the Teensy 3.6 and 3.5 using the uncannyEyes sketch from Adafruit. For the actual Adafruit display, I had to cut the Teensy clock rate down to 24 Mhz in order to get a good display. Using the New Haven display, I was able to bump it up to 48 Mhz (I had bought the New Haven display first, but I miswired it, and then got the Adafruit display -- afterwards, I was able to get the New Haven display working).

Thanks for your help, I'll try out the Adafruit Lib + the uncannyEyes example.

The library was indeed offered by the Teensyduino Setup, so I assumed it will be compatible.


edit: ok i tested the "test" sketch from the Adafruit SSD1351 examples and it works, even at 120MHz(!)
 
Last edited:
Thanks for your help, I'll try out the Adafruit Lib + the uncannyEyes example.

The library was indeed offered by the Teensyduino Setup, so I assumed it will be compatible.

You might want to try one of the examples that comes with the Adafruit library before diving into uncannyEyes (you would need to change the pinouts, and to use the hardware constructor.

In case you didn't see it, I edited my reply about using VIN and 3.3v.
 
thanks! as stated, the "test" sketch works fine.
The pinout is definitely kind of weird but I confirmed SDA being MOSI and SCL being SCK.
My OLED knowingly supports 5V VIN, as well as 3.3V.
 
THANKS! Works great!
And I'm somewhat of a 'noob'. I used this lib on a 1.5" 128x128 cheaper 'knock off' OLED with a ssd1351 off of Amazon on a Teensy 3.6
(btw, only 72Mhz works)
Only needed to make the 96 to 128 changes in code, and all I get is this warning.....

In file included from C:\Users\Pete\Documents\Arduino\T_banding128x128test\banding128x128test\banding128x128test.ino:3:0:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\ssd1351/ssd1351.h:35:59: warning: always_inline function might not be inlinable [-Wattributes]

template <typename T> void __attribute__((always_inline)) swap(T &a, T &b) {

^

Everything runs fine, no complaints. Just thought I'd share the warning message.
I'm off to play with this tiny little screen :)

I got two of them, going to see if I can somehow get them both going.
Any suggestions?

(new to Teensy, Just got my 3.6 the other day :) )

PS: All examples work!
 
Depending on how the code is written two displays should be as simple as:
wiring them the same except for chip select (CS)
Check original display still works with old code
mod original code to use the second chip select - confirm it works and first display doesn't
Then comes the fun but of delcaring a second copy of the display object with the other chip select and finding out if the library takes any shortcuts.

If the library is written correctly you will then be able to write to either display
 
Almost..... I got the same thing to display on both screens. Though I thought I coded it to write different things to each.....

Code:
#include <Arduino.h>
#include <SPI.h>
#include <ssd1351.h>

// use this to do Color c = RGB(...) instead of `RGB c = RGB(...)` or ssd1351::LowColor c = RGB(...)
// because it's slightly faster and guarantees you won't be sending wrong colours to the display.

// Choose color depth - IndexedColor, LowColor and HighColor currently supported
// typedef ssd1351::IndexedColor Color;
// typedef ssd1351::LowColor Color;
typedef ssd1351::HighColor Color;

// Choose display buffering - NoBuffer or SingleBuffer currently supported
// auto display = ssd1351::SSD1351<Color, ssd1351::NoBuffer, 128, 128>();
auto display_A = ssd1351::SSD1351<Color, ssd1351::SingleBuffer, 128, 128>(10, 15, 14, 11, 13);
auto display_B = ssd1351::SSD1351<Color, ssd1351::SingleBuffer, 128, 128>(9, 20, 21, 11, 13);

int i = 0;

void setup() {
  Serial.begin(9600);
  Serial.println("Booting...");
  
  display_A.begin();
  display_B.begin();
  
  display_A.setTextSize(1);
  display_B.setTextSize(1);
  
  Serial.println("Display set up.");
}

void loop() {

  display_A.fillScreen(ssd1351::RGB());
  display_B.fillScreen(ssd1351::RGB());


	display_A.setFont(FreeMono9pt7b);
  display_A.setTextSize(1);
  
  display_B.setFont(FreeMono9pt7b);
  display_B.setTextSize(1);

  char test_string_a_A[] = "0123456789";
  char test_string_a_B[] = "ABCDEFGHIJ";
  
  uint16_t w_a_A = display_A.getTextWidth(test_string_a_A);
  uint16_t w_a_B = display_B.getTextWidth(test_string_a_B);
  
  display_A.setCursor(64 - w_a_A/2, 20);
  display_A.setTextColor(ssd1351::RGB(255, 64, 64));
  display_A.print(test_string_a_A);

  display_B.setCursor(64 - w_a_B/2, 20);
  display_B.setTextColor(ssd1351::RGB(64, 255, 64));
  display_B.print(test_string_a_B);
  
  display_A.setFont(FreeMono9pt7b);
  display_A.setTextSize(1);
  
  display_B.setFont(FreeMono9pt7b);
  display_B.setTextSize(1);
  
  char test_string_b_A[] = "01234567";
  char test_string_b_B[] = "ABCDEFGH";
  
  uint16_t w_b_A = display_A.getTextWidth(test_string_b_A);
  uint16_t w_b_B = display_B.getTextWidth(test_string_b_B);
  
  display_A.setCursor(64 - w_b_A/2, 40);
  display_A.setTextColor(ssd1351::RGB(255, 64, 255));
  display_A.print(test_string_b_A);

  display_B.setCursor(64 - w_b_B/2, 40);
  display_B.setTextColor(ssd1351::RGB(128, 255, 64));
  display_B.print(test_string_b_B);


  
  display_A.drawLine(7, 7, 120, 7, ssd1351::RGB(255, 255, 0));
  display_A.drawLine(120, 7, 120, 120, ssd1351::RGB(0, 255, 0));
  display_A.drawLine(120, 120, 7, 120, ssd1351::RGB(255, 0, 0));
  display_A.drawLine(7, 120, 7, 7, ssd1351::RGB(0, 0, 255));

  display_B.drawLine(7, 7, 120, 7, ssd1351::RGB(128, 0, 255));
  display_B.drawLine(120, 7, 120, 120, ssd1351::RGB(255, 0, 128));
  display_B.drawLine(120, 120, 7, 120, ssd1351::RGB(0, 128, 255));
  display_B.drawLine(7, 120, 7, 7, ssd1351::RGB(128, 255, 0));

  
  display_A.updateScreen();
  display_B.updateScreen();  

}

It sees display_A & display_B as the same.

I use pins (cs=10, dc=15, reset=14, mosi=11, sclk=13) (default) for display_A
and pins (cs=9, dc=20, reset=21, mosi=11, sclk=13) for display_B

If the library is written correctly you will then be able to write to either display

...I guess not?...(edit: another crack at it, hence the question mark...)
 
Last edited:
(ugh, don't have a way to get an image in here....)

It worked, now frustrated though that I can't post the pic I took :(
Said upload failed.

To be honest, I'm no good at this internet social media stuff, message boards,and that. Don't know what I have to do to post a pic.

Here's my new code:

Code:
#include <Arduino.h>
#include <SPI.h>
#include <ssd1351.h>

// use this to do Color c = RGB(...) instead of `RGB c = RGB(...)` or ssd1351::LowColor c = RGB(...)
// because it's slightly faster and guarantees you won't be sending wrong colours to the display.

// Choose color depth - IndexedColor, LowColor and HighColor currently supported
// typedef ssd1351::IndexedColor Color;
// typedef ssd1351::LowColor Color;
typedef ssd1351::HighColor Color;

// Choose display buffering - NoBuffer or SingleBuffer currently supported
// auto display = ssd1351::SSD1351<Color, ssd1351::NoBuffer, 128, 128>();
auto display_A = ssd1351::SSD1351<Color, ssd1351::SingleBuffer, 128, 128>(10, 15, 14, 11, 13);
auto display_B = ssd1351::SSD1351<Color, ssd1351::SingleBuffer, 128, 128>(9, 20, 21, 11, 13);

int i = 0;

void setup() {
  Serial.begin(9600);
  Serial.println("Booting...");
  
  display_A.begin();
  display_A.setTextSize(1);
  
  display_B.begin(); 
  display_B.setTextSize(1);
  
  Serial.println("Display set up.");
}

void loop() {

  display_A.fillScreen(ssd1351::RGB());

  display_A.setFont(FreeMono9pt7b);
  display_A.setTextSize(1);
  char test_string_a_A[] = "0123456789";
  uint16_t w_a_A = display_A.getTextWidth(test_string_a_A);

  display_A.setCursor(64 - w_a_A/2, 20);
  display_A.setTextColor(ssd1351::RGB(255, 64, 64));
  display_A.print(test_string_a_A);
  
  display_A.setFont(FreeMono9pt7b);
  display_A.setTextSize(1);
  char test_string_b_A[] = "01234567";
  uint16_t w_b_A = display_A.getTextWidth(test_string_b_A);

  display_A.setCursor(64 - w_b_A/2, 40);
  display_A.setTextColor(ssd1351::RGB(255, 64, 255));
  display_A.print(test_string_b_A);

  display_A.drawLine(7, 7, 120, 7, ssd1351::RGB(255, 255, 0));
  display_A.drawLine(120, 7, 120, 120, ssd1351::RGB(0, 255, 0));
  display_A.drawLine(120, 120, 7, 120, ssd1351::RGB(255, 0, 0));
  display_A.drawLine(7, 120, 7, 7, ssd1351::RGB(0, 0, 255));

  display_A.updateScreen();
  
  
  display_B.fillScreen(ssd1351::RGB());
 
  display_B.setFont(FreeMono9pt7b);
  display_B.setTextSize(1);  
  char test_string_a_B[] = "ABCDEFGHIJ";
  uint16_t w_a_B = display_B.getTextWidth(test_string_a_B);
  
  display_B.setCursor(64 - w_a_B/2, 20);
  display_B.setTextColor(ssd1351::RGB(64, 255, 64));
  display_B.print(test_string_a_B);
  
  display_B.setFont(FreeMono9pt7b);
  display_B.setTextSize(1);
  char test_string_b_B[] = "ABCDEFGH";
  uint16_t w_b_B = display_B.getTextWidth(test_string_b_B);
  
  display_B.setCursor(64 - w_b_B/2, 40);
  display_B.setTextColor(ssd1351::RGB(128, 255, 64));
  display_B.print(test_string_b_B);

  display_B.drawLine(7, 7, 120, 7, ssd1351::RGB(128, 0, 255));
  display_B.drawLine(120, 7, 120, 120, ssd1351::RGB(255, 0, 128));
  display_B.drawLine(120, 120, 7, 120, ssd1351::RGB(0, 128, 255));
  display_B.drawLine(7, 120, 7, 7, ssd1351::RGB(128, 255, 0));

  display_B.updateScreen();  

}


I had to draw to each screen at a time, handle then separately.

And I had a time getting a good photo ...... , only one out of 8 didn't have camera jitter from holding my phone (not much of a cell phone person either).

BUT, you can't see it, sorry. Don't know how.

The way the lib seems to be written is that I need a pin for cs,dc, & reset for each display. miso & sclk can be shared.
Tried a few different pin combos before it worked.
 
Last edited:
Status
Not open for further replies.
Back
Top