Skip to content

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

Merged
pfeerick merged 10 commits intoEdgeTX:masterfrom
offer-shmuely:shmuely/updates-for-2.12
Apr 22, 2026

Conversation

@offer-shmuely
Copy link
Copy Markdown
Contributor

@offer-shmuely offer-shmuely commented Mar 31, 2026

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)

    • In the Engine preset script, removes the invalid filed=true and normalizes argument order (filled=true etc.), plus a small comment typo fix (“dreaw” → “draw”).
    • File: sdcard/c480x272/SCRIPTS/PRESETS/engine/main.lua
  • Model Locator by RSSI tool (all screen sizes)

    • Refactors signal-type handling into named constants (SIGNAL_NONE/RSSI/1RSS/2RSS) and improves auto-detection logic.
    • Adds LVGL scaling support via lvgl.LCD_SCALE (multiplies many coordinates/sizes), improving UI behavior across display scales.
    • Improves UI text for telemetry choice (e.g. “-- Auto Detect --”).
    • ELRS-related tweaks: TX power handling (show N/A if missing) and make TX power display only visible when ELRS.
    • Version bump: 1.10 → 1.11, date comment updated to 2026.
    • Files:
      • sdcard/c480x272/SCRIPTS/TOOLS/locator_by_rssi/app.lua
      • sdcard/c480x320/SCRIPTS/TOOLS/locator_by_rssi/app.lua
      • sdcard/c800x480/SCRIPTS/TOOLS/locator_by_rssi/app.lua
  • MicroValues widget updates (all screen sizes)

    • Version bump: 1.2 → 1.3 (app.lua).
    • Adds optional serial debug logging support (ENABLE_LOG_TO_SERIAL, serialWrite(...)) in lib_log.lua.
    • lib_widget_tools.lua refactor:
      • Introduces FS font table and M.FONT_LIST, adds scaling awareness (lvgl.LCD_SCALE).
      • Adds periodicStop().
      • Telemetry detection: also checks sensor name VFR in addition to VFR%.
      • Reworks font sizing helpers (getFontIndex, scaled offsets/heights), and removes several badge/text drawing helpers at the end of the file.
    • main.lua widget wrapper:
      • Changes default option sources from single strings to lists of candidate sources (more robust defaults).
      • Renames font choice labels to friendlier strings (“Extra Small (6px)”, etc.).
      • Fixes widget script loading pattern so tool is stored per-widget (wgt._tool) rather than a shared global.
    • Files:
      • 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)

    • Version bump: 1.0 → 1.1
    • Removes style=SOLID from LVGL rectangle calls (likely compatibility with 2.12 LVGL bindings) and keeps filled=true.
    • Same per-widget wgt._tool change as MicroValues to avoid global tool reuse issues.
    • Files:
      • sdcard/c480x272/WIDGETS/Mixers/{app.lua,main.lua}
      • sdcard/c480x320/WIDGETS/Mixers/{app.lua,main.lua}
      • sdcard/c800x480/WIDGETS/Mixers/{app.lua,main.lua}

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.lua tool on the widget instance (wgt._tool) instead of using a shared global.
  • Updates LVGL object definitions (e.g., removing style=SOLID on 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 (filedfilled) and comment typo.
Comments suppressed due to low confidence (3)

sdcard/c480x272/SCRIPTS/TOOLS/locator_by_rssi/app.lua:70

  • log() always calls print(), and the script now logs RSSI/1RSS/2RSS plus several lines per run() call. On radios this can be a noticeable performance hit and can flood logs/console. Consider gating debug logging behind a flag (or is_simulator()), and avoid per-frame logs in main() / 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 calls print(), and the script now logs RSSI/1RSS/2RSS plus several lines per run() call. On radios this can be a noticeable performance hit and can flood logs/console. Consider gating debug logging behind a flag (or is_simulator()), and avoid per-frame logs in main() / 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 calls print(), and the script now logs RSSI/1RSS/2RSS plus several lines per run() call. On radios this can be a noticeable performance hit and can flood logs/console. Consider gating debug logging behind a flag (or is_simulator()), and avoid per-frame logs in main() / 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.

Comment on lines 333 to +338
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)
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread sdcard/c800x480/WIDGETS/MicroValues/lib_widget_tools.lua Outdated
Comment thread sdcard/c480x320/WIDGETS/MicroValues/lib_widget_tools.lua Outdated
Comment thread sdcard/c480x272/WIDGETS/MicroValues/lib_widget_tools.lua Outdated
Comment on lines +282 to +285
if txPower == nil then
txPower = "N/A "
end
return "TX Power: " .. tostring(txPower) .. "mW"
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
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"

Copilot uses AI. Check for mistakes.
Comment on lines +282 to +285
if txPower == nil then
txPower = "N/A "
end
return "TX Power: " .. tostring(txPower) .. "mW"
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
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"

Copilot uses AI. Check for mistakes.
Comment on lines 333 to +338
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)
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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)))
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment thread sdcard/c480x320/SCRIPTS/TOOLS/locator_by_rssi/app.lua
Comment thread sdcard/c480x272/SCRIPTS/TOOLS/locator_by_rssi/app.lua
offer-shmuely and others added 6 commits April 18, 2026 10:04
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>
@pfeerick
Copy link
Copy Markdown
Member

Happy with this as it is for now?

@offer-shmuely
Copy link
Copy Markdown
Contributor Author

i think it can be merge now

@pfeerick pfeerick changed the title updates for 2.12 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 Apr 21, 2026
@pfeerick
Copy link
Copy Markdown
Member

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

@pfeerick pfeerick merged commit c597825 into EdgeTX:master Apr 22, 2026
2 checks passed
@offer-shmuely
Copy link
Copy Markdown
Contributor Author

I will guess that this happens only on the simulator, with the tx16mk1/2

Can you reproduce it on simulator on mk3?
Can you reproduce it on real radio?

@pfeerick
Copy link
Copy Markdown
Member

pfeerick commented Apr 22, 2026

I will guess that this happens only on the simulator, with the tx16mk1/2

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.

@pfeerick
Copy link
Copy Markdown
Member

Similar behaviour on TX16S MK3 hardware and in simulator

@offer-shmuely
Copy link
Copy Markdown
Contributor Author

I see it now, there are who bugs

  1. the print is too wide, so it scroll right and left
  2. there is no lvgl.clear() so when returning to regular layout it is not cleared

will fix it

@offer-shmuely
Copy link
Copy Markdown
Contributor Author

fixed: #276

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