Advertisement
Guest User

VHFAM FREQS FOR MAX7219

a guest
Jan 30th, 2015
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.91 KB | None | 0 0
  1. #include <DcsBios.h>
  2. #include <Servo.h>
  3. #include <LedControl.h>
  4.  
  5. /* SET BAUD RATE IN CONNECT-SERIAL-PORT.CMD TO 115000 (OR WHATEVER YOU SET IN: void setup() Serial.begin(YOUR BAUD RATE HERE)) */
  6.  
  7. LedControl lc=LedControl(12,11,10,1);
  8. /* we always wait a bit between updates of the display */
  9. unsigned long delaytime=250;
  10. /**** Make your changes after this line ****/
  11.  
  12. //String inString = "";
  13.  
  14. void onVhfamFreq1Change(char* newValue) {
  15.   for(int i=0;i<2;i++) {
  16.     lc.setChar(0,i,newValue[i],false);
  17. }
  18.  }
  19.  
  20.  
  21. DcsBios::StringBuffer<2> vhfamFreq1StrBuffer(0x1190, onVhfamFreq1Change);
  22.  
  23.  void onVhfamFreq4Change(char* newValue) {
  24.     for(int i=0;i<2;i++) {
  25.    lc.setChar(0,i+4,newValue[i],false);
  26. }
  27. }
  28. DcsBios::StringBuffer<2> vhfamFreq4StrBuffer(0x1192, onVhfamFreq4Change);
  29.  
  30.  
  31. /**** In most cases, you do not have to change anything below this line ****/
  32.  
  33. /* Instantiate a ProtocolParser object to parse the DCS-BIOS export stream */
  34. DcsBios::ProtocolParser parser;
  35.  
  36. void setup() {
  37.   Serial.begin(115000);
  38.  
  39.    /*
  40.    The MAX72XX is in power-saving mode on startup,
  41.    we have to do a wakeup call
  42.    */
  43.   lc.shutdown(0,false);
  44.   /* Set the brightness to a medium values */
  45.   lc.setIntensity(0,1);
  46.   /* and clear the display */
  47.   lc.clearDisplay(0);
  48. }
  49.  
  50.  
  51. /*
  52. Your main loop needs to pass data from the DCS-BIOS export
  53. stream to the parser object you instantiated above.
  54.  
  55. It also needs to call DcsBios::PollingInput::pollInputs()
  56. to detect changes in the state of connected controls and
  57. pass them on to DCS.
  58. */
  59. void loop() {
  60.   // feed incoming data to the parser
  61.   while (Serial.available()) {
  62.       parser.processChar(Serial.read());
  63.   }
  64.  
  65.   // poll inputs
  66.   DcsBios::PollingInput::pollInputs();
  67. }
  68.  
  69. /*
  70. You need to define
  71. void sendDcsBiosMessage(const char* msg, const char* arg)
  72. so that the string msg, followed by a space, the string arg
  73. and a newline gets sent to the DCS-BIOS import stream.
  74.  
  75. In this example we send it to the serial port, so you need to
  76. run socat to read the data from the serial port and send it
  77. over UDP to DCS-BIOS.
  78.  
  79. If you are using an Ethernet Shield, you would probably want
  80. to send a UDP packet from this subroutine.
  81. */
  82. void sendDcsBiosMessage(const char* msg, const char* arg) {
  83.   Serial.write(msg);
  84.   Serial.write(' ');
  85.   Serial.write(arg);
  86.   Serial.write('\n');
  87. }
  88.  
  89. /*
  90. This subroutine gets called every time a message is received
  91. from the export stream (you need to define it even if it
  92. does nothing).
  93.  
  94. Use this to handle outputs which are not covered by the
  95. DcsBios Arduino library (e.g. displays).
  96. */
  97.  
  98.  
  99.  
  100. void onDcsBiosWrite(unsigned int address, unsigned int value) {
  101.  
  102.  if (address == 0x118e) {
  103.     unsigned int vhfamFreq2Value = (value & 0x00f0) >> 4;
  104.     lc.setChar(0,2,vhfamFreq2Value,true);
  105. }
  106.  
  107.   if (address == 0x118e) {
  108.     unsigned int vhfamFreq3Value = (value & 0x0f00) >> 8;
  109.     lc.setChar(0,3,vhfamFreq3Value,false);
  110. }
  111.  
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement