Jump to content

DCS BIOS - Starting a sketch


0414 Wee Neal

Recommended Posts

Hi

I am not sure how best to explain what I want to know/learn not being a programmer or expert in electronics, so I will put it in laymans terms; please excuse any faux par’s in descriptions!

Stage one – I have built my 1st VHF panel and have wired all of the buttons and switches etc and connected these to an Arduino Nano, this in turn is wired to an RS485 module – All simple so far!

Stage two – I have installed a 6 digit 7 segment display and wired this to an MAX 7219 module and connected this to the same Nano as above…All reasonably simple (I have already setup my Caution Light panel and have this working, so proved the design concept).

Stage three – I have written a sketch which incorporates the code for the VHF radio for each button, switch, encoder etc and uploaded this to the Nano. This all works and buttons operate as they should in DCS Warthog; happy days!

Stage four – Getting the 7 segment displays to work – Here I am struggling. I am not asking anyone to write my sketch as I would like to write this myself, but frankly I have no idea where to start? Can anyone help by answering these questions:

a. I have the MAX7219 datasheet and I am starting to understand, through your tube tutorials and Jeremy Blum text book what it all means. By doing this I can get the displays to light up and say help or 5 etc.

1). What is the next step in being able to tell the displays what to display?

2). Is this done by DCS BIOS? If so is this part of the code -

void onVhfamFreq1RotChange(unsigned int newValue) {
   /* your code here */
}
DcsBios::IntegerBuffer vhfamFreq1RotBuffer(0x11bc, 0x07f8, 3, onVhfamFreq1RotChange);

3). Where it says ‘your code here’ what is this code really doing – In laymans terms please.

Sorry if this seems a dumb set of questions, but I am struggling to understand what I am asking the displays to do, which is a fundamental starting point.

 

Cheers

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

This is what I wrote but I haven't had a chance to test it yet. I'm pretty sure it will work. Its also set up to be a slave for the RS485 bus so unless you already have a master in place you will have to comment out the 1st two command lines and insert the serial IRQ line from the template sketch.

 

I've also added a crap load of comments to help everyone understand what the code is doing.

 

/*
 The following #define tells DCS-BIOS that this is a RS-485 slave device.
 It also sets the address of this slave device. The slave address should be
 between 1 and 126 and must be unique among all devices on the same bus.
*/
#define DCSBIOS_RS485_SLAVE 11

#define TXENABLE_PIN 2 //The Arduino pin that is connected to the RE and DE pins on the RS-485 transceiver.

#include <LedControl.h> 
#include "DcsBios.h"

LedControl lc=LedControl(7,6,5,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 7 is connected to the DataIn 
pin 6 is connected to the CLK 
pin 5 is connected to LOAD
the last number...(1) is for how many MAX7219 we have daisy chained.
*/

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

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

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

void onVhfamFreq4Change(char* newValue) {
   lc.setChar(0,4,newValue[0],false);
   lc.setChar(0,5,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,10);//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();
}

 

I'm still in the beginning of the learning process myself. There are 4 lines taken from the control reference docs. Each for a specific digit of the display. Once you call for it you send it to the display as I have shown above. I sometimes get the lc.setChar mixed up with lc.setDigit.

 

If anyone else can add to this to help explain...this is like the blind leading the blind.:music_whistling: :P

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

Thanks John

 

I am assuming that what we are doing is to extract data from DCS on the radio freq, with the encoders linked to sim to change frequency there?

 

Thanks for the code it means nothing at the moment, so lots of reading to do!

 

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

  • 3 weeks later...

Hi John

 

I had to play around with some of the digit position numbers but it works like a dream, except the DP does not display. When first started the DP illuminates so I know that it works. My sketch so far:

 

/*
 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();
}

 

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

Neal

 

I expect that DCS does not export a decimal point. You will need to set it yourself by turning it on ( true/false ) at the digit you want it to be displayed.

 

Glad it works for you. Compare it to what you started with and see what you needed to do to make it work. Try and make this a learning experience so you can show others what to do later on.

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

  • 1 month later...

DCS-BIOS and Arduino Due

 

When i try upload my sketch to Due there was a problem with a serialpot registers. Sme sketch works fine with Mega. I Bought Due card bexause i have a plan use it with a EMI panel's stepper motors.so, what to do?

Link to comment
Share on other sites

Hi

unfortunately this question is beyond my knowledge to answer, i suggest you post on the DCS BIOS discussion thread which i am sure will illicit a response from the clever people we have the benefit of. Sorry i cant help.

 

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

  • Recently Browsing   0 members

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