SkyCamel Posted April 10, 2023 Report Posted April 10, 2023 I'm trying to program my VRInsight MCP v1 buttons and rotary encoders without the use of LINDA. What I want to achieve is that I can use one rotary encoder for different function by setting a timed flag. In LINDA they use a button on the MCP to switch to different modes (1,2,3) by pressing repeatedly one button. The MCP will stay in the selected mode as long as you're operating a button or rotary encoder and will reverse to mode 1 after a preset delay if nothing is happening on the MCP. I found in Advanced User Guide that it is possible to set a flag by pressing a button and make this a condition for another button's function, but it's not clear how to do that for rotary encoders and how to have a timer as condition. Does anyone know/can help me to achieve what I described above? Cheers, Luc
John Dowson Posted April 10, 2023 Report Posted April 10, 2023 3 hours ago, SkyCamel said: I found in Advanced User Guide that it is possible to set a flag by pressing a button and make this a condition for another button's function, but it's not clear how to do that for rotary encoders and how to have a timer as condition. Does anyone know/can help me to achieve what I described above? Do the rotary encoders use buttons or are they an axis? If they are buttons, you can use the conditional format as explained in the Advanced User guide. However, you cannot use conditional assignments for axes, and there is not concept of times in standard assignments, so for both of these you would have to use a lua script. You would need to use the event.button function to handle the button presses, and you can use the ipc.elapsedtime function to get the timestamps if the button presses to determine the time between button presses to determine what mode you are in. You could also use the event.timer function to check and time-out the current mode. If the rotary encodes use an axis, then you can assign these to write the axis value to an FSUIPC offset, and then pick-up this value in an event.offset handling function. Take a look at the Lua Library document for a description on how to use these functions, and maybe some of the example lua scripts provided (in your FSUIPC7 Documents folder) - maybe the TripleUse.lua as this does different things based upon the period between button presses - and/or maybe take a look un the User Contributions section to see if there is anything there that you can adapt to your needs. I can't write this script for you, but I can help if you get stuck or have any issues. John
SkyCamel Posted April 11, 2023 Author Report Posted April 11, 2023 These are recognized by FSUIPC7 as buttons, P256,21 slow clockwise, P256,20 fast clockwise and than P256, 23 or P256,22 counter clockwise. I could use the push button of the encoder to set a flag to change the function of the encoder, but I would like to find a way so that it will automatically revert back to the initial function, basically automatically resetting the flag, hence the timer condition. I looked into the Lua programming and examples but I fear that will be way over my pay grade 😉 On top of it, the function I need is a "Preset Control" which I'm not very clear if that would even be possible with Lua. Anyhow, I will try to figure something out Cheers Luc
John Dowson Posted April 12, 2023 Report Posted April 12, 2023 22 hours ago, SkyCamel said: I could use the push button of the encoder to set a flag to change the function of the encoder, but I would like to find a way so that it will automatically revert back to the initial function, basically automatically resetting the flag, hence the timer condition. When you set the flag to change the state id the encoder, also store the time using ipc.elapsedtime(). In the function that handles the rotary button presses, you can again get the elapsedtime and check the difference between thus and the mode flag change, and if greater than a certain amount then chage the mode back and then oerform the action based upon the mode. You can also reset the mode elapsedtime flag if still not in the default mode, so it would only switch back to the default/noirmal mode after a certain periond of inactivity. 22 hours ago, SkyCamel said: On top of it, the function I need is a "Preset Control" which I'm not very clear if that would even be possible with Lua. You can activate presets in lua by writing the preset name to offset 0x7C50 using ipc.writeSTR. Note the preset name should ne preceded by P: and the preset name should be as written in the events.txt file, i.e. usually with underscores '_' and not spaces, as they are shown in the preset assignment menu. 23 hours ago, SkyCamel said: I looked into the Lua programming and examples but I fear that will be way over my pay grade 😉 Give it go, show me what you come up with and I can correct it for you. John
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now