Press and hold button

Support for Arduino in combination with Air Manager and Air Player

Moderators: Ralph, russ

Post Reply
Message
Author
CubDriver_197T
Posts: 10
Joined: Fri Apr 30, 2021 12:12 pm

Press and hold button

#1 Post by CubDriver_197T » Wed Oct 13, 2021 1:26 pm

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

User avatar
Ralph
Posts: 5411
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Press and hold button

#2 Post by Ralph » Wed Oct 13, 2021 1:33 pm

Please use the code brackets next time.

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)

CubDriver_197T
Posts: 10
Joined: Fri Apr 30, 2021 12:12 pm

Re: Press and hold button

#3 Post by CubDriver_197T » 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

User avatar
Keith Baxter
Posts: 3026
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Press and hold button

#4 Post by Keith Baxter » Wed Oct 13, 2021 8:50 pm

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
Hi 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.
ice_screenshot_20210816-091647.png
ice_screenshot_20210816-091647.png (7.86 KiB) Viewed 207 times

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 

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests