ESP32-P4 MIPI double-buffering - can't work out how to swap buffers
Posted: Fri Jun 26, 2026 6:35 pm
I'm working on a simple project which is basically loading and displaying images from an SD card to a MIPI LCD.
Not using LVGL, just throwing raw image data around.
Using IDF V5.5.4 ( as that was the example I started with used), Waveshare 3.4" round LCD board, with their BSP, configuration set for 2 buffers
I have pretty much everything working, loading the image data into memory and then using memcpy to copy to the active display buffer, which works, but not cleanly due to the time taken to do the copy.
But I'm now stuck figuring out how to do this properly with double-buffering, specifically
1) How to find which buffer is currently feeding the active display
2) How to make the display swap to the second buffer after I've loaded a new image .
i.e. the steps marked ** below
Use esp_lcd_dpi_panel_get_frame_buffer to get the buffer addresses
** determine which buffer is currently being displayed
Load image from SD card into the non-display buffer
Use esp_cache_msync to ensure it's all flushed from the cache
Set a flag to my "on_vsync" callback to do the swap on the next sync
** within my vsync callback, make the display to start displaying the other buffer
I'm sure there must be a simple answer, I just can't seem to find it!
Not using LVGL, just throwing raw image data around.
Using IDF V5.5.4 ( as that was the example I started with used), Waveshare 3.4" round LCD board, with their BSP, configuration set for 2 buffers
I have pretty much everything working, loading the image data into memory and then using memcpy to copy to the active display buffer, which works, but not cleanly due to the time taken to do the copy.
But I'm now stuck figuring out how to do this properly with double-buffering, specifically
1) How to find which buffer is currently feeding the active display
2) How to make the display swap to the second buffer after I've loaded a new image .
i.e. the steps marked ** below
Use esp_lcd_dpi_panel_get_frame_buffer to get the buffer addresses
** determine which buffer is currently being displayed
Load image from SD card into the non-display buffer
Use esp_cache_msync to ensure it's all flushed from the cache
Set a flag to my "on_vsync" callback to do the swap on the next sync
** within my vsync callback, make the display to start displaying the other buffer
I'm sure there must be a simple answer, I just can't seem to find it!