feat(lua): enable serial terminal scripts (port query, textEdit placeholder, Enter key) - #7578
Open
graycoderep wants to merge 3 commits into
Open
feat(lua): enable serial terminal scripts (port query, textEdit placeholder, Enter key)#7578graycoderep wants to merge 3 commits into
graycoderep 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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 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 and revised serial read buffering. ChangesColor LCD text-edit Enter flow
Lua serial API updates
Estimated code review effort: 3 (Moderate) | ~20 minutes 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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
graycoderep
force-pushed
the
cli-terminal
branch
from
July 21, 2026 04:58
4bfbe4b to
0232fd2
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.
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