A small extensible rendering library for SSD1306 OLED display on Raspberry Pi Pico.
This is ported from ssd1306-on-linux repository and tested on Raspberry Pi Pico.
What's included:
- A simple rendering library to render digits and symbols on SSD1306. [digitRenderer]
- A Pico I2C wrapper to communicate with SSD1306. [i2cSend]
- A utility to create new symbols to display on SSD1306. [mapGenerator]
- A program to display the value of Pico's onboard temperature sensor on SSD1306. [main.c]
The main program main.c uses the digitRenderer library to render digits/symbols on SSD1306 and the i2cSend wrapper to send commands and data to SSD1306. The main loop reads the value of the onboard temperature sensor and displays it to the SSD1306 display.
Steps to build and run the program:
-
Setup the Pico SDK on your system if not already done.
-
Create a new directory in the same directory as
pico-sdk
. Let's name itpico-projects
. -
Clone this repository to
pico-projects
directory usinggit clone https://github.com/bkhajuria/ssd1306-on-pico.git
. -
Switch to the directory
ssd1306-on-pico
. -
Create a new directory named
build
and switch to itmkdir build && cd build
. -
Run
cmake ..
. Build configuration will be done and build files will be written. -
Run
make
. Upon succesful build, target filesssd1306pico.elf
,ssd1306pico.uf2
will be generated.TIP: To speed up the build process, use
make -j4
ormake -j6
depending upon the number of cores available on the system. -
Now flash the Pico by connecting it as a USB mass storage device. To do this, press and hold the BOOTSEL button on Pico, connect it to the system via USB and then release the button. (Checkout the guide).
-
Once connected, drag and drop the
ssd1306pico.uf2
file to the mass storage device. It will get ejected automatically and the program will start running on Pico.
New symbols can be created using the mapGenerator utility. Below illustration adds and displays the Raspberry Pi logo:
- In mapGen.c, Add a new 16*16 matrix to the the
symbolMap
array that represents Raspberry Pi logo. - Increase the value of
NUM_SYMBOLS
macro by 1 (since we added one symbol). - Build by running
make
in the mapGenerator directory. - Run the generated executable as
./mapGen
. - It will print the bitmaps for all the digits and symbols.
- Copy the 32-byte bitmap generated for the new symbol.
- Add the bitmap to the
symbolMap
array in digitRenderer.c. Increase the value ofNUM_SYMBOLS
macro by 1. - Add enumeration for the new symbol in digitRenderer.h.
- To test rendering the new symbol use the
renderSymbol
function.