Skip to content

feat(lua): expose effective touch state - #7647

Open
bultodepapas wants to merge 2 commits into
EdgeTX:mainfrom
bultodepapas:agent/expose-touch-state-lua
Open

bultodepapas wants to merge 2 commits into
EdgeTX:mainfrom
bultodepapas:agent/expose-touch-state-lua

Conversation

@bultodepapas

@bultodepapas bultodepapas commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add the read-only getTouchEnabled() API to the general Lua library on every target.
  • Return nil on radios built without a touchscreen, so scripts can detect unsupported hardware safely.
  • On touchscreen radios, report whether firmware currently accepts touch input: the backlight must be on and neither the model nor global Disable touch function may be active.
  • Add regression coverage for touch enabled, model/global Disable touch, backlight off, and non-touch radios.

Motivation

Lua widgets and applications need a reliable way to inspect the radio's effective touch-input state for indicators and custom interfaces. This remains independent of the firmware feedback discussed in #1085 and implemented by #7565.

Semantics

getTouchEnabled() returns:

  • true when the target has a touchscreen, the backlight is on, and Disable touch is inactive.
  • false when the target has a touchscreen but touch input is currently gated by the backlight or a model/global Disable touch function.
  • nil when the target has no touchscreen.

The API is registered unconditionally, which avoids a missing-function error in portable scripts.

Validation

Native test suites built with warnings treated as errors:

  • TX16SMK3 (touch): 125/125 passed.
  • V12 (non-touch color): 120/120 passed.
  • X9D+ 2019 (non-touch monochrome): 134/134 passed.

Representative Release ARM firmware-size builds also passed for TX16SMK3 and V12.

The 3.0.0 Lua documentation tag matches the version declared by current main.

Supersedes #7593. GitHub does not allow that closed PR to be reopened because its head was rebased/force-pushed.

@bultodepapas

Copy link
Copy Markdown
Contributor Author

@pfeerick, this is the clean successor to #7593 following your post-close feedback. It is now framed as a general Lua radio/UI-state API, rebased onto current main, and validated with all 102 native radio tests. Could you review the API direction when convenient? The contributor account cannot formally assign upstream reviewers.

Copilot AI lite review requested due to automatic review settings August 13, 2026 17:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a small, touch-hardware-gated Lua API to let Lua widgets/apps query whether the firmware’s “Disable touch” special-function state is currently active, matching the state already used in the input/UI path.

Changes:

  • Added getTouchEnabled() to the general Lua API on HARDWARE_TOUCH builds, returning true unless FUNCTION_DISABLE_TOUCH is active.
  • Documented the API’s semantics (special-function state only; not a guarantee the driver is accepting touches).
  • Added a Lua unit test covering both model and global special-function activation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
radio/src/lua/api_general.cpp Adds the getTouchEnabled() Lua binding (touch-only) and luadoc entry.
radio/src/tests/lua.cpp Adds a touch-only Lua test verifying behavior for model vs global disable-touch state.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@3djc

3djc commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

I think it should return nil when no touch is present:

  • ensure it doesn't break by syntax error on non touch radio
  • Indicates no touch screen is installed on those where this is optional

@pfeerick

Copy link
Copy Markdown
Member

The current implementation is focused on FUNCTION_DISABLE_TOUCH SF/GF, while using a more generic getTouchEnabled naming... so I agree on that premise... given the identification that the backlight being off might also reject touch input... it wouldn't hurt to dig a bit more also to see if the current backlight state can be considered also... or left as a documented limitation if it would require too much rework.

@pfeerick pfeerick added the lua-api Lua API related label Aug 14, 2026
@bultodepapas
bultodepapas force-pushed the agent/expose-touch-state-lua branch from 7d3b572 to 9b5a0b0 Compare August 31, 2026 18:42
@bultodepapas

Copy link
Copy Markdown
Contributor Author

Addressed both review points after rebasing onto current main.

getTouchEnabled() is now registered on every Lua-capable target. It returns nil when the radio build has no touchscreen, avoiding a missing-function failure and allowing portable scripts to distinguish unsupported hardware.

On touch targets it now mirrors the firmware input gates: it returns false while the backlight is off or while the model/global Disable touch function is active, and true otherwise.

Regression coverage now exercises touch enabled, model/global Disable touch, backlight off, and non-touch targets. Local validation passed:

  • TX16SMK3 native: 125/125
  • V12 native: 120/120
  • X9D+ 2019 native: 134/134
  • TX16SMK3 and V12 Release ARM firmware-size builds

The PR description and Lua API documentation have also been updated to state these semantics explicitly.

@bultodepapas bultodepapas changed the title feat(lua): expose Disable Touch state feat(lua): expose effective touch state Aug 31, 2026
@pfeerick pfeerick added this to the 3.0 milestone Sep 1, 2026
@pfeerick pfeerick added the enhancement ✨ New feature or request label Sep 1, 2026
- Horus builds set HARDWARE_TOUCH for all PCBs, including X10/X12S
  which have no touch panel; use the runtime HAS_TOUCH_PANEL() check
  where the board provides it.
- Document that a touch while the backlight is off still wakes the
  screen.
- Test: save/restore function contexts instead of clearing them, and
  cover the activeUIFunctions path.
- Align @status wording with the other 3.0 entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request lua-api Lua API related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants