Simple library for using ssd1306 displays with the Raspberry Pi Pico and the pico-sdk.
- copy
font.h
,ssd1306.c
andssd1306.h
to your project - see example
- online documentation
- see
ssd1306.h
and example
- set
PICO_SDK_PATH
- goto
example
mkdir build && cd build && cmake .. && make
- copy the
ssd1306-example.uf2
to your Pico
The library can draw monochrome bitmaps using the functions ssd1306_bmp_show_image and ssd1306_bmp_show_image_with_offset.
For converting an image to the supported format, you can do the following:
- install ImageMagick
- use
convert you_image.png -monochrome your_image.bmp
For embedding your image, you can use tools like bin2c (included in the hxtools package on Debian).
Alternatively, you can you the version included in this repo:
- go in the tools/ directory
make
- usage:
./bin2c your_image.bmp your_image.h
You may also take a look at the example in the example/ directory.
You can also use or own fonts when drawing with ssd1306_draw_char_with_font or ssd1306_draw_string_with_font. The format is:
- a 1-D uint8_t array
- structure of the array:
- the first element of the array is the height
- the second element of the array is the width
- the third element of the array is the additional spacing between chars
- the fourth element of the array is the the first ascii character, this array stores
- the fifth element of the array is the the last ascii character, this array stores
- the following elements encode the pixels of the characters vertically line by line (see); a line can be encoded as more than one
uint8_t
values, when the height is greater than 8; please look atfont.h
and the fonts in theexample/
directory