Vinc_Vega Posted March 3 Posted March 3 (edited) Hi Hammer, The above code doesn't include a Preset Channel display. If you want to have that display e.g. to the last two digits of an already used 8 digit module, you can plug in additional lines to my function"show_UhfFrequency()". See below code snippets for markings "edited code for a F-16 UHF CHAN Display" to see where the changes have to be in the sketch. Beware of, that I neither touched the rest of for the A-10C UHF code nor tested the edited sketch with hardware. Note, that an additional variable "String uhfChan" is created in the head of the sketch to convert the output String of the Channel to an integer and use the "showNumber" feature of the TM1637 library in the end. Spoiler /* use '#define DCSBIOS_DEFAULT_SERIAL' instead if your Arduino board does not feature an ATMega328 or ATMega2650 controller. */ #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" #include <Arduino.h> // ---------- Code for the DCS: A-10C UHF Radio panel ---------- #include <TM1637TinyDisplay6.h> #define CLK 4// Module connection pins (Digital Pins) #define DIO 5 TM1637TinyDisplay6 display(CLK, DIO);// Create the display object // ---------- DCS-BIOS stuff ---------- // variables for he UHF display String uhfFrequency = "251.000"; // temp frequency for startup uint8_t data[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; byte led_intensity = 5; // dimm intensity by the LCP_SIGNAL_LIGHTS switch (BRT / DIM) byte led_intensity_dimm = 0; // ---- edited code for a F-16 UHF CHAN Display String uhfChan = "00"; // amended code for a F-16 UHF CHAN Display // ---- end of edit // read the shown frequency of the (main panel) display void onUhfFrequencyChange(char* newValue) { uhfFrequency = newValue; } DcsBios::StringBuffer<7> uhfFrequencyBuffer(0x1180, onUhfFrequencyChange); // Dimm Displays according to Signal Lights on the Light System Control Panel void onLcpSignalLightsChange(unsigned int newValue) { switch (newValue) { case 0: display.setBrightness(led_intensity_dimm); break; default: display.setBrightness(led_intensity); break; } } DcsBios::IntegerBuffer lcpSignalLightsBuffer(0x1144, 0x0200, 9, onLcpSignalLightsChange); // ---- edited code for a F-16 UHF CHAN Display void onUhfChanDispChange(char* newValue) { uhfChan = newValue; } DcsBios::StringBuffer<2> uhfChanDispBuffer(0x45b0, onUhfChanDispChange); // ---- end of edit // ---------- End of DCS-BIOS stuff ---------- // ---------- Beginn of SETUP section ---------- void setup() { DcsBios::setup(); // startup sequence display.setBrightness(led_intensity); display.showString(" A-10C"); delay(2500); display.clear(); } // ---------- End of SETUP section ---------- // ---------- Begin of the LOOP section ---------- void loop() { DcsBios::loop(); // UHF frquency TM1637 LED display if ((uhfFrequency >= "1") && (uhfFrequency != "***.***")) // display is neither off nor in test mode (normal condition) { show_UhfFrequency(); } if ((uhfFrequency <= "1") && (uhfFrequency == "***.***")) // test mode "***.***" { display.showNumber(888.888); } if ((uhfFrequency <= "1") && (uhfFrequency != "***.***")) // blank displays when UHF Mode is set to OFF or electr. power is removed { display.clear(); } } // ---------- End of LOOP section ---------- // ---------- Declaration of functions ---------- void show_UhfFrequency() { // convert freq string to display the colon after the third digit data[0] = display.encodeASCII(uhfFrequency[0]); // digit 1 int digit2 = String(uhfFrequency[1]).toInt(); // digits 2 to 6 int digit3 = String(uhfFrequency[2]).toInt(); int digit4 = String(uhfFrequency[4]).toInt(); int digit5 = String(uhfFrequency[5]).toInt(); int digit6 = String(uhfFrequency[6]).toInt(); // ---- edited code for a F-16 UHF CHAN Display int digit7 = String(uhfChan[0]).toInt(); int digit8 = String(uhfChan[1]).toInt(); // ---- end of edit display.setSegments(data, 1, 0); display.showNumber(digit2, false, 1, 1); display.showNumberDec(digit3, 0b10000000, false, 1, 2); display.showNumber(digit4, false, 1, 3); display.showNumber(digit5, false, 1, 4); display.showNumber(digit6, false, 1, 5); // ---- edited code for a F-16 UHF CHAN Display display.showNumber(digit7, false, 1, 6); display.showNumber(digit8, false, 1, 7); // ---- end of edit } Regards,, Vinc Edited March 3 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
Hammer3246 Posted March 3 Posted March 3 (edited) 3 hours ago, Vinc_Vega said: Hi Hammer, The above code doesn't include a Preset Channel display. If you want to have that display e.g. to the last two digits of an already used 8 digit module, you can plug in additional lines to my function"show_UhfFrequency()". See below code snippets for markings "edited code for a F-16 UHF CHAN Display" to see where the changes have to be in the sketch. Beware of, that I neither touched the rest of for the A-10C UHF code nor tested the edited sketch with hardware. Note, that an additional variable "String uhfChan" is created in the head of the sketch to convert the output String of the Channel to an integer and use the "showNumber" feature of the TM1637 library in the end. Reveal hidden contents /* use '#define DCSBIOS_DEFAULT_SERIAL' instead if your Arduino board does not feature an ATMega328 or ATMega2650 controller. */ #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" #include <Arduino.h> // ---------- Code for the DCS: A-10C UHF Radio panel ---------- #include <TM1637TinyDisplay6.h> #define CLK 4// Module connection pins (Digital Pins) #define DIO 5 TM1637TinyDisplay6 display(CLK, DIO);// Create the display object // ---------- DCS-BIOS stuff ---------- // variables for he UHF display String uhfFrequency = "251.000"; // temp frequency for startup uint8_t data[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; byte led_intensity = 5; // dimm intensity by the LCP_SIGNAL_LIGHTS switch (BRT / DIM) byte led_intensity_dimm = 0; // ---- edited code for a F-16 UHF CHAN Display String uhfChan = "00"; // amended code for a F-16 UHF CHAN Display // ---- end of edit // read the shown frequency of the (main panel) display void onUhfFrequencyChange(char* newValue) { uhfFrequency = newValue; } DcsBios::StringBuffer<7> uhfFrequencyBuffer(0x1180, onUhfFrequencyChange); // Dimm Displays according to Signal Lights on the Light System Control Panel void onLcpSignalLightsChange(unsigned int newValue) { switch (newValue) { case 0: display.setBrightness(led_intensity_dimm); break; default: display.setBrightness(led_intensity); break; } } DcsBios::IntegerBuffer lcpSignalLightsBuffer(0x1144, 0x0200, 9, onLcpSignalLightsChange); // ---- edited code for a F-16 UHF CHAN Display void onUhfChanDispChange(char* newValue) { uhfChan = newValue; } DcsBios::StringBuffer<2> uhfChanDispBuffer(0x45b0, onUhfChanDispChange); // ---- end of edit // ---------- End of DCS-BIOS stuff ---------- // ---------- Beginn of SETUP section ---------- void setup() { DcsBios::setup(); // startup sequence display.setBrightness(led_intensity); display.showString(" A-10C"); delay(2500); display.clear(); } // ---------- End of SETUP section ---------- // ---------- Begin of the LOOP section ---------- void loop() { DcsBios::loop(); // UHF frquency TM1637 LED display if ((uhfFrequency >= "1") && (uhfFrequency != "***.***")) // display is neither off nor in test mode (normal condition) { show_UhfFrequency(); } if ((uhfFrequency <= "1") && (uhfFrequency == "***.***")) // test mode "***.***" { display.showNumber(888.888); } if ((uhfFrequency <= "1") && (uhfFrequency != "***.***")) // blank displays when UHF Mode is set to OFF or electr. power is removed { display.clear(); } } // ---------- End of LOOP section ---------- // ---------- Declaration of functions ---------- void show_UhfFrequency() { // convert freq string to display the colon after the third digit data[0] = display.encodeASCII(uhfFrequency[0]); // digit 1 int digit2 = String(uhfFrequency[1]).toInt(); // digits 2 to 6 int digit3 = String(uhfFrequency[2]).toInt(); int digit4 = String(uhfFrequency[4]).toInt(); int digit5 = String(uhfFrequency[5]).toInt(); int digit6 = String(uhfFrequency[6]).toInt(); // ---- edited code for a F-16 UHF CHAN Display int digit7 = String(uhfChan[0]).toInt(); int digit8 = String(uhfChan[1]).toInt(); // ---- end of edit display.setSegments(data, 1, 0); display.showNumber(digit2, false, 1, 1); display.showNumberDec(digit3, 0b10000000, false, 1, 2); display.showNumber(digit4, false, 1, 3); display.showNumber(digit5, false, 1, 4); display.showNumber(digit6, false, 1, 5); // ---- edited code for a F-16 UHF CHAN Display display.showNumber(digit7, false, 1, 6); display.showNumber(digit8, false, 1, 7); // ---- end of edit } Regards,, Vinc Thank you Vinc, very much appreciated! I have the Channel on a separate display but this should get me started to where I need. Cheers Ron Edited March 3 by Hammer3246 13900KF NVD4090 32RAM G2
Hammer3246 Posted March 3 Posted March 3 @Vinc_Vega Well I'm beat, I thought I could edit it to work on a second display but I can't. 13900KF NVD4090 32RAM G2
Vinc_Vega Posted March 4 Posted March 4 (edited) @Hammer3246 Have you already tried to declare two display objects? #include <TM1637TinyDisplay6.h> TM1637TinyDisplay6 display(4, 5);// Create a display object -> display for frequency TM1637TinyDisplay6 display2(11, 12);// Create a second display object -> display2 for channel Talk to both displays like so display.clear(); display2.clear(); The last lines of above code than must be changed in somethin like that // ---- edited code for a F-16 UHF CHAN Display display2.showNumber(digit7, false, 1, 0); display2.showNumber(digit8, false, 1, 1); // ---- end of edit Regards, Vinc Edited March 4 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
Hammer3246 Posted March 4 Posted March 4 @Vinc_VegaThanks, I did declare the two displays, and added some other lines similar to those. I get a not declared error when I try to compile it (don't recall which exactly). I'm gone to work for a couple weeks. So I'll try again when I get home. Thanks Ron 13900KF NVD4090 32RAM G2
Recommended Posts