OLED display with Daisy Seed Help

Hi everyone,

Im wanting to connect a OLED display to my daisy seed. So far I have some basic code that I wrote and some that I found. Everytime I try run it onto the OLED it doesn’t work. Im wanting to just write something basic for example “Hello World”

Here is my code

#include <stdio.h>
#include <string.h>
#include “daisy_seed.h”
#include “dev/oled_ssd130x.h”
#include “daisy_patch_sm.h”

using namespace daisy;
using namespace patch_sm;

/** Typedef the OledDisplay to make syntax cleaner below

  • This is a 4Wire SPI Transport controlling an 128x64 sized SSDD1306
  • There are several other premade test
    */
    using MyOledDisplay = OledDisplay;

DaisySeed hw;
MyOledDisplay display;

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

/** Configure the Display */
DaisyPatchSM::PinBank bankD;
bankD = DaisyPatchSM::PinBank::D;

MyOledDisplay::Config disp_cfg;

disp_cfg.driver_config.transport_config.spi_config.periph = SpiHandle::Config::Peripheral::SPI_2;   

disp_cfg.driver_config.transport_config.spi_config.pin_config.nss = hw.GetPin(bankD,1);
disp_cfg.driver_config.transport_config.spi_config.pin_config.miso = Pin();
disp_cfg.driver_config.transport_config.spi_config.pin_config.mosi = hw.GetPin(bankD,9);
disp_cfg.driver_config.transport_config.spi_config.pin_config.sclk = hw.GetPin(bankD,10);

disp_cfg.driver_config.transport_config.pin_config.dc = hw.GetPin(bankD,2);    
disp_cfg.driver_config.transport_config.pin_config.reset = hw.GetPin(bankD,3);

/** 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(true);
    display.SetCursor(0, 0);
    display.WriteString(strbuff, Font_11x18, false);
    display.Update();
}

}

Your code mentions both Seed and Patch SM.
Which is it?

Meant to be seed. I’m a little new to vs code and daisy

If it is seed, then I would not
#include “daisy_patch_sm.h”

As we don’t know your OLED and your exact connections efficient help is not possible. (There are OLEDs with I2C instead of SPI…)

So I have updated the code. Its working as a timer but for now I want a fixed word eg. “Hello World”

#include “daisy_seed.h”

/** Includes the oled display header (not included in Daisy?)*/
#include “dev/oled_ssd130x.h”

/** This prevents us from having to type “daisy::” in front of a lot of things. */
using namespace daisy;

/** Global Hardware access */
DaisySeed hw;

int main(void)
{
/** Initialize our hardware */
hw.Init();

OledDisplay<SSD130x4WireSpi128x64Driver>         display;
OledDisplay<SSD130x4WireSpi128x64Driver>::Config display_cfg;

/** SPI Configuration 
 * 
 *  Most default values are still used, but here are a few 
 *  settings that are most likely to be edited for custom hw
 */

display_cfg.driver_config.transport_config.spi_config.periph = SpiHandle::Config::Peripheral::SPI_1;
display_cfg.driver_config.transport_config.spi_config.baud_prescaler = SpiHandle::Config::BaudPrescaler::PS_8;
/** Set up the SPI Pins for SPI1 */
display_cfg.driver_config.transport_config.spi_config.pin_config.sclk = seed::D8;
display_cfg.driver_config.transport_config.spi_config.pin_config.miso = Pin();
display_cfg.driver_config.transport_config.spi_config.pin_config.mosi = seed::D10;
display_cfg.driver_config.transport_config.spi_config.pin_config.nss = seed::D7;
/** Command and Reset Pins */
display_cfg.driver_config.transport_config.pin_config.dc    = seed::D9;
display_cfg.driver_config.transport_config.pin_config.reset = seed::D12;

/** Initialize it */
display.Init(display_cfg);
/** Set it to black until we start updating. */
display.Fill(false);
display.Update();

/** Infinite Loop */
while(1)
{
    System::Delay(1000);

    /** Get the number of seconds since the program started */
    int seconds = System::GetNow() / 1000.0;

    /** Clear the display */
    display.Fill(false);
    /** Set the cursor away from the edge of the screen */
    display.SetCursor(4, 16);
    /** Write the following, starting at the cursor */
    display.WriteString("Time since startup:", Font_6x8, true);
    /** Update the cursor to the next space below the string */
    display.SetCursor(4, 32);

    /** Create a string representation of the */
    FixedCapStr<16> str("");
    str.AppendInt(seconds);
    /** Write the value to the display */
    display.WriteString(str, Font_11x18, true);

    /** And finally push the updated screen contents to the hardware */
    display.Update();
}

}

Its working but can’t figure out how to do what was mentioned

Google Writestring libdaisy
or so might help.

When it comes to attaching it to for example “Dry/Wet” - can you let me know