radonk1979 Posted April 5, 2023 Posted April 5, 2023 Hi Everyone, I am getting closer to finish my PVI-800 for the KA-50. The two 6bit 7 Segment Displays for LAT and LONG coordinates are working. Now I am working on the NAV Target display. DCS BIOS code: //Display bottom line airfield/fixed/target/correction point void onPviLine2PointChange(char* newValue) { /* your code here */ } DcsBios::StringBuffer<1> pviLine2PointBuffer(0x1932, onPviLine2PointChange); For that I am plannig to use a single 7 Segment display. I was able to get it to show numbers using the following libraries. sevseg.h -> used this example https://www.circuitbasics.com/arduino-7-segment-display-tutorial/ easysevenseg.h I was able to get both to work with the sample code for example a count down. But when I am trying to embed this in the DCS Code I am struggeling. I hope that someone can point me in the right direction. Am I useing the right libraries or am I better of trying to program everything manual like in this sample? https://circuitdigest.com/microcontroller-projects/7-segment-display-interfacing-with-arduino #define segA 2//connecting segment A to PIN2 #define segB 3// connecting segment B to PIN3 #define segC 4// connecting segment C to PIN4 #define segD 5// connecting segment D to PIN5 #define segE 6// connecting segment E to PIN6 #define segF 7// connecting segment F to PIN7 #define segG 8// connecting segment G to PIN8 int COUNT=0;//count integer for 0-9 increment void setup() { for (int i=2;i<9;i++) { pinMode(i, OUTPUT);// taking all pins from 2-8 as output } } void loop() { switch (COUNT) { case 0://when count value is zero show”0” on disp digitalWrite(segA, HIGH); digitalWrite(segB, HIGH); digitalWrite(segC, HIGH); digitalWrite(segD, HIGH); digitalWrite(segE, HIGH); digitalWrite(segF, HIGH); digitalWrite(segG, LOW); break; case 1:// when count value is 1 show”1” on disp digitalWrite(segA, LOW); digitalWrite(segB, HIGH); digitalWrite(segC, HIGH); digitalWrite(segD, LOW); digitalWrite(segE, LOW); digitalWrite(segF, LOW); digitalWrite(segG, LOW); break; case 2:// when count value is 2 show”2” on disp digitalWrite(segA, HIGH); digitalWrite(segB, HIGH); digitalWrite(segC, LOW); digitalWrite(segD, HIGH); digitalWrite(segE, HIGH); digitalWrite(segF, LOW); digitalWrite(segG, HIGH); break; case 3:// when count value is 3 show”3” on disp digitalWrite(segA, HIGH); digitalWrite(segB, HIGH); digitalWrite(segC, HIGH); digitalWrite(segD, HIGH); digitalWrite(segE, LOW); digitalWrite(segF, LOW); digitalWrite(segG, HIGH); break; case 4:// when count value is 4 show”4” on disp digitalWrite(segA, LOW); digitalWrite(segB, HIGH); digitalWrite(segC, HIGH); digitalWrite(segD, LOW); digitalWrite(segE, LOW); digitalWrite(segF, HIGH); digitalWrite(segG, HIGH); break; case 5:// when count value is 5 show”5” on disp digitalWrite(segA, HIGH); digitalWrite(segB, LOW); digitalWrite(segC, HIGH); digitalWrite(segD, HIGH); digitalWrite(segE, LOW); digitalWrite(segF, HIGH); digitalWrite(segG, HIGH); break; case 6:// when count value is 6 show”6” on disp digitalWrite(segA, HIGH); digitalWrite(segB, LOW); digitalWrite(segC, HIGH); digitalWrite(segD, HIGH); digitalWrite(segE, HIGH); digitalWrite(segF, HIGH); digitalWrite(segG, HIGH); break; case 7:// when count value is 7 show”7” on disp digitalWrite(segA, HIGH); digitalWrite(segB, HIGH); digitalWrite(segC, HIGH); digitalWrite(segD, LOW); digitalWrite(segE, LOW); digitalWrite(segF, LOW); digitalWrite(segG, LOW); break; case 8:// when count value is 8 show”8” on disp digitalWrite(segA, HIGH); digitalWrite(segB, HIGH); digitalWrite(segC, HIGH); digitalWrite(segD, HIGH); digitalWrite(segE, HIGH); digitalWrite(segF, HIGH); digitalWrite(segG, HIGH); break; case 9:// when count value is 9 show”9” on disp digitalWrite(segA, HIGH); digitalWrite(segB, HIGH); digitalWrite(segC, HIGH); digitalWrite(segD, HIGH); digitalWrite(segE, LOW); digitalWrite(segF, HIGH); digitalWrite(segG, HIGH); break; break; } if (COUNT<10) { COUNT++; delay(1000);///increment count integer for every second } if (COUNT==10) { COUNT=0;// if count integer value is equal to 10, reset it to zero. delay(1000); } }
Vinc_Vega Posted April 5, 2023 Posted April 5, 2023 (edited) Hi radonk, For a single digit try the following code //Display bottom line airfield/fixed/target/correction point void onPviLine2PointChange(char* newValue) { sevseg.setNumber(newValue); } DcsBios::StringBuffer<1> pviLine2PointBuffer(0x1932, onPviLine2PointChange); In case chars are not allowed, you have to convert the "newValue" into an integer -> atoi(newValue) //Display bottom line airfield/fixed/target/correction point void onPviLine2PointChange(char* newValue) { sevseg.setNumber(atoi(newValue)); } DcsBios::StringBuffer<1> pviLine2PointBuffer(0x1932, onPviLine2PointChange); Regards, Vinc Edited April 5, 2023 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
radonk1979 Posted April 6, 2023 Author Posted April 6, 2023 Hi @Vinc_Vega I tired that and the display is staying blank. Below my code. Both version with the Int and converstion are not working and the display stays blank. At the bottom in the loop section is the sample where the display counts from 0 to 9. That is working so its means the cabeling and display is correct. Any other ideas>? #define DCSBIOS_DEFAULT_SERIAL #include "DcsBios.h" #include <SevSeg.h> SevSeg sevseg; //Display bottom line airfield/fixed/target/correction point void onPviLine2PointChange(char* newValue) { /* your code here */ //sevseg.setNumber(newValue); sevseg.setNumber(atoi(newValue)); } DcsBios::StringBuffer<1> pviLine2PointBuffer(0x1932, onPviLine2PointChange); void setup() { // put your setup code here, to run once: //Set to 1 for single-digit display byte numDigits = 1; //defines common pins while using multi-digit display. Left for single digit display byte digitPins[] = {}; //Defines Arduino pin connections in order: A, B, C, D, E, F, G, DP //byte segmentPins[] = {9,8, 7, 6, 5, 4, 3, 2}; //Braun, Rot, Orange, Gelb, Gruen, Blau, Lila, Grau byte segmentPins[] = {2, 3, 4, 5, 6, 8, 9, 13}; byte displayType = COMMON_CATHODE; //Use COMMON_ANODE for Common Anode display bool resistorsOnSegments = true; //‘false’ if resistors are connected to common pin //Initialize sevseg object. Use COMMON_ANODE instead of COMMON_CATHODE for CA display sevseg.begin(displayType, numDigits, digitPins, segmentPins, resistorsOnSegments); sevseg.setBrightness(50); } void loop() { DcsBios::loop(); //Display numbers 0-9 with 1 seconds delay // for(int i = 0; i <= 10; i++) // { // if (i == 10) //{ //i = 0; //} // sevseg.setNumber(i); // sevseg.refreshDisplay(); // delay(1000); // } }
Vinc_Vega Posted April 6, 2023 Posted April 6, 2023 (edited) You should add the refreshDisplay() line into the Bios part. sevseg.setNumber(atoi(newValue)); sevseg.refreshDisplay(); Edit: difficult to write to the tiny mobile phone display Regards, Vinc Edited April 6, 2023 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
radonk1979 Posted April 6, 2023 Author Posted April 6, 2023 Updated code below. I tried the refreshDisplay in the Loop Part and were it is no. No success. Is there a way to find out what the value of newValue() actually is before trying to display it? #define DCSBIOS_DEFAULT_SERIAL #include "DcsBios.h" #include <SevSeg.h> SevSeg sevseg; //Display bottom line airfield/fixed/target/correction point void onPviLine2PointChange(char* newValue) { /* your code here */ //sevseg.setNumber(newValue); sevseg.setNumber(atoi(newValue)); sevseg.refreshDisplay(); } DcsBios::StringBuffer<1> pviLine2PointBuffer(0x1932, onPviLine2PointChange); void setup() { // put your setup code here, to run once: //Set to 1 for single-digit display byte numDigits = 1; //defines common pins while using multi-digit display. Left for single digit display byte digitPins[] = {}; //Defines Arduino pin connections in order: A, B, C, D, E, F, G, DP //byte segmentPins[] = {9,8, 7, 6, 5, 4, 3, 2}; //Braun, Rot, Orange, Gelb, Gruen, Blau, Lila, Grau byte segmentPins[] = {2, 3, 4, 5, 6, 8, 9, 13}; byte displayType = COMMON_CATHODE; //Use COMMON_ANODE for Common Anode display bool resistorsOnSegments = true; //‘false’ if resistors are connected to common pin //Initialize sevseg object. Use COMMON_ANODE instead of COMMON_CATHODE for CA display sevseg.begin(displayType, numDigits, digitPins, segmentPins, resistorsOnSegments); sevseg.setBrightness(50); //Seven Segment to show "0" at startup sevseg.setNumber(0); } void loop() { DcsBios::loop(); //Display numbers 0-9 with 1 seconds delay // for(int i = 0; i <= 10; i++) // { // if (i == 10) //{ //i = 0; //} // sevseg.setNumber(i); // sevseg.refreshDisplay(); // delay(1000); // } }
Vinc_Vega Posted April 6, 2023 Posted April 6, 2023 (edited) As serial output doesn't work with DcsBios, you may readout the "newValue" to an Oled. I don't have BS installed, so the string probably has more than one char (digit) to display. First char maybe a space. Regards, Vinc Edited April 6, 2023 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
Vinc_Vega Posted April 6, 2023 Posted April 6, 2023 (edited) I can't see the DcsBios statement in the Setup routine. That may cause an issue. Put the following line as the first statement behind void setup() { DcsBios::setup(); Regards, Vinc Edited April 6, 2023 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
radonk1979 Posted April 6, 2023 Author Posted April 6, 2023 I created a test code with the 6digit TM1637 display which I know is working. The top line text is working. I then mode the display line up to //Display bottom line airfield/fixed/target/correction point. When I do this the display is dark and is not showiing anything #define DCSBIOS_DEFAULT_SERIAL #include "DcsBios.h" #include <TM1637TinyDisplay6.h> //#define CLK 11 //#define DIO 12 TM1637TinyDisplay6 display(11, 12); // 6-Digit Display Class //Display bottom line airfield/fixed/target/correction point void onPviLine2PointChange(char* newValue) { /* your code here */ display.showString(newValue); } //Display top line text void onPviLine1TextChange(char* newValue) { /* your code here */ //display.showString(newValue); } DcsBios::StringBuffer<6> pviLine1TextBuffer(0x1924, onPviLine1TextChange); void setup() { DcsBios::setup(); display.begin(); display.setBrightness(4); display2.begin(); display2.setBrightness(4); } void loop() { DcsBios::loop(); }
Vinc_Vega Posted April 6, 2023 Posted April 6, 2023 The StringBuffer line is missing for the bottom line content. And btw. that should only hold one char <1> Regards, Vinc Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
radonk1979 Posted April 6, 2023 Author Posted April 6, 2023 Thank you so much for your help and this code is working with the 6bit TM1637 module. I can see the display showing the correct information Next step is to convert this and figure out with the 1bit display is not working #define DCSBIOS_DEFAULT_SERIAL #include "DcsBios.h" #include <TM1637TinyDisplay6.h> //#define CLK 11 //#define DIO 12 TM1637TinyDisplay6 display(11, 12); // 6-Digit Display Class //Display bottom line airfield/fixed/target/correction point void onPviLine2PointChange(char* newValue) { /* your code here */ display.showString(newValue); } DcsBios::StringBuffer<1> pviLine2PointBuffer(0x1932, onPviLine2PointChange); //Display top line text void onPviLine1TextChange(char* newValue) { /* your code here */ //display.showString(newValue); } DcsBios::StringBuffer<6> pviLine1TextBuffer(0x1924, onPviLine1TextChange); void setup() { DcsBios::setup(); display.begin(); display.setBrightness(4); } void loop() { DcsBios::loop(); }
Vinc_Vega Posted April 6, 2023 Posted April 6, 2023 Have you tried your above code for the single digit and corrected the DcsBios::setup() line? Regards, Vinc Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
radonk1979 Posted April 6, 2023 Author Posted April 6, 2023 The above code works and is showing me the correct waypoint number on my 6bit display Cheers
Vinc_Vega Posted April 6, 2023 Posted April 6, 2023 I mean the sketch you posted 7 hours ago and that is missing the DcsBios::setup line. Regards, Vinc Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
radonk1979 Posted April 6, 2023 Author Posted April 6, 2023 No that one was not working even with the corrected line.
Recommended Posts