Hi All,
Just updated DCS-BIOS Fork and Arduino library to latest versions. I am having a problem with the the BCD Wheels not working. Can someone have a look and see if they spot any issues?
Thanks
#define DCSBIOS_IRQ_SERIAL
#include <DcsBios.h>
DcsBios::ProtocolParser parser;
unsigned long lastTickMillis;
//E-Brake Panel Below
DcsBios::Switch2Pos emerBrake("EMER_BRAKE", 7);
// E-Brake Panel Above
//AUX Lights Panel Below ******************
// 57-A3, 61-A7, 65-A11
const int REFUEL_STATUS_LIGHTS = A3;
const int NIGHT_VISION_LIGHTS_ALL = 20;
const int NIGHT_VISION_LIGHTS_TOP = 21;
const int WEAPONS_STATION_LIGHTS = A7;
const int HARS_SAS_OVERRIDE = 17;
const int SIGNAL_LIGHT_TEST = 22;
const int FIRE_DETECT_BLEED_TEST = 65;
DcsBios::PotentiometerEWMA<5, 128, 5> alcpRsil("ALCP_RSIL", REFUEL_STATUS_LIGHTS);
DcsBios::Switch3Pos alcpNvisLts("ALCP_NVIS_LTS", NIGHT_VISION_LIGHTS_ALL, NIGHT_VISION_LIGHTS_TOP);
DcsBios::PotentiometerEWMA<5, 128, 5> alcpWpnsta("ALCP_WPNSTA", WEAPONS_STATION_LIGHTS);
DcsBios::Switch2Pos alcpHarssas("ALCP_HARSSAS", HARS_SAS_OVERRIDE);
DcsBios::Switch2Pos lampTestBtn("LAMP_TEST_BTN", SIGNAL_LIGHT_TEST);
DcsBios::Switch2Pos alcpFdbaTest("ALCP_FDBA_TEST", FIRE_DETECT_BLEED_TEST);
//AUX Lights Panel Above ******************
// SAS Panel Below*******************************************************************
const int SASP_MONITOR_TEST_L = 4;
const int SASP_MONITOR_TEST_R = 5;
const int SASP_TO_TRIM = 6;
const int SASP_YAW_TRIM = A15;
const int TakeOffTrimLed = 8;
const int SASP_YAW_SAS_L = 9;
const int SASP_YAW_SAS_R = 10;
const int SASP_PITCH_SAS_L = 11;
const int SASP_PITCH_SAS_R = 12;
int SaspYawSasL_Coil = 13; // Magnetic coil CH4
int SaspYawSasR_Coil = 14; // Magnetic coil CH3
int SaspPitchSasL_Coil = 15; // Magnetic coil CH2
int SaspPitchSasR_Coil = 16; // Magnetic coil CH1
//Monitor Test Left/Right TOGGLE ON-OFF-ON
DcsBios::Switch3Pos saspMonitorTest("SASP_MONITOR_TEST", SASP_MONITOR_TEST_L, SASP_MONITOR_TEST_R);
//T/O Trim Button PUSH
DcsBios::Switch2Pos saspToTrim("SASP_TO_TRIM", SASP_TO_TRIM);
//Yaw Trim POTENTIOMETER
DcsBios::PotentiometerEWMA<5, 128, 5> saspYawTrim("SASP_YAW_TRIM", SASP_YAW_TRIM);
//TAKEOFF TRIM Indicator Light (green) LED OUTPUT
//DcsBios::LED takeOffTrim(0x1026, 0x0400, TakeOffTrimLed);
void onSaspToTrimChange(unsigned int newValue) {
if (newValue == 1) {
digitalWrite(TakeOffTrimLed, LOW);
}
else {
digitalWrite(TakeOffTrimLed, HIGH);
}
}
DcsBios::IntegerBuffer takeOffTrimBuffer(0x1026, 0x0400, 10, onSaspToTrimChange);
DcsBios::Switch2Pos saspYawSasL("SASP_YAW_SAS_L", SASP_YAW_SAS_L);
DcsBios::Switch2Pos saspYawSasR("SASP_YAW_SAS_R", SASP_YAW_SAS_R);
DcsBios::Switch2Pos saspPitchSasL("SASP_PITCH_SAS_L", SASP_PITCH_SAS_L);
DcsBios::Switch2Pos saspPitchSasR("SASP_PITCH_SAS_R", SASP_PITCH_SAS_R);
// Yaw SAS Left
void onSaspYawSasLChange(unsigned int newCoilValue) {
switch (newCoilValue){
case 0:
digitalWrite(SaspYawSasL_Coil, LOW);
break;
case 1:
digitalWrite(SaspYawSasL_Coil, HIGH);
break;
}
}
DcsBios::IntegerBuffer saspYawSasLBuffer(0x1108, 0x0400, 10, onSaspYawSasLChange);
// Yaw SAS Right
void onSaspYawSasRChange(unsigned int newCoilValue) {
switch (newCoilValue){
case 0:
digitalWrite(SaspYawSasR_Coil, LOW);
break;
case 1:
digitalWrite(SaspYawSasR_Coil, HIGH);
break;
}
}
DcsBios::IntegerBuffer saspYawSasRBuffer(0x1108, 0x0800, 11, onSaspYawSasRChange);
// Pitch SAS Left
void onSaspPitchSasLChange(unsigned int newCoilValue) {
switch (newCoilValue){
case 0:
digitalWrite(SaspPitchSasL_Coil, LOW);
break;
case 1:
digitalWrite(SaspPitchSasL_Coil, HIGH);
break;
}
}
DcsBios::IntegerBuffer saspPitchSasLBuffer(0x1108, 0x1000, 12, onSaspPitchSasLChange);
// Pitch SAS Right
void onSaspPitchSasRChange(unsigned int newCoilValue) {
switch (newCoilValue){
case 0:
digitalWrite(SaspPitchSasR_Coil, LOW);
break;
case 1:
digitalWrite(SaspPitchSasR_Coil, HIGH);
break;
}
}
DcsBios::IntegerBuffer saspPitchSasRBuffer(0x1108, 0x2000, 13, onSaspPitchSasRChange);
// SAS Panel Above*******************************************************************************************************************************
// IFF Panel Below****************************************************************************************************************************
// Thumbwheel Code
//Mode-1 Wheel 1 ROTARY ENCODER
DcsBios::BcdWheel iffMode1Wheel1("IFF_MODE1_WHEEL1", 27, 26, 25);
//Mode-1 Wheel 2 ROTARY ENCODER
DcsBios::BcdWheel iffMode1Wheel2("IFF_MODE1_WHEEL1", 23, 24);
//Mode-3A Wheel 1 ROTARY ENCODER
DcsBios::BcdWheel iffMode3aWheel1("IFF_MODE1_WHEEL1", 56, 55, 54);
//Mode-3A Wheel 2 ROTARY ENCODER
DcsBios::BcdWheel iffMode3aWheel2("IFF_MODE1_WHEEL1", 58, 59, 60);
//Mode-3A Wheel 3 ROTARY ENCODER
DcsBios::BcdWheel iffMode3aWheel3("IFF_MODE1_WHEEL1", 62, 63, 64);
//Mode-3A Wheel 4 ROTARY ENCODER
DcsBios::BcdWheel iffMode3aWheel4("IFF_MODE1_WHEEL1", 66, 67, 68);
// IFF Code: ZERO - B - A - (HOLD)
const byte iffCodePins[4] = {49, 47, 45, 43};
DcsBios::SwitchMultiPos iffCode("IFF_CODE", iffCodePins, 4);
// IFF Master: OFF - STBY - LOW - NORM - EMER ROTARY ENCODER
const byte iffMasterPins[5] = {34, 36, 38, 40, 42};
DcsBios::SwitchMultiPos iffMaster("IFF_MASTER", iffMasterPins, 5);
//IFF On/Out TOGGLE ON OFF
DcsBios::Switch2Pos iffOnOut("IFF_ON_OUT", 52);
//IFF Out: LIGHT - OFF - AUDIO TOGGLE ON OFF ON
DcsBios::Switch3Pos iffOutAudioLight("IFF_OUT_AUDIO_LIGHT", 32, 33);
//REPLY Push to Test PUSH BUTTON
DcsBios::Switch2Pos iffReplyTest("IFF_REPLY_TEST", 41);
//IFF REPLY Light (green) LED OUTPUT
void onIffReplyTestChange(unsigned int newValue) {
if (newValue == 1) {
digitalWrite(37,LOW);
}
else {
digitalWrite(37,HIGH);
} /* your code here */
}
DcsBios::IntegerBuffer iffReplyTestBuffer(0x1128, 0x8000, 15, onIffReplyTestChange);
//TEST Push to Test PUSH BUTTON
DcsBios::Switch2Pos iffTestTest("IFF_TEST_TEST", 35);
//IFF TEST Light (green) LED OUTPUT
void onIffTestTestChange(unsigned int newValue) {
if (newValue == 1) {
digitalWrite(39,LOW);
}
else {
digitalWrite(39,HIGH);
} /* your code here */
}
DcsBios::IntegerBuffer iffTestTestBuffer(0x112a, 0x0040, 6, onIffTestTestChange);
//Test M-1 TOGGLE OFF-ON-ON
DcsBios::Switch3Pos iffTestM1("IFF_TEST_M1", 50, 48);
//Test M-2 OFF-ON-ON
DcsBios::Switch3Pos iffTestM2("IFF_TEST_M2", 51, 53);
//Test M-3 OFF-ON-ON
DcsBios::Switch3Pos iffTestM3("IFF_TEST_M3", 30, 31);
//Test M-4 OFF-ON-ON
DcsBios::Switch3Pos iffTestM4("IFF_TEST_M4", 28, 29);
//RAD Test/Mon TOGGLE ON-OFF-ON
DcsBios::Switch3Pos iffRadtest("IFF_RADTEST", 44, 46);
//Ident/Mic TOGGLE ON-OFF-ON
DcsBios::Switch3Pos iffMicIdent("IFF_MIC_IDENT", 18, 19);
//IFF Panel Above *************************************************************************************
void setup() {
DcsBios::setup();
lastTickMillis = millis();
// Reversing for IFF Panel Reply and Test LED, SAS Panel TO Trim LED
pinMode(39, OUTPUT);
pinMode(37, OUTPUT);
pinMode(TakeOffTrimLed,OUTPUT);
// SAS Coils
pinMode (SaspPitchSasR_Coil, OUTPUT);
pinMode (SaspPitchSasL_Coil, OUTPUT);
pinMode (SaspYawSasR_Coil, OUTPUT);
pinMode (SaspYawSasL_Coil, OUTPUT);
}
void timerTick()
{
// The timer has expired. Issue a mass reset to all controls. Safe, but may generate additional
// traffic if you have many controls.
// DcsBios::resetAllStates();
}
void loop() {
DcsBios::loop();
unsigned long now = millis();
if(now - lastTickMillis > 10000)
{
timerTick();
lastTickMillis = now;
}
}