|
7 | 7 | *#2 - Provide a very basic testing suite that developers can use to ensure that changes do not break existing sketches |
8 | 8 | */ |
9 | 9 |
|
| 10 | +// Some made-up pin assignments just to make the examples more readable |
| 11 | +const int PIN_A = 1; |
| 12 | +const int PIN_B = 2; |
| 13 | +const int ANALOG_PIN_A = 6; |
| 14 | + |
10 | 15 | // Buttons |
11 | 16 | /////////// |
12 | 17 | // 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); |
| 18 | +DcsBios::ActionButton iffDec("IFF_CODE", "INC", PIN_A); |
14 | 19 |
|
15 | 20 | // 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); |
| 21 | +DcsBios::ToggleButton toggleButtonExample("MSG_0", "ARG_0", "ARG_1", PIN_A); |
17 | 22 |
|
18 | 23 | // A dual mode button with a master switch which toggles the function of a physical pit button between two different DCS functions. Think multi-seat aircraft. |
19 | | -DcsBios::DualModeButton dualModeButtonExample(0, 1, "MSG_INMODE0", "MSG_INMODE1"); |
| 24 | +DcsBios::DualModeButton dualModeButtonExample(PIN_A, PIN_B, "MSG_INMODE0", "MSG_INMODE1"); |
20 | 25 |
|
21 | 26 | // Switches |
22 | 27 | //////////// |
23 | 28 | // A standard two position on/off |
24 | | -DcsBios::Switch2Pos switch2PosExample("MSG_0", 1); |
| 29 | +DcsBios::Switch2Pos switch2PosExample("MSG_0", PIN_A); |
25 | 30 | // A three position on/off/on switch |
26 | | -DcsBios::Switch3Pos switch3PosExample("MSG_0", 1, 2); |
| 31 | +DcsBios::Switch3Pos switch3PosExample("MSG_0", PIN_A, PIN_B); |
27 | 32 | // A multiple position switch, often a rotary switch |
28 | 33 | const byte multiPosPins[4] = {1,2,3,4}; |
29 | 34 | DcsBios::SwitchMultiPos switchMulitPosExample("MSG_0", multiPosPins, 4); |
30 | 35 | // A switch that has a cover in DCS that must be opened before the switch itself can be activated |
31 | | -DcsBios::SwitchWithCover2Pos pltLaunchbarAbort("PLT_LAUNCHBAR_ABORT", "PLT_LAUNCHBAR_ABORT_COVER", 6); |
| 36 | +DcsBios::SwitchWithCover2Pos pltLaunchbarAbort("PLT_LAUNCHBAR_ABORT", "PLT_LAUNCHBAR_ABORT_COVER", PIN_A); |
32 | 37 |
|
33 | 38 | // Analogs |
34 | 39 | /////////// |
35 | | -// Use an analog input, divided into discrete steps |
36 | | -DcsBios::AnalogMultiPos analogMultiPosExample("MSG_0", 1, 10); |
| 40 | +// Use an analog input, divided into (10) discrete steps |
| 41 | +DcsBios::AnalogMultiPos analogMultiPosExample("MSG_0", ANALOG_PIN_A, 10); |
37 | 42 |
|
38 | 43 | // Other stuff |
39 | 44 | // A Binary Coded Decimal wheel usually displaying digits for numeric entry, i.e. IFF code wheels. |
40 | | -DcsBios::BcdWheel bcdWheelExample("MSG_0", 1, 2); |
| 45 | +DcsBios::BcdWheel bcdWheelExample("MSG_0", PIN_A, PIN_B); |
41 | 46 | // A special case of bcdWheel that will send a radio frequency instead of raw digit |
42 | 47 | DcsBios::RadioPreset radioPresetExample("MSG_0", 1, 2, 3, 4, 5); |
43 | 48 |
|
44 | 49 | // Spinning things |
45 | 50 | /////////////////// |
| 51 | +const int DATAPIN = 1; |
| 52 | +const int CLKPIN = 2; |
| 53 | +const int SWPIN = 3; |
| 54 | + |
46 | 55 | // Rotary encoder on two pins to send INC/DEC arguments when rotated |
47 | | -DcsBios::RotaryEncoder rotaryEncoderExample("MSG_0", "ARG_DEC", "ARG_INC", 1, 2); |
| 56 | +DcsBios::RotaryEncoder rotaryEncoderExample("MSG_0", "ARG_DEC", "ARG_INC", PIN_A, PIN_B); |
48 | 57 | // A rotary encoder which will send larger increments when used continuously. Originally written for faster gross adjustments to HSI. |
49 | | -DcsBios::RotaryAcceleratedEncoder rotaryAcceleratedEncoderExample("MSG_0", "ARG_DEC", "ARG_INC", "FAST_INC", "FAST_DEC", 1, 2); |
| 58 | +DcsBios::RotaryAcceleratedEncoder rotaryAcceleratedEncoderExample("MSG_0", "ARG_DEC", "ARG_INC", "FAST_INC", "FAST_DEC", PIN_A, PIN_B); |
| 59 | +// A rotary with pushbutton, used to emulate a concentric rotary encoder. Pushing the button toggles between two functions |
| 60 | +DcsBios::EmulatedConcentricRotaryEncoder ilsRightKnob("ILS_KHZ", "DEC", "INC", "ILS_VOL", "-4500", "+4500", DATAPIN, CLKPIN, SWPIN); |
| 61 | + |
50 | 62 | // A linear/analog axis on a single pin |
51 | | -DcsBios::Potentiometer potentiometerExample("MSG_0", 1); |
| 63 | +DcsBios::Potentiometer potentiometerExample("MSG_0", ANALOG_PIN_A); |
52 | 64 | // A linear axis control where the physical or electrical range of the input does utilize the full 0 to 1023 range. |
53 | | -DcsBios::Potentiometer clippedPotentiometerExample("MSG_0", false, 256, 768); |
| 65 | +DcsBios::Potentiometer clippedPotentiometerExample("MSG_0", ANALOG_PIN_A, false, 256, 768); |
54 | 66 |
|
55 | 67 | // An inverted version of a linear axis control |
56 | | -DcsBios::Potentiometer invertedPotentiometerExample("MSG_0", 1, true); |
| 68 | +DcsBios::Potentiometer invertedPotentiometerExample("MSG_0", ANALOG_PIN_A, true); |
57 | 69 |
|
58 | 70 | // Rotary encoder being used to control something that is an N-pos switch in DCS. 3 represents the number of positions of the switch in DCS. |
59 | | -DcsBios::RotarySwitch rotarySwitchExample("MSG_0", 1, 2, 3); |
| 71 | +DcsBios::RotarySwitch rotarySwitchExample("MSG_0", PIN_A, PIN_B, 3); |
60 | 72 |
|
61 | 73 | // Outputs |
62 | 74 | /////////// |
| 75 | +const int OUT_PIN_A = 15; |
| 76 | +const int ANALOG_OUT_PIN_A = 16; |
63 | 77 | // A single LED |
64 | | -DcsBios::Dimmer defaultDimmerExample(0x1012, 5); |
65 | | -DcsBios::LED masterCaution(0x1012, 0x0800, 13); |
| 78 | +DcsBios::Dimmer defaultDimmerExample(0x1012, OUT_PIN_A); |
| 79 | +DcsBios::LED masterCaution(0x1012, 0x0800, OUT_PIN_A); |
66 | 80 | // An analog output with a value that comes from a DCS address |
67 | | -DcsBios::Dimmer dimmerExample(0x1012, 13); |
68 | | -DcsBios::Dimmer invertedDimmerExample(0x1012, 5, 200, 0); |
| 81 | +DcsBios::Dimmer dimmerExample(0x1012, ANALOG_OUT_PIN_A); |
| 82 | +DcsBios::Dimmer invertedDimmerExample(0x1012, ANALOG_OUT_PIN_A, 200, 0); |
69 | 83 | unsigned int myValueMapper(unsigned int dcsValue) |
70 | 84 | { |
71 | 85 | return dcsValue % 10; |
72 | 86 | } |
73 | | -DcsBios::Dimmer mappedDimmerExample(0x1012, 5, myValueMapper); |
| 87 | +DcsBios::Dimmer mappedDimmerExample(0x1012, ANALOG_OUT_PIN_A, myValueMapper); |
74 | 88 | // A servo motor controlleed from DCS, i.e. a guage. |
75 | | -DcsBios::ServoOutput servoExample(0x1012, 13, 544, 2400); |
| 89 | +DcsBios::ServoOutput servoExample(0x1012, ANALOG_OUT_PIN_A, 544, 2400); |
76 | 90 |
|
77 | 91 | void setup() { |
78 | 92 | DcsBios::setup(); |
|
0 commit comments