Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <DcsBios.h>
- #include <Servo.h>
- #include <LedControl.h>
- /* SET BAUD RATE IN CONNECT-SERIAL-PORT.CMD TO 115000 (OR WHATEVER YOU SET IN: void setup() Serial.begin(YOUR BAUD RATE HERE)) */
- LedControl lc=LedControl(12,11,10,1);
- /* we always wait a bit between updates of the display */
- unsigned long delaytime=250;
- /**** Make your changes after this line ****/
- //String inString = "";
- void onVhfamFreq1Change(char* newValue) {
- for(int i=0;i<2;i++) {
- lc.setChar(0,i,newValue[i],false);
- }
- }
- DcsBios::StringBuffer<2> vhfamFreq1StrBuffer(0x1190, onVhfamFreq1Change);
- void onVhfamFreq4Change(char* newValue) {
- for(int i=0;i<2;i++) {
- lc.setChar(0,i+4,newValue[i],false);
- }
- }
- DcsBios::StringBuffer<2> vhfamFreq4StrBuffer(0x1192, onVhfamFreq4Change);
- /**** 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(115000);
- /*
- The MAX72XX is in power-saving mode on startup,
- we have to do a wakeup call
- */
- lc.shutdown(0,false);
- /* Set the brightness to a medium values */
- lc.setIntensity(0,1);
- /* and clear the display */
- lc.clearDisplay(0);
- }
- /*
- 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();
- }
- /*
- 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) {
- if (address == 0x118e) {
- unsigned int vhfamFreq2Value = (value & 0x00f0) >> 4;
- lc.setChar(0,2,vhfamFreq2Value,true);
- }
- if (address == 0x118e) {
- unsigned int vhfamFreq3Value = (value & 0x0f00) >> 8;
- lc.setChar(0,3,vhfamFreq3Value,false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement