Advertisement
Guest User

sketch.ino

a guest
Jan 31st, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.43 KB | None | 0 0
  1. #include <DcsBios.h>
  2. #include <Servo.h>
  3.  
  4. int latchPin = 8;
  5. int clockPin = 12;
  6. int dataPin = 11;
  7.  
  8. unsigned int leds = 0;
  9.  
  10. /**** Make your changes after this line ****/
  11.  
  12. DcsBios::LEDSR canopyUnlocked(0x10da, 0x0004, 0);
  13. DcsBios::LEDSR gunReady(0x1026, 0x8000, 1);
  14. DcsBios::LEDSR masterCaution(0x1012, 0x0800, 2);
  15. DcsBios::LEDSR oxyFlow(0x112a, 0x0800, 3);
  16. DcsBios::LEDSR dvadrRec(0x11ba, 0x0080, 4);
  17. DcsBios::LEDSR gearLSafe(0x1026, 0x1000, 5);
  18. DcsBios::LEDSR gearNSafe(0x1026, 0x0800, 6);
  19. DcsBios::LEDSR gearRSafe(0x1026, 0x2000, 7);
  20.  
  21.  
  22.  
  23. /**** In most cases, you do not have to change anything below this line ****/
  24.  
  25. /* Instantiate a ProtocolParser object to parse the DCS-BIOS export stream */
  26. DcsBios::ProtocolParser parser;
  27.  
  28. void setup() {
  29.   Serial.begin(500000);
  30.   pinMode(latchPin, OUTPUT);
  31.   pinMode(dataPin, OUTPUT);  
  32.   pinMode(clockPin, OUTPUT);
  33. }
  34.  
  35. /*
  36. Your main loop needs to pass data from the DCS-BIOS export
  37. stream to the parser object you instantiated above.
  38.  
  39. It also needs to call DcsBios::PollingInput::pollInputs()
  40. to detect changes in the state of connected controls and
  41. pass them on to DCS.
  42. */
  43. void loop() {
  44.   // feed incoming data to the parser
  45.   while (Serial.available()) {
  46.       parser.processChar(Serial.read());
  47.   }
  48.  
  49.   // poll inputs
  50.   DcsBios::PollingInput::pollInputs();
  51.  
  52.  
  53.  
  54. updateShiftRegister();
  55.    
  56.  
  57.  
  58.  
  59.  
  60. }
  61.  
  62. /*
  63. You need to define
  64. void sendDcsBiosMessage(const char* msg, const char* arg)
  65. so that the string msg, followed by a space, the string arg
  66. and a newline gets sent to the DCS-BIOS import stream.
  67.  
  68. In this example we send it to the serial port, so you need to
  69. run socat to read the data from the serial port and send it
  70. over UDP to DCS-BIOS.
  71.  
  72. If you are using an Ethernet Shield, you would probably want
  73. to send a UDP packet from this subroutine.
  74. */
  75. void sendDcsBiosMessage(const char* msg, const char* arg) {
  76.   Serial.write(msg);
  77.   Serial.write(' ');
  78.   Serial.write(arg);
  79.   Serial.write('\n');
  80. }
  81.  
  82. /*
  83. This subroutine gets called every time a message is received
  84. from the export stream (you need to define it even if it
  85. does nothing).
  86.  
  87. Use this to handle outputs which are not covered by the
  88. DcsBios Arduino library (e.g. displays).
  89. */
  90. void onDcsBiosWrite(unsigned int address, unsigned int value) {
  91.  
  92. }
  93.  
  94. void updateShiftRegister()
  95. {
  96.    digitalWrite(latchPin, LOW);
  97.    shiftOut(dataPin, clockPin, MSBFIRST, leds);
  98.    digitalWrite(latchPin, HIGH);
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement