#include <Arduino.h> //Angle brackets looks in libraries directory
#define DCSBIOS_DEFAULT_SERIAL //Use DCSBIOS_DEFAULT_SERIAL as IRQ does not work, but this may only apply to sketches utilizing button matrices
#define USE_MATRIX_SWITCHES
#include "DcsBios.h"
#include "controlDefinitions.h" //Quotes look in the same directory as the main file first, then in library directory
//#include "changeAircraft.h"
#include "aircraftControlNames.h"
class Control {
public:
void AssignType(String type) {
if (type == "A-10C"){
DcsBios::MatActionButtonSet test1("UFC_1", &keyMatrix[0][0], LOW);
} else {
//set up other airplane
}
}
};
class Button: public Control {
public:
};
bool runDcsLoop = true; //So we can pause the DCS-Bios main loop
void setup() {
DcsBios::setup();
//Keypad Matrix
for (int y = 0; y < numKeyRows; y++) //Iterate through all the rows in the matrix to set the pinmode to input
{
pinMode(rowKeyPins[y], INPUT_PULLUP); //INPUT_PULLUP stops the pin floating and picking up noise. If using external Pull-up resistors, this could be set to just INPUT.
};
for (int x = 0; x < numKeyCols; x++) //Iterate through all the column pins in the matrix to set the pinmode to OUTPUT-HIGH
{
pinMode(colKeyPins[x], OUTPUT);
digitalWrite(colKeyPins[x], HIGH);
};
//Button Matrix
for (int y = 0; y < numRows; y++) //Iterate through all the rows in the matrix to set the pinmode to input
{
pinMode(rowPins[y], INPUT_PULLUP); //INPUT_PULLUP stops the pin floating and picking up noise. If using external Pull-up resistors, this could be set to just INPUT.
};
for (int x = 0; x < numCols; x++) //Iterate through all the column pins in the matrix to set the pinmode to OUTPUT-HIGH
{
pinMode(colPins[x], OUTPUT);
digitalWrite(colPins[x], HIGH);
};
}
void loop() {
//Button Matrix
for (int x = 0; x < numCols; x++) //Iterate through each Column pin
{
digitalWrite(colPins[x], LOW); //set the current column output to a low (current sink)
for (int y = 0; y < numRows; y++) //Iterate through each row to detect which one is pressed (connected to the OUTPUT-LOW column)
{
btnMatrix[y][x] = digitalRead(rowPins[y]); //update the state of the button in the array, with array address is defined by the current row and column ([y] and [x]).
}
digitalWrite(colPins[x], HIGH); //set the current column output to a high +V source to so it is not recognised as a press when the other columns are LOW.
}
//Keypad Matrix
for (int x = 0; x < numKeyCols; x++) //Iterate through each Column pin
{
digitalWrite(colKeyPins[x], LOW); //set the current column output to a low (current sink)
for (int y = 0; y < numKeyRows; y++) //Iterate through each row to detect which one is pressed (connected to the OUTPUT-LOW column)
{
keyMatrix[y][x] = digitalRead(rowKeyPins[y]); //update the state of the button in the array, with array address is defined by the current row and column ([y] and [x]).
}
digitalWrite(colKeyPins[x], HIGH); //set the current column output to a high +V source to so it is not recognised as a press when the other columns are LOW.
}
if ( runDcsLoop ) //Boolean created so we can pause DCS loop
{
DcsBios::loop();
}
}