Repository navigation
feat(lua): add lvgl.bitmap object - #4
Draft
thomaskistler wants to merge 10 commits into
Draft
thomaskistler wants to merge 10 commits into
thomaskistler wants to merge 10 commits into
Conversation
thomaskistler
force-pushed
the
thomaskistler/lvgl-bitmap-widget
branch
2 times, most recently
from
November 1, 2026 19:23
2d10a0d to
b1cf713
Compare
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
thomaskistler
force-pushed
the
thomaskistler/lvgl-bitmap-widget
branch
from
November 2, 2026 04:16
1b849f5 to
8a43230
Compare
…sh (EdgeTX#7980) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…eTX#7976) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…pp (EdgeTX#7983) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… drive (EdgeTX#7982) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…dgeTX#7977) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Add the bitmap object and Lua registration on upstream main without shared Lua/LVGL hardening. Keep RGB565 and alpha conversion, source/frame decode coalescing, protected bitmap-only setter staging, image-canvas preservation, and source/scaling bounds. Make update virtual for bitmap-specific setters. Retain the existing constructor, callback and manager behavior and cover the feature with bitmap-focused regressions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
thomaskistler
force-pushed
the
thomaskistler/lvgl-bitmap-widget
branch
from
November 3, 2026 06:00
8a43230 to
2c63158
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: N/A (feature; no linked issue). Alternative to EdgeTX#7947, which adds a
bitmapsource tolvgl.image.Summary of changes:
Adds
lvgl.bitmap([parent, ]params), a separate Lua LVGL object (alsolvgl.BITMAPforlvgl.build) that wrapsStaticBitmap.lvgl.imageis not modified.Motivation
lvgl.imagedecodes through LVGL's shared image cache, which has 8 entries (LV_IMG_CACHE_DEF_SIZE). A Lua widget that shows more images than that, for example a map made of 256x256 JPEG tiles, keeps evicting images that are still visible and decodes them again on redraw.lvgl.bitmapdecodes once when itsfilechanges and the object owns the pixels, so a widget can keep one object per image and decide for itself which ones stay decoded.Details
fileis a string or a function, likelvgl.image. The file is only decoded when it changes. A function is only called while the object is visible. Setting a string replaces a previous function.w/hreloads it. Hidden objects keep their pixels.StaticBitmap::setSource(filename)now chooses the format from the file likeBitmapBuffer::loadBitmap: RGB565 for opaque images, ARGB4444 for images with alpha.setSource(filename, fmt)forces a format, and the constructor takes the same optional format. Existing callers (model select, file preview, model bitmap widget) passBMP_ARGB4444explicitly, so their rendering does not change.StaticBitmapalways used ARGB4444, which keeps 4 bits per channel and stores 3 bytes per pixel. For an opaque JPEG tile, an ad-hoc host measurement gave 192 KB and 31.1 dB against the 8-bit decode, versus 128 KB and 39.9 dB for RGB565. With the format chosen from the file, opaque images are byte-identical to whatBitmap.openproduces.LUA_MEM_EXTRA_MAX).fileis only applied after all the parameters of an update have been accepted, together with a size change. A rejectedset()leaves the source alone, and changing the file and the size in oneset()decodes once. Other parameters of a rejectedset()behave as for every other object.sizefunction) and cover at most four times the display area, otherwise creation raises an error instead of allocating an arbitrarily large image. Frames larger than the display are allowed, e.g. inside a scrollable container.set({file=''}). Updates are ignored once the window has been closed.lvgl.label(parent, ...)etc. andlvgl.build) now run in a protected call. Before, an error left the temporary parent set, so objects created afterwards were attached to the wrong parent, and a half-built object kept its window. This is a separate commit (fix(lua): undo a failed LVGL object creation) and is independent oflvgl.bitmap.StaticBitmap::clear()now only deletes child windows.Window::clear()used to delete the image canvas whileBitmapBufferstill pointed at it, andBitmapBuffer::resizeToLVGL()now reports allocation failure instead of leaving data in the wrong format.ETX_BITMAPis inserted afterETX_QRCODE, so the numeric values of laterlvgl.*type constants shift by one.lvgl.bitmapluadoc block. It is marked as introduced in 3.0.0.Validation
Built and tested the native TX16S target on macOS:
cmake -DCMAKE_BUILD_TYPE=Debug -DPCB=X10 -DPCBREV=TX16S ..inbuild/, thencmake --build . --target native-configureandcmake --build native --target gtests-radionative/gtests-radio: 276 tests passed, including 29LuaLvglBitmapand 5LuaLvglObjectErrorstestsLuaLvglBitmaptestsTested on a TX16S Mk2 with a v2.12.5 backport of these two commits (branch
thomaskistler/lvgl-bitmap-2-12-test,tx16sRelease build). A test widget panned a 4x4 set of 256x256 JPEG tiles, with up to 13 on screen at once: withlvgl.imagedragging was slow, since the 8-entry LVGL cache evicts tiles that are still visible, and withlvgl.bitmapit was fast. This was a subjective comparison, with no decode counts or frame timing measured on the radio.Not done: an ARM build of
main, a Companion build, and measuring free heap on the radio.