Skip to content

This is a working example of how you can use U8G2 Library in ESP-IDF

Notifications You must be signed in to change notification settings

StevenSlaa/ESP-IDF-U8G2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

ESP-IDF v5 - u8g2

This is a working example of how you can use u8g2 Library in ESP-IDF. This contains an updated driver by J0003 of nkolban

Special Thanks to:

Background

I wanted to use my SSD1306 Monochrome OLED display inside of the ESP-IDF, but wanted something more versitile than LVGL. I started of with the example within the ESP-IDF. This works reasonably well, but overtime I noticed it is not really optimized to work with monochrome and non touch displays. Also I was running into problems with styling and outdated forum posts. I wanted to have more control. From experience with Arduino I remembered u8g2. Trying to implement it in ESP-IDF I noticed that a hal-driver was neccesary to use it within ESP-IDF. I came a cross a driver from nkolban. It was however not compatible with the latest version of ESP-IDF(V5.2 at time of writing)

How to load U8g2 inside of your ESP-IDF project

Add u8g2 to your project

When you created your clean ESP-IDF project, you have to add a folder inside of you project folder (folder where your main folder is located in) called components. inside of this folder you have to add the u8g2 library. To make it easy, just navigate to your components folder and execute the following command:

git clone https://github.com/olikraus/u8g2.git

Tip: Rename your u8g2 repository folder to u8g2 instead of u8g2-master this keeps your project nice and clean. 😉

Add the hal-driver

In this repository you have to download two files: u8g2_esp32_hal.c and u8g2_esp32_hal.h these two files have to be placed inside of the main folder (where your main.c file is located).

Add the files to the CMakeLists.txt

In the same main folder there is a CMakeLists.txt file. In this file you should add the c-file we have just added. The content of this file should look like this:

idf_component_register(SRCS "main.c" "u8g2_esp32_hal.c" INCLUDE_DIRS ".")

Note: The content of the CMakeLists.txt can differ depending on your specific project. Just remember that u8g2_esp32_hal.c should be added. Otherwise the compiler will complain that it cannot find the file.

Thats it! Take a look inside of the example folder on how to use it.

Other helpfull recources (might be outdated):

About

This is a working example of how you can use U8G2 Library in ESP-IDF

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published