Skip to content

Instantly share code, notes, and snippets.

@ytsuboi
Created April 5, 2026 01:13
Show Gist options
  • Select an option

  • Save ytsuboi/b33b18f3ca7dce450db1e1c5246c309d to your computer and use it in GitHub Desktop.

Select an option

Save ytsuboi/b33b18f3ca7dce450db1e1c5246c309d to your computer and use it in GitHub Desktop.
Throttle, Mixture and Carb Heat with XPL/Pro
// Throttle, Mixture and Carb Heat for X-Plane
// Need XPL/Pro https://www.patreon.com/posts/introducing-xpl-82145446
// Using with XIAO RP2040 but should be ok with other boards
#include <XPLPro.h>
#define XPLPOTS_MAXPOTS 3
#include <XPLPotentiometers.h>
XPLPro XP(&Serial);
#define PIN_THROTTLE 26 //A0
#define PIN_MIXTURE 29 //A3
#define PIN_CARB_HEAT 27 //A1
void potHandler(int pin, float potValue);
XPLPotentiometers pots(&potHandler);
void setup()
{
Serial.begin(XPL_BAUDRATE);
XP.begin("XPLPro Throttle, Mixture, Carb Heat", &xplRegister, &xplShutdown, &xplInboundHandler);
pots.begin(&XP);
}
void loop()
{
XP.xloop();
pots.check();
}
void xplInboundHandler(inStruct *inData)
{
}
void xplShutdown()
{
}
void xplRegister()
{
pots.clear();
pots.addPin(PIN_THROTTLE, XPLPOTS_DATAREFWRITE, XP.registerDataRef("sim/cockpit2/engine/actuators/throttle_ratio_all"), 10 ,0, 1024, 0, 1);
pots.addPin(PIN_MIXTURE, XPLPOTS_DATAREFWRITE, XP.registerDataRef("sim/cockpit2/engine/actuators/mixture_ratio_all"), 10, 0, 1024, 0, 1);
pots.addPin(PIN_CARB_HEAT, XPLPOTS_DATAREFWRITE, XP.registerDataRef("sim/cockpit2/engine/actuators/carb_heat_ratio"), 10, 924, 306, 0, 1);
}
void potHandler(int inPin, float inValue)
{
switch (inPin)
{
case PIN_THROTTLE :
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment