frumpy Posted September 16, 2019 Report Posted September 16, 2019 Hi guys, as the title says, I am trying to do some interfacing. Using the dataref tool, I found that pressing a button within X-Plane sets the dataref from 0 to 1, releasing the button sets it back to 0. I can manually change the value of the dataref and this is working fine. However, when trying to do the same thing in LUA, I'll get several characters displayed on the CDU (like "AAAAA" instead of "A"). I see some people already interfaced the CDU for their private sim or as commercial software, but I wonder how this was done? Example code, which prints "BBBB" one second after clicking the "B" button: function b_pressed() xpl_dataref_write ("ixeg/733/FMC/cdu1_B", "FLOAT", 1) timer_start(1000,timer_b) end function timer_b() xpl_dataref_write ("ixeg/733/FMC/cdu1_B", "FLOAT", 0) sound_play(clicksound) print ("B pressed") end Can anyone help? Quote
Ben Russell Posted September 17, 2019 Report Posted September 17, 2019 What happens if you mouse click the CDU button and hold the mouse down for 1 second? I would expect the same result. You probably need to "release" the CDU button by writing the 0 after a shorter interval. This will probably need to be 1 frame. I don't know how you would do that in FWL script. Quote
frumpy Posted September 17, 2019 Author Report Posted September 17, 2019 (edited) I'm using Air Manager for interfacing. The default value of ...733/CDU/key_x is "-1". Clicking with the mouse within XP sets the dataref to "1", releasing it to "0" - while the CDU prints the character. I found sending just a "0" to the dataref via AM does a keypress, but with several characters. So there is no need to reset the dataref, setting a value of "0" to "0" is handled like a keypress. Sending "0" twice does the same as sending it once. It shows 2-5 characters, not reliably reproduceable. Edited September 17, 2019 by frumpy Quote
jfjoubert Posted September 17, 2019 Report Posted September 17, 2019 I had a quick look with FlyWithLua... When you set the dataref to "0" you will get a single click, so there is no need to set it to "1" and then back to "0". I reliably get only one key press using this method. So in theory what you're doing should work. I assume that it's the way Air Manager handles things... maybe you should also post this question on the Air Manager support forum and see if someone can assist you. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.