|
API Documentation v0.0.1
|
Controls the AMPCD. Adapted from Peter Sawka's original Nano code. More...
#include "DcsBios.h"#include "Wire.h"#include "TCA9534.h"Go to the source code of this file.
Macros | |
| #define | DCSBIOS_DEFAULT_SERIAL |
| This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.) | |
| #define | TXENABLE_PIN 5 |
| Sets TXENABLE_PIN to Arduino Pin 5. | |
| #define | UART1_SELECT |
| Selects UART1 on Arduino for serial communication. | |
| #define | AMPCD_ROT_A A0 |
| AMPCD Rotary Brightness. | |
| #define | AMPCD_ROT_OFF A1 |
| AMPCD Off - No DCS Bios use. | |
| #define | HDG_P 8 |
| HDG +. | |
| #define | HDG_M 10 |
| HDG -. | |
| #define | CRS_P 4 |
| CRS +. | |
| #define | CRS_M 7 |
| CRS -. | |
| #define | AMPCD_BACK_LIGHT 9 |
| DDI Backlighting PWM, must be defined as digital pin #. | |
| #define | AMPCD_IRQ 6 |
| AMPCD IRQ Pin. | |
Functions | |
| DcsBios::Potentiometer | ampcdBrtCtl ("AMPCD_BRT_CTL", AMPCD_ROT_A) |
| DcsBios::Switch3Pos | leftDdiCrsSw ("LEFT_DDI_CRS_SW", CRS_P, CRS_M) |
| DcsBios::Switch3Pos | leftDdiHdgSw ("LEFT_DDI_HDG_SW", HDG_P, HDG_M) |
| void | onInstrIntLtChange (unsigned int newValue) |
| Setup DCS-BIOS control for DDI backlighting. | |
| DcsBios::IntegerBuffer | instrIntLtBuffer (FA_18C_hornet_INSTR_INT_LT, onInstrIntLtChange) |
| void | setup () |
| void | loop () |
Variables | |
| TCA9534 | ampcdButtons [4] |
| bool | lastBtnState [28] |
| Array to hold the last state of the 20 AMPCD buttons, and 4 rocker switches. | |
| bool | buttonState [28] |
| Array to hold the current state of the 20 AMPCD buttons, and 4 rocker switches. | |
| uint8_t | inputRegister [4] |
| Input register for button read logic. | |
| unsigned long | lastDebounceTime [28] |
| Array to hold last time of AMPCD button update for debounce. | |
| unsigned long | debounceDelay = 10 |
| The debounce delay duration in ms, increase if the output flickers. | |
| int | index |
| char * | AMPCD_Btns [] |
| DCS Bios Messages for the 4 AMPCD rocker switches. | |
| char | btnName [20] |
Controls the AMPCD. Adapted from Peter Sawka's original Nano code.
Wiring diagram:
| PIN | Function |
|---|---|
| A0 | AMPCD Rotary Brightness |
| A1 | AMPCD Off - No DCS Bios use |
| 8 | HDG + |
| 10 | HDG - |
| 4 | CRS + |
| 7 | CRS - |
| 9 | DDI Backlighting PWM, must be defined as digital pin # |
| 6 | AMPCD IRQ Pin |
following #define tells DCS-BIOS that this is a RS-485 slave device. It also sets the address of this slave device. The slave address should be between 1 and 126 and must be unique among all devices on the same bus.
#define DCSBIOS_RS485_SLAVE 2
Definition in file 2A3A1-AMPCD.ino.
| #define DCSBIOS_DEFAULT_SERIAL |
This enables the default serial communication for DCS-BIOS. (Used with all other microcontrollers than the ATmega328P or ATmega2560.)
Check if we're on a Mega328 or Mega2560 and define the correct serial interface
Definition at line 79 of file 2A3A1-AMPCD.ino.
| #define TXENABLE_PIN 5 |
Sets TXENABLE_PIN to Arduino Pin 5.
The Arduino pin that is connected to the RE and DE pins on the RS-485 transceiver.
Definition at line 91 of file 2A3A1-AMPCD.ino.
| #define UART1_SELECT |
Selects UART1 on Arduino for serial communication.
Definition at line 92 of file 2A3A1-AMPCD.ino.
| #define AMPCD_ROT_A A0 |
AMPCD Rotary Brightness.
Definition at line 99 of file 2A3A1-AMPCD.ino.
| #define AMPCD_ROT_OFF A1 |
AMPCD Off - No DCS Bios use.
Definition at line 100 of file 2A3A1-AMPCD.ino.
| #define HDG_P 8 |
HDG +.
Definition at line 101 of file 2A3A1-AMPCD.ino.
| #define HDG_M 10 |
HDG -.
Definition at line 102 of file 2A3A1-AMPCD.ino.
| #define CRS_P 4 |
CRS +.
Definition at line 103 of file 2A3A1-AMPCD.ino.
| #define CRS_M 7 |
CRS -.
Definition at line 104 of file 2A3A1-AMPCD.ino.
| #define AMPCD_BACK_LIGHT 9 |
DDI Backlighting PWM, must be defined as digital pin #.
Definition at line 105 of file 2A3A1-AMPCD.ino.
Referenced by onInstrIntLtChange(), and setup().
| #define AMPCD_IRQ 6 |
| void onInstrIntLtChange | ( | unsigned int | newValue | ) |
Setup DCS-BIOS control for DDI backlighting.
Definition at line 145 of file 2A3A1-AMPCD.ino.
References AMPCD_BACK_LIGHT.
| void setup | ( | ) |
Arduino Setup Function
Arduino standard Setup Function. Code who should be executed only once at the program start, belongs in this function.
Initialize last button state array to all 0's.
For each TCA9534 chip 'Begin', and set all of its AMPCD buttons to PinMode = INPUT
Definition at line 156 of file 2A3A1-AMPCD.ino.
References AMPCD_BACK_LIGHT, AMPCD_IRQ, ampcdButtons, and lastBtnState.
| void loop | ( | ) |
Arduino Loop Function
Arduino standard Loop Function. Code who should be executed over and over in a loop, belongs in this function.
Read all the AMPCD button states and send DCSBios Commands in the following TCA9534 order: Left, Top (buttons reversed), Right (buttons reversed), Bottom.
Fix button index for Top and Right buttons to be in the same order as Left and Bottom buttons.
Definition at line 193 of file 2A3A1-AMPCD.ino.
References AMPCD_Btns, ampcdButtons, buttonState, debounceDelay, index, inputRegister, lastBtnState, and lastDebounceTime.
| TCA9534 ampcdButtons[4] |
TCA9534 Chip Array Array for the 4 TCA9534 chips to read the DDI Buttons (indices): Left = 0, Top = 1, Right = 2, Bottom = 3
Definition at line 113 of file 2A3A1-AMPCD.ino.
| bool lastBtnState[28] |
Array to hold the last state of the 20 AMPCD buttons, and 4 rocker switches.
Definition at line 121 of file 2A3A1-AMPCD.ino.
| bool buttonState[28] |
Array to hold the current state of the 20 AMPCD buttons, and 4 rocker switches.
Definition at line 122 of file 2A3A1-AMPCD.ino.
Referenced by loop().
| uint8_t inputRegister[4] |
Input register for button read logic.
Definition at line 123 of file 2A3A1-AMPCD.ino.
Referenced by loop().
| unsigned long lastDebounceTime[28] |
Array to hold last time of AMPCD button update for debounce.
Definition at line 124 of file 2A3A1-AMPCD.ino.
Referenced by loop().
| unsigned long debounceDelay = 10 |
The debounce delay duration in ms, increase if the output flickers.
Definition at line 125 of file 2A3A1-AMPCD.ino.
Referenced by loop().
| int index |
Definition at line 127 of file 2A3A1-AMPCD.ino.
| char* AMPCD_Btns[] |
DCS Bios Messages for the 4 AMPCD rocker switches.
Definition at line 130 of file 2A3A1-AMPCD.ino.
Referenced by loop().
| char btnName[20] |
Definition at line 134 of file 2A3A1-AMPCD.ino.