Closed No1sonuk closed 4 months ago
I don't currently own the F16 so I can't take a look unfortunately. If you're familiar with the dcs lua files you may be able to do it yourself. The way each aircraft structures their lua files is different, but you'd probably be looking for an arg number with a name indicating it's the magnetic compass defined somewhere. Then you would just need to add something like this to the end of the file:
F_16C_50:defineFloat("BACKUP_MAGNETIC_COMPASS", arg_number, { 0, 1 }, "Magnetic Compass", "Backup Magnetic Compass")
There also may be multiple args indicating the various degrees of bank and rotation. You might use the ADI as an example and go searching for 17/18 in the luas to see where those args are defined, as the magnetic compass arg is likely defined in the same file. https://github.com/DCS-Skunkworks/dcs-bios/blob/ecc97a9075b84ebb3685ea1bb22e71727053f6fc/Scripts/DCS-BIOS/lib/modules/aircraft_modules/F-16C_50.lua#L539-L540
I DO have the F-16... There's a "standbycompass.lua". It has this in it:
gauge = { heading = { arg_number = 610, input = {0.0, math.pi * 2.0}, output = {0, 1}, },
pitch = { arg_number = 611, input = {-math.pi/2, math.pi/2}, output = {-0.5, 0.5}, },
bank = { arg_number = 612, input = {-math.pi, math.pi}, output = {-1, 1}, } }
So I guess:
F_16C_50:defineFloat("STANDBY_COMPASS_HEADING", 610, { 0, 1 }, "Standby Compass", "Standby Compass Heading")
F_16C_50:defineFloat("STANDBY_COMPASS_PITCH", 611, { -0.5, 0.5 }, "Standby Compass", "Standby Compass Pitch")
F_16C_50:defineFloat("STANDBY_COMPASS_ROLL", 612, { -1, 1 }, "Standby Compass", "Standby Compass Roll")
Looks right to me! Of course I'd recommend testing first to be safe (all the test tools I'm aware of will load from the json files, so if you just drop that in your F16 lua it should regenerate the json files on mission start and you should be able to verify it works)
So it'll update addresses, etc?
Yup. If you put it after all the previous definitions it shouldn't change any of the existing addresses though - just reserve new addresses for the new controls.
The heading works, but it's inverted. Using "int heading = map(newValue, 0, 65535, 360,0);" works, though.
By inverted, do you mean that a heading of 90 outputs 0.75*65535 and a heading of 270 outputs 0.25*65535?
If so, you might just try swapping the range argument in the function call, e.g.
F_16C_50:defineFloat("STANDBY_COMPASS_HEADING", 610, { 1, 0 }, "Standby Compass", "Standby Compass Heading")
I mapped 0-65535 to 0-360 and the course numbers came out wrong. When mapped 0-65535 to 360-0, it came out right. I'll try reversing the range when I get home from work. About 12 hours from now.
The F-16 has a backup magnetic compass on the instrument panel. This data doesn't appear to be available in DCS-BIOS.