perf(display): reclaim unused LVGL draw buffer - #122
Conversation
zjwhitehead
left a comment
There was a problem hiding this comment.
LGTM. Single-buffer is correct while the SPI flush stays synchronous. Confirm Adafruit endWrite() waits for DMA, then this is a clean SRAM win.
(Could not formally approve: GitHub blocks self-approval on your own PR.)
|
Hardware-in-loop validation (M5Stack StampS3 over USB, no ESC/BMS connected): linked static RAM fell from 140,992 to 120,512 bytes (exactly 20,480 bytes). At runtime, steady free/internal heap rose from 100,892 to 121,216 bytes (+20,324 usable), and the largest contiguous internal allocation rose from 90,112 to 110,592 bytes (exactly +20,480). Under the same safe 10 s dry-cruise state transition, the display handled 52 flushes across sampled windows with 0 skipped flushes; representative flush averages were 782–1,213 us and maxima 1,736–3,146 us, in the baseline range. Heap returned to and remained steady at 121,216 bytes after redraw activity. This confirms the second buffer is unused by the synchronous transport and can be reclaimed without observed display regression. |
Summary
Why
The current Adafruit SPI flush writes the complete dirty rectangle before returning and before calling lv_display_flush_ready(). LVGL therefore cannot render into the second buffer concurrently, so that buffer consumes internal SRAM without providing pipeline throughput.
This reduces target static RAM usage by 20,480 bytes, from 140,920 bytes (43.0%) to 120,440 bytes (36.8%). Double buffering should be restored when the display transport moves to asynchronous DMA.