Hello. I am building my second switch panel for x-plane. My first switch panel has 4 switches and 5 encoders and works fine.
The new panel has 14 switches with 30 possible switch settings . My first 12 switch settings work but the rest don't. After a lot of experimentation I've discovered that only the first 12 FlightSimCommands work. If I move other switch commands to be one of the first 12, they will now work and anything past the 12th command does not work. If I swap the order of the IF statements within the Loop there is no change.
I've put Serial.println statements into the IF statements to insure the program is working. I can see that the execution occurs (the IF is executed when the switch is changed), but the command does not show up on x-plane when using Show Communications although I can see the first 12.
I shortened the code down to 18 possible switch settings with the same results.
I'm running x-plane 10.25 on a mac, latest version of OSX and using a Teensy 3.1.
Any ideas?
-Bill
Here is the compile info:
Binary sketch size: 16,400 bytes (of a 262,144 byte maximum)
Estimated memory use: 4,552 bytes (of a 65,536 byte maximum)
Here is the code:
The new panel has 14 switches with 30 possible switch settings . My first 12 switch settings work but the rest don't. After a lot of experimentation I've discovered that only the first 12 FlightSimCommands work. If I move other switch commands to be one of the first 12, they will now work and anything past the 12th command does not work. If I swap the order of the IF statements within the Loop there is no change.
I've put Serial.println statements into the IF statements to insure the program is working. I can see that the execution occurs (the IF is executed when the switch is changed), but the command does not show up on x-plane when using Show Communications although I can see the first 12.
I shortened the code down to 18 possible switch settings with the same results.
I'm running x-plane 10.25 on a mac, latest version of OSX and using a Teensy 3.1.
Any ideas?
-Bill
Here is the compile info:
Binary sketch size: 16,400 bytes (of a 262,144 byte maximum)
Estimated memory use: 4,552 bytes (of a 65,536 byte maximum)
Here is the code:
Code:
#include <Bounce.h>
/*
Panel #1 for x_plane setup. Includes engine, electrical and de-ice switches
*/
Bounce engStartR = Bounce (15, 5);
Bounce engStartL = Bounce (16, 5);
Bounce engStopR = Bounce (14, 5);
Bounce engStopL = Bounce (17, 5);
Bounce autoIgnL = Bounce (11, 5);
Bounce autoIgnR = Bounce (10, 5);
Bounce batt = Bounce (9, 5);
Bounce gen1 = Bounce (3, 5);
Bounce gen2 = Bounce (2, 5);
Bounce inv = Bounce (8, 5);
Bounce avion = Bounce (7, 5);
FlightSimCommand startEng1;
FlightSimCommand startEng2;
FlightSimCommand stopEng1;
FlightSimCommand stopEng2;
FlightSimCommand ignArmOn1;
FlightSimCommand ignArmOn2;
FlightSimCommand ignArmOff1;
FlightSimCommand ignArmOff2;
FlightSimCommand batteryOn1;
FlightSimCommand batteryOff1;
FlightSimCommand genOn1;
FlightSimCommand genOff1; //beyond this point the commands are not sent to x-plane
FlightSimCommand genOn2;
FlightSimCommand genOff2;
FlightSimCommand invertersOn;
FlightSimCommand invertersOff;
FlightSimCommand avionicsOn;
FlightSimCommand avionicsOff;
void setup() {
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(17, INPUT_PULLUP);
// link commands to xplane
startEng1 = XPlaneRef ("sim/starters/engage_starter_1");
startEng2 = XPlaneRef ("sim/starters/engage_starter_2");
stopEng1 = XPlaneRef ("sim/starters/shut_down_1");
stopEng2 = XPlaneRef ("sim/starters/shut_down_2");
ignArmOn1 = XPlaneRef ("sim/igniters/igniter_arm_on_1");
ignArmOn2 = XPlaneRef ("sim/igniters/igniter_arm_on_2");
ignArmOff1 = XPlaneRef ("sim/igniters/igniter_arm_off_1");
ignArmOff2 = XPlaneRef ("sim/igniters/igniter_arm_off_2");
batteryOn1 = XPlaneRef ("sim/electrical/battery_1_on");
batteryOff1 = XPlaneRef ("sim/electrical/battery_1_off");
genOn1 = XPlaneRef ("sim/electrical/generator_1_on");
genOn2 = XPlaneRef ("sim/electrical/generator_2_on");
genOff1 = XPlaneRef ("sim/electrical/generator_1_off");
genOff2 = XPlaneRef ("sim/electrical/generator_2_off");
invertersOn = XPlaneRef ("sim/electrical/inverters_on");
invertersOff = XPlaneRef ("sim/electrical/inverters_off");
avionicsOn = XPlaneRef ("sim/systems/avionics_on");
avionicsOff = XPlaneRef ("sim/systems/avionics_off");
// start the serial port. Will use this to ouput to the serial monitor while debugging
Serial.begin(9600);
}
void loop() {
FlightSim.update();
if (FlightSim.isEnabled()) {
// read status of all the switches
if (engStartL.update()) {
if (engStartL.fallingEdge()) {
startEng1=1;
} else {
startEng1=0;
}
}
if (engStartR.update()) {
if (engStartR.fallingEdge()) {
startEng2=1;
} else {
startEng2=0;
}
}
if (engStopL.update()) {
if (engStopL.fallingEdge()) {
stopEng1=1;
} else {
stopEng1=0;
}
}
if (engStopR.update()) {
if (engStopR.fallingEdge()) {
stopEng2=1;
} else {
stopEng2=0;
}
}
if (autoIgnL.update()) {
if (autoIgnL.fallingEdge()) {
ignArmOn1=1;
ignArmOff1=0;
} else {
ignArmOn1=0;
ignArmOff1=1;
}
}
if (autoIgnR.update()) {
if (autoIgnR.fallingEdge()) {
ignArmOn2=1;
ignArmOff2=0;
} else {
ignArmOn2=0;
ignArmOff2=1;
}
}
if (batt.update()) {
if (batt.fallingEdge()) {
batteryOn1=1; // battery on
batteryOff1=0;
} else {
batteryOn1=0; // battery on
batteryOff1=1;
}
}
if (gen2.update()) { Serial.println ("gen2 on");
if (gen2.fallingEdge()) {
genOn2=1; // gen1 on
genOff2=0;
} else {
genOn2=0; // gen1 on
genOff2=1;
}
}
if (gen1.update()) {
if (gen1.fallingEdge()) {
genOn1=1; // gen1 on
genOff1=0;
} else {
genOn1=0; // gen1 on
genOff1=1;
}
}
if (inv.update()) {
if (inv.fallingEdge()) {
invertersOn=1; // inverters on
invertersOff=0;
} else {
invertersOn=0; // inverters on
invertersOff=1;
}
}
}
}
Last edited: