Jump to content
The simFlight Network Forums

Bertieb1

Members
  • Posts

    11
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling
  • Location
    London

Bertieb1's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. have you enabled the "select special mode" for NGX in SPAD that may solve your problems? Also have you tried setting the AT off setting for the release of the joy button? If not try getting a list of all the L:Vars by binding a joy button to the "List Local Panel Vars". Once you've identified the correct L:Var, write a Lua script to bind to the AT switch to toggle on and off :).
  2. Folks, my stab at a multi panel script. Add it to your auto section or a key press if you want. It its not consistent throughout but I apologise, but this is a first stab at me empirically learning to use Lua and FSUIPC. Rob 777.txt
  3. Folks, I've just extracted the gauge macro from my favourite aircraft and trying to code the heading select. I want to convert this into a Lua code. I can extract the L:Vars. (L:APhdgSelectBug, degrees) (A:MAGVAR, degrees) 0 (L:headingRefSelect, number) ? + d360 flr (>L:HeadingWindowValue, degrees) Anyone had experience with the syntax? Cheers Rob
  4. I don't know yet, I'm at work at the moment, I will finish at midnight and be home by 1am. I'll have a fiddle and come back to you.... thanks for taking a look.
  5. Pete, sorry it was linked to my previous post. I've had about 5 hours sleep following a night duty so I'm basically coding sleep drunk :). My Saitek multi panel has a "changer" (I can't think of a better word for it) which selects ALT/IAS/HDG/CRS/VS. This comes back as bits from 1 to 5. Changer = {1,2,3,4,5} There is a knob which adjust each of the values, there is also a trim adjustment also. Rotaries = {6,7,19,20} Plus hold/indication buttons for AP/HDG/NAV/BACK/APR/VS. (I haven't started work on those yet) Plus flap/auto throttle, but I've not started work on those as I think they will be fairly straight forward. I've looked at your rotaries script which if I adapt I think will do the job. I have managed to do everything I wanted to do via joybuttons using an adapted version of your HIDDEMO. However, I don't really want to be opening and killing lua scripts; as you right have pointed out, its messy as hell. Your rotaries script takes account of speed of turn, which joybuttons in HIDDEMO doesn't seem to do. I can read the buttons of the multi panel, which is presented as a DWORD. I want to do the following: - Initalise Poll the device, grab the DWORD value Determine what position the changer is in. Record it in an offset and store it. Determine what position the auto throttle device is in. Record it in an offset and change the controls in FSX Go into a polling loop On button press Determine which button has been pressed If it is the changer, record it in an offset. If it is the value knob, read the changer offset then change the appropriate value using L:Vars or appropriate ipc.control If it is the trim control change the appropriate value using L:Vars or appropriate ipc.control If it is a button/autothrottle/flaps change the appropriate value using L:Vars or appropriate ipc.control I know that the ipc.control offsets are, I know what the L:Vars are and I know the logic I need to use them. Its just dealing with reading what button is being actually being pushed. Its as simple as that. Obviously the changer/buttons/autothrottle/flaps don't required slow/fast turn bits so I can trim that out. I think I'm on the right track with this script. I have just had an epiphany, that when the changer has turned, two bits per turn has toggled. So if I turn from ALT to HDG, the bit for ALT needs to be turned off and the bit for HDG needs to be turned on. This is why I was seeing two bit changes. :oops:
  6. Okay, i'm having another attack of the stupids....... Rotaries = {6,7,19,20} Changer = {1,2,3,4,5} Pushbuts = {8,9,10,11,12,13,14,15} Spring = {17,18} Switch = {16} function poll(Time) -- read any data available from the device (only need most recent report) data, n = com.readlast(dev, rd) if n ~= 0 then -- Data was returned, so get the status of all the possible "buttons" we are using -- one value of 32 bits Buttons = com.gethidbuttons(dev, data) -- See if any changes occurred: Diff = logic.Xor(Buttons, PrevButtons) PrevButtons = Buttons ipc.log(Buttons) ipc.log("Diff: " .. Diff) if Diff ~= 0 then offset = 0x3340 buttonbit = 1 j = 1 while Rotaries[j] ~= nil do mask = logic.Shl(1, Rotaries[j]-1) ipc.log("Mask: " .. mask) if logic.And(Diff,mask) ~= 0 then ipc.log("Change fired") -- This one changed -- See if changed in less than the "boundary" time thisbutton = buttonbit if (LastTimes[j] ~= nil) and ((Time - LastTimes[j]) < FastTimeLimit) then thisbutton = buttonbit + buttonbit -- Use next higher button for fast end LastTimes[j] = Time -- Toggle a virtual button accordingly ipc.togglebitsUB(offset, thisbutton) end j = j + 1 buttonbit = 4 * buttonbit if logic.And(j,15) == 0 then buttonbit = 1 offset = offset + 4 end end buttonbit = 1 j = 1 while Changer[j] ~= nil do mask = logic.Shl(1, Changer[j]-1) ipc.log("Mask: " .. mask) if logic.And(Diff,mask) ~= 0 then ipc.log("Changer fired") ipc.clearbitsUB(offset,1) ipc.clearbitsUB(offset,2) ipc.clearbitsUB(offset,4) ipc.clearbitsUB(offset,8) ipc.clearbitsUB(offset,16) -- This one changed -- See if changed in less than the "boundary" time ipc.log("Button bit: " .. buttonbit) thisbutton = buttonbit -- if (LastTimes[j] ~= nil) and ((Time - LastTimes[j]) < FastTimeLimit) then --thisbutton = buttonbit + buttonbit -- Use next higher button for fast -- end -- LastTimes[j] = Time -- Toggle a virtual button accordingly ipc.togglebitsUB(offset, thisbutton) end j = j + 1 buttonbit = 4 * buttonbit if logic.And(j,15) == 0 then buttonbit = 1 offset = offset + 4 end end end end end event.timer(Pollrate, "poll") For some reason when I turn the changer button I'm getting duplicate toggling of the virtual buttons... I think that I'm not clearing the bits properly from the last change.... anyone have any ideas? 861313 LUA: 1 861313 LUA: Diff: 9 861313 LUA: Mask: 32 861313 LUA: Mask: 64 861313 LUA: Mask: 262144 861313 LUA: Mask: 524288 861313 LUA: Mask: 1 861313 LUA: Changer fired 861469 LUA: Button bit: 1 861500 LUA: Mask: 2 861516 LUA: Mask: 4 861516 LUA: Mask: 8 861516 LUA: Changer fired 861672 LUA: Button bit: 64 861703 LUA: Mask: 16 Anyone help a lua newbie out?
  7. Cancel my last, I stopped to think in terms of bits and stopped over complicating it. Sorry guys. 6/7 did the trick.
  8. Sorry to resurrect this thread, but I'm looking to play with the rotaries.lua as well. (Pete if you are reading this, please be gentle buddy, I've just got up following a night shift. I'm trying to get away from opening and killing mini scripts constantly to event driven programming - the way you prefer) I've got a Saitek multi panel, and I can see it in rotaries.lua. The values from the panel appear to be presented as a single DWord. The knob which changes the value for ALT/VS/IAS etc, when turned clockwise or anticlockwise seems to read this as a button press, rather than a specific value. SPAD doesn't remember the position of the knob when I restart, so I'm assuming that SPAD is just recording the number of button presses and gives it a notional position in its GUI. Therefore the knob is simply a record of going clockwise or anticlockwise. -- See if any changes occurred: Diff = logic.Xor(Buttons, PrevButtons) PrevButtons = Buttons ipc.log(Buttons) ipc.log("Diff: " .. Diff) Which gives me this in the log 33208421 LUA: 66 33208421 LUA: Diff: 0 33208453 LUA: 2 33208453 LUA: Diff: 64 33208484 LUA: 2 33208484 LUA: Diff: 0 33208515 LUA: 34 33208515 LUA: Diff: 32 33208546 LUA: 34 In my mind this is the bits in the dword being toggled. Now, I've done a bit of RTFM, and there needs to be a mask applied to pick up which bits have actually changed. In the rotaries script, I'm assuming generating the mask is done here Rotaries = {} This is where my mind gets broken, I've tried everything in that rotaries I can think of, 20,40 (hex values for 32/64) 32/64. Am I correct in assuming the rotaries array is actually expecting a value passed to it? i.e. The knob is at position 20, the knob is at position 21?
  9. Sorted - I'll sort the error checking and the like later. n = ipc.readLvar("L:ALT_mcpVar") n = n + 1000 ipc.writeLvar("L:ALT_mcpVar", n)
  10. Pete, I read the documentation, my work thus far was from solely your documentation - I didn't quite get the stab of what you meant in your documentation. So I did the RTFM, I just didn't U(nderstand)TFM. I will have a look at Lua Thanks for clarifying this. :)
  11. First post, and I'm a FSUIPC virgin so be gentle. I'm looking to interface my dads SAITEK Multi panel with the Posky 777. I set the rotary switch clockwise it sends the appropriate virtual joystick to FSX. FSUIPC is recognising the button. I've created a macro file and this appears in my list. I've exposed the L:Vars.... I use the set option I.e. L:AP_ALT=Set,9000 this works fine.... it sets the altitude to 9000 When I use the increment L:AP_ALT=Inc,1000 this doesn't work. I've fiddled with the parameter option too... I'm stumped. Any ideas?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.