HELP hw_output_set digital output issue

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
snar5
Posts: 5
Joined: Fri Jan 22, 2021 12:43 am

HELP hw_output_set digital output issue

#1 Post by snar5 »

I'm sure there is something I'm missing but given the code below, I can't seem to get the digital lights to change state(on/off). I really thought during BETA I had this going but for some reason not now.
I have an autopilot button call TURB that when pressed should turn/off an LED.
In the hardware window in AirManager I can use the button to turn it on and off in the sim (X-Plane)
Alson in the hardware window the little lightbulb IS NOT changing. I think here is where I am confused

The "state" prints 0 or 1 in the console window every time its pressed so I'm pretty sure the calls are being made correctly.

Code: Select all

ap_TURB_light = hw_output_add("AP TURB light", false)

xpl_dataref_subscribe("CRJ/autopilot/turb_light","INT", function(state)
   print (state)
       if state then      
        hw_output_set(ap_TURB_light, true)
    else
         hw_output_set(ap_TURB_light, false)
       
    end
 
end)
image.png
I would appreciate any input someone might have as to what is happening. Like I said I thought, but not positive its been months, that I had this working in the beta version.

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: HELP hw_output_set digital output issue

#2 Post by Keith Baxter »

Hi,

A Dataref with type "INT" returns a integer. {0,1,2,3... etc}. Not a boolean "true" ,"false"

Try this.

Code: Select all

ap_TURB_light = hw_output_add("AP TURB light", false)

xpl_dataref_subscribe("CRJ/autopilot/turb_light","INT", function(state)
   print (state)
       if state ==1 then      
        hw_output_set(ap_TURB_light, true)
    else
         hw_output_set(ap_TURB_light, false)
       
    end
 
end)
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

snar5
Posts: 5
Joined: Fri Jan 22, 2021 12:43 am

Re: HELP hw_output_set digital output issue

#3 Post by snar5 »

I can't believe I made that mistake! I knew it was something I was doing wrong. Thanks so much. Man I feel stupid for spending so much time on trying to solve it when it was right there!

lol :x

Thank you,
Mark

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: HELP hw_output_set digital output issue

#4 Post by Keith Baxter »

snar5 wrote: Wed Aug 04, 2021 6:06 pm I can't believe I made that mistake! I knew it was something I was doing wrong. Thanks so much. Man I feel stupid for spending so much time on trying to solve it when it was right there!

lol :x

Thank you,
Mark
No worries Mark.


Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Post Reply