frumpy Posted December 21, 2017 Report Posted December 21, 2017 (edited) Hi guys, I'm doing some interfacing with buttons, LEDs and switches. I'm almost done programming a MCP testbed. Unfortunately these ones: ixeg/733/autopilot/HDG_bug_inc_90 ixeg/733/autopilot/HDG_bug_dec_90 change the heading by 90°, but I need a command for 1° steps. Also there is no command for the altitude knob! I can use the default X-Plane ones, but thats 10' increments, not hundreds. Besides that, everything seems to work. Could you please add those commands? Thanks, Olli p.s. Sending the command 10 times will take care of the 10' steps^^ But still no help for the heading Edited December 21, 2017 by frumpy Quote
mfor Posted December 21, 2017 Report Posted December 21, 2017 Not sure if this does what you want, but you can set MCP heading (and altitude) by simply writing the values into sim/cockpit/autopilot/heading_mag sim/cockpit/autopilot/altitude Quote
frumpy Posted December 21, 2017 Author Report Posted December 21, 2017 Thanks for answering - thats what I did, but basically it's not usable because the transmission of signals takes too long. It's working almost realtime with the other encoders, but with writing the dataref it's just slow... Quote
mfor Posted December 22, 2017 Report Posted December 22, 2017 (edited) Hmm it's fairly fast for me, do you really need sub-millisecond responses for heading data? Or do you mean on your hardware side? If so it might be possible to create a plugin that exposes a custom command and handles the dataref reads/writes. Edited December 22, 2017 by mfor Quote
frumpy Posted December 22, 2017 Author Report Posted December 22, 2017 (edited) 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: Edited December 22, 2017 by frumpy 2 Quote
Ben Russell Posted December 22, 2017 Report Posted December 22, 2017 Try this one: sim/cockpit2/autopilot/heading_dial_deg_mag_pilot I've personally used it for hardware integration with a GoFlight unit that we used at an FSCon(16?) for a few days with no issues. Should work just fine. Quote
mfor Posted December 22, 2017 Report Posted December 22, 2017 (edited) Edit: Misread what you were saying. From the video it seems like the dataref might not be updated every frame (since then you should be able to move it about 35 (or 25/2) degres per second. In that case try Ben's dataref to see if that is faster. If not what you can do is use some sort of local desired value which you can modify quickly, i.e. don't read the set heading (only at program start or when idle) and just do the calculation on a locally stored value that you then write to the dataref. Edited December 22, 2017 by mfor Quote
frumpy Posted December 22, 2017 Author Report Posted December 22, 2017 No, the encoder sends twice the signals that I need, thats why I use only every second signal. This way one click equals one degree in heading change. The thing is really that the HDG_bug_inc_90 command from the first post should only move by one degree, not 90 - then it would work like the course knob as you see on the video. I'll check Ben's recommendation tonight, however I think I would stil be bound to the time delay due to reading&writing the dataref. Olli Quote
Ben Russell Posted December 22, 2017 Report Posted December 22, 2017 5 minutes ago, frumpy said: No, the encoder sends twice the signals that I need, thats why I use only every second signal. This way one click equals one degree in heading change. The thing is really that the HDG_bug_inc_90 command from the first post should only move by one degree, not 90 - then it would work like the course knob as you see on the video. I'll check Ben's recommendation tonight, however I think I would stil be bound to the time delay due to reading&writing the dataref. Olli I've added; ixeg/733/autopilot/HDG_bug_inc_1 and ixeg/733/autopilot/HDG_bug_dec_1 Functionality as requested. Can't comment as to when it will be available for download but it's in the code... Thanks for your support.. 3 Quote
mfor Posted December 22, 2017 Report Posted December 22, 2017 (edited) See my edited post. I kind of assumed since you can write the datarefs fairly quickly, they would be updated every frame, but apparently that is not the case. A local variable however should be able to solve the problem of reading the previous (old) value and incrementing it, that is assuming that the function is actually called every (other) time you turn the knob. Edit: You can (and should) add acceleration to that variable as well, or wait until you get your hands on the updated version Edited December 22, 2017 by mfor Quote
frumpy Posted December 22, 2017 Author Report Posted December 22, 2017 10 hours ago, Ben Russell said: I've added; ixeg/733/autopilot/HDG_bug_inc_1 and ixeg/733/autopilot/HDG_bug_dec_1 Functionality as requested. That's great news, thank you very much!! That'll make a nice toy. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.