feat(lua): enable serial terminal scripts (port query, textEdit placeholder, Enter key) - #7578
feat(lua): enable serial terminal scripts (port query, textEdit placeholder, Enter key)#7578graycoderep wants to merge 3 commits into
Conversation
Scripts using serialRead()/serialWrite() had no way to tell whether a serial port is actually configured for LUA, so a script talking to an external device could only sit there receiving nothing with no way to explain why. Return the port number and its name, or nil when no port is in LUA mode.
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe PR adds Enter-key submission to color LCD text fields, configurable text-edit placeholders and Lua Enter callbacks, plus a Lua API for querying the Lua-mode serial port. ChangesColor LCD text-edit Enter flow
Sequence Diagram(s)sequenceDiagram
participant TextArea
participant Keyboard
participant TextEdit
participant LuaCallback
TextArea->>Keyboard: detect Enter button
Keyboard->>Keyboard: hide without cancellation
Keyboard->>TextEdit: invoke onEnter during field cleanup
TextEdit->>LuaCallback: call enter callback with bounded text
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
An empty text field always renders as "---", both in the field itself and as the text area placeholder while editing. That is right for settings screens but wrong for free-form input, where the field should simply look empty. The default is unchanged, so no existing screen is affected; scripts can now pass placeholder="" (or any hint text) to lvgl.textEdit.
For a one-line text area LVGL sends LV_EVENT_READY only to the text area, while the OK checkmark also sends it to the keyboard object - and the keyboard object is what EdgeTX listens on. As a result the Enter key neither committed the value nor closed the keyboard: it did nothing at all. Detect the Enter key on the keyboard itself and route it through a new FormField::onEnter(), so it commits and closes like the checkmark. A field may additionally install an enter handler to treat Enter as "submit" as opposed to the checkmark's "keep editing"; lvgl.textEdit exposes this as the enter callback, which lets a script send a typed command on Enter.
4bfbe4b to
0232fd2
Compare
|
@coderabbitai summary Note: the walkthrough/summary is stale — it still mentions |
|
✅ Action performedSummary regeneration triggered. |
|
✅ Action performedSummary regeneration triggered. |
Summary of changes:
These three changes all came out of writing a Lua app that turns the radio into
a serial terminal for any device with a text CLI over UART (flight controllers,
ESCs, GPS modules) through a port set to LUA mode. Each removes a concrete
obstacle. They are technically independent, but the app needs all three, so they
are kept together rather than split into PRs that could land partially.
What this is worth in practice: out in the field it turns hardware the pilot is
already holding into one more tool, with no laptop involved. Connecting to a
UART correctly is the whole setup. And the moment radios gain USB host support,
the very same app does exactly this over an ordinary USB-C cable to the flight
controller, with no wiring at all - so the groundwork here keeps paying off.
1.
feat(lua): newserialGetLuaPort()A script using
serialRead()/serialWrite()had no way to find out whether anyserial port is actually set to LUA mode. Without it a script can only sit there
receiving nothing, unable to tell the user why. Returns the port number and its
name, or
nilwhen no port is in LUA mode.2.
feat(color): custom placeholder on text edit fieldsAn empty text field always renders as
---, both in the field itself and as thetext area placeholder while editing. That is right for settings screens but
wrong for free-form input, where an empty field should simply look empty. The
default is unchanged, so no existing screen is affected; scripts can pass
placeholder = ""(or hint text) tolvgl.textEdit.3.
fix(color): keyboard Enter key does nothing on single-line fieldsFor a one-line text area LVGL sends
LV_EVENT_READYonly to the text area,while the OK checkmark also sends it to the keyboard object - and the keyboard
object is what EdgeTX listens on. The result is that the Enter key neither
commits the value nor closes the keyboard: it does nothing at all, on every
single-line field in the radio.
The Enter key is now detected on the keyboard and routed through a new
FormField::onEnter(), so it commits and closes like the checkmark. A field mayadditionally install an enter handler to treat Enter as "submit" as opposed to
the checkmark's "keep editing";
lvgl.textEditexposes this as anentercallback, which is what lets the terminal app send a typed command on Enter.
There are no local changes to the vendored LVGL.
Testing:
additions runs on the radio.
Betaflight 2025.12.5) on a UART with Configuration/MSP:
#opens the CLI,commands echo and answer, and the keyboard Enter change commits/sends as
expected.
"---"), so existing screenskeep their current appearance; the new behaviour only applies to fields that
pass the parameter.
Summary by CodeRabbit
New Features
Bug Fixes