pico-ssd1306
0.1
Simple library for using ssd1306 displays with the Raspberry Pi Pico and the pico-sdk.
|
#include <pico/stdlib.h>
#include <hardware/i2c.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... | |
simple driver for ssd1306 displays
|
inline |
draw monochrome bitmap
[in] | p | : instance of display |
[in] | data | : image data (whole file) |
[in] | size | : size of image data in bytes |
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
[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 |
|
inline |
clear display buffer
[in] | p | : instance of display |
void ssd1306_clear_pixel | ( | ssd1306_t * | p, |
uint32_t | x, | ||
uint32_t | y | ||
) |
clear pixel on buffer
[in] | p | : instance of display |
[in] | x | : x position |
[in] | y | : y position |
|
inline |
set contrast of display
[in] | p | : instance of display |
[in] | val | : contrast |
|
inline |
deinitialize display
[in] | p | : instance of display |
void ssd1306_draw_char | ( | ssd1306_t * | p, |
uint32_t | x, | ||
uint32_t | y, | ||
uint32_t | scale, | ||
char | c | ||
) |
draw char with builtin font
[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 |
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
[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 |
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
[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 |
void ssd1306_draw_line | ( | ssd1306_t * | p, |
int32_t | x1, | ||
int32_t | y1, | ||
int32_t | x2, | ||
int32_t | y2 | ||
) |
draw pixel on buffer
[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 |
void ssd1306_draw_pixel | ( | ssd1306_t * | p, |
uint32_t | x, | ||
uint32_t | y | ||
) |
draw pixel on buffer
[in] | p | : instance of display |
[in] | x | : x position |
[in] | y | : y position |
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
[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 |
void ssd1306_draw_string | ( | ssd1306_t * | p, |
uint32_t | x, | ||
uint32_t | y, | ||
uint32_t | scale, | ||
const char * | s | ||
) |
draw string with builtin font
[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 |
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
[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 |
bool ssd1306_init | ( | ssd1306_t * | p, |
uint16_t | width, | ||
uint16_t | height, | ||
uint8_t | address, | ||
i2c_inst_t * | i2c_instance | ||
) |
initialize display
[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 |
true | for Success |
false | if initialization failed |
|
inline |
set invert display
[in] | p | : instance of display |
[in] | inv | : inv==0: disable inverting, inv!=0: invert |
|
inline |
turn off display
[in] | p | : instance of display |
|
inline |
turn on display
[in] | p | : instance of display |
void ssd1306_show | ( | ssd1306_t * | p | ) |
display buffer, should be called on change
[in] | p | : instance of display |