Jump to content
The simFlight Network Forums

ccb777

Members
  • Content Count

    6
  • Joined

  • Last visited

Posts posted by ccb777


  1. Hi Frank.

     

    From what you describe, it sound like the same problem I encountered.

    What I noticed when connecting via a LUA script was that all of the events that I was monitoring would be called on startup and the resulting values were sent from LUA to Arduino.

    I was only receiving a half dozen or so of these messages on the Arduino side. The rest were either lost or corrupt. After startup and things settled down, everything worked fine.

    I send all of my com writes via my own function and log what I send to a text file. I could then see exactly what was sent to the Arduino card. The bottom line was, I was loosing a lot of messages at startup. (Buffer overflow.)

    I resolved this by doing two things.

    First, Increased the buffers size on the Arduino card.

    Second, I introduced a delay in my ComWrite function of 300 ms for the first 20 seconds after startup. I use a delay of 50 ms thereafter.

    This allowed the Arduino card to keep pace with LUA on startup.

    Hope this helps,

    Chris.

     


  2. Hi Father Dane,

    The following LUA code will do what you require.

    Just copy and paste it into Notepad and save the file with a .lua extension. eg: 'PMDG_737_NGX_IRS.lua'

    The file needs to be placed in you Modules folder for FSUIPC to see it.

     

    You will then be able to assign this lUA script to a switch, or as many switches as you like, in the usual way.

    It will be listed as 'Lua PMDG 737 NGX IRS'

    You need to set the Parameter option to select what you wish it to do.

    Parameter of 10 will set the Left IRS to OFF

    Parameter of 12 will set the Left IRS to NAV

    The script doesn't care where the IRS switch is currently at, it just moves it from there to the required position.

    Other Parameters are listed at the top of the lua script. Any invalid Parameter will just be ignored.

     

    I have only tested this in FSX as I do not have the NGX for P3d,  though I see no reason why it would not work in P3D.

     

    Hope this helps.

     

    Chris.

     

    --	Parameters to send via FSUIPC
    
    --	10	-	Left IRS OFF
    --	11	-	Left IRS ALIGN
    --	12	-	Left IRS NAV
    --	13	-	Left IRS ATT
    --	20	-	Right IRS OFF
    --	21	-	Right IRS ALIGN
    --	22	-	Right IRS NAV
    --	23	-	Right IRS ATT
    
    PMDGBaseVar = 	0x00011000		-- 69632
    PMDG_ClkL = 	0x20000000		-- 536870912
    PMDG_ClkR = 	0x80000000		-- -2147483648
    
    function Left_IRS(New_Pos)
    	local Current_Pos = ipc.readLvar ('ngx_switch_255_a') /10
    	while New_Pos > Current_Pos do
    		ipc.control(PMDGBaseVar + 255, PMDG_ClkR)
    		Current_Pos = Current_Pos + 1
    	end
    	while New_Pos < Current_Pos do
    		ipc.control(PMDGBaseVar + 255, PMDG_ClkL)
    		Current_Pos = Current_Pos - 1
    	end
    end
    
    function Right_IRS(New_Pos)
    	local Current_Pos = ipc.readLvar ('ngx_switch_256_a') /10
    	while New_Pos > Current_Pos do
    		ipc.control(PMDGBaseVar + 256, PMDG_ClkR)
    		Current_Pos = Current_Pos + 1
    	end
    	while New_Pos < Current_Pos do
    		ipc.control(PMDGBaseVar + 256, PMDG_ClkL)
    		Current_Pos = Current_Pos - 1
    	end
    end
    
    MyPosition = ipcPARAM - 10
    IRS = 1
    
    if MyPosition > 9 then
    	MyPosition = MyPosition - 10
    	IRS = 2
    end
    
    if MyPosition >= 0 and MyPosition < 4 then
    	if IRS == 1 then
    		Left_IRS (MyPosition)
    	elseif IRS == 2 then
    		Right_IRS (MyPosition)
    	end
    end

     

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.