SSD1306 OLED compatibility?

Hello! I’m trying to hook up an OLED display to my Daisy Seed, and since SSD1309 is not easliy available here, I got a SSD1306. I’ve read that the drivers should be compatible, so I hooked everything up along to kreiff’s schematic:

but unfortunatelly after flashing the OLED Seed example I’m not getting any output on the display.

Are the hardware libraries not compatible with the SSD1306? If so then how to modify them to get some results?

If you look in the OLED display driver code, its says:

// Set up for now with:
// SCL → PG11 (SPI1_SCK)
// SDA → PB4 (SPI1_MOSI)
// RES → PB8 (I2C1_SDA)
// DC → PB9 (I2C1_SCL)

You can check it out here: libdaisy/src/hid/oled_display.cpp

I haven’t tested this, but I have the same problem as you – finding affordable SSD1309 displays – so I am curious about whether the SSD1306 works. Please report back! :slight_smile:

Thanks Staffan, unfortunatelly that pinout didn’t work either. But in the header file for the oled library there’s a comment by @shensley about the driver beeing inspired by a ssd1306 library from here. Theres also a todo list that says “re-add support for SSD1306 displays”, so maybe not all hope is lost :slight_smile:

I crosschecked the command lists between these two (SSD1306 and SSD1309) displays and couldn’t find any difference. That’s where my current knowledge allows me to go at the moment. Any pointers would be great!

Sorry @utarefson, I wish I could help you.

I tried with an I2C SSD1306 display I had laying about two months ago, but that project didn’t work out, so I switched to my trusty old LCD keypads that I’ve used for many Arduino projects. I wrote a lib for that one instead! :slight_smile: It is now in libdaisy: libDaisy/lcd_hd44780.cpp at master · electro-smith/libDaisy · GitHub

Ok, I managed to get it to work under Arduino. Converting the project I was working on was a bit pita but at the end it works almost like with cpp libdaisy.

The SSD1306 is connected via SPI just as in the diagram above. I’m using the standard u8g2 library and everything works as it should. I even managed it to display real time pot values. Only thing is occasional misreading (value jumping between actual reading and 0). Got it on picture:
ezgif.com-gif-maker
(don’t mind the vertical scanning flicker, it’s only on recording). I think this has to do with adc reading interruptions between daisyduino and analogRead function used to print the value on display, but I’m not sure after all.

One another thing I noticed is that the MCU is getting pretty hot, like 55-60°C. Are these kind of temperatures safe to run? Gonna have to get some radiator on this thing.

2 Likes

Great! Please share the code! :slight_smile: I’d like to start working with OLEDs, but in “pure” c++ (not DaisyDuino).

Here’s the code:

It’s a guitar pedal reverb with pitch shifted tail. I modified the Daisy Petal library to implement Pod- like Led control and also changed switch pins.

1 Like

Thanks a lot @utarefson for sharing! :slight_smile: Ah, so with the u8g2 lib you didn’t have to change a thing. That is good news för the SSD1306.

So thanks to the latest libDaisy update I was able to get the 1306 OLED running under VS Code. I even implemented it to run with DaisyPetal library, but I’m having a hard time to get it to print knob values. Analysing some Patch examples I came to something like this:

while(1)

{

System::Delay(10);

float pwet = hw.GetKnobValue(hw.KNOB_3);

unsigned long dwet = (unsigned long)pwet;  

hw.display.Fill(false);

std::string str = "WET: " + std::to_string(dwet);

char *      cstr = &str[0];

hw.display.SetCursor(0, 0);

hw.display.WriteString(cstr,Font_6x8,true);

hw.display.Update();

}

but it’s returning only “WET: 0”

Do I mess something up with the float to unsigned long conversion?

Ok I got it to work, for future reference it should go like this:

while(1)

{



System::Delay(10);

hw.ProcessAllControls();

float pwet = hw.GetKnobValue(hw.KNOB_3);

 

hw.display.Fill(false);

std::string str = "WET: " + std::to_string(static_cast<uint32_t>(100 * pwet));

char *      cstr = &str[0];

hw.display.SetCursor(0, 0);

hw.display.WriteString(cstr,Font_6x8,true);

hw.display.Update();

}

Man, I really wish that at least the examples would be documented better by commenting.

I have to tell you, as a non-programmer, every feature I want to implement is like breaking through an open door. So far I got everything to work but busting through github/forum/slack every time for days is getting more and more frustrating.

/rant :slight_smile:

1 Like

You might find ‘sndkit’ which is a ‘literate’ DSP library to have the commenting you want - at least for the DSP side. Take a look at:
https://pbat.ch/sndkit/osc/
Which is the ‘code’ for osc.
Here’s the forum entry where Paul B described sndkit:

Sndkit: a sonic toolkit for everyone

1 Like

@utarefson floating point string printing adds quite a bit of bloat to the library. So the option is available, but has to be added explicitly.

You can add the following to your Makefile, and the function should behave as you expected in the first example:

LDFLAGS = -u _printf_float

Alternatively, there are some helper macros for faking it without the jump in flash usage.

For example:

float foo = 0.5f;
sprintf(buffer, "Print this float: " FLT_FMT3 "\n", FLT_VAR3(foo));

(More examples of these helpers is illustrated in the seed/Logger example.)

We appreciate the feedback, and are actively working on creating better documentation inside and outside of the code.