|
1 | | -/* use '#define DCSBIOS_DEFAULT_SERIAL' instead if your Arduino board |
2 | | - * does not feature an ATMega328 or ATMega2650 controller. |
3 | | - */ |
4 | 1 | #define DCSBIOS_DEFAULT_SERIAL |
5 | 2 | #include <DcsBios.h> |
6 | 3 |
|
| 4 | +/* This file serves two purposes: |
| 5 | + *#1 - Provided compilable demonstrations of each type of controls availble in DCS-Bios arduino library. This is not meant to be deployed onto |
| 6 | + * hardware, as several pins conflict and the messages are made up. |
| 7 | + *#2 - Provide a very basic testing suite that developers can use to ensure that changes do not break existing sketches |
| 8 | + */ |
| 9 | + |
| 10 | +// Buttons |
| 11 | +/////////// |
| 12 | +// The simplest push button, a single momentary button on a single pin, which sends ARG_0 to MSG_0 |
| 13 | +DcsBios::ActionButton iffDec("IFF_CODE", "INC", 1); |
| 14 | + |
| 15 | +// Used when a physical switch is a momentary button, but needs to sent alternating arguments each time it is pressed |
| 16 | +DcsBios::ToggleButton toggleButtonExample("MSG_0", "ARG_0", "ARG_1", 1); |
| 17 | + |
| 18 | +// Switches |
| 19 | +//////////// |
| 20 | +// A standard two position on/off |
| 21 | +DcsBios::Switch2Pos switch2PosExample("MSG_0", 1); |
| 22 | +// A three position on/off/on switch |
| 23 | +DcsBios::Switch3Pos switch3PosExample("MSG_0", 1, 2); |
| 24 | +// A multiple position switch, often a rotary switch |
| 25 | +const byte multiPosPins[4] = {1,2,3,4}; |
| 26 | +DcsBios::SwitchMultiPos switchMulitPosExample("MSG_0", multiPosPins, 4); |
| 27 | + |
| 28 | +// Analogs |
| 29 | +/////////// |
| 30 | +// Use an analog input, divided into discrete steps |
7 | 31 | DcsBios::AnalogMultiPos analogMultiPosExample("MSG_0", 1, 10); |
8 | | -DcsBios::RadioPreset radioPresetExample("MSG_0", 1, 2, 3, 4, 5); |
| 32 | + |
| 33 | +// Other stuff |
| 34 | +// A Binary Coded Decimal wheel usually displaying digits for numeric entry, i.e. IFF code wheels. |
9 | 35 | DcsBios::BcdWheel bcdWheelExample("MSG_0", 1, 2); |
10 | | -DcsBios::ActionButton actionButtonExample("MSG_0", "ARG_0", 1); |
11 | | -DcsBios::ToggleButton toggleButtonExample("MSG_0", "ARG_0", "ARG_1", 1); |
| 36 | +// A special case of bcdWheel that will send a radio frequency instead of raw digit |
| 37 | +DcsBios::RadioPreset radioPresetExample("MSG_0", 1, 2, 3, 4, 5); |
| 38 | + |
| 39 | +// Spinning things |
| 40 | +/////////////////// |
| 41 | +// Rotary encoder on two pins to send INC/DEC arguments when rotated |
12 | 42 | DcsBios::RotaryEncoder rotaryEncoderExample("MSG_0", "ARG_DEC", "ARG_INC", 1, 2); |
| 43 | +// A rotary encoder which will send larger increments when used continuously. Originally written for faster gross adjustments to HSI. |
13 | 44 | DcsBios::RotaryAcceleratedEncoder rotaryAcceleratedEncoderExample("MSG_0", "ARG_DEC", "ARG_INC", "FAST_INC", "FAST_DEC", 1, 2); |
| 45 | +// A linear/analog axis on a single pin |
14 | 46 | DcsBios::Potentiometer potentiometerExample("MSG_0", 1); |
| 47 | +// An inverted version of a linear axis control |
15 | 48 | DcsBios::InvertedPotentiometer invertedPotentiometerExample("MSG_0", 1); |
16 | | -DcsBios::Switch2Pos switch2PosExample("MSG_0", 1); |
17 | | -DcsBios::Switch3Pos switch3PosExample("MSG_0", 1, 2); |
18 | | -const byte multiPosPins[4] = {1,2,3,4}; |
19 | | -DcsBios::SwitchMultiPos switchMulitPosExample("MSG_0", multiPosPins, 4); |
20 | 49 |
|
| 50 | +// Outputs |
| 51 | +/////////// |
| 52 | +// A single LED |
21 | 53 | DcsBios::Dimmer defaultDimmerExample(0x1012, 5); |
| 54 | +DcsBios::LED masterCaution(0x1012, 0x0800, 13); |
| 55 | +// An analog output with a value that comes from a DCS address |
| 56 | +DcsBios::Dimmer dimmerExample(0x1012, 13); |
22 | 57 | DcsBios::Dimmer invertedDimmerExample(0x1012, 5, 200,0); |
23 | 58 | unsigned int myValueMapper(unsigned int dcsValue) |
24 | 59 | { |
25 | 60 | return dcsValue % 10; |
26 | 61 | } |
27 | 62 | DcsBios::Dimmer mappedDimmerExample(0x1012, 5, myValueMapper); |
28 | | - |
29 | | -DcsBios::LED masterCaution(0x1012, 0x0800, 13); |
| 63 | +// A servo motor controlleed from DCS, i.e. a guage. |
| 64 | +DcsBios::ServoOutput servoExample(0x1012, 13, 544, 2400); |
30 | 65 |
|
31 | 66 | void setup() { |
32 | 67 | DcsBios::setup(); |
|
0 commit comments