Arduino TKJHAT
Arduino library for Pico HAT extension board
Loading...
Searching...
No Matches
ssd1306.h File Reference
#include <pico/stdlib.h>
#include <hardware/i2c.h>

Go to the source code of this file.

Classes

struct  ssd1306_t
 holds the configuration More...

Enumerations

enum  ssd1306_command_t
 defines commands used in ssd1306

Functions

void ssd1306_bmp_show_image (ssd1306_t *p, const uint8_t *data, const long size)
 draw monochrome bitmap
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
void ssd1306_clear (ssd1306_t *p)
 clear display buffer
void ssd1306_clear_pixel (ssd1306_t *p, uint32_t x, uint32_t y)
 clear pixel on buffer
void ssd1306_clear_square (ssd1306_t *p, uint32_t x, uint32_t y, uint32_t width, uint32_t height)
 clear square at given position with given size
void ssd1306_contrast (ssd1306_t *p, uint8_t val)
 set contrast of display
void ssd1306_deinit (ssd1306_t *p)
 deinitialize display
void ssd1306_draw_char (ssd1306_t *p, uint32_t x, uint32_t y, uint32_t scale, char c)
 draw char with builtin 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
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
void ssd1306_draw_line (ssd1306_t *p, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
 draw line on buffer
void ssd1306_draw_pixel (ssd1306_t *p, uint32_t x, uint32_t y)
 draw pixel on buffer
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
void ssd1306_draw_string (ssd1306_t *p, uint32_t x, uint32_t y, uint32_t scale, const char *s)
 draw string with builtin 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
bool ssd1306_init (ssd1306_t *p, uint16_t width, uint16_t height, uint8_t address, i2c_inst_t *i2c_instance)
 initialize display
void ssd1306_invert (ssd1306_t *p, uint8_t inv)
 set invert display
void ssd1306_poweroff (ssd1306_t *p)
 turn off display
void ssd1306_poweron (ssd1306_t *p)
 turn on display
void ssd1306_show (ssd1306_t *p)
 display buffer, should be called on change

Detailed Description

simple driver for ssd1306 displays

Definition in file ssd1306.h.

Function Documentation

◆ ssd1306_bmp_show_image()

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

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)

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_clear_square()

void ssd1306_clear_square ( ssd1306_t * p,
uint32_t x,
uint32_t y,
uint32_t width,
uint32_t height )

clear 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_contrast()

void ssd1306_contrast ( ssd1306_t * p,
uint8_t val )

set contrast of display

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

◆ ssd1306_deinit()

void ssd1306_deinit ( ssd1306_t * p)

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 line 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 )

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)

turn off display

Parameters
[in]p: instance of display

◆ ssd1306_poweron()

void ssd1306_poweron ( ssd1306_t * p)

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