Advertisement
Guest User

UHF FREQS FOR MAX7219

a guest
Jan 30th, 2015
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.13 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.  
  13.  
  14. DcsBios::RotaryEncoder uhf10mhzSel("UHF_10MHZ_SEL", "DEC", "INC", 6, 7);
  15.  
  16.  
  17. void onUhf100mhzSelChange(char* newValue) {
  18.     for(int i=0;i<1;i++) {
  19.     lc.setChar(0,i,newValue[i],false);
  20. }
  21.  
  22.  
  23. }
  24. DcsBios::StringBuffer<1> uhf100mhzSelStrBuffer(0x1178, onUhf100mhzSelChange);
  25.  
  26. void onUhfPoint25SelChange(char* newValue) {
  27.     for(int i=0;i<2;i++) {
  28.     lc.setChar(0,i+4,newValue[i],false);
  29. }
  30. }
  31.  
  32. DcsBios::StringBuffer<2> uhfPoint25SelStrBuffer(0x117a, onUhfPoint25SelChange);
  33. /**** In most cases, you do not have to change anything below this line ****/
  34.  
  35. /* Instantiate a ProtocolParser object to parse the DCS-BIOS export stream */
  36. DcsBios::ProtocolParser parser;
  37.  
  38. void setup() {
  39.   Serial.begin(115000);
  40.  
  41.    /*
  42.    The MAX72XX is in power-saving mode on startup,
  43.    we have to do a wakeup call
  44.    */
  45.   lc.shutdown(0,false);
  46.   /* Set the brightness to a medium values */
  47.   lc.setIntensity(0,1);
  48.   /* and clear the display */
  49.   lc.clearDisplay(0);
  50. }
  51.  
  52.  
  53. /*
  54. Your main loop needs to pass data from the DCS-BIOS export
  55. stream to the parser object you instantiated above.
  56.  
  57. It also needs to call DcsBios::PollingInput::pollInputs()
  58. to detect changes in the state of connected controls and
  59. pass them on to DCS.
  60. */
  61. void loop() {
  62.   // feed incoming data to the parser
  63.   while (Serial.available()) {
  64.       parser.processChar(Serial.read());
  65.   }
  66.  
  67.   // poll inputs
  68.   DcsBios::PollingInput::pollInputs();
  69. }
  70.  
  71. /*
  72. You need to define
  73. void sendDcsBiosMessage(const char* msg, const char* arg)
  74. so that the string msg, followed by a space, the string arg
  75. and a newline gets sent to the DCS-BIOS import stream.
  76.  
  77. In this example we send it to the serial port, so you need to
  78. run socat to read the data from the serial port and send it
  79. over UDP to DCS-BIOS.
  80.  
  81. If you are using an Ethernet Shield, you would probably want
  82. to send a UDP packet from this subroutine.
  83. */
  84. void sendDcsBiosMessage(const char* msg, const char* arg) {
  85.   Serial.write(msg);
  86.   Serial.write(' ');
  87.   Serial.write(arg);
  88.   Serial.write('\n');
  89. }
  90.  
  91. /*
  92. This subroutine gets called every time a message is received
  93. from the export stream (you need to define it even if it
  94. does nothing).
  95.  
  96. Use this to handle outputs which are not covered by the
  97. DcsBios Arduino library (e.g. displays).
  98. */
  99.  
  100.  
  101.  
  102. void onDcsBiosWrite(unsigned int address, unsigned int value) {
  103.  
  104.     if (address == 0x1170) {
  105.     unsigned int uhf10mhzSelValue = (value & 0x3c00) >> 10;
  106.     lc.setChar(0,1,uhf10mhzSelValue,false);
  107.  
  108. }
  109.  
  110. if (address == 0x1178) {
  111.     unsigned int uhf1mhzSelValue = (value & 0x0f00) >> 8;
  112.     lc.setChar(0,2,uhf1mhzSelValue,false);
  113.    
  114. }
  115.  
  116. if (address == 0x1178) {
  117.     unsigned int uhfPoint1mhzSelValue = (value & 0xf000) >> 12;
  118.     lc.setChar(0,3,uhfPoint1mhzSelValue,false);
  119. }
  120.  
  121.  
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement