Skip to content

Add virtual inputs and virtual switches #5885

Open
wimalopaan wants to merge 18 commits intoEdgeTX:mainfrom
wimalopaan:wmvcontrols
Open

Add virtual inputs and virtual switches #5885
wimalopaan wants to merge 18 commits intoEdgeTX:mainfrom
wimalopaan:wmvcontrols

Conversation

@wimalopaan
Copy link
Copy Markdown
Contributor

@wimalopaan wimalopaan commented Feb 8, 2025

This PR adds virtual inputs (Vin1 ... Vin16) and virtual switches (V01 ... V64) and neccessary LUA support functions

  • setVirtualInput()
  • setVirtualSwitch()
  • getVirtualSwitch()

A LUA widget lvglControls (see: https://github.com/wimalopaan/LUA/tree/main/WIDGETS/lvglControls ) is provided for demonstration a simple use case: extending the number of physical inputs and physical switches of the radio via a widget that provides some virtual touch controls for these virtual inputs and virtual switches.

Another purpose is to extend the amount of physical knobs, etc. of the radio by connecting some external device via serial (AUX1, AUX2) to the radio, and installing a custom widget, that reads from the serial and uses the above functions to set the virtual inputs and virtual switches.

A proposal for such a serial protocol can be found: https://github.com/wimalopaan/Electronics?tab=readme-ov-file#hwext

Rationale:
In the good old days there were radios like the FrSky X9E that provide a large amount of potentiometers and switches. This type of radio was/is very popular for controlling crawler/ships- or other functional-models. The number of these physical items is still limited and due to their physical nature, the labels for all these elements are also handwritten on paper.
With the advent of the lvgl LUA support it is possible to create virtual controls that perfectly fit into the UI look-and-feel of EdgeTx and also are not very compute-intensive. This opens the way to use widgets to provide arbitrary virtual controls and switches with customisable labes and colors. It also opens the way to use widgets to read from serials like AUX1/AUX2 and get controls data from some external devices (e.g. a µC with some physical potiometers, switches, incrementals, ... connected).

Alternative:
There is a cumbersome alternative way to achieve a similar but very limited result: a widget could use the function shmSet() to transport up to 16 values, to a mixer script which could pick them up via shmGet() and simple return them (only up to 6). These output values of the mixer script could then be used as mixer-inputs. There is no such a way for switches.

Example Widget:

lvgl1
lvgl2
lvgl3
lvgl4

@3djc
Copy link
Copy Markdown
Collaborator

3djc commented Feb 8, 2025

Please do not add something like this on bw, it will make scrolling a nightmare! (And likely Colors too)

@wimalopaan
Copy link
Copy Markdown
Contributor Author

Please do not add something like this on bw, it will make scrolling a nightmare! (And likely Colors too)

On BW it should be not available (need to check COLORLCD)

On COLORLCD: why do you think scrolling would be an issue?

@wimalopaan
Copy link
Copy Markdown
Contributor Author

I added the possibility to explicitly activate a virtual control (input, switch). If no LUA script activates some virtual controls, they do not show up at all.
A LUA script can activate some of them by using

  • activateVirtualInput()
  • activateVirtualSwitch()

@wimalopaan wimalopaan force-pushed the wmvcontrols branch 4 times, most recently from ba8f0ba to d62a841 Compare February 11, 2025 11:04
@wimalopaan wimalopaan marked this pull request as ready for review February 12, 2025 12:13
@wimalopaan wimalopaan force-pushed the wmvcontrols branch 3 times, most recently from 0c8ed57 to 7f3a149 Compare February 15, 2025 10:12
@wimalopaan wimalopaan force-pushed the wmvcontrols branch 2 times, most recently from e837be6 to f296d20 Compare March 6, 2025 17:13
@wimalopaan
Copy link
Copy Markdown
Contributor Author

The complete API for the virtual controls (virtual inputs, virtual switches) now comprises the following LUA functions:

  • setVirtualInput()
  • getVirtualInput()
  • activateVirtualInput()
  • setVirtualSwitch()
  • getVirtualSwitch()
  • activateVirtualSwitch()

@wimalopaan
Copy link
Copy Markdown
Contributor Author

@elecpower What does the label "needs: companion" mean?

@pfeerick
Copy link
Copy Markdown
Member

pfeerick commented Mar 31, 2025 via email

@wimalopaan
Copy link
Copy Markdown
Contributor Author

Ok, think I need some advice here ;-)

In firmware/simulator a widget activates virtual sources / switches. This is to prevent littering the sources lists / switches lists with unused virtual controls. The question is now how to emulate this activation process, since widget installation in simulation started from companion is not persistent. So, this activation hast to be done by other means. Maybe an extra dialog for the model config? But that wouldn't exist in firmware/simulator.

@elecpower
Copy link
Copy Markdown
Collaborator

As a guide Companion:

  • must be able read and write the yml files without data loss or corruption (not negotiable);
  • update radio and model settings editing to support maintenance of the feature as radio firmware (unless performed using lua as it is not currently implemented in Companion or reliant on radio firmware runtime environment eg receiver capabilities or custom hardware mods)
  • update two-way interfacing between simulator and libsimulators including "faking" the runtime environment for the libsimulator

@elecpower
Copy link
Copy Markdown
Collaborator

Also populate lookup lists eg sources and switches

@wimalopaan wimalopaan force-pushed the wmvcontrols branch 3 times, most recently from d7202a2 to 39a7816 Compare January 11, 2026 06:55
@wimalopaan wimalopaan force-pushed the wmvcontrols branch 4 times, most recently from 3195023 to 0e8d54b Compare January 25, 2026 06:38
@wimalopaan wimalopaan force-pushed the wmvcontrols branch 3 times, most recently from 5048a24 to e2734bf Compare February 1, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants