help with fmc message light

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
smartarze
Posts: 9
Joined: Sat May 02, 2020 3:24 am

help with fmc message light

#1 Post by smartarze »

Hi all I will admit straight away that I'm new to scripting, what I'm trying to achieve is to make an LED light up when the fmc message light illuminates in the sim, I'm using the zibo mod with Xplane. I have spent all day on it and seem more confused than when i started, can't get my head around it.

The dataref for the light is laminar/B738/fmod/fms_message (i think)
Im using arduino mega2560 and the led is connected to A15

If someone could help me out it would give me a starting block to work out some more.

much appreciated

Ian

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: help with fmc message light

#2 Post by Sling »

If you post the code you already started we can help you figure out where you are going wrong.

smartarze
Posts: 9
Joined: Sat May 02, 2020 3:24 am

Re: help with fmc message light

#3 Post by smartarze »

I need sleep! :D

I deleted everything i had to start again as i messed it up so much, this is as far as i've got using samples i found to try and figure it out.

-- This function will be called when new data is available from X-plane
function fmc_message(altitude)
print("fmc_message: " .. altitude)
end

-- subscribe X-plane datarefs on the AirBus
xpl_dataref_subscribe("laminar/B738/fmod/fms_message", "FLOAT", fmc_message)

outp_id = hw_output_add("fmc_message", false)

This is probably all wrong and makes no sense but its updating the console in air manger from 0.0 to 1.0 and back to 0.0 again when i make the message light some on in the sim.

Ian

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: help with fmc message light

#4 Post by Sling »

Ian,

You are almost there. You just need to update the output to toggle your external led.

Notice i’ve posted this code in a code box. Please do this next time as it’s easier for us to read.

Code: Select all

-- This function will be called when new data is available from X-plane
function fmc_message(msg_lt)
print("fmc_message: " .. msg_lt)
local msg_lt_on = fif(msg_lt == 1, true, false)
hw_output_set(outp_id, msg_lt_on)
end

-- subscribe X-plane datarefs on the AirBus
xpl_dataref_subscribe("laminar/B738/fmod/fms_message", "FLOAT", fmc_message)

outp_id = hw_output_add("fmc_message", false)
You’ll also notice I called the callback data msg_lt as this is more meaningful than altitude which has noting to do with this. Other than that all I added was a couple of lines to handle the hardware output updating.

I hope this helps.

Tony

smartarze
Posts: 9
Joined: Sat May 02, 2020 3:24 am

Re: help with fmc message light

#5 Post by smartarze »

thanks Tony

seeing the code i require makes it so much easier to understand, when i did it first time round i did change the altitude but forgot this time round.........It was 5am and i'd been experimenting all night :)

Ian

smartarze
Posts: 9
Joined: Sat May 02, 2020 3:24 am

Re: help with fmc message light

#6 Post by smartarze »

Tony

I have now used the code and fired up the sim, The led comes on as it should but goes out after a few seconds while the msg light in the sim remains lit, I noticed in the dataref tool that the msg light data ref is sending 1.0 then a few seconds later 0.0, this is also the case in the air manager console.

How would i keep the led lit to match the fmc in the sim?

Ian

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: help with fmc message light

#7 Post by Sling »

Hmm,

You would need a data source that matches what the sim is doing unless you can spot a pattern like the light always stays on for a fixed amount longer than what the dataref says. There must be some trigger that makes the sim light turn off. You just need to figure out what it is.

Tony

smartarze
Posts: 9
Joined: Sat May 02, 2020 3:24 am

Re: help with fmc message light

#8 Post by smartarze »

Tony

ok thanks I'll see what i can find

Thanks for your help so far

Very much appreciated

Ian

smartarze
Posts: 9
Joined: Sat May 02, 2020 3:24 am

Re: help with fmc message light

#9 Post by smartarze »

Tony sussed it,

was using the wrong data ref

This is what was required laminar/B738/fmc/fmc_message instead of laminar/B738/fmod/fms_message

This value stays at 1 while the light on the sim fmc is illuminated thus keeping the physical led lit.

The fmod dataref was for the ding sound that occurs when the light comes on, hence the 0.0, 1.0, 0.0

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: help with fmc message light

#10 Post by Sling »

That makes sense. Glad you have it working now :D

Post Reply