August 20, 20232 yr Dear community, I am trying to adapt an 8 position rotary switch for the PMDG 747 EFIS range knob. This requires recognizing the direction in which the rotary switch is being turned. Every of the 8 positions has its own Lua script and its own offset. When the switch is turned and reaches a new position, the offset of this position is set to "2". The script then checks if the offset of the position preceding (clockwise) the actual position is also "2" - it would mean the switch has been turned clockwise. This works pretty well, but if I turn the switch too much, I geht jumps and mostly increases where there should be decreases. I am suspecting the internal memory. Do you have any ideas? Best regards, Holger Script for the first position: ipc.writeUB(0x66CA,2) -- setting the offset of the current position to 2 btnstate = ipc.readUB(0x66C9) -- reading the offset of the position before (clockwise) if btnstate == 2 -- if the switch is turned in clockwise direction, the offset has been set to two at the previous detent then ipc.writeUB(0x66C9,1) -- resetting the offset of the previous detent ipc.control(70158,16384) -- command for increasing range else -- if btnstate is not 2 it means the switch has been turned counter clockwise ipc.control(70158,8192) -- command for decreasing range end Script for the second position: ipc.writeUB(0x66CB,2) btnstate = ipc.readUB(0x66CA) if btnstate == 2 then ipc.writeUB(0x66CA,1) ipc.control(70158,16384) -- command for increasing range else ipc.control(70158,8192) -- command for decreasing range end Etc. Holger TillmannSIM: FS9/2004 // FSX<p>CPU: Intel Core i5-4670K 4x3.40GHz (for FSX OCed to 4.2), GPU: ASUS GTX 760 Direct CU II OC, GeForce® 9800 GTX +MB: ASRock Z87 Extreme6 Z87 DDR3RAM: Crucial 4GB PC3-12800 DDR3-1600 CL8 Ballistix Tactical
August 21, 20232 yr Hi Holger, I tried this years ago with SIOC - with no success. The script in itself was okay, like yours, but I/O sometimes skipped switch positions and that blew the script. I ended up with assigning a value to each rotary position and, when switching, storing the previous position in a variable, then I scripted each possible combination and compared the current with the previous position. And it was mandatory to set the rotary in the VC to the position of the hardware switch manually when starting the flight (rotary position 1 = 5NM). That worked, at least most of the time. In SIOC every change of state of a variable (rotary position) would trigger the script. The script would do that (without any syntax): IF [current position = 2] AND [previous position = 1] THEN increase and SET [previous position = 2] IF [current position = 2] AND [previous position = 3] THEN decrease and SET [previous position = 2] IF [current position = 3] AND [previous position = 2] THEN increase and SET [previous position = 3] IF [current position = 3] AND [previous position = 4] THEN decrease and SET [previous position = 3] IF [current position = 4] AND [previous position = 3] THEN increase and SET [previous position = 4] IF [current position = 4] AND [previous position = 5] THEN decrease and SET [previous position = 4] and so on. I think you get the picture. I still needed to move the rotary slowly and only one step at a time. Boris
August 22, 20232 yr Author Thank you, Boris. Yes, I get what you mean. I have to say that I don't have this problem with the FSLabs bus, so this problem may be PMDG related.I will experiment a bit with pause commands ("sleep") and see how this works. Holger TillmannSIM: FS9/2004 // FSX<p>CPU: Intel Core i5-4670K 4x3.40GHz (for FSX OCed to 4.2), GPU: ASUS GTX 760 Direct CU II OC, GeForce® 9800 GTX +MB: ASRock Z87 Extreme6 Z87 DDR3RAM: Crucial 4GB PC3-12800 DDR3-1600 CL8 Ballistix Tactical
August 23, 20232 yr Author Update: I also experienced this problem in FSLabs. I have opened a thread in the FSUIPC forum:https://forum.simflight.com/topic/97821-possible-problem-writing-into-free-custom-fsuipc-offsets/ Holger TillmannSIM: FS9/2004 // FSX<p>CPU: Intel Core i5-4670K 4x3.40GHz (for FSX OCed to 4.2), GPU: ASUS GTX 760 Direct CU II OC, GeForce® 9800 GTX +MB: ASRock Z87 Extreme6 Z87 DDR3RAM: Crucial 4GB PC3-12800 DDR3-1600 CL8 Ballistix Tactical
Archived
This topic is now archived and is closed to further replies.