ELECTRICAL MASTER BATTERY issues

Peer support for Air Manager desktop users

Moderators: russ, Ralph

Message
Author
Toddimus
Posts: 33
Joined: Wed Feb 17, 2021 6:01 pm

Re: ELECTRICAL MASTER BATTERY issues

#11 Post by Toddimus »

Just to follow up a bit further...

Thanks to @JackZ and @Gilles for looking into it further and apologies to @Ralph for not understanding at first. I did some more testing and found that I can get it to work reliably with v3.3 of the plugin but not v3.4 Beta.

Originally, I had a timer function added in to blink an LED (at a 4 second duty cycle) when the battery voltage dropped below a threshold. That seems to break the whole switch LUA script, which used to work. Also had a user property for engine/battery select that would modify the string to send for either battery 1 or battery 2. I'll save that debugging for another day!

Using this script below, with the v3.3 plugin, I have working Arduino hardware battery switches (and indicator LEDs) working again. Coding with LUA is still weird for me, given the required order of things is not intuitive for me, like "regular" Arduino sketches. That's my problem, not yours. ;) Here's what works for now:

Code: Select all

led1 = hw_output_add("Batt 1 LED", false)

led2 = hw_output_add("Batt 2 LED", false)

function check_val1(val1)
    --print(tostring(val1))
    if (val1 == true) then
        hw_output_set(led1, true)
    else
        hw_output_set(led1, false)
    end
end
function check_val2(val2)
    --print(tostring(val2))
    if (val2 == true) then
        hw_output_set(led2, true)
    else
        hw_output_set(led2, false)
    end
end

fs2020_variable_subscribe("ELECTRICAL MASTER BATTERY:1", "Bool", check_val1)
fs2020_variable_subscribe("ELECTRICAL MASTER BATTERY:2", "Bool", check_val2)

function battery1_switch_callback(pos)
    if(pos == 1) then
    fs2020_variable_write("ELECTRICAL MASTER BATTERY:1", "Bool", true)
    else
    fs2020_variable_write("ELECTRICAL MASTER BATTERY:1", "Bool", false)
    end
end
function battery2_switch_callback(pos)
    if(pos == 1) then
    fs2020_variable_write("ELECTRICAL MASTER BATTERY:2", "Bool", true)
    else
    fs2020_variable_write("ELECTRICAL MASTER BATTERY:2", "Bool", false)
    end
end

hw_switch_add("Battery 1 switch", 1, battery1_switch_callback)
hw_switch_add("Battery 2 switch", 1, battery2_switch_callback)
Now if Microsobo would just fix/expose more of the variables and events, I could add some dimming/de-icing functionality to my hardware cockpit to make those extra switches and knobs do something in the sim!
IMG_6296.jpg
Simstrumentation Instrument developer
Check us out http://www.simstrumentation.com or https://github.com/Simstrumentation/Air-Manager

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: ELECTRICAL MASTER BATTERY issues

#12 Post by Ralph »

I recommend to use the latest beta, which also has support for L variables and H events.

Toddimus
Posts: 33
Joined: Wed Feb 17, 2021 6:01 pm

Re: ELECTRICAL MASTER BATTERY issues

#13 Post by Toddimus »

Ralph wrote: Thu Jun 03, 2021 7:00 pm I recommend to use the latest beta, which also has support for L variables and H events.
Thanks, I'll have to give that a try. I'm assuming you mean the actual Air Manager 4.0 (Beta 40) program, and not the 3.4 Beta plugin. Or would that be required to use the latest Air Manager Beta?
I haven't been following the development posts too much. Would this allow me to get "direct" access from Air Manager to the G1000 soft buttons, instead of using the MobiFlight WASM module to achieve the same goal? If so, that would be great! Less extra processes running in the background is never a bad thing.
Simstrumentation Instrument developer
Check us out http://www.simstrumentation.com or https://github.com/Simstrumentation/Air-Manager

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: ELECTRICAL MASTER BATTERY issues

#14 Post by Ralph »

No not the Air Manager beta, you can just keep the regular 4.0.1 version. Yes you will be able to use H events and L variables.

Post Reply