FlightSImparts.eu
www.FlightSimParts.eu  Flight Simulation, Electronics, Ideas, How To’s, Interesting Articles
Belgium
Shopping pages
XPLane direct plugin, communicates with Xplane directly from Arduino new version available on patreon/curiosityworkshop
More info about this article and curiosity workshop on Patreon.com Last week I came across a new plugin for XPLane and did some tests which were simply wonderfull. Writing minimal code and controlling datarefs and sending commands to XPlane 11. Datarefs can be read, write or readwrite. You can add a series of datarefs to query in combination with commands if you like. My tests involved reading the state of the beacon switch (sample code included with the download) and reading the NAV and COM frequencies out of XPLane and display them on my MicroDrivers. First the included sample, reading the beacon switch state. #include <arduino.h> #include <XPLDirect.h> // include file for the X-plane direct interface XPLDirect Xinterface(&Serial); // create an instance of it //in setup Serial.begin(XPLDIRECT_BAUDRATE); // start serial interface, dont change Xinterface.begin("Xplane Demo"); // needed for initialization //the dataref you want to query Xinterface.registerDataRef("sim/cockpit2/switches/beacon_on", XPL_READ, 100, 0, &beacon); //in the loop you need to add following, needs to run every cycle Xinterface.xloop(); In the loop part you can do whatever you would like to do, simple normal Arduino code, nothing fancy. My second try was retrieving the NAV data out of XPLane via the plugin and display these on my MicroDrivers. I used previously created code (available on the website) to drive the MicroDrivers and added the above code to adapt and send the retrieved values to the displays. It was very direct and simple, change the frequency in XPlane and the result was immediately visible on the MicroDrivers without any lag. Apart from the code above the only thing needed was uncomment the serial communication and add the line ToDisplay.A = nav1_stb; that is all. ToDisplay.A = nav1_stb; ToDisplay.B = nav1;
To get the plugin and Arduino library please go to Patreon/curiosityworkshop To receive the Arduino sketch for NAV displays, request it at