pico-ssd1306  0.1
Simple library for using ssd1306 displays with the Raspberry Pi Pico and the pico-sdk.
Data Structures | Enumerations | Functions
ssd1306.h File Reference
#include <pico/stdlib.h>
#include <hardware/i2c.h>
Include dependency graph for ssd1306.h:

Go to the source code of this file.

Data Structures

struct  ssd1306_t
 holds the configuration More...
 

Enumerations

enum  ssd1306_command_t {
  SET_CONTRAST = 0x81 , SET_ENTIRE_ON = 0xA4 , SET_NORM_INV = 0xA6 , SET_DISP = 0xAE ,
  SET_MEM_ADDR = 0x20 , SET_COL_ADDR = 0x21 , SET_PAGE_ADDR = 0x22 , SET_DISP_START_LINE = 0x40 ,
  SET_SEG_REMAP = 0xA0 , SET_MUX_RATIO = 0xA8 , SET_COM_OUT_DIR = 0xC0 , SET_DISP_OFFSET = 0xD3 ,
  SET_COM_PIN_CFG = 0xDA , SET_DISP_CLK_DIV = 0xD5 , SET_PRECHARGE = 0xD9 , SET_VCOM_DESEL = 0xDB ,
  SET_CHARGE_PUMP = 0x8D
}
 defines commands used in ssd1306
 

Functions

bool ssd1306_init (ssd1306_t *p, uint16_t width, uint16_t height, uint8_t address, i2c_inst_t *i2c_instance)
 initialize display More...
 
void ssd1306_deinit (ssd1306_t *p)
 deinitialize display More...
 
void ssd1306_poweroff (ssd1306_t *p)
 turn off display More...
 
void ssd1306_poweron (ssd1306_t *p)
 turn on display More...
 
void ssd1306_contrast (ssd1306_t *p, uint8_t val)
 set contrast of display More...
 
void ssd1306_invert (ssd1306_t *p, uint8_t inv)
 set invert display More...
 
void ssd1306_show (ssd1306_t *p)
 display buffer, should be called on change More...
 
void ssd1306_clear (ssd1306_t *p)
 clear display buffer More...
 
void ssd1306_clear_pixel (ssd1306_t *p, uint32_t x, uint32_t y)
 clear pixel on buffer More...
 
void ssd1306_draw_pixel (ssd1306_t *p, uint32_t x, uint32_t y)
 draw pixel on buffer More...
 
void ssd1306_draw_line (ssd1306_t *p, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
 draw pixel on buffer More...
 
void ssd1306_draw_square (ssd1306_t *p, uint32_t x, uint32_t y, uint32_t width, uint32_t height)
 draw filled square at given position with given size More...
 
void ssd1306_draw_empty_square (ssd1306_t *p, uint32_t x, uint32_t y, uint32_t width, uint32_t height)
 draw empty square at given position with given size More...
 
void ssd1306_bmp_show_image_with_offset (ssd1306_t *p, const uint8_t *data, const long size, uint32_t x_offset, uint32_t y_offset)
 draw monochrome bitmap with offset More...
 
void ssd1306_bmp_show_image (ssd1306_t *p, const uint8_t *data, const long size)
 draw monochrome bitmap More...
 
void ssd1306_draw_char_with_font (ssd1306_t *p, uint32_t x, uint32_t y, uint32_t scale, const uint8_t *font, char c)
 draw char with given font More...
 
void ssd1306_draw_char (ssd1306_t *p, uint32_t x, uint32_t y, uint32_t scale, char c)
 draw char with builtin font More...
 
void ssd1306_draw_string_with_font (ssd1306_t *p, uint32_t x, uint32_t y, uint32_t scale, const uint8_t *font, const char *s)
 draw string with given font More...
 
void ssd1306_draw_string (ssd1306_t *p, uint32_t x, uint32_t y, uint32_t scale, const char *s)
 draw string with builtin font More...
 

Detailed Description

simple driver for ssd1306 displays

Function Documentation

◆ ssd1306_bmp_show_image()

void ssd1306_bmp_show_image ( ssd1306_t p,
const uint8_t *  data,
const long  size 
)
inline

draw monochrome bitmap

Parameters
[in]p: instance of display
[in]data: image data (whole file)
[in]size: size of image data in bytes

◆ ssd1306_bmp_show_image_with_offset()

void ssd1306_bmp_show_image_with_offset ( ssd1306_t p,
const uint8_t *  data,
const long  size,
uint32_t  x_offset,
uint32_t  y_offset 
)

draw monochrome bitmap with offset

Parameters
[in]p: instance of display
[in]data: image data (whole file)
[in]size: size of image data in bytes
[in]x_offset: offset of horizontal coordinate
[in]y_offset: offset of vertical coordinate

◆ ssd1306_clear()

void ssd1306_clear ( ssd1306_t p)
inline

clear display buffer

Parameters
[in]p: instance of display

◆ ssd1306_clear_pixel()

void ssd1306_clear_pixel ( ssd1306_t p,
uint32_t  x,
uint32_t  y 
)

clear pixel on buffer

Parameters
[in]p: instance of display
[in]x: x position
[in]y: y position

◆ ssd1306_contrast()

void ssd1306_contrast ( ssd1306_t p,
uint8_t  val 
)
inline

set contrast of display

Parameters
[in]p: instance of display
[in]val: contrast

◆ ssd1306_deinit()

void ssd1306_deinit ( ssd1306_t p)
inline

deinitialize display

Parameters
[in]p: instance of display

◆ ssd1306_draw_char()

void ssd1306_draw_char ( ssd1306_t p,
uint32_t  x,
uint32_t  y,
uint32_t  scale,
char  c 
)

draw char with builtin font

Parameters
[in]p: instance of display
[in]x: x starting position of char
[in]y: y starting position of char
[in]scale: scale font to n times of original size (default should be 1)
[in]c: character to draw

◆ ssd1306_draw_char_with_font()

void ssd1306_draw_char_with_font ( ssd1306_t p,
uint32_t  x,
uint32_t  y,
uint32_t  scale,
const uint8_t *  font,
char  c 
)

draw char with given font

Parameters
[in]p: instance of display
[in]x: x starting position of char
[in]y: y starting position of char
[in]scale: scale font to n times of original size (default should be 1)
[in]font: pointer to font
[in]c: character to draw

◆ ssd1306_draw_empty_square()

void ssd1306_draw_empty_square ( ssd1306_t p,
uint32_t  x,
uint32_t  y,
uint32_t  width,
uint32_t  height 
)

draw empty square at given position with given size

Parameters
[in]p: instance of display
[in]x: x position of starting point
[in]y: y position of starting point
[in]width: width of square
[in]height: height of square

◆ ssd1306_draw_line()

void ssd1306_draw_line ( ssd1306_t p,
int32_t  x1,
int32_t  y1,
int32_t  x2,
int32_t  y2 
)

draw pixel on buffer

Parameters
[in]p: instance of display
[in]x1: x position of starting point
[in]y1: y position of starting point
[in]x2: x position of end point
[in]y2: y position of end point

◆ ssd1306_draw_pixel()

void ssd1306_draw_pixel ( ssd1306_t p,
uint32_t  x,
uint32_t  y 
)

draw pixel on buffer

Parameters
[in]p: instance of display
[in]x: x position
[in]y: y position

◆ ssd1306_draw_square()

void ssd1306_draw_square ( ssd1306_t p,
uint32_t  x,
uint32_t  y,
uint32_t  width,
uint32_t  height 
)

draw filled square at given position with given size

Parameters
[in]p: instance of display
[in]x: x position of starting point
[in]y: y position of starting point
[in]width: width of square
[in]height: height of square

◆ ssd1306_draw_string()

void ssd1306_draw_string ( ssd1306_t p,
uint32_t  x,
uint32_t  y,
uint32_t  scale,
const char *  s 
)

draw string with builtin font

Parameters
[in]p: instance of display
[in]x: x starting position of text
[in]y: y starting position of text
[in]scale: scale font to n times of original size (default should be 1)
[in]s: text to draw

◆ ssd1306_draw_string_with_font()

void ssd1306_draw_string_with_font ( ssd1306_t p,
uint32_t  x,
uint32_t  y,
uint32_t  scale,
const uint8_t *  font,
const char *  s 
)

draw string with given font

Parameters
[in]p: instance of display
[in]x: x starting position of text
[in]y: y starting position of text
[in]scale: scale font to n times of original size (default should be 1)
[in]font: pointer to font
[in]s: text to draw

◆ ssd1306_init()

bool ssd1306_init ( ssd1306_t p,
uint16_t  width,
uint16_t  height,
uint8_t  address,
i2c_inst_t *  i2c_instance 
)

initialize display

Parameters
[in]p: pointer to instance of ssd1306_t
[in]width: width of display
[in]height: heigth of display
[in]address: i2c address of display
[in]i2c_instance: instance of i2c connection
Returns
bool.
Return values
truefor Success
falseif initialization failed

◆ ssd1306_invert()

void ssd1306_invert ( ssd1306_t p,
uint8_t  inv 
)
inline

set invert display

Parameters
[in]p: instance of display
[in]inv: inv==0: disable inverting, inv!=0: invert

◆ ssd1306_poweroff()

void ssd1306_poweroff ( ssd1306_t p)
inline

turn off display

Parameters
[in]p: instance of display

◆ ssd1306_poweron()

void ssd1306_poweron ( ssd1306_t p)
inline

turn on display

Parameters
[in]p: instance of display

◆ ssd1306_show()

void ssd1306_show ( ssd1306_t p)

display buffer, should be called on change

Parameters
[in]p: instance of display