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

Virtual events (WiP) #250

Merged
merged 3 commits into from
Oct 13, 2019
Merged

Virtual events (WiP) #250

merged 3 commits into from
Oct 13, 2019

Conversation

raphaelcoeffic
Copy link
Member

@raphaelcoeffic raphaelcoeffic commented Oct 6, 2019

This is a first PoC for the virtual events. It has been only tested with T16 on the simulator.
The event checks in the UI can probably be simplified once we have something working.

This PR introduces support for virtual events (added to OpenTX 2.3) and implements automatic selection of the target platform (aka radio) based on the screen resolution, this supporting automatically all the radios supported in OpenTX, as long as the screen format is one of those already supported.

Let's make the tests properly. Here is a list of targets that need testing (non-exhaustive):

  • X9D+
  • X9D+ 2019 (D16 only)
  • X-lite, X-lite-S & X-lite-Pro (D16 only)
  • X7
  • X10(S), X10(S) Express (D16 only) & T16 (using OpenTX 2.3 from current 2.3 branch)
  • T12

Please make sure you have OpenTX 2.3.1 installed and unzip this file at the root of your SD card and report how it works:
betaflight-tx-lua-scripts_1.3.0_virtual_events.zip

Depending on your target, you should test executing the scripts directly from the SD manager and/or as a telemetry script. Both should work properly.

Copy link
Member

@mikeller mikeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me so far.
What is the minimum OpenTX release to be able to run this?
And how well supported are the virtual events on the different devices? Are there any devices that will need specific testing?

@raphaelcoeffic
Copy link
Member Author

This needs to run on latest opentx, which is 2.3.1 for now.

We will need tests on basically all the targets. There is a test script that @3djc wanted to update to test the virtual events (in case it does not work as expected) and potential issues need to be reported to opentx for fixing the virtual events if necessary.

Some targets with the exact same keys and hardware don’t need to be tested separately (ex: T16 / X10, all the X-lites share the same navigation).

@mikeller
Copy link
Member

mikeller commented Oct 7, 2019

@raphaelcoeffic: We are close to releasing Betaflight 4.1. Normally we do a release of the lua scripts to go with a firmware release. Do you think this is stable enough to be released this or next week? If not we should look into fixing #245 independent of this, and then releasing the scripts for now, and adding this pull request after the release.

@raphaelcoeffic
Copy link
Member Author

Definitely not ready yet, lot’s of tests required on many targets I don’t own.

Fixing the other issue might be just as challenging if we are to break other targets... I really don’t know what can be done best.

@mikeller
Copy link
Member

mikeller commented Oct 8, 2019

@raphaelcoeffic: I guess in this case is to delay releasing a new version of the lua scripts until we've got the virtual events at a point where we can release them. We can crowdsource the testing to the users in here, and we can add an announcement about this to the release notes for Betaflight 4.1.
So to my understanding the problem that exists with the current scripts was introduced in 2.3, so users can avoid the problem by staying with 2.2 for now?

@raphaelcoeffic
Copy link
Member Author

@mikeller I assume so, yes. However, it would be really good to have the "crowdsourced tests" done ASAP ;-)

@Matze-Jung
Copy link

That's pretty interesting! I took another approach a few months ago and mapped the inputs by radio-name identifier. But from my testing, it takes some more memory.
If virtual events work well, some things will become simpler, others will no longer be in the hands of LUA script devs.

@mikeller
Copy link
Member

mikeller commented Oct 8, 2019

Since this change uses functionality that is brand new in OpenTX this will need to be tested thoroughly on as many supported hardware types as possible.
So if you are a Betaflight TX lua script user, can you please use these steps to test and provide feedback (do this for as many different TX models as you can):

  • Upgrade OpenTX on your TX to 2.3.1;
  • Download this build and install it on the TX by copying the folders in obj/ over your TX SD card:

betaflight-tx-lua-scripts_1.3.0_virtual_events_2.zip

  • run the Betaflight TX lua scripts, and
  • verify that all screens on your TX look like they should;
  • verify that all the buttons / scroll wheels used on your TX to control lua scripts work as they should;
  • if something isn't working properly, leave a comment below stating the TX model and the problem you found;
  • if all is fine, check if somebody already mentioned that everything is working for your TX model, and if not, add a comment below stating the TX model and that everything worked for you.

Thank you very much for helping us to improve the scripts!

@raphaelcoeffic
Copy link
Member Author

@mikeller could you please update your zip file with my latest changes? I believe this should work better. The older version showed to have some flows when testing on the simulator and X9D+.

@mikeller
Copy link
Member

mikeller commented Oct 9, 2019

@raphaelcoeffic: Done, it's betaflight-tx-lua-scripts_1.3.0_virtual_events_2.zip.

mikeller
mikeller previously approved these changes Oct 9, 2019
@vkolotov
Copy link

vkolotov commented Oct 9, 2019

An issue here with XLite Pro running v2.3.1 OTX. Joystick events are 90 degrees inverted, e.g.:

  • when you push right it actually generates "up" event (cursor goes up)
  • when you push left, "down" event generated
  • when you push down, nothing happens
  • when you push down for 2 secs, a dialog with "save page" appears
  • when you push up, screens get changed

Note: enter event works as expected

@raphaelcoeffic
Copy link
Member Author

raphaelcoeffic commented Oct 9, 2019

@vkolotov is this related to opentx/opentx#6916 ?

Please note that the goal here is to have something that offer a consistent user experience with the normal OpenTx menus that work the same.

@vkolotov
Copy link

vkolotov commented Oct 9, 2019

@vkolotov is this related to opentx/opentx#6916 ?

I doubt it is related. I've copied over the new scripts and it changed direction.

The navigation in the radio controller (not in lua script) remained unchanged when I upgraded it to v2.3.1 OTX.

@vkolotov
Copy link

vkolotov commented Oct 9, 2019

I have just reverted the scripts (copied over the backup, the latest release) and it works as expected. So it must be something wrong in the test version (zip archive provided here).

@frozenskys
Copy link
Contributor

Is there a reason to still use the events.lua for mapping events if we can just use the virtual events directly in the ui.lua script?

@McGiverGim
Copy link
Member

Tested with QX7S, to me it seems that the wheel is inverted, but I'm not totally sure if it was like this before.

@raphaelcoeffic
Copy link
Member Author

Is there a reason to still use the events.lua for mapping events if we can just use the virtual events directly in the ui.lua script?

In fact no, this is going away next.

@vkolotov @McGiverGim I use different events now for +/- and prev/next, so that this should now work in the proper direction (same as radio nav).

@raphaelcoeffic
Copy link
Member Author

raphaelcoeffic commented Oct 9, 2019

Please note that the navigation is still tilted by 90° on T12 and X-lite(s, etc...). This will be fixed in OpenTx and be available in 2.3.2.

While testing, you might find that it works slightly differently from before, which should not be an issue, as long as it works.

The goal here is really to make supporting different targets simple and automatic, so that new targets are supported automatically, rather than having to be added one by one.

@McGiverGim
Copy link
Member

@raphaelcoeffic now the wheel works as expected.

But there is another bug (it was before too), how can I change the page? If I remember correctly, before it was with the "menu" button (the three horizontal lines), but now it does nothing. But if I go out of the Betaflight lua script, the next time I enter in I'm on a new page.

incValue(1)
elseif event == userEvent.press.minus or event == userEvent.repeatPress.minus or event == userEvent.dial.left then
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file looks so much cleaner now! 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, a matter of taste as it seems :-) Anyway, that saves a bit of memory by avoiding the userEvent structure.

menuActive = 1
currentState = pageStatus.displayMenu
elseif userEvent.press.pageDown and (event == userEvent.longPress.enter) then -- Horus
if (event == EVT_VIRTUAL_ENTER_LONG) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be if (event == EVT_VIRTUAL_MENU_LONG) then ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MENU_LONG cannot be used in telemetry scripts (triggers the “Reset ...” menu).

@raphaelcoeffic
Copy link
Member Author

how can I change the page?

@McGiverGim I think it should be the "page" key. Have you tried it? "page long" should go back one page, and "page" should lead you to the next page.

@McGiverGim
Copy link
Member

@McGiverGim I think it should be the "page" key. Have you tried it? "page long" should go back one page, and "page" should lead you to the next page.

The page key returns to the others telemetry pages, as always did I think.

@McGiverGim
Copy link
Member

Now I understand because each time I go out and in of the Betaflight script I have a different page: the page key, that rolls the telemetry pages, has been assigned to roll too the Betaflight pages. In the X7 this has been always the menu button.

@raphaelcoeffic
Copy link
Member Author

The page key returns to the others telemetry pages, as always did I think.

hmm... I obviously forgot that bit... Then I need to re-instate the menu key ;-)

@McGiverGim
Copy link
Member

hmm... I obviously forgot that bit... Then I need to re-instate the menu key ;-)

True, executing directly the script from the folders explorer, works ok. But I have it in the telemetry page. Is more intuitive to use the page key as you did, but it seems to interfere with Open TX. Maybe it can be disabled until we press Exit? Now I know because it was assigned to the menu key 😋

@raphaelcoeffic
Copy link
Member Author

@McGiverGim can you please re-try with my latest change?

@McGiverGim
Copy link
Member

@McGiverGim can you please re-try with my latest change?

Now it produces an infinite loop, rolling all the pages of the Betaflight script 😮

@raphaelcoeffic
Copy link
Member Author

Now it produces an infinite loop, rolling all the pages of the Betaflight script 😮

F...! that'S what happens when I don't test it before... sorry for that!

@McGiverGim
Copy link
Member

I can't test it until tomorrow. You don't need to make the same change when long pressing the menu to move page back?

@frozenskys
Copy link
Contributor

frozenskys commented Oct 9, 2019

@raphaelcoeffic that's working a lot better, however... ENTER_LONG triggers the “Reset ...” menu AND the BF popup menu on my X7 :| (unless I've done something wrong...)

src/BF/bf.lua Outdated
@@ -9,6 +9,8 @@ assert(loadScript(radio.preLoad))()
assert(loadScript(protocol.transport))()
assert(loadScript(SCRIPT_HOME.."/MSP/common.lua"))()

isTelemScript = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra vowels don't cost extra. 😁 How about isTelemetryScript?

- uses the screen resolution to determine the target.
- changes menu key mapping based on telemetry script vs standalone script.
@asizon
Copy link
Member

asizon commented Oct 10, 2019

Testes in X9D+, I think it take a long time for saving pages, more slowly that the previous version, can it make more fast??

@McGiverGim
Copy link
Member

Tested latest version, some things that are different from the "old" script:

  • Now I can't go back in the Betaflight pages. Before, menu key go forward, and long menu key go backward. Now the long press in the menu key shows the menu.
  • Before the menu appeared with the enter key. Now it does nothing.

I think is important to have a backward key. I understand that the problem is that the page key does not work as expected. Is there a way to tell Open TX to ignore the page key until we get out of the script?

@raphaelcoeffic
Copy link
Member Author

I think is important to have a backward key. I understand that the problem is that the page key does not work as expected. Is there a way to tell Open TX to ignore the page key until we get out of the script?

no, it is actually reserved for changing between telemetry pages.

@mikeller mikeller added this to the 1.4 milestone Oct 13, 2019
@mikeller mikeller merged commit 4fd9cbe into master Oct 13, 2019
@RipperDrone RipperDrone mentioned this pull request Oct 13, 2019
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.

7 participants