kees69
05-20-2014, 06:07 PM
For a friend of mine i try to write a little script that can turn the COM frequency by using a gray type rotary encorder of open cockpits. The script should see in which directory the encoder is turning. If it is turning left, it should generate an other button in FSUIPC then when turning right. I use the virtual Joystick in FSUPIC at the offset $3343.
Now i did write this script:
Var 158 Link IOCARD_ENCODER Input 1 Aceleration 1 Type 2 // input 52 voor Paul
{
L0 = v158
IF L0 > 0
{
&COM1 = setBIT 5 // set bit 5 of joystick COM1 incr
&COM1 = CLEARBIT 6 // clear bit 6 of joystick
}
ELSE
{
&COM1 = setBIT 6 // set bit 6 of joystick COM1 decr
&COM1 = CLEARBIT 5 // clear bit 5 of joystick
}
}
Var 160 name COM1 Link FSUIPC_OUT Offset $3343 Length 4
The script works fine. According to the direction of the encoder, another button in FSUIPC is activated. But The problem is that it will not repeat that button when I keep turning the encoder in the same direction.
eg. If the COM = 120.25 and I turn the encoder to the right, it becomes 121.25. But it doesn't go further. Now when I turn the encoder to the left it goes back to 120.25, but again not further...
Does anybody have a clue on this?
Kind regards,
Kees Schroijen
Now i did write this script:
Var 158 Link IOCARD_ENCODER Input 1 Aceleration 1 Type 2 // input 52 voor Paul
{
L0 = v158
IF L0 > 0
{
&COM1 = setBIT 5 // set bit 5 of joystick COM1 incr
&COM1 = CLEARBIT 6 // clear bit 6 of joystick
}
ELSE
{
&COM1 = setBIT 6 // set bit 6 of joystick COM1 decr
&COM1 = CLEARBIT 5 // clear bit 5 of joystick
}
}
Var 160 name COM1 Link FSUIPC_OUT Offset $3343 Length 4
The script works fine. According to the direction of the encoder, another button in FSUIPC is activated. But The problem is that it will not repeat that button when I keep turning the encoder in the same direction.
eg. If the COM = 120.25 and I turn the encoder to the right, it becomes 121.25. But it doesn't go further. Now when I turn the encoder to the left it goes back to 120.25, but again not further...
Does anybody have a clue on this?
Kind regards,
Kees Schroijen