Open voltangle opened 1 year ago
I have not tested this on a real device because the radio doesn't have enough memory even for 20 frames
I'm using the simpler simu
to test (does not use Qt) and it "works". By that I mean that it does not crash or causes any bad memory accesses (tested with -DASAN=YES
; LLVM's address sanitiser).
That method of delay seems weird "while (time + 10 > getTime()) do end", the run() function should do work and exit as soon as it can. Also using CPU time for nothing.
Have you try do it incrementally.. i.e, on every call to run() do only 1 frame?? and if it is too soon to display the next frame, exit run() without doing anything? You will need to keep track of the what is your current displayed frame as well as the last displayed time at script level variables.
That's a good suggestion, thanks! But that's an issue with the script logic, and it should definitely not result in the simulator dying btw now it works fine after upgrading to 2.8.1, so yea that's that
No Lua script should be able to crash the radio. But there are a lot of checks missing.
The challenge with embeded programming is that is not like traditional PC software. In many embeded systems, they use what is called "Cooperative Multitasking" that is that a running task has to give up the CPU to switch to other tasks. That was the original intention on OpenTX/EdgeTx. EdgeTX changed it multi-tasking library to a more modern one, but the LUA programming philosofy shoud still be the same. Short running method calls and not hog the CPU
Hello frankiearzu,
I look for a method to keep a message on my screen 3s. I have tried this method without success
local idSA = getFieldInfo("sh").id
local ss = getValue (idSA) -- ON=1024, OFF=-1024
if ss > 0 then -- chech SwReset switch
local timeMs = getTime()
lcd.drawText(20 , 50, "RESET SWITCH TOGGLED", DBLSIZE + RED + SHADOWED)
while (timeMs + 3 > getTime()) do end
end
Thanks for your help,
Pierre
You cannot have delays or long delay loops in LUA. Every time a refresh it called, it needs to return as soon as posible.You can do a state machine.. with 2 states: Normal and DiplayMsg.You start in Display state,Every time refresh is called, if you need to show a message, you record your start time and switch to display state.In the display state, you display your message, and check if the time is past 3s.. If so, you change your state back to normal.On Mar 31, 2024, at 5:59 AM, pierrotm777 @.***> wrote: Hello frankiearzu, I look for a method to keep a message on my screen 3s. I have tried this method without success local idSA = getFieldInfo("sh").id local ss = getValue (idSA) -- ON=1024, OFF=-1024 if ss > 0 then -- chech SwReset switch local timeMs = getTime() lcd.drawText(20 , 50, "RESET SWITCH TOGGLED", DBLSIZE + RED + SHADOWED) while (timeMs + 3 > getTime()) do end end
Thanks for your help, Pierre
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
Do you have an example how to change the display state ?
Is just a variable, you assign a value to it. You can say value 1 is normal, value 2 is displaying message.So in your main loop you will have an IF for each of the state (1 and 2) and put the corresponding code for each. On Mar 31, 2024, at 9:44 AM, pierrotm777 @.***> wrote: Do you have an example how to change the display state ?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
Ok, thanks
Is there an existing issue for this problem?
What part of EdgeTX is the focus of this bug?
Simulator
Current Behavior
The whole thing crashes when running this code:
...with this error:
Expected Behavior
Well, not crash and at least show a meaningful error message 🤷
Steps To Reproduce
Version
2.8.0
Transmitter
Taranis Q X7
Anything else?
For debugging purposes, here is a file with some video data: badapple.lua.zip