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

2 Likes

@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.

1 Like

Thank you! As I said in the previous post I got it to work by adapting a Patch example, but it will surely be very helpful in the future :slight_smile: For now I’m using 7 pin spi 1306 display, but I also plan on testing the 4 pin I2C one which I have laying around. Will report back!

1 Like

Hi, Did you get the I2C driver for 1306 working? I realised I have I2C version so wondered if this was easier to set up? I read through your trials with anticipation and sympathy. I’m also not much of a programmer and find the amount of research and asking advice on forums becomes very frustrating, only to spend days trying to figure out a problem to arrive at a dead end. I started trying to set up the HD44780 1602 lcd display, a popular supported model I thought but found out the driver for Daisy is only parallel not I2C.

I2C OLED displays work fine with Daisy Seed.
But, patch.Init() doesn’t have I2C signals available on the P1 connector. SPI OLEDs work on patch.Init() via the P1 connector.

Hiya,

I just found the Daisy Seed example for OLED but it says it is SPI. Is there an example for I2C?

  • This is a 4Wire SPI Transport controlling an 128x64 sized SSDD1306

Is there an example code for I2C from the proof of concept here?

This code is from a thread here entitled “Weird stripe on I2C OLED display” :


#include <stdio.h>
#include <string.h>
#include "daisy_seed.h"
#include "dev/oled_ssd130x.h"

using namespace daisy;
using MyOledDisplay = OledDisplay<SSD130xI2c128x64Driver>;

DaisySeed     hw;
MyOledDisplay display;

int main(void)
{
    uint8_t message_idx;
    hw.Configure();
    hw.Init();

    /** Configure the Display */
    MyOledDisplay::Config disp_cfg;
    // disp_cfg.driver_config.transport_config.pin_config.dc    = hw.GetPin(9);
    // disp_cfg.driver_config.transport_config.pin_config.reset = hw.GetPin(30);
    /** And Initialize */
    display.Init(disp_cfg);

    message_idx = 0;
    char strbuff[128];
    while(1)
    {
        System::Delay(500);
        switch(message_idx)
        {
            case 0: sprintf(strbuff, "Testing. . ."); break;
            case 1: sprintf(strbuff, "Daisy. . ."); break;
            case 2: sprintf(strbuff, "1. . ."); break;
            case 3: sprintf(strbuff, "2. . ."); break;
            case 4: sprintf(strbuff, "3. . ."); break;
            default: break;
        }
        message_idx = (message_idx + 1) % 5;
        display.Fill(false);
        display.SetCursor(0, 0);
        display.WriteString(strbuff, Font_11x18, true);
        display.Update();
    }
}

The weird stripe was from using a display which had a different chip. Read the thread, it works fine for my I2C OLEDs

Thanks. The pins on SM for I2C are:
B8 - I2C_SDA
B9 - I2C_SCL

I’m thinking this would be right:

disp_cfg.driver_config.transport_config.pin_config.SDA = hw.GetPin(B8);
disp_cfg.driver_config.transport_config.pin_config.SCL = hw.GetPin(B7);

or

disp_cfg.driver_config.transport_config.pin_config.I2C_SDA = hw.GetPin(B8);
disp_cfg.driver_config.transport_config.pin_config.I2C_SCL = hw.GetPin(B7);

image