Jump to content
The simFlight Network Forums

Recommended Posts

Posted

I have been playing with Air Manager to place monitoring of switches to a tablet, such things as starter, fuel valve, master engine, etch. These switches are being set through either Honeycomb Alpha or Bravo and an HID device. The HID device has 2 rotary switches sending forward and backward pulses. I used the Key Assignment UI to check viability.

The keys section in the FSUIPC7.ini shows:

7=49,13,66058,0     -{lalt+lshift+1: Press=PANEL_LIGHTS_SET }-
8=34,13,66058,0     -{lalt+lshift+PgDn: Press=PANEL_LIGHTS_SET }-
9=37,13,66974,0     -{lalt+lshift+Left: Press=GLARESHIELD_LIGHTS_SET }-
10=39,13,66974,0   -{lalt+lshift+Right: Press=GLARESHIELD_LIGHTS_SET }-

As you well know, MSFS uses indexing which can be handled in FSUIPC7 by using the ipc.execCalcCode("A:LIGHT_POTENTIOMETER:3, Percent").

Air Manager can manipulate switches on a touch screen. It also shows the status of a switch using variable subscriptions.

The Air Manager Lua code to do this is:

fs2020_variable_subscribe("LIGHT POTENTIOMETER:3", "Percent",                  --instrument/panel
                                           "LIGHT POTENTIOMETER:5", "Percent", update)    --glare 

Air Manager uses its event management to also manipulate the MSFS events:

First it sets the knob positions based on the subscribe:

function update(inst, flood)
    --show correct knob positions
    inst_dim_lvl = inst[2]
    flood_dim_lvl = flood[1]
    rotate(inst_lt_knob,  inst_dim_lvl * 300 - 150)
    rotate(flood_lt_knob,  flood_dim_lvl * 300 - 150)
end

The update function manipulates the image. If the image on the touch screen is used, the Air Manager defined image updates the events. The panel (inst image) is defined by:

--instrument light dimmer
inst_lt_knob = img_add("da62 dimmer knob.png", 34, 56, 112, 112)
inst_lt = dial_add(nil, 34, 56, 112, 112, function(dir)
    local new_val = var_cap(inst_dim_lvl + dir * 0.05, 0, 1)
    fs2020_event("K:PANEL_LIGHTS_SET", 1, 1)
    fs2020_event("K:LIGHT_POTENTIOMETER_SET", 3, new_val * 100)
end)

In using my HID device and its knobs, I would like to accomplish the same, left to dim the light, right to brighten the light. I'm almost certain my code will work but have doubts about enlisting a variable in an ipc.execCalcCode("code"). Here is the code I want to use. 

event.key(49,13,1,"PANEL_LIGHTS_SET-") --{lalt+lshift+1: Press=PANEL_LIGHTS_SET  -}-
event.key(34,13,1,"PANEL_LIGHTS_SET+") --{lalt+lshift+1: Press=PANEL_LIGHTS_SET  +}-

function PANEL_LIGHTS_SET-()
    panelneg = ipc.execCalcCode("A:LIGHT_POTENTIOMETER:3, Percent")    
    panelneg = (panelneg * -1)
    panelneg = panelneg - 3
    ipc.execCalcCode("1 (>K:PANEL_LIGHTS_SET, Bool)")        
    ipc.execCalcCode("panelneg (>K:LIGHT_POTENTIOMETER_SET:3, Percent)")            
end

function PANEL_LIGHTS_SET+()
    panelneg = ipc.execCalcCode("A:LIGHT_POTENTIOMETER:3, Percent")    
    panelneg = panelneg + 3
    ipc.execCalcCode("1 (>K:PANEL_LIGHTS_SET, Bool)")        
    ipc.execCalcCode("panelneg (>K:LIGHT_POTENTIOMETER_SET:3, Percent)")            
end

I use the ipc.execCalcCode due to the indexing. The glareshield light uses  ipc.execCalcCode("glareneg (>K:LIGHT_POTENTIOMETER_SET:5, Percent)").

Thanks for your time.

Posted
11 hours ago, DaveSCUSA said:

    panelneg = ipc.execCalcCode("A:LIGHT_POTENTIOMETER:3, Percent")    

This will not work - you cannot get a return value from ipc.execCalcCode. If you want to read a value of a simvar/a-type variable, you have to add this to an offset and read the value from the offset. You can add any simvar to a free FSUIPC offset using the facilities described in section Adding Simulator variables (simvars) to FSUIPC offsets on page 34 of the Advanced User guide.

Also this is incorrect:

12 hours ago, DaveSCUSA said:

    ipc.execCalcCode("panelneg (>K:LIGHT_POTENTIOMETER_SET:3, Percent)")            

This will try to write the string "panelneg", whereas you want to use the value of the variable, and there is no indexing on events, but you can use two parameters like this:

    ipc.execCalcCode(panelneg .." (>K:3:LIGHT_POTENTIOMETER_SET)")

Otherwise, maybe try
    ipc.execCalcCode(panelneg .." (>K:LIGHT_POTENTIOMETER_3_SET)")

It may be easier to define a couple of presets to inc/dec the panel lighting brightness and assign to these. What aircraft are you using? Maybe there is a preset already available...

John

Posted

Thank you John,

As I said, I am using Air Manager to detect switch positions delivered to MSFS from a keypad.

The AM code is from a series of AM instruments for the Diamond DA62. They are available to purchase (AU$28).

For consistency,  I want to use the same MSFS  variables, events in the Lua used to read the keypad with keypress combinations.

There is a potentiometer control but I can't figure out how to tell the control which potentiometer (glareshield and instrument). Could you point out how?

The MSFS indexes show which electrical connection.

Thanks

 

Posted

On the MF HubHop site there are 3 pot. controls - two for lights (flood and instrument) and one for rudder trim:

image.thumb.png.05bc8104f41d207d4c01f19c149b5c86.png

Take a look at these - and also the comments (w.r.t calibration and animation). You can define your own presets based on these for your axis values. Take a look and try to define your own presets based on these (i.e. change to use the values that your axis is sending). Please try, if you have problems let me know and I can provide a preset/calc code for standard axes values (-16834 to + 16833).

John

Posted

Thanks. Can global variables or LVars in Lua be shared between Air Manager logic (in Lua) and FSUIPC7 Lua. FSUIPC7 compiles on the fly. Air Manager compiles when a panel is shown (executed). Does not need the sim to be running.

I can figure how to code to tell when both are running.

Posted
34 minutes ago, DaveSCUSA said:

Can global variables or LVars in Lua be shared between Air Manager logic (in Lua) and FSUIPC7 Lua. FSUIPC7 compiles on the fly

No. Lua global variables are only visible to lua scripts started by FSUIPC.

I don't know anything about Air Manager, only FSUIPC. 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.