Skip to content

File syn_oled.c

FileList > display > syn_oled.c

Go to the source code of this file

Generic Monochrome OLED Display Driver (SSD1306, SH1106, SSD1309 over I2C).

  • #include "syn_oled.h"
  • #include "../util/syn_assert.h"
  • #include <string.h>

Public Functions

Type Name
void syn_oled_canvas_flush_cb (const uint8_t * buf, size_t len, void * ctx)
Canvas flush callback matching SYN_Canvas_FlushFn signature.
void syn_oled_flush_canvas (SYN_OLED * oled, const SYN_Canvas * c)
Flush canvas pixel buffer to physical OLED display screen.
SYN_Status syn_oled_init (SYN_OLED * oled, SYN_GPIO_Pin scl, SYN_GPIO_Pin sda, uint8_t i2c_addr, uint16_t w, uint16_t h, SYN_OLEDType type)
Initialize Monochrome OLED display context.
void syn_oled_set_contrast (SYN_OLED * oled, uint8_t contrast)
Set display contrast level.
void syn_oled_set_display_on (SYN_OLED * oled, bool on)
Turn display ON or OFF (power save mode).
void syn_oled_set_invert (SYN_OLED * oled, bool invert)
Set display color inversion.

Public Static Functions

Type Name
bool get_canvas_pixel (const SYN_Canvas * c, uint16_t x, uint16_t y)
void send_command (SYN_OLED * oled, uint8_t cmd)
void write_i2c_reg (SYN_SoftI2C * i2c, uint8_t dev_addr, uint8_t reg, uint8_t val)

Public Functions Documentation

function syn_oled_canvas_flush_cb

Canvas flush callback matching SYN_Canvas_FlushFn signature.

void syn_oled_canvas_flush_cb (
    const uint8_t * buf,
    size_t len,
    void * ctx
) 

Parameters:

  • buf Framebuffer byte array.
  • len Byte array length.
  • ctx Context pointer (SYN_OLED instance).

function syn_oled_flush_canvas

Flush canvas pixel buffer to physical OLED display screen.

void syn_oled_flush_canvas (
    SYN_OLED * oled,
    const SYN_Canvas * c
) 

Parameters:

  • oled OLED context.
  • c Source Canvas context.

function syn_oled_init

Initialize Monochrome OLED display context.

SYN_Status syn_oled_init (
    SYN_OLED * oled,
    SYN_GPIO_Pin scl,
    SYN_GPIO_Pin sda,
    uint8_t i2c_addr,
    uint16_t w,
    uint16_t h,
    SYN_OLEDType type
) 

Parameters:

  • oled OLED context.
  • scl I2C SCL GPIO pin.
  • sda I2C SDA GPIO pin.
  • i2c_addr I2C slave address (e.g. 0x3C or 0x3D).
  • w Width in pixels (e.g. 128).
  • h Height in pixels (e.g. 64 or 32).
  • type OLED IC Controller type (SSD1306, SH1106, SSD1309).

Returns:

SYN_OK on success.


function syn_oled_set_contrast

Set display contrast level.

void syn_oled_set_contrast (
    SYN_OLED * oled,
    uint8_t contrast
) 

Parameters:

  • oled OLED context.
  • contrast Contrast level (0 to 255).

function syn_oled_set_display_on

Turn display ON or OFF (power save mode).

void syn_oled_set_display_on (
    SYN_OLED * oled,
    bool on
) 

Parameters:

  • oled OLED context.
  • on True for display ON.

function syn_oled_set_invert

Set display color inversion.

void syn_oled_set_invert (
    SYN_OLED * oled,
    bool invert
) 

Parameters:

  • oled OLED context.
  • invert True for inverted display (black on white).

Public Static Functions Documentation

function get_canvas_pixel

static bool get_canvas_pixel (
    const SYN_Canvas * c,
    uint16_t x,
    uint16_t y
) 

function send_command

static void send_command (
    SYN_OLED * oled,
    uint8_t cmd
) 

function write_i2c_reg

static void write_i2c_reg (
    SYN_SoftI2C * i2c,
    uint8_t dev_addr,
    uint8_t reg,
    uint8_t val
) 


The documentation for this class was generated from the following file src/syntropic/display/syn_oled.c