Skip to content

New LUA scripts & widgets - #3

Open
jurgelenas wants to merge 242 commits into
masterfrom
unified-lua-lsp
Open

jurgelenas wants to merge 242 commits into
masterfrom
unified-lua-lsp

Conversation

@jurgelenas

Copy link
Copy Markdown
Member

No description provided.

jurgelenas and others added 21 commits August 16, 2026 23:13
GREEN and RED are raw primaries -- RGB(0,255,0) and RGB(255,0,0),
colors.cpp:51-54 -- so a full-width LQ bar in GREEN was the loudest thing
on the screen, and it stayed that way whatever theme the pilot had
chosen. The theme carries the same three meanings in colours picked to
sit together: EDIT, ACTIVE and WARNING. Bars, the status LED and the LQ
headline now take those and repaint with the theme.

Text keeps a separate ramp. COLOR_THEME_ACTIVE is a bright yellow, which
is fine as a bar fill and illegible as a word on the light themes'
near-white panel, so warnings in text stay ORANGE.

Bar tracks are the disabled grey at part opacity. Solid it read as a
second bar competing with its own fill; the theme's soft secondary
disappeared into the panel entirely, which left the fill a floating stub
with nothing to measure it against.

The 1/2 tier keeps both bars, which is the point of the layout -- it is
the size the widget is usually placed at, and the mirrored-blocks draft
this replaced could not keep even one there. The battery row drops before
either bar is squeezed below the height at which it stops being a bar.
TQly sits beside TRSS on the same row in percent, so a bare -94 there
invites reading it as one too. The unit is not something the width ladder
gets to trade away.

It was the first thing to go, which left the narrowest rung showing
"TRSS -94". Now the pack total goes first, then the row splits, and the
DOWNLINK header is what drops last -- the right order, because TQly and
TRSS name themselves and a bare number does not name its unit.

Costs nothing at the sizes that matter: the 396px zone still fits the row
under its header, and the 198px one reaches the headerless rung it was
already using.
Both were COLOR_THEME_PRIMARY1, which is the text colour -- RGB(0,0,0) on
the light themes. As a glyph that is correct and as a filled block it is a
black bar dropped onto a blue panel, which is what they looked like.

COLOR_THEME_FOCUS is what EdgeTX uses everywhere else to mean "this one is
active", which is exactly what a lit power cell and the live antenna cell
are saying, and it follows the theme.

Power deliberately stays off the green/amber/red ramp: 500 mW is not
worse than 50, so a health colour there would be claiming something the
number does not mean.

The mismatch banners move from RED to COLOR_THEME_WARNING with them, so
the whole widget now draws from the theme. The single exception is ORANGE
for warning text, because COLOR_THEME_ACTIVE is a yellow that cannot be
read on a near-white panel.
Four adjustments from looking at it on the radio rather than in the plan.

The status LED was centred on the strip height, which is the text's line
box plus padding, so it sat below the RF mode beside it -- near enough to
read as a mistake rather than a choice. It now centres on the line box,
landing on the same centre as the antenna cells, and it is a third
smaller: at half the row height an indicator stops being a dot and starts
competing with the text. It also gets a fixed lane, so its radius can be
tuned without the RF mode moving sideways.

TX POWER's meter was absorbing the whole gap between the RF mode and the
antenna cells, which dragged its own reading to the far side of the strip
with nothing tying the two together. The meter now has a natural width
measured off the row, the reading sits a fixed gap after it, and the slack
stays to their right. Whether the meter fits at all is now measured
against the antenna cells' position instead of assumed from the width
gate.

The panel is inset from the zone rather than filling it, so two widgets
side by side no longer share one edge, and the content is inset again from
the panel's own border -- full-width bars starting and ending on the
border read as spilling out of the panel.

And at half width TX POWER moves above the uplink panel instead of below
the group rows. It is link configuration, like the RF mode and the antenna
it now sits with; last place filed it under the flight controller's
readings, which is not what it is.
Remove the ELRS handset address distinction
At 400K baud the module splits a command answer into 27-byte chunks and
serves the continuation only on CMD_QUERY. The session hurried the read
deadline instead of the query one, so every extra chunk waited for the
2 s keep-alive: a confirm dialog took 2 s to appear, and again after
Confirm. Query the next chunk on the next tick, as the legacy script did.

Route every command step through one send path that retries a push the
radio's single output slot refused and resets chunk state only after a
successful send, so a one-chunk idle answer after a chunked executing
one is no longer swallowed and Bind dismisses on its own. The click guard
keys on the live popup, not on the field's stale status.

Both UIs show "Sending..." while a click or confirm is unanswered, after
a 200 ms grace so healthy links go straight to the dialog. The B&W popup
repaints the page after a cancel.

The simulator now chunks command answers and serves continuation chunks
only on CMD_QUERY like the firmware, with the firmware's 2 s timeout;
maxPacketBytes = 35 reproduces the 400K/500 Hz case.
@CapnBry

CapnBry commented Sep 8, 2026

Copy link
Copy Markdown
Member

Whew. A lot to get through but almost all these are small tweaks. I really like the visual redo you did on the VTX Admin, it looks great and the widget is a lot easier to glance at now. This took the better part of 2 days to get through all the code again with so many different scripts on so many platforms, but here's the abridged review notes!

  • Deleting elrs.lua? Why did we add it to this repo if it wasn't going to live here? I'm fine with however we think we should handle it but this is the Lua repo so I think we should move it to a legacy folder, merge the main repo's version in here, remove it from the main repo. For this PR I'd just leave it where it is currently and then a separate PR to deal with it.
  • Remove edgetx-lua-stdlib
  • Bind Tool - UID_MAX_ATTEMPTS is too low, I got MANY "no response" while the module rebooted. Maybe 10-12 instead of 6?
  • B&W Bind - Title should be "ExpressLRS Bind" and version number goes in the EXIT string for consistency with main tools lua (use same format too?)
  • Why do the B&W tools scripts require an EdgeTX version? Isn't the version gating just for proper lvgl support?
  • "alert" is the same thing as "dialog" except one is B&W and the other is lvgl. Should they be named the same?
  • Why aren't the version and nomodule messages in alert instead of multiple copies in the UI? Telemtry/VTX admin widgets fullscreen UI also duplicates the nomodule message.
  • The Dialogs.showNoModule minumum bauds are incorrect. These are suggested bauds. Also Baud should not be caps. It also does not include the bit about setting the "internal RF type" in sys either and perhaps F1000 should be 1000Hz because there are many 1000Hz modes.
  • TextEdit - No way to select next character or back up?
    if event == EVT_VIRTUAL_PREV_PAGE then
      self.cur = math.max(self.cur - 1, 1)
    elseif event == EVT_VIRTUAL_NEXT_PAGE then
      self.cur = math.min(self.cur + 1, math.min(self.maxLen, #self.value + 1))
    end
    
  • TextEdit - Maybe also move the things that return true to the top and everything else that returns nil just fall through to the return nil? Also return nil is unneeded
  • VTX Admin top bar UI - Can it look more like a "Value" type builtin widget? Same font sizes as the builtin does, with small "VTX" and large band/channel, left aligned to match the same visual style
  • Telem Widget - Align values vertically for PWR/BATT and TQly/TRSS.
  • Telem Widget - PWR reads 0 mW when not connected but others show --
  • Telem Widget - No last GPS position on disconnect? If not in your design plans that's fine, something for later.
  • Telem Widget - Fullscreen - Maybe merge RSSI 1 / RSSI 2 onto one line so the RSNR can be added?
  • Telem Widget - 1x4 layout TX16S with all EdgeTX bars (trim, pots, etc) still on, LQ wraps to 2 lines? Honestly it is impressive that this is the only visual glitch I ran into when testing every shape. I bet this was a ton of work to make each one look right!

AIness

  • README.md is loaded with AI bloat about directory structure. This is user-facing documentation and this does not help the user. I mean this whole thing is bloated with describing what every button does and what screen resolutions are supported by one widget and bullshit like that. Please just do this by hand and don't ask AI to do it. I can also do it if you'd prefer
    • ExpressLRS Lua Scripts - I think we can change this to just one line about what the repo is. No need to list the things that are in it, they are listed below
    • Features - remove
    • Installation section - First line is good, the full directory structure needs to go
    • Section for each tool / widget is good, but remove all the AI explanation of how it works, just a single sentence about what each thing is and screenshots are good
    • Compatibility. Good, but the bit about the bind manager "The bind phrase manager additionally requires ExpressLRS 4.1+" (delete the rest)
  • You gotta get stop letting the AI generate novels about everything, Like what is all the garbage at the top of every file that instead of just saying what the file is, it goes on about minor architecture features it seems to be proud of. Even the function comments read like a 4 year old who just read a book on design patterns and obfuscate the meaning. Comments are only supposed to say as much as they need to, not describe the history of code. Sometimes it wants to add the license, sometimes it wants to tell you what EdgeTX version was important when the header was added but is no longer correct, sometimes it goes on rambling story. You don't have to change these but in the future please try to reduce comments to only meaningful important things that aren't obvious.

ELRS Version requirement

We know what the ELRS version is from the deviceinfo header, and we know what version the script requires, but these scripts just sort of fail to work properly if the ELRS version isn't high enough. It could display a message about it.

*** DO NOT MAKE THAT CHANGE, I DO NOT WANT TO REVIEW NEW FEATURE CODE AGAIN *** this could be done in a separate PR if you want. Somebody should though.

After a value write the session re-read the parent folder and its value
and INFO siblings but skipped COMMAND fields, so a command the firmware
hides or shows in response kept its stale visibility until a full
reload. Legacy elrs.lua made the same change in cc2e010; the firmware
keeps Send VTx always visible because scripts did not re-read commands.

The simulator now applies the firmware's VTX Admin visibility rules:
Channel, Pwr Lvl and Pitmode hide while Band/Enable is Disabled, and
Pitmode hides at Pwr Lvl "-". Send VTx hides with Band/Enable too,
which exercises the command re-read.
Re-read sibling crsf command fields after a value write
Retain legacy elrs.lua for old radios support
@jurgelenas

jurgelenas commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Deleting elrs.lua? Why did we add it to this repo if it wasn't going to live here? I'm fine with however we think we should handle it but this is the Lua repo so I think we should move it to a legacy folder, merge the main repo's version in here, remove it from the main repo. For this PR I'd just leave it where it is currently and then a separate PR to deal with it.

Addressed in #23

Remove edgetx-lua-stdlib

I was hoping for EdgeTX team to release official EdgeTX Lua typedefs based on my https://github.com/jurgelenas/edgetx-lua-stdlib idea. Unfortunately the progress has stalled. Will remove it later.

Bind Tool - UID_MAX_ATTEMPTS is too low, I got MANY "no response" while the module rebooted. Maybe 10-12 instead of 6?

Addressed in #25

B&W Bind - Title should be "ExpressLRS Bind" and version number goes in the EXIT string for consistency with main tools lua (use same format too?)

Addressed in #26

Why do the B&W tools scripts require an EdgeTX version? Isn't the version gating just for proper lvgl support?

I think I had more reasons for it, but the only thing that I can remember now is that we are using directories for tool scripts.

"alert" is the same thing as "dialog" except one is B&W and the other is lvgl. Should they be named the same?
Why aren't the version and nomodule messages in alert instead of multiple copies in the UI? Telemtry/VTX admin widgets fullscreen UI also duplicates the nomodule message.
The Dialogs.showNoModule minumum bauds are incorrect. These are suggested bauds. Also Baud should not be caps. It also does not include the bit about setting the "internal RF type" in sys either and perhaps F1000 should be 1000Hz because there are many 1000Hz modes.

Addressed in #27

TextEdit - No way to select next character or back up?
if event == EVT_VIRTUAL_PREV_PAGE then
self.cur = math.max(self.cur - 1, 1)
elseif event == EVT_VIRTUAL_NEXT_PAGE then
self.cur = math.min(self.cur + 1, math.min(self.maxLen, #self.value + 1))
end
TextEdit - Maybe also move the things that return true to the top and everything else that returns nil just fall through to the return nil? Also return nil is unneeded

Addressed in #28

VTX Admin top bar UI - Can it look more like a "Value" type builtin widget? Same font sizes as the builtin does, with small "VTX" and large band/channel, left aligned to match the same visual style

Good idea. I have updated telemetry widget top bar layout too.

Addressed in #29

Telem Widget - Align values vertically for PWR/BATT and TQly/TRSS.

Addressed in #30

Telem Widget - PWR reads 0 mW when not connected but others show --
Telem Widget - No last GPS position on disconnect? If not in your design plans that's fine, something for later.
Telem Widget - Fullscreen - Maybe merge RSSI 1 / RSSI 2 onto one line so the RSNR can be added?

Addressed in #31

Telem Widget - 1x4 layout TX16S with all EdgeTX bars (trim, pots, etc) still on, LQ wraps to 2 lines? Honestly it is impressive that this is the only visual glitch I ran into when testing every shape. I bet this was a ton of work to make each one look right!

Could not reproduce this one. Could you share a screenshot? What EdgetTX version you were using?

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.

5 participants