I am currently building a P28R Cockpit and have just wired up throttle, pitch, and mixture levers.
So far a lot of encoders, switches and potis are working magnificent.
However, I have trouble writing to the datarefs for throttle, mix and pitch.
I feel this is very basic and must have been asked a number of times, yet I was unable to find an answer in the forums and elsewhere, which finally lead to me asking for help here.
Should I have overlooked something, please excuse my oversight.
Okay, now to the point:
The Goal
Moving the three magic levers with my hardware.
What I tried
I am sending a float value, e.g. to the mixture_ratio dataref like this:
Note, that I tried each of them individually, of course.
All other inputs are disconnected.
Code: Select all
percent = 0.6 -- calculated value between 0.00 and 1
xpl_dataref_write("sim/cockpit/actuators/mixture_ratio_all", "FLOAT", {percent})
xpl_dataref_write("sim/cockpit/actuators/mixture_ratio_all", "FLOAT", percent)
xpl_dataref_write("sim/cockpit/actuators/mixture_ratio", "FLOAT[8]", {percent})
xpl_dataref_write("sim/cockpit/actuators/mixture_ratio", "FLOAT[8]", percent)
Code: Select all
xpl_dataref_write("sim/operation/override/override_mixture", "INT", 1)
When I replace the percent value with a hardcoded value to rule out a problem with the hardware the effect remains.
The Symptom
Whenever the value (percent) is lower than 1, e.g. 0.93, the DataRef becomes 0.
So something is transmitted and I can see both the lever jumping to full aft, as well as the DataRef jump to 0.0000 in the DataRef Editor.
When the value is 1 (and only then) the DataRef becomes 1. Again: lever and DataRef jump to the new position.
I have also tested a premade PA28 panel for AM which features those levers and observed the same effect.
Either I do not understand the examples and oversee something very simple or it is more complicated than it seems.
Help would be greatly appreciated
Another thought...
Writing this made me realize that it only works when the value is exactly 1. There are no decimals then, so it is 1 and not 1.00.
In all the other cases it is actually a decimal number. Could it be, that the decimals are simply cut off and e.g. 0.4(...) becomes 0?
Anyways,
Kind regards and many thanks,
Christopher
Edit:
I am running:
x-plane 11.52 on Windows10
AirPlugin 3.2
AirManager 3.7.4 on Ubuntu 20.04