Hello Pete,
I am back with this after some time. I have now a joystick card connected to button presses as follows:
button 1 = last number of decimal is 5 (fsuipc 0)
button 2 = last number of decimal is 0 (fsuipc 1)
button 9 = pre-last number of decimal is 3
button 10 = pre-last number of decimal is 2
button 11 = pre-last number of decimal is 5
button 12 = pre-last number of decimal is 4
button 13 = pre-last number of decimal is 1
button 14 = pre-last number of decimal is 0
button 17 = pre-last number of decimal is 6
button 18 = pre-last number of decimal is 7
button 19 = pre-last number of decimal is 8
button 20 = pre-last number of decimal is 9
button 25 = whole is 108 (fsuipc 24)
button 26 = whole is 109 (fsuipc 25)
button 41 = whole is 110
button 42 = whole is 111
button 43 = whole is 112
button 44 = whole is 113
button 45 = whole is 114
button 46 = whole is 115
button 47 = whole is 116
button 48 = whole is 117
button 35 = DME test
button 36 = DME ON/OFF
So for example frequency 113.45 is coded with button press: 44 + 12 + 1
Now I am trying to make LUA script to determine the frequency which is currently set and send it to FS.
while 1 do
joy = 1
wholeeight = ipc.testbuttonflag(joy,24)
wholenine = ipc.testbuttonflag(joy,25)
wholeten = ipc.testbuttonflag(joy,40)
wholeeleven = ipc.testbuttonflag(joy,41)
wholetwelve = ipc.testbuttonflag(joy,42)
wholethirteen = ipc.testbuttonflag(joy,43)
wholefourteen = ipc.testbuttonflag(joy,44)
wholefifteen = ipc.testbuttonflag(joy,45)
wholesixteen = ipc.testbuttonflag(joy,46)
wholeseventeen = ipc.testbuttonflag(joy,47)
decimalzero = ipc.testbuttonflag(joy,13)
decimalone = ipc.testbuttonflag(joy,12)
decimaltwo = ipc.testbuttonflag(joy,9)
decimalthree = ipc.testbuttonflag(joy,8)
decimalfour = ipc.testbuttonflag(joy,11)
decimalfive = ipc.testbuttonflag(joy,10)
decimalsix = ipc.testbuttonflag(joy,16)
decimalseven = ipc.testbuttonflag(joy,17)
decimaleight = ipc.testbuttonflag(joy,18)
decimalnine = ipc.testbuttonflag(joy,19)
lastzero = ipc.testbuttonflag(joy,1)
lastfive = ipc.testbuttonflag(joy,0)
frequencywhole = (wholeeight * 800) + (wholenine * 900) + (wholeten * 1000) + (wholeeleven * 1100) + (wholetwelve * 1200) + (wholethirteen * 1300) + (wholefourteen * 1400) + (wholefifteen * 1500) + (wholesixteen * 1600)+ (wholeseventeen * 1700)
frequencydecimal = (decimalzero * 0) + (decimalone * 10) + (decimaltwo * 20) + (decimalthree * 30) + (decimalfour * 40) + (decimalfive * 50) + (decimalsix * 60) + (decimalseven * 70) + (decimaleight * 80) + (decimalnine * 90) + (lastzero * 0) + (lastzero * 5)
frequency = frequencywhole + frequencydecimal
ipc.writeDD(0350,frequency)
ipc.sleep(500)
end
Questions to the code: I know that LUA can handle button numbers 0 - 31. Any ideas what can I do with numbers greater > 31? It would be very useful to handle them as some external applications in windows can without problems...
I am not sure if I have chosen correctly the ipc.writeDD to do the task - right?
The frequency is in the format suitable for offset 0350, I hope I did at least this correctly :razz:
Sorry it the code is unnecessarily complicated, still newbie with LUA.
Thank you again for your time!
Pavel