April 14, 201115 yr Author Hi Artem,that looks quite impressive!Will test it ASAP... Also looking for someone to write instructions how to set things up.already done:FSUIPC Forum How to install a LUA file or script I will try around to get this work with the MD11...For the NGX: if you wish, we could work together as I could gather the LUA variables (If there are any hopefully) and you could make the LUA script.But maybe there's a brilliant SDK whos helping us then... :( Guenter Steiner -------------------------------------------------------------------------------------- Betatester for: A2A, LORBY, FSR-Pillow Tester --------------------------------------------------------------------------------------
April 14, 201115 yr Commercial Member For the NGX: if you wish, we could work together as I could gather the LUA variables (If there are any hopefully) and you could make the LUA script.But maybe there's a brilliant SDK whos helping us then... :(Hi, GünterWhy not :-) For me it's easier to write a code than to hunt on variables.But let's wait and see what the magic SDK they had prepared for us. Artem Crum, EASA PPL•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••LINDA → Lua Integrated Non-complex Device Assigning•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
April 14, 201115 yr Author Why not :-) For me it's easier to write a code than to hunt on variables.And for me its vice versa... :biggrin:btw you've noted english is not your main language... where are you from if I may ask? (no need to answer!)but maybe we could talk german And I tried now your script:AP dials working great!But the DH and BRG1/2 stuff isn't working right now(will start FS and try again...)One suggestion: could you please add a function to toggle between BRG1 and BRG2?many thanks!!!!! Guenter Steiner -------------------------------------------------------------------------------------- Betatester for: A2A, LORBY, FSR-Pillow Tester --------------------------------------------------------------------------------------
April 14, 201115 yr Commercial Member I'm from Russia, not speaking german at all, sorry.DH and BRG code should work, I'am using this script right now and see no problems. Any error messages in FSUIPC log?Toggle BRG1/BRG2... For now I made the script with idea to assign MCP CTR konb to BRG1 and MCP TFC knob to BRG2 – to visually match the JS41 EFIS. But may be it's a better idea to use MCP CTR knob to control both BRGs and use knob press to toggle between them. Is that what you mean?MCP TFC knob then can be used for both displays' brightness and something else we may need. What do you think?Now I'm working on BARO knob to make it control both BARO and pressurasion panel's Land Level. With toggle on press again. Artem Crum, EASA PPL•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••LINDA → Lua Integrated Non-complex Device Assigning•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
April 14, 201115 yr Author But may be it's a better idea to use MCP CTR knob to control both BRGs and use knob press to toggle between them. Is that what you mean? Yes exactly....But no need to delete the other possibility. Just make different parameters.That is why I have such big gaps between certain parameters: to have space between them to insert code at a later point...And yes, I get a "Thread killed" log message (but LUA script is working afterwards for ALT, HDg etc)Can't fin and error in the script or why it is behaving so...??? Guenter Steiner -------------------------------------------------------------------------------------- Betatester for: A2A, LORBY, FSR-Pillow Tester --------------------------------------------------------------------------------------
April 14, 201115 yr Commercial Member And yes, I get a "Thread killed" log message (but LUA script is working afterwards for ALT, HDg etc)Can't fin and error in the script or why it is behaving so...???Could you please add this lines to your fsuipc.ini:[General]Debug=PleaseLogExtras=x4 And show me several lines from fsuipc.log above and below the "Thread killed" message. Actually I don't see any difference in code between AP ALT and BRG/DH blocks... everything seems the same. Artem Crum, EASA PPL•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••LINDA → Lua Integrated Non-complex Device Assigning•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
April 14, 201115 yr Author Ahhhhhhhhhhhhhhh....damned!I forgot to assign the Button to "LuaValue J41AP" instead of just "Lua J41AP"I haven't seen that difference the whole time.... grrrrrrrmany, many thanks for your help!!!it is working now, of course!!!! Guenter Steiner -------------------------------------------------------------------------------------- Betatester for: A2A, LORBY, FSR-Pillow Tester --------------------------------------------------------------------------------------
April 14, 201115 yr Author Oh, and for the MCP FTC zoom dial switch I have assigned the Flightplan zoom.Normally switched in VC at the WXfake panelHere is te LUA code for it -- zoom outelseif ipcPARAM == 205 then ipc.control(66587,4930) ipc.control(66587,8031)-- zoom inelseif ipcPARAM == 206 then ipc.control(66587,4940) ipc.control(66587,8031) Guenter Steiner -------------------------------------------------------------------------------------- Betatester for: A2A, LORBY, FSR-Pillow Tester --------------------------------------------------------------------------------------
April 14, 201115 yr Commercial Member I forgot to assign the Button to "LuaValue J41AP" instead of just "Lua J41AP"I haven't seen that difference the whole time.... grrrrrrrNice to hear you made it :-)So, what about BRG1/2 - do we really need to put them to one knob or leave it like it is right now? No problem to do it other way, but then will be a little problem with knob rotation direction. I mean that left BRG knob on JS41 rotates counerclockwise and the right BRG - clockwise. When I use both knobs on MCP I set them to work in direction accordingly to JS41 EFIS knobs. And if we gonna use the alternative approach with one rotary on MCP for both BRGs, then we should rotate it in defferent directions for each of BRGs or rotate the same direction, but loosing visual feedback on JS41 knobs. Usability nuances :-)And if we put both of BRGs to one MCP knob, then second MCP knob becomes empty... only display brightness, which is not so interesting :-)upd:Just saw your answer about FPL zoom. Good idea. Artem Crum, EASA PPL•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••LINDA → Lua Integrated Non-complex Device Assigning•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
April 14, 201115 yr Author So, what about BRG1/2 - do we really need to put them to one knob or leave it like it is right now? No problem to do it other way, but then will be a little problem with knob rotation direction. I mean that left BRG knob on JS41 rotates counerclockwise and the right BRG - clockwise. When I use both knobs on MCP I set them to work in direction accordingly to JS41 EFIS knobs. And if we gonna use the alternative approach with one rotary on MCP for both BRGs, then we should rotate it in defferent directions for each of BRGs or rotate the same direction, but loosing visual feedback on JS41 knobs. Usability nuances :-) good point, have't thought about it!but I think you can program it easily (hopefully) that the MCP dial switch will change with every BRG:increasing counterclockwise when in BRG1 mode and increasing clockwise when in BRG2 mode..I think it should be very intuitive for the user and you should get easily used to it, what do you think?And as I said: please don't delete te current code.Just add this to the LUA script as Parameters 80 to 90too sad, that we couldn't get the fitting hardware for every different addon ... :biggrin:But 737NGX and the MCP would be a perfect fitting!!!! Guenter Steiner -------------------------------------------------------------------------------------- Betatester for: A2A, LORBY, FSR-Pillow Tester --------------------------------------------------------------------------------------
April 14, 201115 yr Commercial Member And as I said: please don't delete te current code.Just add this to the LUA script as Parameters 80 to 90Ok. I'll do it later today and post the results. Artem Crum, EASA PPL•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••LINDA → Lua Integrated Non-complex Device Assigning•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
April 14, 201115 yr Commercial Member Made it!Updates:1. Settings (70-80 block) to control both BRGs with one MCP knob, use knob press to toggle between BRG1 and BRG22. Settings (80-90 block) to control ADI&HSI brightness and FPL Zoom with one MCP knob, press to toggle3. Settings (90-100 block) to control BARO and Landing Elev with one MCP knob, press to toggleFor all dual function knob settings current mode is shown in floating LUA window, which disappears automaticaly after a second.Here it is: -- ########################################################### ---- ## VRI MCP Rotaries/Display script v1.0b 14 apr. 2011 ## ---- ## For PMDG JS41 / by Artem Crum, [email protected] ## -- -- ## Based on script originaly written by Guenter Steiner ## ---- ########################################################### ---- WHAT~s FOR-- This script is for controlling PMDG JS41 autopilot rotaries with VRInsight MCP Combo unit-- Script updates MCP display info accordingly to what is set inside the simulator-- !!! ONLY rotaries are programmed here, not the buttons. Use Guenter~s original script for buttons !!!-- HOW TO USE-- bla-bla-bla about setting up the staff... -- to be written by someone whou knows english better than I do ---- 1) BTW Script should be started automaticaly form *ipcReady.lua* file in modules folder-- You should add there something like that: ipc.runlua("pmdg-js41-rotaries.lua")---- 2) In FSUIPC~s Buttons/Switches section the "LuaValue pmdg-js41-rotaries" control should be used-- -- 3) !!! Both press and release settings should be set in FSUIPC for each MCP button !!!-- LuaValue parameters-- Press/Release settings in FSUIPC-------------------------------------- 1/2 - ALT plus-- 3/4 - ALT plus fast-- 5/6 - ALT minus-- 7/8 - ALT minus fast--------------------------------------- 11/12 - HDG plus-- 13/14 - HDG plus fast-- 15/16 - HDG minus-- 17/18 - HDG minus fast--------------------------------------- 21/22 - CRS plus-- 23/24 - CRS plus fast-- 25/26 - CRS minus-- 27/28 - CRS minus fast--------------------------------------- 31/32 - IAS plus-- 33/34 - IAS plus fast-- 35/36 - IAS minus-- 37/38 - IAS minus fast--------------------------------------- 41/42 - VS plus-- 43/44 - VS minus--------------------------------------- 51/52 - EFIS BRG1 plus / ADI Brightnes plus << BRG controls, version with two MCP knobs, -- 53/54 - EFIS BRG1 minus / ADI Brightnes minus << both CTR and TFC -- 55/56 - EFIS BRG2 plus / HSI Brightnes plus-- 57/58 - EFIS BRG2 minus / HSI Brightnes minus-- 59/60 - Toggle BRG / Brightness mode (BRG - default mode)--------------------------------------- 61/62 - EFIS DH plus << While rotating MCP ALT display will show the DH currently set-- 63/64 - EFIS DH plus fast To get back to AP ALT display use 69/70 params and assign them-- 65/66 - EFIS DH minus to MCP DH (MINS) rotary press. -- 67/68 - EFIS DH minus fast-- 69/70 - Update MCP ALT dispay << Returns MCP ALT display to normal mode (shows AP ALT in JS41)--------------------------------------- 71/72 - EFIS BRGs plus << BRG controls, version with one MCP knob -- 73/74 - EFIS BRGs minus << and toggle between BRG1 and BRG2 -- 75/76 - Toggle BRG1 / BRG2 modes--------------------------------------- 81/82 - ADI&HSI Brightness / FPL Zoom plus-- 83/84 - ADI&HSI Brightness / FPL Zoom minus-- 85/86 - Toggle Brightness / Zoom modes--------------------------------------- 91/92 - BARO / Elev plus-- 93/94 - BARO / Elev plus fast-- 95/96 - BARO / Elev minus-- 97/98 - BARO / Elev minus fast-- 99/100 - RARO / Elev toggle--------------------------------------- VRI COM-port settingsif VRImodel == nil then VRIdevice = "COM3" VRIdriver = "COM9"end-- ################################################# ---- ## !!! No user settings below this boundry !!! ## -- -- ################################################# ---- COM port paramsspeed = 115200 handshake = 0 minsize = 8maxsize = 8 -- Tuning fast rotation speedsfast_alt = 10 -- << increment value when rotary in fast mode fast_hdg = 5fast_crs = 5fast_ias = 3fast_dh = 5 -- << Decision heightfast_baro = 10fast_elev = 10 -- << Landing Elevation-- Setting initial varibles valuesefis_brg1 = 0efis_brg2 = 0efis_dh_alt = 5dim = 0 -- << Brightness / BRG togglebaro = 1 -- << BARO / Landing Elev togglebrg = 1 -- << BRG1 / BRG2 togglezoom = 0 -- << Dim / Zoom toggle-- Trying to make a persistent connection to VRI MCPdev = com.open(VRIdevice, speed, handshake)if dev == 0 then ipc.log("Could not open VRIdevice port!") ipc.display("Could not open VRIdevice port!") ipc.sleep(5000)end-- Working with MCP Rotariesfunction JS41dials(param) -- AP ALT Rotary if param > 0 and param < 10 then -- ALT plus if param == 1 or param == 2 then Var = ipc.readLvar("IrcAltSelKnob") if Var > 100 then Var = 1 end ipc.writeLvar("IrcAltSelKnob", Var+1) ipc.control(66587,3921) ipc.control(66587,8031) -- ALT plus fast elseif param == 3 or param == 4 then Var = ipc.readLvar("IrcAltSelKnob") if Var > 100 then Var = 1 end ipc.writeLvar("IrcAltSelKnob", Var+5) for n=1, fast_alt, 1 do ipc.control(66587,3921) end ipc.control(66587,8031) -- ALT minus elseif param == 5 or param == 6 then Var = ipc.readLvar("IrcAltSelKnob") if Var < 1 then Var = 100 end ipc.writeLvar("IrcAltSelKnob", Var-1) ipc.control(66587,3920) ipc.control(66587,8031) -- ALT minus fast elseif param == 7 or param == 8 then Var = ipc.readLvar("IrcAltSelKnob") if Var < 1 then Var = 100 end ipc.writeLvar("IrcAltSelKnob", Var-5) for n=1, fast_alt, 1 do ipc.control(66587,3920) end ipc.control(66587,8031) end -- Updating MCP display -- Only altitude ipc.sleep(50) -- << waiting for FSX data update buffer = ipc.readLvar("L:AltSelAlt")/100 if buffer < 0 then buffer = 0 end com.write(dev, string.format("ALT%03d", buffer), 8) return -- << finishing function execution end -- ############################################################## -- -- AP HDG Rotary if param > 10 and param < 20 then -- HDG plus if param == 11 or param == 12 then ipc.control(66587,26902) ipc.control(66587,8031) -- HDG plus fast elseif param == 13 or param == 14 then for n=1, fast_hdg, 1 do ipc.control(66587,26902) end ipc.control(66587,8031) -- HDG minus elseif param == 15 or param == 16 then ipc.control(66587,26901) ipc.control(66587,8031) -- HDG minus fast elseif param == 17 or param == 18 then for n=1, fast_hdg, 1 do ipc.control(66587,26901)end ipc.control(66587,8031) end -- Updating MCP display -- Only heading ipc.sleep(150) -- << waiting for FSX data update buffer = ipc.readLvar("L:HDGBug") com.write(dev, string.format("HDG%03d", buffer), 8) return -- << finishing function execution end -- ############################################################## -- -- AP CRS Rotary if param > 20 and param < 30 then -- CRS plus if param == 21 or param == 22 then ipc.control(66587,26702) ipc.control(66587,8031) -- CRS plus fast elseif param == 23 or param == 24 then for n=1, fast_crs, 1 do ipc.control(66587,26702) end ipc.control(66587,8031) -- CRS minus elseif param == 25 or param == 26 then ipc.control(66587,26701) ipc.control(66587,8031) -- CRS minus fast elseif param == 27 or param == 28 then for n=1, fast_crs, 1 do ipc.control(66587,26701) end ipc.control(66587,8031) end -- No need to send data to MCP here, just exiting return -- << finishing function execution end -- ############################################################## -- -- AP IAS Rotary if param > 30 and param < 40 then -- IAS plus if param == 31 or param == 32 then ipc.control(66587,26802) ipc.control(66587,8031) -- IAS plus fast elseif param == 33 or param == 34 then for n=1, fast_ias, 1 do ipc.control(66587,26802) end ipc.control(66587,8031) -- IAS minus elseif param == 35 or param == 36 then ipc.control(66587,26801) ipc.control(66587,8031) -- IAS minus fast elseif param == 37 or param == 38 then for n=1, fast_ias, 1 do ipc.control(66587,26801) end ipc.control(66587,8031) end -- No need to send data to MCP here, just exiting return -- << finishing function execution end -- ############################################################## -- -- AP VS Rotary if param > 40 and param < 50 then -- VS inc if param == 41 or param == 42 then buffer = ipc.readLvar("L:VSIASTarget") Var = ipc.readLvar("L:AP_PitchWheel") ipc.writeLvar("AP_PitchWheel", Var+10) ipc.writeLvar("L:VSIASTarget", buffer+100) ipc.control(65894) ipc.control(66587,8031) ipc.sleep(40) com.write(dev, string.format("DSP_%04d", buffer), 8) -- VS dec elseif param == 43 or param == 44 then buffer = ipc.readLvar("L:VSIASTarget") Var = ipc.readLvar("L:AP_PitchWheel") ipc.writeLvar("AP_PitchWheel", Var-10) ipc.writeLvar("L:VSIASTarget", buffer-100) ipc.control(65895) ipc.control(66587,8031) ipc.sleep(40) com.write(dev, string.format("DSP_%04d", buffer), 8) end return -- << finishing function execution end -- ############################################################## -- -- EFIS BRG Rotaries (version 1 --> with two MCP knobs, both CTR and TFC) if param > 50 and param <= 60 then -- BRG1 plus if param == 51 or param == 52 then -- Normal (BRG) mode if dim == 0 then efis_brg1 = efis_brg1 - 1 if efis_brg1 < 0 then efis_brg1 = 0 end ipc.writeLvar("L:LeftBearingCircleKnob", efis_brg1) ipc.control(66587,220) ipc.control(66587,8031) -- Brightness mode else buffer = ipc.readLvar("LeftAdiDimKnob") if buffer < 96 then buffer = buffer + 5 end ipc.control(66587,2210) ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftAdiDimKnob",buffer) end -- BRG1 minus elseif param == 53 or param == 54 then -- Normal (BRG) mode if dim == 0 then efis_brg1 = efis_brg1 + 1 if efis_brg1 > 3 then efis_brg1 = 3 end ipc.writeLvar("L:LeftBearingCircleKnob", efis_brg1) ipc.control(66587,220) ipc.control(66587,8031) -- Brightness mode else buffer = ipc.readLvar("LeftAdiDimKnob") if buffer > 5 then buffer = buffer - 5 end ipc.control(66587,2210) ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftAdiDimKnob",buffer) end end -- BRG2 plus if param == 55 or param == 56 then -- Normal (BRG) mode if dim == 0 then efis_brg2 = efis_brg2 - 1 if efis_brg2 < 0 then efis_brg2 = 0 end ipc.writeLvar("L:LeftBearingDiamondKnob", efis_brg2) ipc.control(66587,223) ipc.control(66587,8031) -- Brightness mode else buffer = ipc.readLvar("LeftHsiDimKnob") if buffer > 5 then buffer = buffer - 5 end ipc.control(66587,21907) ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftHsiDimKnob",buffer) end -- BRG2 minus elseif param == 57 or param == 58 then -- Normal (BRG) mode if dim == 0 then efis_brg2 = efis_brg2 + 1 if efis_brg2 > 3 then efis_brg2 = 3 end ipc.writeLvar("L:LeftBearingDiamondKnob", efis_brg2) ipc.control(66587,223) ipc.control(66587,8031) -- Brightness mode else buffer = ipc.readLvar("LeftHsiDimKnob") if buffer < 96 then buffer = buffer + 5 end ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftHsiDimKnob",buffer) end end -- Toggle to DIM rotary mod and back if param == 59 then dim = 1 ipc.display("Display brightness mode ON",1) elseif param == 60 then dim = 0 ipc.display("Display brightness mode OFF",1) end return -- << finishing function execution end -- ############################################################## -- -- EFIS DH Rotary if param > 60 and param <= 70 then -- DH plus if param == 61 or param == 62 then ipc.control(66587,22111) if efis_dh_alt < 200 then efis_dh_alt = efis_dh_alt + 5 else efis_dh_alt = efis_dh_alt + 10 end if efis_dh_alt > 990 then efis_dh_alt = 990 end -- DH plus fast elseif param == 63 or param == 64 then for n=1, fast_dh, 1 do ipc.control(66587,22111) if efis_dh_alt < 200 then efis_dh_alt = efis_dh_alt + 5 else efis_dh_alt = efis_dh_alt + 10 end end if efis_dh_alt > 990 then efis_dh_alt = 990 end -- DH minus elseif param == 65 or param == 66 then ipc.control(66587,22110) if efis_dh_alt <= 200 then efis_dh_alt = efis_dh_alt - 5 else efis_dh_alt = efis_dh_alt - 10 end if efis_dh_alt < 5 then efis_dh_alt = 5 end -- DH minus fast elseif param == 67 or param == 68 then for n=1, fast_dh, 1 do ipc.control(66587,22110) if efis_dh_alt <= 200 then efis_dh_alt = efis_dh_alt - 5 else efis_dh_alt = efis_dh_alt - 10 end end if efis_dh_alt < 5 then efis_dh_alt = 5 end end -- Updating MCP display to show DH com.write(dev, string.format("ALT%03d", efis_dh_alt), 8) -- Revert to AP ALT display if param == 69 or param == 70 then buffer = ipc.readLvar("L:AltSelAlt")/100 if buffer < 0 then buffer = 0 end com.write(dev, string.format("ALT%03d", buffer), 8) end return -- << finishing function execution end -- ############################################################## -- -- EFIS BRG Rotaries (version 2 --> MCP CTR knob controls both BRGs) if param > 70 and param <= 80 then -- BRG plus if param == 71 or param == 72 then -- BRG1 if brg == 1 then efis_brg1 = efis_brg1 - 1 if efis_brg1 < 0 then efis_brg1 = 0 end ipc.writeLvar("L:LeftBearingCircleKnob", efis_brg1) ipc.control(66587,220) ipc.control(66587,8031) -- BRG2 else efis_brg2 = efis_brg2 + 1 if efis_brg2 > 3 then efis_brg2 = 3 end ipc.writeLvar("L:LeftBearingDiamondKnob", efis_brg2) ipc.control(66587,223) ipc.control(66587,8031) end -- BRG minus elseif param == 73 or param == 74 then -- BRG1 if brg == 1 then efis_brg1 = efis_brg1 + 1 if efis_brg1 > 3 then efis_brg1 = 3 end ipc.writeLvar("L:LeftBearingCircleKnob", efis_brg1) ipc.control(66587,220) ipc.control(66587,8031) -- BRG2 else efis_brg2 = efis_brg2 - 1 if efis_brg2 < 0 then efis_brg2 = 0 end ipc.writeLvar("L:LeftBearingDiamondKnob", efis_brg2) ipc.control(66587,223) ipc.control(66587,8031) end end -- Toggle BRG1 / BRG2 if param == 75 then brg = 2 ipc.display("BRG2 Diamond knob selected",1) elseif param == 76 then brg = 1 ipc.display("BRG1 Circle knob selected",1) end return -- << finishing function execution end -- ############################################################## -- -- Displays~ brightness / FPL Zoom if param > 80 and param <= 90 then -- Plus if param == 81 or param == 82 then -- Zoom mode if zoom == 1 then ipc.control(66587,4930) ipc.control(66587,8031) -- Brightness mode else -- ADI plus buffer = ipc.readLvar("LeftAdiDimKnob") if buffer < 96 then buffer = buffer + 5 end -- ipc.control(66587,2210) ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftAdiDimKnob",buffer) -- HSI plus buffer = ipc.readLvar("LeftHsiDimKnob") if buffer < 96 then buffer = buffer + 5 end ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftHsiDimKnob",buffer) end -- Minus elseif param == 83 or param == 84 then -- Zoom mode if zoom == 1 then ipc.control(66587,4940) ipc.control(66587,8031) -- Brightness mode else -- ADI minus buffer = ipc.readLvar("LeftAdiDimKnob") if buffer > 5 then buffer = buffer - 5 end -- ipc.control(66587,2210) ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftAdiDimKnob",buffer) -- HSI minus buffer = ipc.readLvar("LeftHsiDimKnob") if buffer > 5 then buffer = buffer - 5 end -- ipc.control(66587,21907) ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftHsiDimKnob",buffer) end end -- Toggle to Zoom / Brightness modes if param == 85 then zoom = 0 ipc.display("Brightness mode",1) elseif param == 86 then zoom = 1 ipc.display("Zoom mode",1) end return -- << finishing function execution end -- ############################################################## -- -- BARO / Land Elev if param > 90 and param <= 100 then -- Plus if param == 91 or param == 92 then -- BARO if baro == 1 then currbaro = ipc.readUW(0x330) currbaro = currbaro + 1 ipc.writeUW(0x330, currbaro) -- Elev else ipc.control(66587,1021) end -- Plus fast elseif param == 93 or param == 94 then -- BARO if baro == 1 then currbaro = ipc.readUW(0x330) currbaro = currbaro + fast_baro ipc.writeUW(0x330, currbaro) -- Elev else for n=1, fast_elev, 1 do ipc.control(66587,1021) end end -- Minus elseif param == 95 or param == 96 then -- BARO if baro == 1 then currbaro = ipc.readUW(0x330) currbaro = currbaro - 1 ipc.writeUW(0x330, currbaro) -- Elev else ipc.control(66587,1020) end -- Minus fast elseif param == 97 or param == 98 then -- BARO if baro == 1 then currbaro = ipc.readUW(0x330) currbaro = currbaro - fast_baro ipc.writeUW(0x330, currbaro) -- Elev else for n=1, fast_elev, 1 do ipc.control(66587,1020) end end end -- Toggle to BARO / Elev modes if param == 99 then baro = 0 ipc.display("Land Elev mode",1) elseif param == 100 then baro = 1 ipc.display("BARO mode",1) end return -- << finishing function execution end -- ############################################################## --endevent.param("JS41dials") Artem Crum, EASA PPL•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••LINDA → Lua Integrated Non-complex Device Assigning•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
April 14, 201115 yr Commercial Member Idea for future:We can use "modes" logic for user controlled buttons. Ex.: mode one to control lights and anti-ice systems and mode two to control engine start/stop functions. And we can use MCP's AP Disengage switch to choose the mode (hardware switch is better than button because it's always visible and we definitely know what mode is on right now).Actually we can set any number of modes and not only for user buttons but for whole MCP unit... if we need this somehow. Artem Crum, EASA PPL•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••LINDA → Lua Integrated Non-complex Device Assigning•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
April 15, 201115 yr Author good idea!I haven'T now tested your new LUA but will ASAP and report back!!!many thanks for this!I think we are a good team for any further LUA scriptings Guenter Steiner -------------------------------------------------------------------------------------- Betatester for: A2A, LORBY, FSR-Pillow Tester --------------------------------------------------------------------------------------
April 17, 201115 yr Commercial Member More updates on script:1. New structurePackage now contains two scripts - one small which automaticaly starts the bigger one if PMDG JS41 aircraft selected (based on Word Not Allowed's original script). This made to optimize resource usage when loading any other aircraft and to reload script when reloading JS41. IpcReady.lua should be modified now to run "mcp-init.lua". Second file should be named "pmdg-js41-knobs.lua". If you're updating from the previous version and already made button/swithches assignment in FSUIPC you can change the name of previous lua to the new one in order to not to loose them. See fsuipc.ini [LuaFiles] section and rename there "pmdg-js41-dials" (or what name you did set) to the new one "pmdg-js41-knobs".2. Main if-elseif-end block simplified by putting main code to separate lua functions named by MCP knobs.3. On rotating/pushing SPD knob the MCP display now shows the current JS41 bug selected (V1/Vr/V2/Vyse) and it's speed.4. On rotating VS knob display shows vertical speed set with correct plus/minus sign.mcp-init.lua -- Dispatcher for aircraft specific lua scripts-- Should be started from ipcReady.lua -- add there: ipc.runlua("pmdg-js41-knobs.lua")-- Originaly: -- LUA Script V 1.0-- 25.09.2010-- Word Not Allowed Prokopiu-- Modified:-- 17.04.2011-- Artem Crum-- Purpose: optimization and further development-- Purpose 2: just learning and having fun...ipc.set("VRIdevice", "com3")ipc.set("VRIdriver", "com9")function setAirplane(offset, value) acftname = ipc.readSTR(0x3D00, 35) ipc.log("Aircraft: " .. acftname .. ":") handleName = "Error" ipc.macro("LuaKill pmdg-js41-knobs") ipc.macro("LuaKill pmdg-js41-buttons") if string.find(acftname,"PMDG Jetstream 41",0,true) then handleName = "pmdg-js41" ipc.macro("Lua pmdg-js41-knobs") ipc.macro("Lua pmdg-js41-buttons") else handleName="ms-common" -- ipc.macro("Lua ms-common") end ipc.log("Aircraft type: " .. handleName) ipc.set("aircraftType", handleName)endsetAirplane(0x3D00, "")event.offset(0x3D00, "STR", 99, "setAirplane") ###################################################################################pmdg-js41-knobs.lua -- ########################################################### ---- ## VRI MCP Rotaries/Display script v1.1b 18 apr. 2011 ## ---- ## For PMDG JS41 / by Artem Crum, [email protected] ## -- -- ## Based on script originaly written by Guenter Steiner ## ---- ########################################################### ---- WHAT~s FOR-- This script is for controlling PMDG JS41 autopilot rotaries with VRInsight MCP Combo unit-- Script updates MCP display info accordingly to what is set inside the simulator-- !!! ONLY rotaries are programmed here, not the buttons. Use Guenter~s original script for buttons !!!-- HOW TO USE-- bla-bla-bla about setting up the staff... -- to be written by someone whou knows english better than I do ---- 1) BTW Script should be started automaticaly by mcp-init.lua script---- 2) In FSUIPC~s Buttons/Switches section the "LuaValue pmdg-js41-rotaries" control should be used-- -- 3) !!! Both press and release settings should be set in FSUIPC for each MCP button !!!-- LuaValue parameters-- Press/Release settings in FSUIPC-------------------------------------- 1/2 - ALT plus-- 3/4 - ALT plus fast-- 5/6 - ALT minus-- 7/8 - ALT minus fast--------------------------------------- 11/12 - HDG plus-- 13/14 - HDG plus fast-- 15/16 - HDG minus-- 17/18 - HDG minus fast--------------------------------------- 21/22 - CRS plus-- 23/24 - CRS plus fast-- 25/26 - CRS minus-- 27/28 - CRS minus fast--------------------------------------- 31/32 - IAS plus-- 33/34 - IAS plus fast-- 35/36 - IAS minus-- 37/38 - IAS minus fast-- 39/40 - IAS bug select--------------------------------------- 41/42 - VS plus-- 43/44 - VS minus--------------------------------------- 51/52 - EFIS BRG1 plus / ADI Brightnes plus << BRG controls, version with two MCP knobs, -- 53/54 - EFIS BRG1 minus / ADI Brightnes minus << both CTR and TFC -- 55/56 - EFIS BRG2 plus / HSI Brightnes plus-- 57/58 - EFIS BRG2 minus / HSI Brightnes minus-- 59/60 - Toggle BRG / Brightness mode (BRG - default mode)--------------------------------------- 61/62 - EFIS DH plus << While rotating MCP ALT display will show the DH currently set-- 63/64 - EFIS DH plus fast To get back to AP ALT display use 69/70 params and assign them-- 65/66 - EFIS DH minus to MCP DH (MINS) rotary press. -- 67/68 - EFIS DH minus fast-- 69/70 - Update MCP ALT dispay << Returns MCP ALT display to normal mode (shows AP ALT in JS41)--------------------------------------- 71/72 - EFIS BRGs plus << BRG controls, version with one MCP knob -- 73/74 - EFIS BRGs minus << and toggle between BRG1 and BRG2 -- 75/76 - Toggle BRG1 / BRG2 modes--------------------------------------- 81/82 - ADI&HSI Brightness / FPL Zoom plus-- 83/84 - ADI&HSI Brightness / FPL Zoom minus-- 85/86 - Toggle Brightness / Zoom modes--------------------------------------- 91/92 - BARO / Elev plus-- 93/94 - BARO / Elev plus fast-- 95/96 - BARO / Elev minus-- 97/98 - BARO / Elev minus fast-- 99/100 - RARO / Elev toggle--------------------------------------- ################################################# ---- ## !!! No user settings below this boundry !!! ## -- -- ################################################# --VRIdevice = ipc.get("VRIdevice")VRIdriver = ipc.get("VRIdriver")-- COM port paramsspeed = 115200 handshake = 0 minsize = 8maxsize = 8 -- Tuning fast rotation speedsfast_alt = 10 -- << increment value when rotary in fast mode fast_hdg = 5fast_crs = 5fast_ias = 5fast_dh = 5 -- << Decision heightfast_baro = 10fast_elev = 10 -- << Landing Elevation-- Setting initial varibles valuesprev_mask = 0prev_num = 0efis_brg1 = 0efis_brg2 = 0efis_dh_alt = 5dim = 0 -- << Brightness / BRG togglebaro = 1 -- << BARO / Landing Elev togglebrg = 1 -- << BRG1 / BRG2 togglezoom = 0 -- << Dim / Zoom toggleias_bug = 1ias_v1 = 0ias_vr = 45ias_v2 = 50ias_vy = 55-- Trying to make a persistent connection to VRI MCPdev = com.open(VRIdevice, speed, handshake)if dev == 0 then ipc.log("Could not open VRIdevice port!") ipc.display("Could not open VRIdevice port!") ipc.sleep(5000)end-- Initial dispaly databuffer = ipc.readLvar("L:AltSelAlt")/100com.write(dev, string.format("ALT%03d", buffer), 8)ipc.sleep(50)com.write(dev, "SPD000", 8)ipc.sleep(50)com.write(dev, "DSP0 ", 8)ipc.sleep(50)com.write(dev, "DSP1 ", 8)-- Working with MCP Rotariesfunction JS41dials(param) -- AP ALT Rotary if param > 0 and param <= 10 then AltKnob (param) -- AP HDG Rotary elseif param > 10 and param <= 20 then HdgKnob (param) -- AP CRS Rotary elseif param > 20 and param <= 30 then CrsKnob (param) -- AP IAS Rotary elseif param > 30 and param <= 40 then SpdKnob(param) -- AP VS Rotary elseif param > 40 and param <= 50 then VsKnob (param) -- EFIS BRG Rotaries (version 1 --> with two MCP knobs, both CTR and TFC) elseif param > 50 and param <= 60 then BrgKnobs (param) -- EFIS DH Rotary elseif param > 60 and param <= 70 then MinsKnob (param) -- EFIS BRG Rotaries (version 2 --> MCP CTR knob controls both BRGs) elseif param > 70 and param <= 80 then CtrKnob (param) -- Displays~ brightness / FPL Zoom elseif param > 80 and param <= 90 then TfcKnob (param) -- BARO / Land Elev elseif param > 90 and param <= 100 then BaroKnob (param) endend-- ############################################################## ---- ############################################################## --function HdgKnob (param) -- HDG plus if param == 11 or param == 12 then ipc.control(66587,26902) ipc.control(66587,8031) -- HDG plus fast elseif param == 13 or param == 14 then for n=1, fast_hdg, 1 do ipc.control(66587,26902) end ipc.control(66587,8031) -- HDG minus elseif param == 15 or param == 16 then ipc.control(66587,26901) ipc.control(66587,8031) -- HDG minus fast elseif param == 17 or param == 18 then for n=1, fast_hdg, 1 do ipc.control(66587,26901)end ipc.control(66587,8031) end -- Updating MCP display -- Only heading ipc.sleep(150) -- << waiting for FSX data update buffer = ipc.readLvar("L:HDGBug") com.write(dev, string.format("HDG%03d", buffer), 8)end-- ############################################################## ---- ############################################################## --function AltKnob (param) -- ALT plus if param == 1 or param == 2 then Var = ipc.readLvar("IrcAltSelKnob") if Var > 100 then Var = 1 end ipc.writeLvar("IrcAltSelKnob", Var+1) ipc.control(66587,3921) ipc.control(66587,8031) -- ALT plus fast elseif param == 3 or param == 4 then Var = ipc.readLvar("IrcAltSelKnob") if Var > 100 then Var = 1 end ipc.writeLvar("IrcAltSelKnob", Var+5) for n=1, fast_alt, 1 do ipc.control(66587,3921) end ipc.control(66587,8031) -- ALT minus elseif param == 5 or param == 6 then Var = ipc.readLvar("IrcAltSelKnob") if Var < 1 then Var = 100 end ipc.writeLvar("IrcAltSelKnob", Var-1) ipc.control(66587,3920) ipc.control(66587,8031) -- ALT minus fast elseif param == 7 or param == 8 then Var = ipc.readLvar("IrcAltSelKnob") if Var < 1 then Var = 100 end ipc.writeLvar("IrcAltSelKnob", Var-5) for n=1, fast_alt, 1 do ipc.control(66587,3920) end ipc.control(66587,8031) end -- Updating MCP display -- Only altitude ipc.sleep(50) com.write(dev, "DSP0 ", 8) ipc.sleep(50) -- << waiting for FSX data update buffer = ipc.readLvar("L:AltSelAlt")/100 if buffer < 0 then buffer = 0 end com.write(dev, string.format("ALT%03d", buffer), 8)end-- ############################################################## ---- ############################################################## --function MinsKnob (param) -- DH plus if param == 61 or param == 62 then ipc.control(66587,22111) if efis_dh_alt < 200 then efis_dh_alt = efis_dh_alt + 5 else efis_dh_alt = efis_dh_alt + 10 end if efis_dh_alt > 990 then efis_dh_alt = 990 end -- DH plus fast elseif param == 63 or param == 64 then for n=1, fast_dh, 1 do ipc.control(66587,22111) if efis_dh_alt < 200 then efis_dh_alt = efis_dh_alt + 5 else efis_dh_alt = efis_dh_alt + 10 end end if efis_dh_alt > 990 then efis_dh_alt = 990 end -- DH minus elseif param == 65 or param == 66 then ipc.control(66587,22110) if efis_dh_alt <= 200 then efis_dh_alt = efis_dh_alt - 5 else efis_dh_alt = efis_dh_alt - 10 end if efis_dh_alt < 5 then efis_dh_alt = 5 end -- DH minus fast elseif param == 67 or param == 68 then for n=1, fast_dh, 1 do ipc.control(66587,22110) if efis_dh_alt <= 200 then efis_dh_alt = efis_dh_alt - 5 else efis_dh_alt = efis_dh_alt - 10 end end if efis_dh_alt < 5 then efis_dh_alt = 5 end end -- Updating MCP display to show DH com.write(dev, "DSP0 DH ", 8) ipc.sleep(50) com.write(dev, "DSP1 ", 8) if efis_dh_alt == 5 then com.write(dev, string.format("ALT000", efis_dh_alt), 8) else com.write(dev, string.format("ALT%03d", efis_dh_alt), 8) end -- Revert to AP ALT display if param == 69 or param == 70 then buffer = ipc.readLvar("L:AltSelAlt")/100 if buffer < 0 then buffer = 0 end ipc.sleep(100) com.write(dev, string.format("ALT%03d", buffer), 8) ipc.sleep(50) com.write(dev, "DSP0 ", 8) endend-- ############################################################## ---- ############################################################## ---- back compatibilityfunction BrgKnobs (param) -- BRG1 plus if param == 51 or param == 52 then -- Normal (BRG) mode if dim == 0 then efis_brg1 = efis_brg1 - 1 if efis_brg1 < 0 then efis_brg1 = 0 end ipc.writeLvar("L:LeftBearingCircleKnob", efis_brg1) ipc.control(66587,220) ipc.control(66587,8031) -- Brightness mode else buffer = ipc.readLvar("LeftAdiDimKnob") if buffer < 96 then buffer = buffer + 5 end ipc.control(66587,2210) ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftAdiDimKnob",buffer) end -- BRG1 minus elseif param == 53 or param == 54 then -- Normal (BRG) mode if dim == 0 then efis_brg1 = efis_brg1 + 1 if efis_brg1 > 3 then efis_brg1 = 3 end ipc.writeLvar("L:LeftBearingCircleKnob", efis_brg1) ipc.control(66587,220) ipc.control(66587,8031) -- Brightness mode else buffer = ipc.readLvar("LeftAdiDimKnob") if buffer > 5 then buffer = buffer - 5 end ipc.control(66587,2210) ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftAdiDimKnob",buffer) end end -- BRG2 plus if param == 55 or param == 56 then -- Normal (BRG) mode if dim == 0 then efis_brg2 = efis_brg2 - 1 if efis_brg2 < 0 then efis_brg2 = 0 end ipc.writeLvar("L:LeftBearingDiamondKnob", efis_brg2) ipc.control(66587,223) ipc.control(66587,8031) -- Brightness mode else buffer = ipc.readLvar("LeftHsiDimKnob") if buffer > 5 then buffer = buffer - 5 end ipc.control(66587,21907) ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftHsiDimKnob",buffer) end -- BRG2 minus elseif param == 57 or param == 58 then -- Normal (BRG) mode if dim == 0 then efis_brg2 = efis_brg2 + 1 if efis_brg2 > 3 then efis_brg2 = 3 end ipc.writeLvar("L:LeftBearingDiamondKnob", efis_brg2) ipc.control(66587,223) ipc.control(66587,8031) -- Brightness mode else buffer = ipc.readLvar("LeftHsiDimKnob") if buffer < 96 then buffer = buffer + 5 end ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftHsiDimKnob",buffer) end end -- Toggle to DIM rotary mod and back if param == 59 then dim = 1 ipc.display("Display brightness mode ON",1) elseif param == 60 then dim = 0 ipc.display("Display brightness mode OFF",1) endend-- ############################################################## ---- ############################################################## --function TfcKnob (param) -- Plus if param == 81 or param == 82 then -- Zoom mode if zoom == 1 then ipc.control(66587,4930) ipc.control(66587,8031) -- Brightness mode else -- ADI plus buffer = ipc.readLvar("LeftAdiDimKnob") if buffer < 96 then buffer = buffer + 5 end -- ipc.control(66587,2210) ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftAdiDimKnob",buffer) -- HSI plus buffer = ipc.readLvar("LeftHsiDimKnob") if buffer < 96 then buffer = buffer + 5 end ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftHsiDimKnob",buffer) end -- Minus elseif param == 83 or param == 84 then -- Zoom mode if zoom == 1 then ipc.control(66587,4940) ipc.control(66587,8031) -- Brightness mode else -- ADI minus buffer = ipc.readLvar("LeftAdiDimKnob") if buffer > 5 then buffer = buffer - 5 end -- ipc.control(66587,2210) ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftAdiDimKnob",buffer) -- HSI minus buffer = ipc.readLvar("LeftHsiDimKnob") if buffer > 5 then buffer = buffer - 5 end -- ipc.control(66587,21907) ipc.sleep(5) ipc.control(66587,8031) ipc.writeLvar("LeftHsiDimKnob",buffer) end end -- Toggle to Zoom / Brightness modes if param == 85 then zoom = 0 ipc.display("Brightness mode",1) elseif param == 86 then zoom = 1 ipc.display("Zoom mode",1) endend-- ############################################################## ---- ############################################################## --function BaroKnob (param) -- Plus if param == 91 or param == 92 then -- BARO if baro == 1 then currbaro = ipc.readUW(0x330) currbaro = currbaro + 1 ipc.writeUW(0x330, currbaro) -- Elev else ipc.control(66587,1021) end -- Plus fast elseif param == 93 or param == 94 then -- BARO if baro == 1 then currbaro = ipc.readUW(0x330) currbaro = currbaro + fast_baro ipc.writeUW(0x330, currbaro) -- Elev else for n=1, fast_elev, 1 do ipc.control(66587,1021) end end -- Minus elseif param == 95 or param == 96 then -- BARO if baro == 1 then currbaro = ipc.readUW(0x330) currbaro = currbaro - 1 ipc.writeUW(0x330, currbaro) -- Elev else ipc.control(66587,1020) end -- Minus fast elseif param == 97 or param == 98 then -- BARO if baro == 1 then currbaro = ipc.readUW(0x330) currbaro = currbaro - fast_baro ipc.writeUW(0x330, currbaro) -- Elev else for n=1, fast_elev, 1 do ipc.control(66587,1020) end end end -- Toggle to BARO / Elev modes if param == 99 then baro = 0 ipc.display("Land Elev mode",1) elseif param == 100 then baro = 1 ipc.display("BARO mode",1) endend-- ############################################################## ---- ############################################################## --function CtrKnob (param) -- BRG plus if param == 71 or param == 72 then -- BRG1 if brg == 1 then efis_brg1 = efis_brg1 - 1 if efis_brg1 < 0 then efis_brg1 = 0 end ipc.writeLvar("L:LeftBearingCircleKnob", efis_brg1) ipc.control(66587,220) ipc.control(66587,8031) -- BRG2 else efis_brg2 = efis_brg2 + 1 if efis_brg2 > 3 then efis_brg2 = 3 end ipc.writeLvar("L:LeftBearingDiamondKnob", efis_brg2) ipc.control(66587,223) ipc.control(66587,8031) end -- BRG minus elseif param == 73 or param == 74 then -- BRG1 if brg == 1 then efis_brg1 = efis_brg1 + 1 if efis_brg1 > 3 then efis_brg1 = 3 end ipc.writeLvar("L:LeftBearingCircleKnob", efis_brg1) ipc.control(66587,220) ipc.control(66587,8031) -- BRG2 else efis_brg2 = efis_brg2 - 1 if efis_brg2 < 0 then efis_brg2 = 0 end ipc.writeLvar("L:LeftBearingDiamondKnob", efis_brg2) ipc.control(66587,223) ipc.control(66587,8031) end end -- Toggle BRG1 / BRG2 if param == 75 then brg = 2 ipc.display("BRG2 Diamond knob selected",1) elseif param == 76 then brg = 1 ipc.display("BRG1 Circle knob selected",1) endend -- ############################################################## ---- ############################################################## --function VsKnob (param) -- VS inc if param == 41 or param == 42 then buffer = ipc.readLvar("L:VSIASTarget") Var = ipc.readLvar("L:AP_PitchWheel") ipc.writeLvar("AP_PitchWheel", Var+10) ipc.writeLvar("L:VSIASTarget", buffer+100) ipc.control(65894) ipc.control(66587,8031) ipc.sleep(40) com.write(dev, "DSP0 VS ", 8) if buffer > 0 then com.write(dev, string.format("DSP1%+03d", buffer), 8) else com.write(dev, string.format("DSP1%004d", buffer), 8) end -- VS dec elseif param == 43 or param == 44 then buffer = ipc.readLvar("L:VSIASTarget") Var = ipc.readLvar("L:AP_PitchWheel") ipc.writeLvar("AP_PitchWheel", Var-10) ipc.writeLvar("L:VSIASTarget", buffer-100) ipc.control(65895) ipc.control(66587,8031) ipc.sleep(40) com.write(dev, "DSP0 VS ", 8) if buffer > 0 then com.write(dev, string.format("DSP1%+03d", buffer), 8) else com.write(dev, string.format("DSP1%004d", buffer), 8) end end end-- ############################################################## ---- ############################################################## --function CrsKnob (param) -- CRS plus if param == 21 or param == 22 then ipc.control(66587,26702) ipc.control(66587,8031) -- CRS plus fast elseif param == 23 or param == 24 then for n=1, fast_crs, 1 do ipc.control(66587,26702) end ipc.control(66587,8031) -- CRS minus elseif param == 25 or param == 26 then ipc.control(66587,26701) ipc.control(66587,8031) -- CRS minus fast elseif param == 27 or param == 28 then for n=1, fast_crs, 1 do ipc.control(66587,26701) end ipc.control(66587,8031) end end-- ############################################################## ---- ############################################################## --function SpdKnob (param) -- IAS plus if param == 31 or param == 32 then ipc.control(66587,26802) ipc.control(66587,8031) if ias_bug == 1 then ias_v1 = ias_v1 + 1 com.write(dev, "DSP0V1 ", 8) com.write(dev, "DSP1 ", 8) com.write(dev, string.format("SPD%03d", ias_v1), 8) elseif ias_bug == 2 then ias_vr = ias_vr + 1 com.write(dev, "DSP0Vr ", 8) com.write(dev, string.format("SPD%03d", ias_vr), 8) elseif ias_bug == 3 then ias_v2 = ias_v2 + 1 com.write(dev, "DSP0V2 ", 8) com.write(dev, string.format("SPD%03d", ias_v2), 8) elseif ias_bug == 4 then ias_vy = ias_vy + 1 com.write(dev, "DSP0Vyse", 8) com.write(dev, string.format("SPD%03d", ias_vy), 8) end -- IAS plus fast elseif param == 33 or param == 34 then for n=1, fast_ias, 1 do ipc.control(66587,26802) end if ias_bug == 1 then ias_v1 = ias_v1 + fast_ias com.write(dev, "DSP0V1 ", 8) com.write(dev, "DSP1 ", 8) com.write(dev, string.format("SPD%03d", ias_v1), 8) elseif ias_bug == 2 then ias_vr = ias_vr + fast_ias com.write(dev, "DSP0Vr ", 8) com.write(dev, string.format("SPD%03d", ias_vr), 8) elseif ias_bug == 3 then ias_v2 = ias_v2 + fast_ias com.write(dev, "DSP0V2 ", 8) com.write(dev, string.format("SPD%03d", ias_v2), 8) elseif ias_bug == 4 then ias_vy = ias_vy + fast_ias com.write(dev, "DSP0Vyse", 8) com.write(dev, string.format("SPD%03d", ias_vy), 8) end ipc.control(66587,8031) -- IAS minus elseif param == 35 or param == 36 then ipc.control(66587,26801) ipc.control(66587,8031) if ias_bug == 1 then ias_v1 = ias_v1 - 1 if ias_v1 < 0 then ias_v1 = 0 end com.write(dev, "DSP0V1 ", 8) com.write(dev, "DSP1 ", 8) com.write(dev, string.format("SPD%03d", ias_v1), 8) elseif ias_bug == 2 then ias_vr = ias_vr - 1 if ias_vr < 0 then ias_vr = 0 end com.write(dev, "DSP0Vr ", 8) com.write(dev, string.format("SPD%03d", ias_vr), 8) elseif ias_bug == 3 then ias_v2 = ias_v2 - 1 if ias_v2 < 0 then ias_v2 = 0 end com.write(dev, "DSP0V2 ", 8) com.write(dev, string.format("SPD%03d", ias_v2), 8) elseif ias_bug == 4 then ias_vy = ias_vy - 1 if ias_vy < 0 then ias_vy = 0 end com.write(dev, "DSP0Vyse", 8) com.write(dev, string.format("SPD%03d", ias_vy), 8) end -- IAS minus fast elseif param == 37 or param == 38 then for n=1, fast_ias, 1 do ipc.control(66587,26801) end if ias_bug == 1 then ias_v1 = ias_v1 - fast_ias if ias_v1 < 0 then ias_v1 = 0 end com.write(dev, "DSP0V1 ", 8) com.write(dev, "DSP1 ", 8) com.write(dev, string.format("SPD%03d", ias_v1), 8) elseif ias_bug == 2 then ias_vr = ias_vr - fast_ias if ias_vr < 0 then ias_vr = 0 end com.write(dev, "DSP0Vr ", 8) com.write(dev, string.format("SPD%03d", ias_vr), 8) elseif ias_bug == 3 then ias_v2 = ias_v2 - fast_ias if ias_v2 < 0 then ias_v2 = 0 end com.write(dev, "DSP0V2 ", 8) com.write(dev, string.format("SPD%03d", ias_v2), 8) elseif ias_bug == 4 then ias_vy = ias_vy - fast_ias if ias_vy < 0 then ias_vy = 0 end com.write(dev, "DSP0Vyse", 8) com.write(dev, string.format("SPD%03d", ias_vy), 8) end ipc.control(66587,8031) end -- knob press - Vbug select if param == 39 or param == 40 then ipc.writeLvar("L:IrcIasKnobPush", 1) ipc.control(66587,2681) ipc.control(66587,8031) ipc.sleep(200) ipc.writeLvar("L:IrcIasKnobPush", 0) ipc.control(66587,8031) ias_bug = ias_bug + 1 if ias_bug > 4 then ias_bug = 1 end -- showing current bug selected if ias_bug == 1 then com.write(dev, "DSP0V1 ", 8) com.write(dev, "DSP1 ", 8) com.write(dev, string.format("SPD%03d", ias_v1), 8) elseif ias_bug == 2 then com.write(dev, "DSP0Vr ", 8) com.write(dev, "DSP1 ", 8) com.write(dev, string.format("SPD%03d", ias_vr), 8) elseif ias_bug == 3 then com.write(dev, "DSP0V2 ", 8) com.write(dev, "DSP1 ", 8) com.write(dev, string.format("SPD%03d", ias_v2), 8) elseif ias_bug == 4 then com.write(dev, "DSP0Vyse", 8) com.write(dev, "DSP1 ", 8) com.write(dev, string.format("SPD%03d", ias_vy), 8) end end endipc.log("MCP-JS41-DIALS: loaded")event.param("JS41dials") Artem Crum, EASA PPL•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••LINDA → Lua Integrated Non-complex Device Assigning•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
Create an account or sign in to comment