Skip to content
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

Add virtual inputs and virtual switches #5885

Open
wants to merge 7 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 2 times, most recently from a5ae59f to 0c8ed57 Compare February 14, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants