Well, the IXEG runs at about 35fps, I assume this is also the frequency the datarefs are updated.
I am using Air Manager v3 as a plugin, I am not too familar with programming. Also due to my
encoder setup, I can only use every second signal. Here is the code:
hdg_counter = 0 -- init
function hdg_dial_change(hdg_direction)
print(tostring(hdg_direction))
hdg_counter = hdg_counter + 1
if hdg_counter == 2 then hdg_counter = 0 -- use every second click
else
if hdg_direction == 1 then
new_hdg=hdg_act+1
xpl_dataref_write("sim/cockpit/autopilot/heading_mag", "FLOAT", new_hdg)
elseif hdg_direction == -1 then
new_hdg=hdg_act-1
xpl_dataref_write("sim/cockpit/autopilot/heading_mag", "FLOAT", new_hdg)
end
end
end
hw_dial_add("ARDUINO_MEGA2560_A_D37", "ARDUINO_MEGA2560_A_D36", hdg_dial_change) -- thats the encoder
function hdg_dtaref(heading)
hdg_act=heading
end
xpl_dataref_subscribe("sim/cockpit/autopilot/heading_mag","FLOAT",hdg_dtaref) -- subscribe to the dataref, save as global variable every time it's changed
I made a video while toying around with it, the Course knob uses a command, the Heading knob the change of dataref: