-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
widget options: add useable defaults #5917
Comments
There are Lua API functions getSwitchIndex and getSourceIndex that will return the index for a named switch or source. I can use similar code when parsing the option defaults for SWITCH and SOURCE options if the supplied value is a string. However in the current implementation getSwitchIndex and getSourceIndex will compare against the user names if the user has renamed the switches or sources. So getSwitchIndex("SF"..CHAR_UP) will fail if the SF switch has been given a custom name. I would suggest that getSwitchIndex and getSourceIndex should probably check both the default names and custom user names (if present). Thoughts? |
for the switch, local options = {
{ "switch1", SWITCH, getSwitchIndex("SA" .. CHAR_UP) },
{ "switch2", SWITCH, getSwitchIndex("SA-") },
{ "switch3", SWITCH, getSwitchIndex("SA".. CHAR_DOWN) },
} and although personally I do not care about switch name changes (I do not do that, nor i know someone who does) regarding the source, can you show what you are talking about? |
Currently this: { "switch1", SWITCH, getSwitchIndex("SA" .. CHAR_UP) }, will not work if the switch has been renamed before you add the widget to the radio. For source something like this: { "source1", SOURCE, getSourceIndex("CH3") }, However at the moment this will not work because the widget options are processed at startup before any model is loaded, so most of the sources (e.g. channels) are unavailable. |
So what can be done? |
I would suggest that getSwitchIndex() and getSourceIndex() be changed to:
If necessary we could add new functions isSwitchAvailable() and isSourceAvailable() to check whether the switch/source is actually present. There is one other complication to do with telemetry sensors. Since the index of a sensor can't be determined unless the sensor is actually discovered it will not be possible to use them in the options default value. |
In case the telemetry sensor is not exist, i do not need it, since he can not produce data. |
In the current code this can't be done. All of the widget files on the SD card are loaded at radio startup, (compiled if needed), and the 'options' table is processed to build the default options data in memory. This all happens before any model is loaded so no telemetry sensors can exist. The 'options' table is never re-examined. So trying to use getSourceIndex() for a telemetry sensor in the options table will always fail. |
Can the options calculation run once again before each presentation of options-window? |
See PR #5926 |
Is there an existing issue for this feature request?
Is your feature request related to a problem?
I am aways frustrated when I need to define default values to options in lua widgets
you need to supply the id of the switch, but it is not well documented, and it is changing from version to version
so I need to define and maintain tables for each version
Describe the solution you'd like
suggestion
for SWITCH, allow to define name of the switch and direction
"SF"..CHAR_UP | "SF"..CHAR_DOWN | "SF-"
or better
"SFu" | "SF-" | "SFd"
for SOURCE, that may not be available, I would like it to have array of options, and to choose the first one that exist
e.g.
cell | VFAS | RxBt | A1 | A2
or
RQly | VFR | RSSI | 1Rss
so it will look like this
Describe alternatives you've considered
No response
Additional context
requested from @philmoz and he may look at this.
The text was updated successfully, but these errors were encountered: