Jump to content

DCS Bios - VHF AM sketch issue


0414 Wee Neal

Recommended Posts

Hi

 

I have been working on a sketch (fro Warhog) for my vhf am radio and so far it all works well; except I cannot seem to get the decimal point to show.

 

I am using a Nano connected to a MAX7219 module, which has a 6 digit 7 segment display attached.

 

The sketch:

 

/*
 Tell DCS-BIOS to use a serial connection and use interrupt-driven
 communication. The main program will be interrupted to prioritize
 processing incoming data.
 
 This should work on any Arduino that has an ATMega328 controller
 (Uno, Pro Mini, many others).
*/
#define DCSBIOS_IRQ_SERIAL
#include <DcsBios.h>
#include <SegmentDisplay.h>
#include <LedControl.h>

//pin 3 is connected to the DataIn 
//pin 5 is connected to the CLK 
//pin 4 is connected to LOAD
LedControl lc=LedControl(3,5,4,1); //This creates an instance of a single controller named "lc"
/*
The sequence of pins used above are in the following order... LedControl(DIN,CLK,LOAD,# OF IC's) 
pin 3 is connected to the DataIn 
pin 5 is connected to the CLK 
pin 4 is connected to LOAD
the last number...(1) is for how many MAX7219 we have daisy chained.
*/

void onVhfamFreq1Change(char* newValue) {
  lc.setChar(0,1,newValue[0],false);
  lc.setChar(0,2,newValue[1],true);
}
DcsBios::StringBuffer<2> vhfamFreq1StrBuffer(0x1190, onVhfamFreq1Change);

void onVhfamFreq2Change(unsigned int newValue) {
  lc.setChar(0,3,newValue,false);
}
DcsBios::IntegerBuffer vhfamFreq2Buffer(0x118e, 0x00f0, 4, onVhfamFreq2Change);

void onVhfamFreq3Change(unsigned int newValue) {
    lc.setChar(0,4,newValue,false);
}
DcsBios::IntegerBuffer vhfamFreq3Buffer(0x118e, 0x0f00, 8, onVhfamFreq3Change);

void onVhfamFreq4Change(char* newValue) {
   lc.setChar(0,5,newValue[0],false);
   lc.setChar(0,6,newValue[1],false);
}
DcsBios::StringBuffer<2> vhfamFreq4StrBuffer(0x1192, onVhfamFreq4Change);

void setup() {
 DcsBios::setup();

 //This initializes the MAX7219 and gets it ready of use:
 lc.shutdown(0,false); //turn on the display
 lc.setIntensity(0,8);//set the brightness 
 lc.clearDisplay(0); //clear the display 

//The following series of "lc.setChar" commands are used to display the number 8 in each digit.  This allows us to see each that LED segment is actually working.
 lc.setChar(0,0,'8',false);// The first number...0,  means there are no other MAX7219's connected to the one we are using. 
 lc.setChar(0,1,'8',false);// The second number...1, indicates the digit you are sending data too...digit numbering starts at 0. 
 lc.setChar(0,2,'8',true);//  The third number in single quotes is the character thats displayed
 lc.setChar(0,3,'8',false);// The statement... true/false is to turn on or off the decimal point (dp) for that particular digit. 
 lc.setChar(0,4,'8',false);
 lc.setChar(0,5,'8',false);
}

void loop() {
 DcsBios::loop();
}

 

When the Nano is first connected all of the digits and the 3rd DP illuminate. When connecting to the .Cmd and DCS Warthog the radio frequency displays no problem, except the DP.

 

can anyone advise on what may be wrong?

 

Thanks

 

Neal

Desktop PC:

Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti

Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels.

Link to comment
Share on other sites

  • 2 weeks later...

Hi, here is modifications what i did for your sketch, and now it´s works with my system.Btw at the original radio, i can´t see the decimal points trough those small openings...

/*

Tell DCS-BIOS to use a serial connection and use interrupt-driven

communication. The main program will be interrupted to prioritize

processing incoming data.

 

This should work on any Arduino that has an ATMega328 controller

(Uno, Pro Mini, many others).

*/

#define DCSBIOS_IRQ_SERIAL

#include <DcsBios.h>

#include <LedControl.h>

 

//pin 3 is connected to the DataIn

//pin 5 is connected to the CLK

//pin 4 is connected to LOAD

LedControl lc=LedControl(9,7,8,1); //This creates an instance of a single controller named "lc"

/*

The sequence of pins used above are in the following order... LedControl(DIN,CLK,LOAD,# OF IC's)

pin 3 is connected to the DataIn

pin 5 is connected to the CLK

pin 4 is connected to LOAD

the last number...(1) is for how many MAX7219 we have daisy chained.

*/

 

void onVhfamFreq1Change(char* newValue) {

lc.setChar(0,5,newValue[0],false);

lc.setChar(0,4,newValue[1],true);

}

DcsBios::StringBuffer<2> vhfamFreq1StrBuffer(0x1190, onVhfamFreq1Change);

 

void onVhfamFreq2Change(unsigned int newValue) {

lc.setChar(0,3,newValue,false);

}

DcsBios::IntegerBuffer vhfamFreq2Buffer(0x118e, 0x00f0, 4, onVhfamFreq2Change);

 

void onVhfamFreq3Change(unsigned int newValue) {

lc.setChar(0,2,newValue,false);

}

DcsBios::IntegerBuffer vhfamFreq3Buffer(0x118e, 0x0f00, 8, onVhfamFreq3Change);

 

void onVhfamFreq4Change(char* newValue) {

lc.setChar(0,1,newValue[0],false);

lc.setChar(0,0,newValue[1],false);

}

DcsBios::StringBuffer<2> vhfamFreq4StrBuffer(0x1192, onVhfamFreq4Change);

 

void setup() {

DcsBios::setup();

 

//This initializes the MAX7219 and gets it ready of use:

lc.shutdown(0,false); //turn on the display

lc.setIntensity(0,8);//set the brightness

lc.clearDisplay(0); //clear the display

 

//The following series of "lc.setChar" commands are used to display the number 8 in each digit. This allows us to see each that LED segment is actually working.

lc.setChar(0,5,'8',false);// The first number...0, means there are no other MAX7219's connected to the one we are using.

lc.setChar(0,4,'8',false);// The second number...1, indicates the digit you are sending data too...digit numbering starts at 0.

lc.setChar(0,3,'8',true);// The third number in single quotes is the character thats displayed

lc.setChar(0,2,'8',false);// The statement... true/false is to turn on or off the decimal point (dp) for that particular digit.

lc.setChar(0,1,'8',false);

lc.setChar(0,0,'8',false);

}

 

void loop() {

DcsBios::loop();

}

Link to comment
Share on other sites

Reason for modification

 

I bought from Ebay 7segment display module with 7219 controller attached.

and when i did a test with your code, it works but those numbers which are meant to be right was left etc.etc.

Link to comment
Share on other sites

Hi

Its a great sense of achievement when it works! I solved the DP matter, which is simply a case of changing false to true on the relevant digit. An important observation is that with my 6 digit display and 7219 module I could only wire in 1 DP.

 

Neal

Desktop PC:

Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti

Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels.

Link to comment
Share on other sites

Hi

Its a great sense of achievement when it works! I solved the DP matter, which is simply a case of changing false to true on the relevant digit. An important observation is that with my 6 digit display and 7219 module I could only wire in 1 DP.

 

Neal

 

Why was that Neal...not enough space for traces.

 

One thing to note regarding this decimal point. The real radio uses a rolling tape display and its designed to provide a decimal point before the number. I have taken some graphic license and redesigned the panel to incorporate a 7 seg display. As a result the decimal point can only be placed after the number due to the layout of the digits. This of course would not have any impact on the UHF radio as it uses an LCD type display which will allow the decimal point to be located at the correct spot.

 

As to turning it on (the dp), I had a feeling you would figure that out yourself Neal. Good work.:thumbup:

 

Don't forget to post some pics of the radio when your done.

Regards

John W

aka WarHog.

 

My Cockpit Build Pictures...



John Wall

 

My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing

 

 

WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram,



AIO Water Cooler, M.2 512GB NVMe,

500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display

VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals

Link to comment
Share on other sites

  • 3 years later...

Hi everyone,

 

I have a question for what you guys did with the "Preset Channel Selector."

 

Did you guys use a rotary encoder with a thumbwheel attached and a bcd to 7 segment decoder like the CD4511BE?

 

I haven't been able to find a good thumbwheel as well. they are always cheap and too small.

 

This is the next panel I am attacking and looking for some guidance. Thanks!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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