chore: fix LVGL parameters for presets tool and Mixes widget, Model Locator scales screen better and has telemetry type auto-detection, MicroValues widget does telemetry detection and more robust source choices#267
Conversation
There was a problem hiding this comment.
Pull request overview
Updates multiple EdgeTX Lua widgets/tools for 2.12.0 compatibility, addressing recent API changes that broke scripts.
Changes:
- Refactors widget entrypoints to store the loaded
app.luatool on the widget instance (wgt._tool) instead of using a shared global. - Updates LVGL object definitions (e.g., removing
style=SOLIDon rectangles) and adds LCD scale handling in UI layouts. - Enhances MicroValues tooling (font helpers/logging tweaks) and cleans up a few UI/config strings + minor typos.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 18 comments.
Show a summary per file
| File | Description |
|---|---|
| sdcard/c800x480/WIDGETS/Mixers/main.lua | Refactors widget wrapper to attach tool to widget instance. |
| sdcard/c800x480/WIDGETS/Mixers/app.lua | Adjusts LVGL rectangle params for 2.12 compatibility; bumps version. |
| sdcard/c800x480/WIDGETS/MicroValues/main.lua | Updates defaults/labels and refactors wrapper to per-widget tool storage. |
| sdcard/c800x480/WIDGETS/MicroValues/lib_widget_tools.lua | Refactors font helpers, adds scaling + new helpers, logging fallback. |
| sdcard/c800x480/WIDGETS/MicroValues/lib_log.lua | Adds optional serial debug logging toggle. |
| sdcard/c800x480/WIDGETS/MicroValues/app.lua | Version bump only. |
| sdcard/c800x480/SCRIPTS/TOOLS/locator_by_rssi/app.lua | Refactors signal type handling, adds scaling, updates UI and logging. |
| sdcard/c480x320/WIDGETS/Mixers/main.lua | Same widget wrapper refactor (per-instance tool). |
| sdcard/c480x320/WIDGETS/Mixers/app.lua | Same LVGL rectangle param adjustments; bumps version. |
| sdcard/c480x320/WIDGETS/MicroValues/main.lua | Same as c800x480: defaults/labels + wrapper refactor. |
| sdcard/c480x320/WIDGETS/MicroValues/lib_widget_tools.lua | Same as c800x480: font/scaling/logging helper refactor. |
| sdcard/c480x320/WIDGETS/MicroValues/lib_log.lua | Same as c800x480: optional serial debug output. |
| sdcard/c480x320/WIDGETS/MicroValues/app.lua | Version bump only. |
| sdcard/c480x320/SCRIPTS/TOOLS/locator_by_rssi/app.lua | Same as c800x480: scaling, signal type constants, UI/log updates. |
| sdcard/c480x272/WIDGETS/Mixers/main.lua | Same widget wrapper refactor (per-instance tool). |
| sdcard/c480x272/WIDGETS/Mixers/app.lua | Same LVGL rectangle param adjustments; bumps version. |
| sdcard/c480x272/WIDGETS/MicroValues/main.lua | Same as c800x480: defaults/labels + wrapper refactor. |
| sdcard/c480x272/WIDGETS/MicroValues/lib_widget_tools.lua | Same as c800x480: font/scaling/logging helper refactor. |
| sdcard/c480x272/WIDGETS/MicroValues/lib_log.lua | Same as c800x480: optional serial debug output. |
| sdcard/c480x272/WIDGETS/MicroValues/app.lua | Version bump only. |
| sdcard/c480x272/SCRIPTS/TOOLS/locator_by_rssi/app.lua | Same as c800x480: scaling, signal type constants, UI/log updates. |
| sdcard/c480x272/SCRIPTS/PRESETS/engine/main.lua | Fixes LVGL rectangle field typos (filed → filled) and comment typo. |
Comments suppressed due to low confidence (3)
sdcard/c480x272/SCRIPTS/TOOLS/locator_by_rssi/app.lua:70
log()always callsprint(), and the script now logs RSSI/1RSS/2RSS plus several lines perrun()call. On radios this can be a noticeable performance hit and can flood logs/console. Consider gating debug logging behind a flag (oris_simulator()), and avoid per-frame logs inmain()/updateSignalValues()unless explicitly enabled.
local function log(fmt, ...)
print("[locator] ".. string.format(fmt, ...))
end
sdcard/c480x320/SCRIPTS/TOOLS/locator_by_rssi/app.lua:70
log()always callsprint(), and the script now logs RSSI/1RSS/2RSS plus several lines perrun()call. On radios this can be a noticeable performance hit and can flood logs/console. Consider gating debug logging behind a flag (oris_simulator()), and avoid per-frame logs inmain()/updateSignalValues()unless explicitly enabled.
local function log(fmt, ...)
print("[locator] ".. string.format(fmt, ...))
end
sdcard/c800x480/SCRIPTS/TOOLS/locator_by_rssi/app.lua:70
log()always callsprint(), and the script now logs RSSI/1RSS/2RSS plus several lines perrun()call. On radios this can be a noticeable performance hit and can flood logs/console. Consider gating debug logging behind a flag (oris_simulator()), and avoid per-frame logs inmain()/updateSignalValues()unless explicitly enabled.
local function log(fmt, ...)
print("[locator] ".. string.format(fmt, ...))
end
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function M.getFontSize(wgt, txt, max_w, max_h, max_font_size) | ||
| local w, h, v_offset = M.lcdSizeTextFixed(txt, FONT_38) | ||
| if w <= max_w and h <= max_h then | ||
| -- log("[%s] FONT_38 %dx%d", txt, w, h, txt) | ||
| return FONT_38, w, h, v_offset | ||
| local maxFontIndex = M.getFontIndex(max_font_size, nil) | ||
| --log("getFontSize() [%s] %dx%d (maxIndex: %d)", txt, max_w, max_h, maxFontIndex) | ||
|
|
||
| if maxFontIndex>=5 then | ||
| local w, h, v_offset = M.lcdSizeTextFixed(txt, FS.FONT_38) |
There was a problem hiding this comment.
maxFontIndex can be nil when max_font_size isn't found in M.FONT_LIST (since getFontIndex(..., nil) returns nil). The subsequent if maxFontIndex>=5 / >=4 comparisons will then throw an error. Consider defaulting to a numeric index (e.g., #M.FONT_LIST) or guarding maxFontIndex before numeric comparisons.
| if txPower == nil then | ||
| txPower = "N/A " | ||
| end | ||
| return "TX Power: " .. tostring(txPower) .. "mW" |
There was a problem hiding this comment.
The text callback mutates txPower (txPower = "N/A " when nil). UI callbacks ideally should be side-effect free; also this changes txPower from number/nil to string, which can affect later numeric comparisons (e.g., the warning visibility check against targetTXPower1/2). Prefer returning a formatted string without modifying txPower (e.g., format "N/A" when nil).
| if txPower == nil then | |
| txPower = "N/A " | |
| end | |
| return "TX Power: " .. tostring(txPower) .. "mW" | |
| local txPowerText = (txPower == nil) and "N/A" or tostring(txPower) | |
| return "TX Power: " .. txPowerText .. "mW" |
| if txPower == nil then | ||
| txPower = "N/A " | ||
| end | ||
| return "TX Power: " .. tostring(txPower) .. "mW" |
There was a problem hiding this comment.
The text callback mutates txPower (txPower = "N/A " when nil). UI callbacks ideally should be side-effect free; also this changes txPower from number/nil to string, which can affect later numeric comparisons (e.g., the warning visibility check against targetTXPower1/2). Prefer returning a formatted string without modifying txPower (e.g., format "N/A" when nil).
| if txPower == nil then | |
| txPower = "N/A " | |
| end | |
| return "TX Power: " .. tostring(txPower) .. "mW" | |
| local displayTxPower = txPower | |
| if displayTxPower == nil then | |
| displayTxPower = "N/A " | |
| end | |
| return "TX Power: " .. tostring(displayTxPower) .. "mW" |
| function M.getFontSize(wgt, txt, max_w, max_h, max_font_size) | ||
| local w, h, v_offset = M.lcdSizeTextFixed(txt, FONT_38) | ||
| if w <= max_w and h <= max_h then | ||
| -- log("[%s] FONT_38 %dx%d", txt, w, h, txt) | ||
| return FONT_38, w, h, v_offset | ||
| local maxFontIndex = M.getFontIndex(max_font_size, nil) | ||
| --log("getFontSize() [%s] %dx%d (maxIndex: %d)", txt, max_w, max_h, maxFontIndex) | ||
|
|
||
| if maxFontIndex>=5 then | ||
| local w, h, v_offset = M.lcdSizeTextFixed(txt, FS.FONT_38) |
There was a problem hiding this comment.
maxFontIndex can be nil when max_font_size isn't found in M.FONT_LIST (since getFontIndex(..., nil) returns nil). The subsequent if maxFontIndex>=5 / >=4 comparisons will then throw an error. Consider defaulting to a numeric index (e.g., #M.FONT_LIST) or guarding maxFontIndex before numeric comparisons.
| log("signalValue: %s, signalMin: %s, signalMax: %s, txPower: %s", signalValue, signalMin, signalMax, txPower) | ||
| -- log("getRSSI(): %s", getRSSI()) | ||
|
|
||
| signalPercent = math.floor(100 * ((signalValue - signalMin) / (signalMax - signalMin))) |
There was a problem hiding this comment.
When no signal is detected, updateSignalValues() sets signalValue=nil and signalMin/signalMax=0, but main() still computes signalPercent using arithmetic on signalValue and divides by (signalMax - signalMin). This will error on nil (or divide by 0). Add a guard in main() (or ensure signalValue/signalMax are set to safe defaults) before calculating signalPercent.
| signalPercent = math.floor(100 * ((signalValue - signalMin) / (signalMax - signalMin))) | |
| if signalValue ~= nil and signalMax ~= signalMin then | |
| signalPercent = math.floor(100 * ((signalValue - signalMin) / (signalMax - signalMin))) | |
| else | |
| signalPercent = 0 | |
| end |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Happy with this as it is for now? |
|
i think it can be merge now |
|
Thanks Offer! :) For the mixes widget, you might want to check what happens when you come back from full-screen... it could be a bug on our side, but it is also doing something odd in retaining touch input just for that widget, and is stacking the channel bars... as if it is still partially in fullscreen mode. This was for c480x320 (i.e. TX15). Screen.Recording.2026-04-22.103628.mp4 |
|
I will guess that this happens only on the simulator, with the tx16mk1/2 Can you reproduce it on simulator on mk3? |
No, both hardware and then simulator for TX15, both on 2.12.0 I'll try with the TX16S MK3 later to see if that is the same. |
|
Similar behaviour on TX16S MK3 hardware and in simulator |
|
I see it now, there are who bugs
will fix it |
|
fixed: #276 |
due to last minute changes in 2.12.0
it break some of the lua scripts
PR #267 “updates for 2.12” (open) is a set of fixes/adjustments to SD-card Lua scripts/widgets to cope with last-minute EdgeTX 2.12.0 changes that broke some scripts. Overall: 22 files changed (+607 / −568).
Key changes
Fix LVGL rectangle property usage (typo/compat)
filed=trueand normalizes argument order (filled=trueetc.), plus a small comment typo fix (“dreaw” → “draw”).sdcard/c480x272/SCRIPTS/PRESETS/engine/main.luaModel Locator by RSSI tool (all screen sizes)
SIGNAL_NONE/RSSI/1RSS/2RSS) and improves auto-detection logic.lvgl.LCD_SCALE(multiplies many coordinates/sizes), improving UI behavior across display scales.sdcard/c480x272/SCRIPTS/TOOLS/locator_by_rssi/app.luasdcard/c480x320/SCRIPTS/TOOLS/locator_by_rssi/app.luasdcard/c800x480/SCRIPTS/TOOLS/locator_by_rssi/app.luaMicroValues widget updates (all screen sizes)
app.lua).ENABLE_LOG_TO_SERIAL,serialWrite(...)) inlib_log.lua.lib_widget_tools.luarefactor:FSfont table andM.FONT_LIST, adds scaling awareness (lvgl.LCD_SCALE).periodicStop().VFRin addition toVFR%.getFontIndex, scaled offsets/heights), and removes several badge/text drawing helpers at the end of the file.main.luawidget wrapper:toolis stored per-widget (wgt._tool) rather than a shared global.sdcard/c480x272/WIDGETS/MicroValues/{app.lua,lib_log.lua,lib_widget_tools.lua,main.lua}sdcard/c480x320/WIDGETS/MicroValues/{app.lua,lib_log.lua,lib_widget_tools.lua,main.lua}sdcard/c800x480/WIDGETS/MicroValues/{app.lua,lib_log.lua,lib_widget_tools.lua,main.lua}Mixers widget (all screen sizes)
style=SOLIDfrom LVGL rectangle calls (likely compatibility with 2.12 LVGL bindings) and keepsfilled=true.wgt._toolchange as MicroValues to avoid global tool reuse issues.sdcard/c480x272/WIDGETS/Mixers/{app.lua,main.lua}sdcard/c480x320/WIDGETS/Mixers/{app.lua,main.lua}sdcard/c800x480/WIDGETS/Mixers/{app.lua,main.lua}