-
-
Notifications
You must be signed in to change notification settings - Fork 350
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
fix(lua): Do not pass key event that triggered telemetry view to lua #4168
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased onto correct branch. Please take note of the changes requested above.
Unfortunately the EVT_ENTRY event comes in after the LONG_PAGE event had arrived in the resumeLua subprogram. Alternatively it would be necessary to walk through the queue every time when pulling an event to see if an EVT_ENTRY event exists. |
Ok, maybe I should have a look. There is probably a simpler solution to this issue. The present PR feels like a hack to hide something else. |
…script screen are active
The origin of the problem seems to be in guiMain (main.cpp). The previous implementation did not guarantee that keyboard events are not sent to luaTask, if neiter a telemetry script nor a standalone LUA script is active. Successfully tested on radio (X7 ACCESS) and simulator for the 2.9 branch and on simulator only for the main branch. |
@philmoz do you have an idea what's going on? |
Explenation in more detail: My first PR solved this issue by clearing the event queue in interface.cpp just after a LUA telemetry screen became visible. As @raphaelcoeffic correctly guessed, this PR only hided the cause of the problem which is in my opinion in guiMain: Original code:
In this code events are passed to luaTask even if neither telemetry nor standalone screens are active. Thus I changed the code in this PR to:
|
I think you've identified the cause of the problem; but I'm not entirely happy with the solution. This is the only case where a non-zero event value is passed to luaTask (color radios call luaPushEvent separately). I think it would be better to test if a telemetry script or standalone script is running and call luaPushEvent, then call luaTask as is; but with a 0 event value.
You will also need to add this to the start of main.cpp:
|
You are absolultely right that moving luaTask must be considered very carefully.
luaTask with allowLcdUsage == false is called anyway in each iteration of perMain. Thus luaTask is always called twice, even if there is no foreground script active. Concerning my PR we have to check whether a move of luaTask with allowLcdUsage==true has side effects. Unfortunately I was not able to understand the logic in resumeLua. Concerning your version, I propose a modification:
which was tested successfully in simulator. If luaPushEvent is called in HandleGui as you proposed, the event parameter of function luaTask becomes obsolete. And it is better to call the low level subroutine luaPushEvent in luaTask. |
The color LCD code always calls luaPushEvent outside of the luaTask function. My recommendation it to make the B&W code match this and remove the event parameter from luaTask. |
…ndalone script screen are active" This reverts commit f99ad97.
…ript screens are active
Done. Checked successfully with branch main on XQ7 ACCESS (emulator) and on branch 2.9 on XQ7 ACCESS (emulator + radio). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There don't appear to be any negative side effects of this on TX16S, X9D+ or Zorro when tried with standalone lua like ELRS / MPM config Lua, or telemetry screen widges like yappu / iNav telemetry or colorlcd lua widgets.
Fixes (Taranis only) #3253
After switching to the telemetry view, the LUA key event buffer could still contain the key event that was used to switch to the telemetry screen. See below an example for script evt1.lua
evt1.zip
on a Taranis Q X7 ACCESS:
with patch:
Key event received 1 4097
without patch:
Key event received 1 99
Key event received 1 131 (long page)
Key event received 1 4097
This behavior is unrequested and does neither occur in opentx nor in elder edgetx releases.
Summary of changes:
The LUA key event buffer is cleared at the beginning of resumeLUA if the radio just switched to the telemetry view.