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 ****/
- DcsBios::RotaryEncoder uhf10mhzSel("UHF_10MHZ_SEL", "DEC", "INC", 6, 7);
- void onUhf100mhzSelChange(char* newValue) {
- for(int i=0;i<1;i++) {
- lc.setChar(0,i,newValue[i],false);
- }
- }
- DcsBios::StringBuffer<1> uhf100mhzSelStrBuffer(0x1178, onUhf100mhzSelChange);
- void onUhfPoint25SelChange(char* newValue) {
- for(int i=0;i<2;i++) {
- lc.setChar(0,i+4,newValue[i],false);
- }
- }
- DcsBios::StringBuffer<2> uhfPoint25SelStrBuffer(0x117a, onUhfPoint25SelChange);
- /**** 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 == 0x1170) {
- unsigned int uhf10mhzSelValue = (value & 0x3c00) >> 10;
- lc.setChar(0,1,uhf10mhzSelValue,false);
- }
- if (address == 0x1178) {
- unsigned int uhf1mhzSelValue = (value & 0x0f00) >> 8;
- lc.setChar(0,2,uhf1mhzSelValue,false);
- }
- if (address == 0x1178) {
- unsigned int uhfPoint1mhzSelValue = (value & 0xf000) >> 12;
- lc.setChar(0,3,uhfPoint1mhzSelValue,false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement