Jump to content

Recommended Posts

Posted

Building my A10 VHF Comm panels and I noticed for the frequency display and output for the Preselect Display, DCS Bios has you write your own code for the displays, and I'm clueless when it comes to this. Does anyone have a sketch I can "borrow" for these displays. For the Frequency display, I'm using an 8 digit 7 segmented LED display, (only 6 digits are visible in my panel) and 2 single digit 7 segmented displays for the preselect display. Thanks!!

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted
18 hours ago, Vinc_Vega said:

If your chip is a Max7219 or so, you could use the ledcontrol library for your displays. 😉

https://wayoda.github.io/LedControl/pages/software.html#7Seg

 

Regards, Vinc

 

Thanks Vinc. The 4 digit 7 segment displays I have do have the max7219s attached I believe, so thank you for the suggeston for using this library. Unfortunately I still have no idea how the code should be written in the sketch as I know nothing about writing code. Up until now, I have just copied and pasted the appropriate code from BORT in to my arduino sketches. I was hoping someone that knows how to write code and has already written the code for these displays, wouldn't mind sharing it for those of us without coding knowledge and experience. If there's any kind of tutorial on writing code for these displays with regard to using them in DCS, please let me know, as I'd love to learn as well. Thanks! 

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Posted (edited)

@Kenpilot

not yet perfect but something you can play with and try your displays ...

One Max7219; displays 0 to 5 for the frequency and 6 and 7 for the presets

Spoiler
// ---------- A-10C - VHF FM radio panel ----------
// ---------- Chip declaration here ----------  
#define DCSBIOS_IRQ_SERIAL
// #define DCSBIOS_DEFAULT_SERIAL  // for use with no Arduino Chips
#include "DcsBios.h"
#include <Wire.h>

#include "LedControl.h"
/* Create a new LedControl variable.
 * We use pins 12,11 and 10 on the Arduino for the SPI interface
 * Pin 12 is connected to the DATA IN-pin of the first MAX7221
 * Pin 11 is connected to the CLK-pin of the first MAX7221
 * Pin 10 is connected to the LOAD(/CS)-pin of the first MAX7221
 * There will only be a single MAX7221 attached to the arduino 
 */  
LedControl lc=LedControl(12,11,10,1); 

byte  led_intensity = 8;
String VhfFmFrequencyS = "30.000 ";
String VhffmPreset = " 1";

// ---------- DCS content here below ----------
// altenative output of the last two digits (nice rolling effect)
void onVhfFmFrequencySChange(char* newValue) {
	VhfFmFrequencyS = String(newValue);
}
DcsBios::StringBuffer<7> vhfFmFrequencySBuffer(0x1368, onVhfFmFrequencySChange);

// show the VHF FM Preset Channel
void onVhffmPresetChange(char* newValue) {
	VhffmPreset = newValue;
}
DcsBios::StringBuffer<2> VhffmPresetBuffer(0x1196, onVhffmPresetChange);


void setup() {
  DcsBios::setup();
  /*
   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 value */
  lc.setIntensity(0,led_intensity);
  /* and clear the display */
  lc.clearDisplay(0);
  /* we always wait a bit between updates of the display */
  delay(500);
}

void loop() {
  DcsBios::loop();
  showDisplay();    // see below for the function
}

void showDisplay()
{
  lc.shutdown(0,false);
  // display VHF frequency on displays 0 to 5
  if (VhfFmFrequencyS.toInt() < 100)	{
      lc.setChar(0,0,(VhfFmFrequencyS[5]),false);
      lc.setChar(0,1,(VhfFmFrequencyS[4]),false);  
      lc.setChar(0,2,(VhfFmFrequencyS[3]),false);  
      lc.setChar(0,3,(VhfFmFrequencyS[1]),true);  
      lc.setChar(0,4,(VhfFmFrequencyS[0]),false);  
      lc.setChar(0,5," ",false);  
     }
  else	{
      lc.setChar(0,0,(VhfFmFrequencyS[6]),false);
      lc.setChar(0,1,(VhfFmFrequencyS[5]),false);       
      lc.setChar(0,2,(VhfFmFrequencyS[4]),false);
      lc.setChar(0,3,(VhfFmFrequencyS[2]),true);
      lc.setChar(0,4,(VhfFmFrequencyS[1]),false);
      lc.setChar(0,5,(VhfFmFrequencyS[0]),false);
      }
  // display VHF preset channel on displays 6 and 7
  // version without leading zero
  if(VhffmPreset.toInt() < 10)	{
      lc.setChar(0,6,(VhffmPreset[1]),false);
      lc.setChar(0,7," ",false);
      }
  else	{
      lc.setChar(0,6,(VhffmPreset[1]),false);
      lc.setChar(0,7,(VhffmPreset[0]),false);
      } 
}

 

PS: in case of questions, just PM me.

Regards, Vinc

 

Edit: corrected code of leading digits for frequencies below 100.000 and presets less than 10  😉

Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted
On 4/14/2024 at 5:17 PM, No1sonuk said:

There's a "control reference" section of the DCS-BIOS files.

 

On 4/19/2024 at 9:28 AM, Vinc_Vega said:

@Kenpilot

not yet perfect but something you can play with and try your displays ...

One Max7219; displays 0 to 5 for the frequency and 6 and 7 for the presets

  Reveal hidden contents
// ---------- A-10C - VHF FM radio panel ----------
// ---------- Chip declaration here ----------  
#define DCSBIOS_IRQ_SERIAL
// #define DCSBIOS_DEFAULT_SERIAL  // for use with no Arduino Chips
#include "DcsBios.h"
#include <Wire.h>

#include "LedControl.h"
/* Create a new LedControl variable.
 * We use pins 12,11 and 10 on the Arduino for the SPI interface
 * Pin 12 is connected to the DATA IN-pin of the first MAX7221
 * Pin 11 is connected to the CLK-pin of the first MAX7221
 * Pin 10 is connected to the LOAD(/CS)-pin of the first MAX7221
 * There will only be a single MAX7221 attached to the arduino 
 */  
LedControl lc=LedControl(12,11,10,1); 

byte  led_intensity = 8;
String VhfFmFrequencyS = "30.000 ";
String VhffmPreset = " 1";

// ---------- DCS content here below ----------
// altenative output of the last two digits (nice rolling effect)
void onVhfFmFrequencySChange(char* newValue) {
	VhfFmFrequencyS = String(newValue);
}
DcsBios::StringBuffer<7> vhfFmFrequencySBuffer(0x1368, onVhfFmFrequencySChange);

// show the VHF FM Preset Channel
void onVhffmPresetChange(char* newValue) {
	VhffmPreset = newValue;
}
DcsBios::StringBuffer<2> VhffmPresetBuffer(0x1196, onVhffmPresetChange);


void setup() {
  DcsBios::setup();
  /*
   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 value */
  lc.setIntensity(0,led_intensity);
  /* and clear the display */
  lc.clearDisplay(0);
  /* we always wait a bit between updates of the display */
  delay(500);
}

void loop() {
  DcsBios::loop();
  showDisplay();    // see below for the function
}

void showDisplay()
{
  lc.shutdown(0,false);
  // display VHF frequency on displays 0 to 5
  if (VhfFmFrequencyS.toInt() < 100)	{
      lc.setChar(0,0,(VhfFmFrequencyS[5]),false);
      lc.setChar(0,1,(VhfFmFrequencyS[4]),false);  
      lc.setChar(0,2,(VhfFmFrequencyS[3]),false);  
      lc.setChar(0,3,(VhfFmFrequencyS[1]),true);  
      lc.setChar(0,4,(VhfFmFrequencyS[0]),false);  
      lc.setChar(0,5," ",false);  
     }
  else	{
      lc.setChar(0,0,(VhfFmFrequencyS[6]),false);
      lc.setChar(0,1,(VhfFmFrequencyS[5]),false);       
      lc.setChar(0,2,(VhfFmFrequencyS[4]),false);
      lc.setChar(0,3,(VhfFmFrequencyS[2]),true);
      lc.setChar(0,4,(VhfFmFrequencyS[1]),false);
      lc.setChar(0,5,(VhfFmFrequencyS[0]),false);
      }
  // display VHF preset channel on displays 6 and 7
  // version without leading zero
  if(VhffmPreset.toInt() < 10)	{
      lc.setChar(0,6,(VhffmPreset[1]),false);
      lc.setChar(0,7," ",false);
      }
  else	{
      lc.setChar(0,6,(VhffmPreset[1]),false);
      lc.setChar(0,7,(VhffmPreset[0]),false);
      } 
}

 

PS: in case of questions, just PM me.

Regards, Vinc

 

Edit: corrected code of leading digits for frequencies below 100.000 and presets less than 10  😉

 

Thanks Vinc! I'll be trying this tonight or tomorrow. I'll PM you with any issues or further questions. Thanks so much for your help!!

 

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...