Hello there!
I'm very new to FSUIPC (order #1342052) and still getting acquainted with this marvellous bit of software. Thank you Pete! So far (as well as the basic stuff like axis assignments) I've managed to program hardware buttons to control some features in A2A aircraft using their published L:Var list. For example, their PA-24 and PA-28 use an S-TEC System 30 autopilot with a 'turn knob' (separate to the HDG knob). I've set up a hardware button to drive this anticlockwise using its L:Var - L:ApTurnKnob. The knob has a range of -50 (full left) to 50 (full right) with 0 of course being the centre position. Therefore it's set as follows...
This works wonderfully and I use another button to turn the knob clockwise.
I also managed to instantaneously centre the knob with a third button using the L:ApTurnKnob=SET action. However, this leads onto my question... I'd love to be able to smoothly centre the knob by pressing a single button using the 'INC' and 'DEC' actions; however, I suspect that a custom Lua function will be necessary for this.
The basic logic would be that if the knob's position was <0 then it should INC until reaching zero, and if its position was >0 then it should DEC until it's at zero. I'm sure this is a pretty simple undertaking, and if anyone could suggest a bit of code that would do this, I'd be very grateful. It's a rather trivial little thing I know, but it should help get me started with some simple Lua programming and the basic syntax etc. (I'm completely new to Lua but have worked with Visual Basic a bit.)
Thanks,
Nick
P.S. I also tried using the parameter of 0 in the example pictured above, expecting this would cause the knob to stop at its centred position but it didn't - it's just kept turning. The closest I could get was using a -1 or 1 parameter. Anyway, this is a slight aside as ideally I'd like to be able to just use a single hardware button to centre the knob. ;-)
(...Edited to improve post title.)