Jump to content

dcs bios - 6 digit 7 seg


Regnad517

Recommended Posts

I think this is my last obstacle as far as programming.

 

I got this very nice 6 digit 7 segment tm1637

https://www.amazon.com/RobotDyn-6-Digit-7-segment-Display-76x19mm/dp/B071GN8ZGT?th=1

 

I have only been able to find 1 library for it

https://github.com/TinyTronics/TM1637_6D

 

That library only supports int variables. Im trying to use this as the ILS but want the Char variable options in advanced for matching game numbers.

 

I tried modifying the 4 digit 7 seg library I have and made progress, but the 6 digit writes data right to left so 108 shows up as 801, etc... and cannot set a cursor start point due to the right to left.

 

Any ideas?

 

Thanks again.

Link to comment
Share on other sites

Hi,

i had the same problem. After a long search problem solved. If you write lc.setChar(0,i,newValue,false);

 

You must invate ! this in the case who´s write. Exemple

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

 

//String inString = "";

 

void onVhfamFreq1Change(char* newValue) {

for(int i=0;i<2;i++) {

lc.setChar(0,i+4,newValue[!i],false);

}

 

}

 

 

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

 

void onVhfamFreq4Change(char* newValue) {

for(int i=0;i<2;i++) {

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

}

}

My english is not good but i hope help you:)

Aircrafts: F-16C | TF-51 | M2000C | F/A-18C | AV-8B | Viggen | KA-50 | A-10C | UH-1 | Mi-8 |

Maps: Caucasus | Persian Gulf | NTTR | Normandy | Syria

System: AMD Ryzen 3700X | 32GB Ram | AMD Radeon RX 5700 XT | Win10 64Bit | 1TB 970 EVO M.2 SSD

Equipment: TrackIR 5_Trackclip Pro |TM Warthog HOTAS | Oculus Rift S

Link to comment
Share on other sites

I think you can use this librarie for 4 or 6 digit tube. You must test it. I use 4 digit tube.

Aircrafts: F-16C | TF-51 | M2000C | F/A-18C | AV-8B | Viggen | KA-50 | A-10C | UH-1 | Mi-8 |

Maps: Caucasus | Persian Gulf | NTTR | Normandy | Syria

System: AMD Ryzen 3700X | 32GB Ram | AMD Radeon RX 5700 XT | Win10 64Bit | 1TB 970 EVO M.2 SSD

Equipment: TrackIR 5_Trackclip Pro |TM Warthog HOTAS | Oculus Rift S

Link to comment
Share on other sites

You can kontakt IAN. He make´s dcs bios. Send him an PM. I think he can help you.

;-)

Aircrafts: F-16C | TF-51 | M2000C | F/A-18C | AV-8B | Viggen | KA-50 | A-10C | UH-1 | Mi-8 |

Maps: Caucasus | Persian Gulf | NTTR | Normandy | Syria

System: AMD Ryzen 3700X | 32GB Ram | AMD Radeon RX 5700 XT | Win10 64Bit | 1TB 970 EVO M.2 SSD

Equipment: TrackIR 5_Trackclip Pro |TM Warthog HOTAS | Oculus Rift S

Link to comment
Share on other sites

Ian has helped me many many times already. I think I will be satisfied with this, at least it is working. Not as pretty as Ian would do it, but its working lol

 

Thanks

 

I spoke too soon - I can get Khz working on its own, and I can get Mhz working on its own, but cannot figure out how to get them both working together on this particular LED since it doesn't write normally or with place holders and I cannot nest a void statement within an if statement. Grrrrr Gonna sleep on it


Edited by Regnad517
Link to comment
Share on other sites

So I am back at this - IAN, can you look at this and tell me if there is a workaround. I do know this code will not compile but it hopefully gives you an idea of what I am trying to Accomplish

 

void onIlsMhzChange(unsigned int newValue) 
{

if (newValue==0)
 {
   void onIlsKhzChange(char* newValue) 
   {
       if (newValue==1)
       {
         int8_t ListDisp[6] = {8,0,1,5,9,0};
         int8_t ListDispPoint[6] = {POINT_OFF,POINT_OFF,POINT_OFF,POINT_ON,POINT_OFF,POINT_OFF};
         String millisstring;
         tm1637_6D.display(ListDisp, ListDispPoint);
       }
   }
   DcsBios::StringBuffer<2> ilsKhzStrBuffer(0x1172, onIlsKhzChange);
 }  

}
DcsBios::IntegerBuffer ilsMhzBuffer(0x1168, 0x0060, 5, onIlsMhzChange);

 

 

The idea is first I check for the char for the Mhz, if its 0 than the char should be 108. Great I got that fine, but then I need it to also check for the Khz while passing the 108 value. I understand there will be a crap ton of if else statements, but am willing to do that for this 6digit to work.


Edited by Regnad517
Link to comment
Share on other sites

OK - 3 posts in a row - I GOT IT WORKING

 

Not the prettiest way in the world but what I did was modified the 4 digit 1637 library to hold 6 coloms. Then I simply edited the DCS Bios A10C.lua for the ILS values so they write reversed (108 = 801, 109 = 901, etc...)

 

All is working perfectly!

Link to comment
Share on other sites

Yeah Sure.

 

First off I had to modify the library for the 4Digit 7Seg library file to be 6 Coloms rather than 4. Unfortunately since the 6 Digit display writes right to left there is still some confusion on cursor placement. I wrote a quick little display 1,2,3,4,5,6 to see which cursor placement each went in

 

Here is the code I had to change in the library

(Line 40)

#define TM1637_MAX_COLOM    6                 // number of coloms (digits)

Since there are only 4 values for the Mhz i did simple if, else statements

 

For the Khz, I went into the A10c.lua file found in your Saved Games directory of the user profile and changed the Khz values to be reversed

 

defineSetCommandTumb("ILS_KHZ", 53, 3003, 249, 0.1, {0.0, 0.9}, {"01", "51", "03", "53", "05", "55", "07", "57", "09", "59"}, false, "ILS Panel", "ILS Frequency KHz")

 

Here is the final code that works perfectly

 

/* Mega and Uno pinout is the same
*  GRND = GRND
*  VCC = 5V
*  D10 = Digital input pin - this code uses pin 3
*  CLK = Digital input pin - this code uses pin 2
*/
#define DCSBIOS_DEFAULT_SERIAL
#include "TM1637_6D.h"
#include <Wire.h> 
#include "SevenSegmentTM1637.h"
#define CLK 2 //pins definitions for TM1637 and can be changed to other ports
#define DIO 3
SevenSegmentTM1637 am(2,3); // CLK pin first, D10 pin second
TM1637_6D tm1637_6D(CLK,DIO);
#include "DcsBios.h"

// DCS-Bios Mhz Call
void onIlsMhzChange(unsigned int newValue) {
// Convert int values to char values reversed
 if (newValue==0){
   am.setCursor(0,0);
   am.print(801);
 }
   else
 if (newValue==1){
   am.setCursor(0,0);
   am.print(901);
 }  
   else
 if (newValue==2){
   am.setCursor(0,0);
   am.print("011");
 }  
   else
 if (newValue==3){
   am.setCursor(0,0);
   am.print(111);
 }  
}
DcsBios::IntegerBuffer ilsMhzBuffer(0x1168, 0x0060, 5, onIlsMhzChange);

// DCS-Bios Khz call with modified A10C.lua
void onIlsKhzChange(char* newValue) {
   am.setCursor(0,3);
   am.print(newValue);
}
DcsBios::StringBuffer<2> ilsKhzStrBuffer(0x1172, onIlsKhzChange);

// End DCS-Bios Code

void setup()
 {
   DcsBios::setup();
   am.init();
   am.clear();
 }

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

 

Ive also since added the 6 digit library to the code to add a decimal point between the Mhz and the Khz

 

I have no doubt that someone could have wrote code much better than mine, but pretty proud I got it working on my own :thumbup:


Edited by Regnad517
Link to comment
Share on other sites

  • 3 weeks later...

Well I finally got around to fixing this as well. Hated the idea of having to modify the A10.lua so I dug in and finally figured it out. Here is the new code I am using for this

 

 

/* Mega and Uno pinout is the same
*  GRND = GRND
*  VCC = 5V
*  D10 = Digital input pin - this code uses pin 3
*  CLK = Digital input pin - this code uses pin 2
*/
#define DCSBIOS_DEFAULT_SERIAL

#include <Wire.h> 
#include "SevenSegmentTM1637.h"

SevenSegmentTM1637 am(2,3); // CLK pin first, D10 pin second

#include "DcsBios.h"


// DCS-Bios Code
void onIlsMhzChange(char* newValue) {
   am.setCursor(0,0);
   am.print(newValue[0]);
   am.setCursor(0,1);
   am.print(newValue[1]);
   am.setCursor(0,2);
   am.print(newValue[2]);
}
DcsBios::StringBuffer<3> ilsMhzStrBuffer(0x116e, onIlsMhzChange);

void onIlsKhzChange(char* newValue) {

   am.setCursor(0,3);
   am.print(newValue[1]);
   am.setCursor(0,4);
   am.print(newValue[0]);
}
DcsBios::StringBuffer<2> ilsKhzStrBuffer(0x1172, onIlsKhzChange);

// End DCS-Bios Code

void setup()
 {
   DcsBios::setup();
   am.init();
   am.clear();
 }

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

 

Much cleaner and I don't have to modify the values in .lua

Link to comment
Share on other sites

  • 2 years later...
Well I finally got around to fixing this as well. Hated the idea of having to modify the A10.lua so I dug in and finally figured it out. Here is the new code I am using for this

 

 

/* Mega and Uno pinout is the same
*  GRND = GRND
*  VCC = 5V
*  D10 = Digital input pin - this code uses pin 3
*  CLK = Digital input pin - this code uses pin 2
*/
#define DCSBIOS_DEFAULT_SERIAL

#include <Wire.h> 
#include "SevenSegmentTM1637.h"

SevenSegmentTM1637 am(2,3); // CLK pin first, D10 pin second

#include "DcsBios.h"


// DCS-Bios Code
void onIlsMhzChange(char* newValue) {
   am.setCursor(0,0);
   am.print(newValue[0]);
   am.setCursor(0,1);
   am.print(newValue[1]);
   am.setCursor(0,2);
   am.print(newValue[2]);
}
DcsBios::StringBuffer<3> ilsMhzStrBuffer(0x116e, onIlsMhzChange);

void onIlsKhzChange(char* newValue) {

   am.setCursor(0,3);
   am.print(newValue[1]);
   am.setCursor(0,4);
   am.print(newValue[0]);
}
DcsBios::StringBuffer<2> ilsKhzStrBuffer(0x1172, onIlsKhzChange);

// End DCS-Bios Code

void setup()
 {
   DcsBios::setup();
   am.init();
   am.clear();
 }

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

 

Much cleaner and I don't have to modify the values in .lua

 

Hi Regnad517,

 

I try since a few days to use 2 of this 6 digit 7 seg on a Arduino Nano for UHF/VHF Display for the M2000C

 

Works great on USB but not with the #define DCSBIOS_RS485_SLAVE protocol :(

 

Have you find a solution ?

 

FYI

I tried to disable #define TM1637_DEBUG in SevenSegmentTM1637.h

and/or try to quote the Serial.begin and Serial.print but not better

 

For Sharing this is the code for the UHF/VHF display on M2000C

 

#include <SevenSegmentTM1637.h>
#define TM1637_MAX_LINES 1 // number of display lines
#define TM1637_MAX_COLOM 6 // number of coloms (digits)
SevenSegmentTM1637 uhf(6,7);
SevenSegmentTM1637 vhf(4,5);
#define DCSBIOS_DEFAULT_SERIAL
#include <DcsBios.h>

void onUhfFrequencyChange(char* newValue) {
//Display from left to the right
uhf.setCursor(0,2);
uhf.print(newValue[0]);
uhf.setCursor(0,1);
uhf.print(newValue[1]);
uhf.setCursor(0,0);
uhf.print(newValue[2]);
uhf.setCursor(0,5);
uhf.printRaw(128,5);
uhf.setCursor(0,4);
uhf.print(newValue[3]);
uhf.setCursor(0,3);
uhf.print(newValue[3]);
}
DcsBios::StringBuffer<5> uhfFrequencyBuffer(0x7334, onUhfFrequencyChange);

void onVhfFrequencyChange(char* newValue) {
vhf.setCursor(0,2);
vhf.print(newValue[0]);
vhf.setCursor(0,1);
vhf.print(newValue[1]);
vhf.setCursor(0,0);
vhf.print(newValue[2]);
vhf.setCursor(0,5);
vhf.printRaw(128,5);
vhf.setCursor(0,4);
vhf.print(newValue[3]);
vhf.setCursor(0,3);
vhf.print(newValue[3]);
}
DcsBios::StringBuffer<5> vhfFrequencyBuffer(0x732a, onVhfFrequencyChange);


void setup() {
DcsBios::setup();
uhf.init();
uhf.clear();
uhf.printRaw(128,4);
uhf.printRaw(128,5);

vhf.init();
vhf.clear();
vhf.printRaw(128,4);
vhf.printRaw(128,5);
}

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


Edited by Petit_Malin
Link to comment
Share on other sites

  • 8 months later...
  • Recently Browsing   0 members

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