Skip to content

Add LVGL implementation of displayio - #11887

Merged
tannewt merged 8 commits into
adafruit:mainfrom
tannewt:lvgl_displayio
Nov 17, 2026
Merged

tannewt merged 8 commits into
adafruit:mainfrom
tannewt:lvgl_displayio

Conversation

@tannewt

@tannewt tannewt commented Nov 17, 2026

Copy link
Copy Markdown
Member

Generally this splits displayio related modules into legacy and lvgl implementation directories. Headers stay at the outside level and include the implementation specific version.

The LVGL version does not do everything that the legacy version does because there are many weird corners. For example, the color conversion stuff we do for e-paper doesn't fit nicely into LVGL.

The LVGL implementation is focused on speed instead of memory footprint. This means that some code that legacy displayio can run slowly won't run with LVGL. Unfortunately, LVGL may run out of memory during compositing and is hard to recover from. A new safe mode is added for this case so that the failure is clear.

Another primary consideration in the LVGL implementation is the internal buffer formats and how they impact future acceleration. For example, TileGrid stores indexed bitmaps as-is (unless used in a tile mapping) so that chips with accelerated color mapping can be used.

We don't use LVGL for tile mapping because it causes many many images to change content and triggers a full display refresh. Instead, we store a pre-composed full color buffer for multi-tile TileGrids. This costs RAM but makes compositing much easier. TileGrid scrolling is optimized to have four views into this buffer to prevent moving many pixels.

@tannewt
tannewt requested a review from mikeysklar November 17, 2026 00:18
Comment thread shared-bindings/hashlib/__init__.c Resolved
@tannewt
tannewt removed the request for review from mikeysklar November 17, 2026 00:36
Generally this splits displayio related modules into legacy and lvgl
implementation directories. Headers stay at the outside level and
include the implementation specific version.

The LVGL version does not do everything that the legacy version does
because there are many weird corners. For example, the color conversion
stuff we do for e-paper doesn't fit nicely into LVGL.

The LVGL implementation is focused on speed instead of memory
footprint. This means that some code that legacy displayio can run
slowly won't run with LVGL. Unfortunately, LVGL may run out of memory
during compositing and is hard to recover from. A new safe mode is added
for this case so that the failure is clear.

Another primary consideration in the LVGL implementation is the internal
buffer formats and how they impact future acceleration. For example,
TileGrid stores indexed bitmaps as-is (unless used in a tile mapping) so
that chips with accelerated color mapping can be used.

We don't use LVGL for tile mapping because it causes many many images to
change content and triggers a full display refresh. Instead, we store a
pre-composed full color buffer for multi-tile TileGrids. This costs RAM
but makes compositing much easier. TileGrid scrolling is optimized to
have four views into this buffer to prevent moving many pixels.

Co-authored-by: Mikey Sklar <mikeysklar@gmail.com>
@tannewt
tannewt marked this pull request as ready for review November 17, 2026 01:01
The blinka and terminal font bitmaps lost const for every build, which
moved about 1 KB from flash into DRAM. ESP32-S2 boards then overflowed
dram0_0_seg by 600 to 1200 bytes. Only LVGL builds need them writable.

Tested: Metro ESP32-S2 builds (dram0 99.73%) and boots, terminal font
reads from flash. Metro ESP32-P4 boots and runs homeview.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mikeysklar

mikeysklar commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Tested on Metro ESP32-P4 with homeview and Teensy Chess, works well.

The S2 DRAM overflow is the dropped const in gen_display_resources.py, fix in tannewt#27.

A few ESP_LOGI calls look left over from debugging, in lvgl_port.c, port.c, Bitmap.c and FramebufferDisplay.c.

I'll follow up with an LVGL re-pin for PPA rotate once lvgl#10979 lands.

@dhalbert dhalbert left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great progress toward unified displayio!

Since there was a lot of refactoring of shared displayio code, I tested the PyPortal artifact from this build (I know it's not LVGL) against 11.0.0-alpha.3. Claude wrote a thorough displayio test and I stepped through it on a PyPortal and PyPortal Titano, one running the PR build and one the stock build. Saw no differences.

(Yes, I could have used a camera, but my eyes are good and I don't want to spend tokens on that now.)

A few comments.

Also, did you run the code comments through the kind of prose clarifier I asked you for in a previous PR? The comments are ok, but clearly LLM output.

Comment thread ports/espressif/supervisor/lvgl_port.c Resolved
Comment thread shared-module/displayio/lvgl/Palette.c Resolved
dhalbert
dhalbert previously approved these changes Nov 17, 2026

@dhalbert dhalbert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK! Let's get it in and in use.

@dhalbert

dhalbert commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

There are DRAM-size-related build errors like dram0_0_seg' overflowed by 64 bytes.

@tannewt

tannewt commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

There are DRAM-size-related build errors like dram0_0_seg' overflowed by 64 bytes.

Yup, working on it.

@tannewt

tannewt commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Ok, @dhalbert the build is green.

@mikeysklar mikeysklar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tannewt
tannewt merged commit 5b503f5 into adafruit:main Nov 17, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants