UI states + apiVersion detection for TOOLS script #288
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds UI states. This makes it easier to organise the code in
run_ui()
and gives us more control over what is executed and when it's executed.There's three states:
init
for init stuff likeapiVersion
detectionmainMenu
for the main menu codepages
for page codeapiVersion
detection for TOOLS script is done by usingbackground.lua
for now.It works by entering the
init
state when starting the script. It stays in this state until power is connected to the quad and it receives theapiVersion
. If the quad is already powered this check only takes a second before it then moves onto themainMenu
state. No pages are loaded until one is selected from the menu. Pages are unloaded when leaving thepages
state.The TELEMETRY version works as before with
background.lua
doingapiVersion
detection in the background.It's always forced topages
state.EDIT: Added commit to allow detecting
apiVersion
in init state for TELEMETRY script too. It's useful in those cases where the ui is brought on screen beforebackground.lua
is done with init. Doesn't use more memory since the memory use in init state is well below the peak memory use.currentState
(renamed topageState
) is now only used for pages.currentLine
is renamed tocurrentField
as that's a better description of what it actually is.Fixed
api/requiredVersion
check for the main menu.I have tested this for a while now and haven't found anything that doesn't work like it should. Memory use is pretty much the same as it currently is.