Skip to content

Example of using OLED 1306 via I2C (2 Wire) with Electrosmith Daisy Seed music microcontroller

Notifications You must be signed in to change notification settings

doohinkus/daisy-seed-OLED

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 

Repository files navigation

Daisy Seed OLED 1306 I2C/ 2 Wire (gnd, vcc, slc, sda)

Example of using OLED with Electrosmith Daisy Seed music microcontroller. daisy_seed_i2c_oled

Wiring

DaisySeed_OLED_FOUR_PIN

Copy OLED example

Use the helper script to copy the OLED example into a new folder.

./helper.py copy seed/IC2_OLED --source seed/OLED

Change directories into the new folder:

cd ./seed/IC2OLED

Config the copied OLED code

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

using namespace daisy;

/** Typedef the OledDisplay to make syntax cleaner below 
 *  This is a 2Wire I2C Transport controlling an 128x64 sized SSDD1306
 * 
 *  There are several other premade test 
*/
using MyOledDisplay = OledDisplay<SSD130xI2c128x32Driver>;

DaisySeed     hw;
MyOledDisplay display;

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

    /** Configure the Display */
    MyOledDisplay::Config display_config;

    display_config.driver_config.transport_config.i2c_address = 0x3C;
    display_config.driver_config.transport_config.i2c_config.periph = I2CHandle::Config::Peripheral::I2C_1;
    display_config.driver_config.transport_config.i2c_config.speed  = I2CHandle::Config::Speed::I2C_100KHZ;
    display_config.driver_config.transport_config.i2c_config.mode = I2CHandle::Config::Mode::I2C_MASTER;
    display_config.driver_config.transport_config.i2c_config.pin_config.scl = {DSY_GPIOB, 8};
    display_config.driver_config.transport_config.i2c_config.pin_config.sda = {DSY_GPIOB, 9};

    display.Init(display_config);
    
    /** And Initialize */
    display.Init(display_config);

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

Compile

make .

Reset seed

Press both white buttons.

Upload

make program-dfu

Why DSY_GPIOB, 8 and DSY_GPIOB, 9?

display_config.driver_config.transport_config.i2c_config.pin_config.scl = {DSY_GPIOB, 8};
display_config.driver_config.transport_config.i2c_config.pin_config.sda = {DSY_GPIOB, 9};
Screenshot 2024-09-07 at 9 59 41 AM

Why Ox3C?

Ox3c

About

Example of using OLED 1306 via I2C (2 Wire) with Electrosmith Daisy Seed music microcontroller

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published