*** EDIT: SOLUTION FOUND just skip to the post further down viewtopic.php?f=36&t=39021&p=384359#p384387 ***
Having written up the solution here https://forum.flightgear.org/viewtopic.php?f=36&t=38531&start=30#p379310 kindly guided by the community because I'm not great at programming, I've found myself at a stumbling block.
On my interface I have a four position switch for APR VOR MAP PLAN, and I was just changing the property instrumentation/efis/mfd/mode-num to 0,1,2 or 3 using xml protocol from the arduino for that property but as all I see is the switch moving but no update to the radar display so I suspect there's more to it so I dug into the code as previously advised by a very helpful member who wants to remain nameless, but this one is not so straight forward.
to increment or decrement the switch position there are two hotspots in the glareshield.xml that send either:
Boeing747.Efis.ctl_func("display",1); or
Boeing747.Efis.ctl_func("display",-1);
In my new arduino-747.nas file I've got things like the following so I'd like to use the same sort of format, please note that I'm not great with nasal so I'm really after a solid description of the code rather than a theoretical answer, thanks in advance
- Code: Select all
setlistener("input/arduino/ap/ap-dis-but", func(state)
{
if(state.getBoolValue())
{
# AP disengage
Boeing747.afds.input(2,0);Boeing747.afds.ap_update();
}
else {}
},1,0);
With this in mind (or if you know a clever way *and can describe it for a novice* ) how could you trigger either:
Boeing747.EfisR.ctl_func("display",1); or Boeing747.Efis.ctl_func("display",-1); by using an updated property (this bit is easy)
eg two new properties for the two hotspots:
arduino/efis/radar-mode-up
arduino/efis/radar-mode-down
*But the tricky bit* know where the switch position is i.e. APR, VOR, MAP, PLAN (not just that it's 1 or -1).
I suspect there'll be a clever nasal way just to maybe use one property - say an integer (I could create a new property like arduino/efis/radar-mode of value 1 or 2) while also sending the property instrumentation/efis/mfd/mode-num (which can be 0,1,2,3)
here's the section of the efis.nas that receives the 1 or -1
- Code: Select all
elsif(md=="display")
{
var num =me.mfd_mode_num.getValue();
num+=val;
if(num<0)num=0;
if(num>3)num=3;
me.mfd_mode_num.setValue(num);
me.mfd_display_mode.setValue(me.mfd_mode_list[num]);
# for all modes except plan, acft is up. For PLAN,
# north is up.
var isPLAN = (num == 3);
setprop("instrumentation/nd/aircraft-heading-up", !isPLAN);
setprop("instrumentation/nd/user-position", isPLAN);
me.nd_plan_wpt.setValue(getprop("autopilot/route-manager/current-wp"));
me.update_nd_center();
me.update_nd_plan_center();
}
The solution seems tantalisingly close - I might even have stumbled on the solution while typing this up but I can't quite see it, can anyone shed some light?