Skip to content

Conversation

klutvott123
Copy link
Member

@klutvott123 klutvott123 commented Nov 21, 2019

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 like apiVersion detection

  • mainMenu for the main menu code

  • pages for page code

apiVersion detection for TOOLS script is done by using background.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 the apiVersion. If the quad is already powered this check only takes a second before it then moves onto the mainMenu state. No pages are loaded until one is selected from the menu. Pages are unloaded when leaving the pages state.

The TELEMETRY version works as before with background.lua doing apiVersion detection in the background. It's always forced to pages 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 before background.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 to pageState) is now only used for pages.

currentLine is renamed to currentField 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.

@mikeller mikeller added this to the 1.5 milestone Nov 23, 2019
@mikeller mikeller merged commit 4c3e125 into betaflight:master Nov 23, 2019
@klutvott123 klutvott123 deleted the ui-states branch November 26, 2019 19:04
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.

2 participants