U8g2 runs 7x slower in ESP-IDF compared to running it in Arduino IDE

myetam
Posts: 3
Joined: Sat Oct 26, 2024 11:25 am

U8g2 runs 7x slower in ESP-IDF compared to running it in Arduino IDE

Postby myetam » Sat Oct 26, 2024 11:55 am

Edit:
TLDR; I found the issue. It is to do with the esp u8g2 compatibility component: https://github.com/mkfrey/u8g2-hal-esp-idf
I2C clock rate is defined as a constant in the u8g2_esp32_hal.h file. Default is 50k. I changed it to 400k and now I get about 20fps.

Code: Select all

#define I2C_MASTER_FREQ_HZ 50000     //  I2C master clock frequency
Original post:
I moved from Arduino to ESP-IDF and u8g2 runs over 7x slower on esp-idf.
FPS on esp-idf is about 4.2.
FPS on arduino is about 32.2.

I also uploaded a very short video showing both examples running at the same time.
You can see how much faster the Arduino sketch is:
- https://www.youtube.com/watch?v=24YG6woalU0

I2C is supposed to be running at 400 kHz on the u8g2 in esp-idf but seems like somehow its much slower.

Does anyone have an idea on what is slowing u8g2 down when it's running in esp-idf or what kind of mistake I made?
Any feedback or suggestions are appreciated.


Btw. I have also tested the LVGL library that's available on ESP32 components (https://components.espressif.com/compon ... _lvgl_port) and it works well and it is fast but I'd prefer to use u8g2 if possible.
Last edited by myetam on Sun Oct 27, 2024 1:41 pm, edited 1 time in total.

myetam
Posts: 3
Joined: Sat Oct 26, 2024 11:25 am

Re: U8g2 runs 7x slower in ESP-IDF compared to running it in Arduino IDE

Postby myetam » Sun Oct 27, 2024 9:13 am

I found the issue. There is a constant that sets the I2C frequency in the u8g2_esp32_hal.h file. The default is set to 50k.

Code: Select all

#define I2C_MASTER_FREQ_HZ 50000     //  I2C master clock frequency
I changed it to 400k (the I2C standard I think) and now I get about 20 fps which is good enough.

Who is online

Users browsing this forum: No registered users and 358 guests