I'm attempting to create an annunciator test button, and having a small difficulty. the button functions when pressed and does actuate the test button in the sim, but only for a very brief period. How can do I get Arduino/air Manager to "see" when I hold the button for a period of time?
Here is my code as of right now...
function button_pressed()
print("TEST")
xpl_command("sim/annunciator/test_all_annunciators")
end
hw_button_add("TEST", button_pressed)
xpl_dataref_subscribe("sim/cockpit/warnings/annunciator_test_timeout", "FLOAT", function(state)
xpl_dataref_subscribe("sim/cockpit/warnings/annunciator_test_pressed", "INT", function(state)
end)
end)
Thanks,
Justin
Press and hold button
Re: Press and hold button
Please use the code brackets next time.
Press and hold requires you to use start and stop events in the command. So:
Press and hold requires you to use start and stop events in the command. So:
Code: Select all
function button_pressed()
xpl_command("sim/annunciator/test_all_annunciators", 1)
end
function button_released()
xpl_command("sim/annunciator/test_all_annunciators", 0)
end
hw_button_add("TEST", button_pressed, button_released)
-
- Posts: 13
- Joined: Fri Apr 30, 2021 12:12 pm
Re: Press and hold button
Thanks for the helping hand, Ralph.
I don’t know what you mean by using the code brackets. This is all quite new to me and I’m just plodding along as best I can.
Justin
I don’t know what you mean by using the code brackets. This is all quite new to me and I’m just plodding along as best I can.
Justin
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Press and hold button
Hi Justin,CubDriver_197T wrote: ↑Wed Oct 13, 2021 8:40 pm Thanks for the helping hand, Ralph.
I don’t know what you mean by using the code brackets. This is all quite new to me and I’m just plodding along as best I can.
Justin
Welcome to the forum. This is a common thing that newbies to the forum do not know and often taken for granted by us all. You will learn all the quirks in time.The code brackets are the </> icon in this image. By clicking on the icon you can enter code within the brackets. It makes it easier for all to read and separates code from what one wants to explain.
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card