Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <DcsBios.h>
- #include <Servo.h>
- int latchPin = 8;
- int clockPin = 12;
- int dataPin = 11;
- unsigned int leds = 0;
- /**** Make your changes after this line ****/
- DcsBios::LEDSR canopyUnlocked(0x10da, 0x0004, 0);
- DcsBios::LEDSR gunReady(0x1026, 0x8000, 1);
- DcsBios::LEDSR masterCaution(0x1012, 0x0800, 2);
- DcsBios::LEDSR oxyFlow(0x112a, 0x0800, 3);
- DcsBios::LEDSR dvadrRec(0x11ba, 0x0080, 4);
- DcsBios::LEDSR gearLSafe(0x1026, 0x1000, 5);
- DcsBios::LEDSR gearNSafe(0x1026, 0x0800, 6);
- DcsBios::LEDSR gearRSafe(0x1026, 0x2000, 7);
- /**** In most cases, you do not have to change anything below this line ****/
- /* Instantiate a ProtocolParser object to parse the DCS-BIOS export stream */
- DcsBios::ProtocolParser parser;
- void setup() {
- Serial.begin(500000);
- pinMode(latchPin, OUTPUT);
- pinMode(dataPin, OUTPUT);
- pinMode(clockPin, OUTPUT);
- }
- /*
- Your main loop needs to pass data from the DCS-BIOS export
- stream to the parser object you instantiated above.
- It also needs to call DcsBios::PollingInput::pollInputs()
- to detect changes in the state of connected controls and
- pass them on to DCS.
- */
- void loop() {
- // feed incoming data to the parser
- while (Serial.available()) {
- parser.processChar(Serial.read());
- }
- // poll inputs
- DcsBios::PollingInput::pollInputs();
- updateShiftRegister();
- }
- /*
- You need to define
- void sendDcsBiosMessage(const char* msg, const char* arg)
- so that the string msg, followed by a space, the string arg
- and a newline gets sent to the DCS-BIOS import stream.
- In this example we send it to the serial port, so you need to
- run socat to read the data from the serial port and send it
- over UDP to DCS-BIOS.
- If you are using an Ethernet Shield, you would probably want
- to send a UDP packet from this subroutine.
- */
- void sendDcsBiosMessage(const char* msg, const char* arg) {
- Serial.write(msg);
- Serial.write(' ');
- Serial.write(arg);
- Serial.write('\n');
- }
- /*
- This subroutine gets called every time a message is received
- from the export stream (you need to define it even if it
- does nothing).
- Use this to handle outputs which are not covered by the
- DcsBios Arduino library (e.g. displays).
- */
- void onDcsBiosWrite(unsigned int address, unsigned int value) {
- }
- void updateShiftRegister()
- {
- digitalWrite(latchPin, LOW);
- shiftOut(dataPin, clockPin, MSBFIRST, leds);
- digitalWrite(latchPin, HIGH);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement