Jump to content

Major Announcement: New software to to connect panels to DCS


FSFIan

Recommended Posts

  • Replies 398
  • Created
  • Last Reply

Top Posters In This Topic

could you do me an example of the on dcs bios write with the vhfam radio digit, sorry to be a pain but my old brain is struggling with this. thanks george..

AMD A8-5600K @ 4GHz, Radeon 7970 6Gig, 16 Gig Ram, Win 10 , 250 gig SSD, 40" Screen + 22 inch below, Track Ir, TMWH, Saitek combat pedals & a loose nut behind the stick :thumbup:

Link to comment
Share on other sites

untested:

#include <DcsBios.h>
#include <Servo.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>


LiquidCrystal_I2C lcd1(0x21, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
LiquidCrystal_I2C lcd2(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
/**** Make your changes after this line ****/
void onUhfFrequencyChange(char* newValue) {
lcd1.setCursor(0, 0);
lcd1.print(newValue); 

}
DcsBios::StringBuffer<7> uhfFrequencyBuffer(0x1180, onUhfFrequencyChange);

void onClockHhChange(char* newValue) {
lcd1.setCursor(0, 1);
lcd1.print(newValue);
}
DcsBios::StringBuffer<2> clockHhBuffer(0x10fe, onClockHhChange);

void onClockMmChange(char* newValue) {
lcd1.setCursor(3, 1);
lcd1.print(newValue);
}
DcsBios::StringBuffer<2> clockMmBuffer(0x1100, onClockMmChange);

void onClockSsChange(char* newValue) {
lcd1.setCursor(6, 1);
lcd1.print(newValue);
}
DcsBios::StringBuffer<2> clockSsBuffer(0x1102, onClockSsChange);

void onClockEtcChange(char* newValue) {
lcd1.setCursor(9, 1);
lcd1.print(newValue);
}
DcsBios::StringBuffer<3> clockEtcBuffer(0x1104, onClockEtcChange);

void onVhfamFreq1Change(char* newValue) {
lcd2.setCursor(0, 0);
lcd2.print(newValue);
}
DcsBios::StringBuffer<2> vhfamFreq1StrBuffer(0x1190, onVhfamFreq1Change);

void onVhfamFreq4Change(char* newValue) {
lcd2.setCursor(6, 0);
lcd2.print(newValue);
}
DcsBios::StringBuffer<2> vhfamFreq4StrBuffer(0x1192, onVhfamFreq4Change);

void onVhffmFreq1Change(char* newValue) {
lcd2.setCursor(0, 2);
lcd2.print(newValue);
}
DcsBios::StringBuffer<2> vhffmFreq1StrBuffer(0x119a, onVhffmFreq1Change);

void onVhffmFreq4Change(char* newValue) {
lcd2.setCursor(4, 2);
lcd2.print(newValue);
}
DcsBios::StringBuffer<2> vhffmFreq4StrBuffer(0x119e, onVhffmFreq4Change);
/**** In most cases, you do not have to change anything below this line ****/

/* Instantiate a ProtocolParser object to parse the DCS-BIOS export stream */
DcsBios:rotocolParser parser;

void setup() {
Serial.begin(115000);
lcd1.begin(16, 2);
lcd1.clear();
lcd2.begin(16, 2);
lcd2.clear();

}

/*
Your main loop needs to pass data from the DCS-BIOS export
stream to the parser object you instantiated above.

It also needs to call DcsBios:ollingInput::pollInputs()
to detect changes in the state of connected controls and
pass them on to DCS.
*/
void loop() {
// feed incoming data to the parser
while (Serial.available()) {
parser.processChar(Serial.read());
}

// poll inputs
DcsBios:ollingInput::pollInputs();
}

/*
You need to define
void sendDcsBiosMessage(const char* msg, const char* arg)
so that the string msg, followed by a space, the string arg
and a newline gets sent to the DCS-BIOS import stream.

In this example we send it to the serial port, so you need to
run socat to read the data from the serial port and send it
over UDP to DCS-BIOS.

If you are using an Ethernet Shield, you would probably want
to send a UDP packet from this subroutine.
*/
void sendDcsBiosMessage(const char* msg, const char* arg) {
Serial.write(msg);
Serial.write(' ');
Serial.write(arg);
Serial.write('\n');
}

/*
This subroutine gets called every time a message is received
from the export stream (you need to define it even if it
does nothing).

Use this to handle outputs which are not covered by the
DcsBios Arduino library (e.g. displays).
*/
void onDcsBiosWrite(unsigned int address, unsigned int value) {

 /* moved these lines down here */
 if (address == 0x118e) {
   unsigned int vhfamFreq2Value = (value & 0x00f0) >> 4;
   lcd2.setCursor(2, 0);
   lcd2.print(Value);
 }

}

 

BTW, this is a great example of how to ask a question. Because you provided complete example code, I could answer this in two minutes by showing you what I meant instead of trying to write an explanation or coming up with my own example code and circuit description.


Edited by [FSF]Ian
  • Like 1
Link to comment
Share on other sites

This wont verify. I get error message as below and lcd2.print(Value); is highlighted.

 

UHF_LCD_TEST.ino: In function 'void onDcsBiosWrite(unsigned int, unsigned int)':

UHF_LCD_TEST:131: error: 'Value' was not declared in this scope

 

thanks George.

AMD A8-5600K @ 4GHz, Radeon 7970 6Gig, 16 Gig Ram, Win 10 , 250 gig SSD, 40" Screen + 22 inch below, Track Ir, TMWH, Saitek combat pedals & a loose nut behind the stick :thumbup:

Link to comment
Share on other sites

IAN this gets better and better, I now have displays for CMSC,CMSP,UHF Radio, Both VHF Radios, Clock. ILS & TACAN are to do but now shouldn't be a problem, I can now begin to assemble panels and connect up the switches,rotaries,pots & encoders.

I cannot believe how easy it has been, Yes I have had a couple of questions but I had switches and rotary switches and encoders up and running moving the ones in dcs within hours of downloading the DCS_BIOS.

AMD A8-5600K @ 4GHz, Radeon 7970 6Gig, 16 Gig Ram, Win 10 , 250 gig SSD, 40" Screen + 22 inch below, Track Ir, TMWH, Saitek combat pedals & a loose nut behind the stick :thumbup:

Link to comment
Share on other sites

Hey guys so I'm posting the code for the shift registers (PISO,74HC165n) below. I didn't have time to look into the rotary encoders so they are non-functioning at this point.

 

DcsBios.cpp

http://pastebin.com/xPNAB6QF

 

DcsBios.h

http://pastebin.com/NCG42KXY

 

shift register sketch

http://pastebin.com/aTLntT1K

 

 

Here is the sketches for the 7seg leds and the max7219 (remember to change your baud rate)

 

UHF FREQS FOR MAX7219

http://pastebin.com/BuDQAMqZ

 

 

VHFAM FREQS FOR MAX7219

http://pastebin.com/QGZexyWF

 

 

During the weekend I will try to do the SIPO registers (74HC595) for leds and also test code for linking multiple 74hc165 together and linking multiple max7219 together.

Link to comment
Share on other sites

 

Felm for the Rots you may need external pullup resistors I saw a instruction using 3 resistors to make sure the Rots go high and low.

 

Hmmm, my setup is like this https://i.imgur.com/HkqIn28.png

 

Instead of switches I put the rots and each leg goes to a different register pin (pulled low). The common pin goes to 5v with no external resistor. I will put another 10k on the common pin, see if it changes anything.

Link to comment
Share on other sites

IAN this gets better and better, I now have displays for CMSC,CMSP,UHF Radio, Both VHF Radios, Clock. ILS & TACAN are to do but now shouldn't be a problem, I can now begin to assemble panels and connect up the switches,rotaries,pots & encoders.

I cannot believe how easy it has been, Yes I have had a couple of questions but I had switches and rotary switches and encoders up and running moving the ones in dcs within hours of downloading the DCS_BIOS.

 

Ian, the above statement is a testament to the fact that your DCS-BIOS has broken the barrier. If you recall a conversation we had many months ago that novice cockpit builders can usually find ways to make switches and buttons work without too much trouble. It was always the displays that ended up being the barrier. From the perspective of a novice cockpit builder like myself, making that part of the cockpit functional was not only extremely problematic it was a barrier which most of us could not break. It was also the point where many just gave up, being satisfied that at least we could make a switch work ...until of course ED broke it with another update:cry:.

 

You, my friend, with DCS-BIOS in hand has given us all the ability to break that barrier and remove the frustrations we have all had. GOOdnights statement above is the defining moment when the entire cockpit becomes completely open and available to all of us regardless of how little background one has in electronics or programming. Now anyone who has the motivation, the money and an extremely unbalanced mental condition:huh: can realize their dreams of a fully functional cockpit. And that is all because of your caring and dedication to this community.

 

I, personally,would like to thank you so very much for everything you've done and all that you have contributed towards making DCS so much more emmersive than anything I have ever seen in the past.

 

Thank you Ian.:)

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

Ian, the above statement is a testament to the fact that your DCS-BIOS has broken the barrier. If you recall a conversation we had many months ago that novice cockpit builders can usually find ways to make switches and buttons work without too much trouble. It was always the displays that ended up being the barrier. From the perspective of a novice cockpit builder like myself, making that part of the cockpit functional was not only extremely problematic it was a barrier which most of us could not break. It was also the point where many just gave up, being satisfied that at least we could make a switch work ...until of course ED broke it with another update:cry:.

 

You, my friend, with DCS-BIOS in hand has given us all the ability to break that barrier and remove the frustrations we have all had. GOOdnights statement above is the defining moment when the entire cockpit becomes completely open and available to all of us regardless of how little background one has in electronics or programming. Now anyone who has the motivation, the money and an extremely unbalanced mental condition:huh: can realize their dreams of a fully functional cockpit. And that is all because of your caring and dedication to this community.

 

I, personally,would like to thank you so very much for everything you've done and all that you have contributed towards making DCS so much more emmersive than anything I have ever seen in the past.

 

Thank you Ian.:)

 

It is truly amazing work. Ian essentially built us a house which we can decorate and modify to fit each of our specific needs. He also didn't just built it and abandon us, he is helping us each step of the way. Open source and community driven to the max. I actually feel proud being part of this even with my meager contributions.

Link to comment
Share on other sites

Yes to the above and I have absolutely no electronics or programming background so even a complete 50+ year old noob can do it..

AMD A8-5600K @ 4GHz, Radeon 7970 6Gig, 16 Gig Ram, Win 10 , 250 gig SSD, 40" Screen + 22 inch below, Track Ir, TMWH, Saitek combat pedals & a loose nut behind the stick :thumbup:

Link to comment
Share on other sites

Flem that's shaping up nicely. A few recommendations:

 

1) Don't modify DcsBios files directly unless your trying to submit a patch. It will bite you when it's time to upgrade. You can create cpp and h files inside your sketch or create a second libraries folder containing all you add-ons.

2) Don't depend on externally defined globals if at all possible. In your current code anyone who includes DcsBios.h will be required to define the global leds variable even if I'm not using shift registers. Better to pass in a pointer to the leds in the constructor. This would allow me to have two shift regsiters on different pins... or string two 8 bit registers together.

3) Don't update the shift register in the main loop. You should wait for the bios write on address 0xfffe. The update shift register is a slow operation and could interrupt processing data off the serial port if done where you have it right now.

Link to comment
Share on other sites

Ian asked me to make a GUI for handling serialports <--> DCS-BIOS communication.

I've posted DcsBiosCOMHandler for anyone interested to test.

As I haven't got Arduino boards and such I have not been able to test it. Hopefully someone here can give me some feedback.

Once it seems to shape up I think it will end up on Github (DCS-BIOS). Waiting for Ian's input.

Anywhoo if you are interested give it a shot. Attaching screenshot.

 

 

  • Lists all SerialPorts by default
  • You can "remove"/hide the SerialPorts not applicable (telephones etc)
  • Settings kept in a text file
  • Right click on a SerialPort opens up SerialPort comm parameters
  • Will show bytes sent in either direction (actually remembered I am using wrong int type for that :music_whistling:)
  • Rotating gear --> Data is being received from DCS-BIOS

 

:pilotfly:

dcsbios_com_handler_screenshot_alpha.thumb.jpg.e534453084ed5dc9584e5e616d09ce7a.jpg


Edited by ArturDCS
spelling
Link to comment
Share on other sites

Gadroc, many thanks for the advice. For 1 and 2 I am about to start work on the code for chained chips so I'll definitely take your recommendations into account.

 

About 3, do you mean I do it like this:

 

void onDcsBiosWrite(unsigned int address, unsigned int value) {

updateShiftRegister();

}

 

Because otherwise I'm not sure yet how I can make the code wait for DcsBios to write before calling the update shift register.


Edited by Felm
Link to comment
Share on other sites

Thanks! Out of curiosity though, what's the 0xfffe address? I looked it up in the control ref and both .h and .cpp files but didnt find it.

 

The data gets shifted out even without the if statement.

 

The 0xfffe address is a "magic number" it's the last data sent for a frame of the simulation. If you shift out data without it, your shifting out data for ever byte of data sent from the simulation. In a typical case that means you shifting the same data out 70-150 times every 30ms. This is probably causing you to lose data as the shift routine your using is slow (arduino function are written for safety not speed).

 

Any output updates LCD Screens, LEDs, etc. Should only be updated during the 0xfffe call. Otherwise you're doing it way more than you need to and you're possible displaying incorrect data.

Link to comment
Share on other sites

Thanks! Out of curiosity though, what's the 0xfffe address? I looked it up in the control ref and both .h and .cpp files but didnt find it.

 

It's in the control reference docs in the "MetadataEnd" module.

The update counter (which is constantly changing) lives at that address, so it is guaranteed to receive a write access in every update. DCS-BIOS is coded in a way that guarantees this to be the very last write access in a given update, so it doubles as the signal for "end of update, you now have ~30 ms until you have to react to the next one".

Link to comment
Share on other sites

The 0xfffe address is a "magic number" it's the last data sent for a frame of the simulation. If you shift out data without it, your shifting out data for ever byte of data sent from the simulation. In a typical case that means you shifting the same data out 70-150 times every 30ms. This is probably causing you to lose data as the shift routine your using is slow (arduino function are written for safety not speed).

 

Any output updates LCD Screens, LEDs, etc. Should only be updated during the 0xfffe call. Otherwise you're doing it way more than you need to and you're possible displaying incorrect data.

 

Ian;2307544']It's in the control reference docs in the "MetadataEnd" module.

The update counter (which is constantly changing) lives at that address, so it is guaranteed to receive a write access in every update. DCS-BIOS is coded in a way that guarantees this to be the very last write access in a given update, so it doubles as the signal for "end of update, you now have ~30 ms until you have to react to the next one".

 

Thanks to both of you for all the info, I am learning so much this is great! Ah, the elusive "MetadataEnd" module...second time I forgot to change from the a10c module.

 

Gadroc, I've been bashing my head on the keyboard since your last post trying to avoid a global variable but I'm a bit stuck. I can't see how to avoid using one since the bitSet happens in the .cpp file but the shiftout happens in the .ino sketch. How can the .ino know that the variable it's supposed to shift out has had its bits set in the .cpp file without using a global variable? I've tried googling for it but everything points to using extern variables. :helpsmilie:

 

Here is some very raw code

 


//****************.CPP FILE*********************

LEDSR2::LEDSR2(unsigned int address, unsigned int mask, char pin, unsigned int SRleds) {
address_ = address;
mask_ = mask;
pin_ = pin;
SRleds_ = SRleds;
}
void LEDSR2::onDcsBiosWrite(unsigned int address, unsigned int value) {
if (address_ == address) {
	if (value & mask_) {
		bitSet(SRleds_, pin_);   // THIS GUY DOESNT GET SHIFTED OUT!!!!??
	} else {
		bitClear(SRleds_, pin_); // THIS GUY DOESNT GET SHIFTED OUT!!!!??
	}
}
}


//*******************.H FILE*************

class LEDSR2 : ExportStreamListener {
private:
	void onDcsBiosWrite(unsigned int address, unsigned int value);
	unsigned char pin_;
	unsigned int address_;
	unsigned int mask_;
	unsigned int SRleds_;
public:
	LEDSR2(unsigned int address, unsigned int mask, char pin, unsigned int SRleds);
};

//**********************.INO SKETCH***********

[...]

unsigned int leds =0;

DcsBios::LEDSR2 masterCaution(0x1012, 0x0800, 2, leds);



[...]


void onDcsBiosWrite(unsigned int address, unsigned int value) {
  if (address == 0xfffe) {
       updateShiftRegister();
   }
}

void updateShiftRegister()
{
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, leds); // "leds" HAS NOT HAD ITS BITS SET ???
  digitalWrite(latchPin, HIGH);
}


 

wat do? put the class in the ino file?

Link to comment
Share on other sites

Gadroc, I've been bashing my head on the keyboard since your last post trying to avoid a global variable but I'm a bit stuck. I can't see how to avoid using one since the bitSet happens in the .cpp file but the shiftout happens in the .ino sketch. How can the .ino know that the variable it's supposed to shift out has had its bits set in the .cpp file without using a global variable? I've tried googling for it but everything points to using extern variables. :helpsmilie:

You need to research pointers. I won't directly give you the code, as using them without understanding them is a recipe for very very nasty crashes. Basically you define the variable in your sketch, pass in a pointer to the variable location in the constructor. Then the deference the pointer when setting the bit.

Link to comment
Share on other sites

CMSP Panel

 

Guys

 

Is DCS-Bios capable of displaying the CMSP output data onto a 20X2 transflective STN LCD or will I have to bin it and go with a viewport.? I am trying to do a proof of concept wiring diagram using an arduino mega before I start any soldering. Cheers

Windows 7 64 Home Premium, i5 3570K (3.4 @ 4.4GHz), Asus P8Z77-V LX, 16GB dual channel 1600 ram, EVGA Nvidia GTX980ti, 240 GB OCZ SSD, 3 TB Raptor, Thrustmaster Warthog Hotas and Throttle, Saitek Pro Combat Rudder pedals.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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