Skip to content

Add virtual inputs and virtual switches #5885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

wimalopaan
Copy link
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
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
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
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
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
Contributor Author

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

@pfeerick
Copy link
Member

pfeerick commented Mar 31, 2025 via email

@wimalopaan
Copy link
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
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
Collaborator

Also populate lookup lists eg sources and switches

@wimalopaan wimalopaan force-pushed the wmvcontrols branch 2 times, most recently from 08bce1f to 9c300bf Compare May 7, 2025 13:50
@JimB40
Copy link
Collaborator

JimB40 commented May 11, 2025

I'd rather see virtual inputs symbols with VIxx syntax. Using 2 capital letters.

@wimalopaan
Copy link
Contributor Author

I'd rather see virtual inputs symbols with VIxx syntax. Using 2 capital letters.

... and rename virtual switches to VSxx.

@wimalopaan wimalopaan force-pushed the wmvcontrols branch 4 times, most recently from be6d00d to 6baf99b Compare May 18, 2025 04:39
@wimalopaan wimalopaan force-pushed the wmvcontrols branch 3 times, most recently from eb83022 to 4e1c571 Compare May 27, 2025 04:33
@wimalopaan wimalopaan force-pushed the wmvcontrols branch 2 times, most recently from 7f26ac4 to 4e4327a Compare June 4, 2025 03:57
@wimalopaan wimalopaan force-pushed the wmvcontrols branch 3 times, most recently from 289a5ab to 47baf9a Compare June 23, 2025 07:37
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.

5 participants