Hello Pete,
I did exactly as you said, using the Liar Lua as a template, and now have the Flight Illusion GSA40 Directional Gyro reporting the magnetic heading and properly possessing the stability of a gyrocompass. Thanks much for your advice! I cut & pasted the code below in case anyone else has this issue (of course, if you see coding glitches or inefficiencies, please comment if you wish.)
-- "spoofMH4TH" is a Lua plug-in for FSUIPC4
-- that spoofs magnetic heading as true heading for FSUIPC clients.
-- Adapted from Pete Dowson's "Liar" Lua by charlie172sierra
-- PROBLEM:
-- Flight Illusion's GSA40 Directional Gyro can only indicate true heading with the desirable
-- characteristic of gyro stability but with the huge drawback of not indicating magnetic heading, OR
-- desirably indicate magnetic heading but with the huge drawback of having all of the lags
-- associated with a whiskey compass.
-- SOLUTION:
-- Use Lua plug-in to read magnetic variation and true heading, compute magnetic heading, and
-- spoof magnetic heading as true heading for Flight Illusion's gauges Control Program V 7.0.8
-- (the FSUIPC client.) Flight Illusion's GSA40 Directional Gyro will then indicate magnetic
-- heading despite "thinking" that it is still indicating the true heading.
-- NOTES:
-- This is a work-around for my inability to enable the encoders on the GSA40 Directional Gyro.
-- Were the encoders enabled, I'd simply adjust the DG heading to match the whiskey compass
-- heading (like compensating for gyro drift.)
-- Flight Illusion's Control Program 7.0.8 identifies true heading as "real heading" in the configuration
-- window for the GSA40.
-- Within FSUIPC (enabled in registered version only), user must define a key press that
-- activates "Lua spoofMH4TH". It may also be desirable to define a different
-- key press that toggles: "LuaToggle spoofMH4TH".
-- ****************** Begin main routine ********************************
-- Loop till flag 0 is set (setting 0 can be done by toggling the Lua off)
while ipc.testflag(0) == false do
-- ***** read magnetic variation & true heading *****
mv, th = ipc.readStruct( 0x02A0, "1SW", 0x0580, "1UD")
-- ***** convert from FS units to aviation units *****
mv = mv * 360 / 65536
th = th * 360 / (65536 * 65536)
-- ***** determine magnetic heading **************
mh = th - mv
-- ***** convert from aviation units to FS units *****
mh = (mh / 360) * (65536 * 65536)
-- ***** spoof magnetic heading as true heading ****
ipc.writeStruct(0x0024,"1UW",0x0580,"1UW",4,"1UD",mh)
-- Sleep for 50 mSecs so the update gets done roughly 20 times per second
ipc.sleep(50)
end
-- ****************** end main routine ********************************
-- Lua was toggled off
-- Now undo the overrides (otherwise they'll take about 12 seconds to die, with frozen values provided!)
ipc.writeStruct(0x0024,"1UW",0x0580,"1UW",0)
Thanks again - FSUIPC helped me resolve a really annoying 3rd party hardware&software issue!
David