Rapti Posted January 30, 2023 Posted January 30, 2023 (edited) Hello friends, maybe someone can help me here. I want to show certain values of the UHF on a display in my A-10 cockpit (for example the preset). The display is a 3.5in Arduino display. I must confess that I have little idea of DCS programming and do everything by Try&Error. I wrote the following program which writes the static text and graphics to the display. For the output of the preset channel I have the following code in DCS BIOS: void onUhfPresetChange(char* newValue) { /* your code here */ } DcsBios::StringBuffer<2> uhfPresetBuffer(0x1188, onUhfPresetChange); If I include this in my code then nothing happens in the display. The code compiles without any problems Could someone go over the code for a moment and tell me if I have a general problem in the code? https://pastebin.com/KbpkEs0S #define DCSBIOS_DEFAULT_SERIAL #include "DcsBios.h" #include <LCDWIKI_GUI.h> //Core graphics library #include <LCDWIKI_KBV.h> //Hardware-specific library LCDWIKI_KBV mylcd(ILI9481,A3,A2,A1,A0,A4); #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF void onUhfPresetChange(char* newValue) { mylcd.Set_Text_colour(RED); mylcd.Set_Text_Back_colour(BLACK); mylcd.Set_Text_Size(6); mylcd.Print_String(newValue, 294, 110); } DcsBios::StringBuffer<2> uhfPresetBuffer(0x1188, onUhfPresetChange); void setup() { DcsBios::setup(); Serial.begin(9600); mylcd.Init_LCD(); Serial.println(mylcd.Read_ID(), HEX); mylcd.Fill_Screen(BLACK); mylcd.Set_Text_Mode(0); mylcd.Set_Text_colour(GREEN); mylcd.Set_Text_Back_colour(BLACK); mylcd.Set_Text_Size(3); mylcd.Set_Rotation(1); mylcd.Print_String("ARC", 400, 20); mylcd.Print_String("210", 400, 45); mylcd.Set_Text_colour(WHITE); mylcd.Set_Text_Back_colour(BLACK); mylcd.Set_Text_Size(1); mylcd.Set_Rotation(3); mylcd.Print_String("DIGITAL", 405, 80); mylcd.Print_String("COMBAT", 407, 90); mylcd.Print_String("SIMULATOR", 398, 100); mylcd.Set_Text_Size(7.5); mylcd.Set_Text_Back_colour(WHITE); mylcd.Print_String("251.025", 105, 250); mylcd.Set_Text_Size(3); mylcd.Set_Text_colour(RED); mylcd.Set_Text_Back_colour(BLACK); mylcd.Print_String("VHF-A", 30, 40); mylcd.Print_String("VHF-F", 30, 160); mylcd.Print_String("UHF", 30, 270); mylcd.Set_Draw_color(RED); mylcd.Draw_Rectangle(20, 258, 86, 298); //mylcd.Draw_Rectangle(20, 115, 460, 155); //mylcd.Draw_Rectangle(20, 165, 460, 205); //mylcd.Set_Draw_color(RED); //mylcd.Fill_Rectangle(435, 70, 455, 100); //mylcd.Draw_Rectangle(435, 120, 455, 150); //mylcd.Draw_Rectangle(437, 122, 453, 148); //mylcd.Draw_Rectangle(435, 170, 455, 200); // mylcd.Draw_Rectangle(437, 172, 453, 198); mylcd.Set_Draw_color(WHITE); mylcd.Draw_Rectangle(265, 80, 350, 160); mylcd.Set_Text_colour(GREEN); mylcd.Set_Text_Back_colour(BLACK); mylcd.Set_Text_Size(2); mylcd.Print_String("PRESET", 274, 85); //mylcd.Set_Text_colour(RED); //mylcd.Set_Text_Back_colour(BLACK); //mylcd.Set_Text_Size(6); //mylcd.Print_String("3", 294, 110); mylcd.Set_Text_colour(GREEN); mylcd.Set_Text_Back_colour(BLUE); mylcd.Set_Text_Size(2); mylcd.Print_String("TACAN: 71X", 265, 180); mylcd.Print_String("ILS: 11", 265, 200); } void loop() { DcsBios::loop(); } Edited January 30, 2023 by Rapti
No1sonuk Posted January 31, 2023 Posted January 31, 2023 I can't get it to work either, and my character LCD display is showing the values changing, so it's not DCS. Your code is too complex for me to fault-find this evening. Maybe you should start over and make it modular to begin with. Get it displaying a simple value changing first, then go into the fancy formatting.
Vinc_Vega Posted January 31, 2023 Posted January 31, 2023 Try to remove or comment the "Serial" statements within the Setup loop. Regards, Vinc Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
Rapti Posted January 31, 2023 Author Posted January 31, 2023 (edited) 14 minutes ago, Vinc_Vega said: Try to remove or comment the "Serial" statements within the Setup loop. Regards, Vinc both of them? Edited January 31, 2023 by Rapti
Vinc_Vega Posted January 31, 2023 Posted January 31, 2023 (edited) Yes, both "Serial" statements as they may disturb the communication managed by DCS-Bios. Regards, Vinc Edited January 31, 2023 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
No1sonuk Posted January 31, 2023 Posted January 31, 2023 I just tried the OP sketch without those two lines and it now displays the changing number. Good call, Vinc. I would still suggest a rewrite in modular form, though. 1
Vinc_Vega Posted January 31, 2023 Posted January 31, 2023 (edited) Thanks for the reply The Serial protocol seems to conflict the DcsBios communication. For debugging I mostly put Bios commands within compiler switches to separate them from Serial commands. See below for your imagination. Regards, Vinc // #define TEST // uncomment for testmode #ifndef TEST #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" #endif ... void setup() { #ifdef TEST Serial.begin(115200); Serial.println("Booting..."); #endif #ifndef TEST DcsBios::setup(); #endif ... void loop() { #ifdef TEST run_display_test(); #endif #ifndef TEST DcsBios::loop(); #endif ... Edited January 31, 2023 by Vinc_Vega 1 Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
No1sonuk Posted January 31, 2023 Posted January 31, 2023 I usually send to an I2C character LCD for debugging.
Rapti Posted February 1, 2023 Author Posted February 1, 2023 (edited) Hi Vinc, thanks for your help. Works great! thats the new code: https://pastebin.com/hGaPPxqM regards Ivor 20230201_083653.mp4 Edited February 1, 2023 by Rapti 3
Metallkasten Posted February 6, 2023 Posted February 6, 2023 This was great. I tweaked it a little since it didn't seem to fit correctly on the elegoo tft display I have, I switched to all green/black as a matter of personal preference, and did some slight rearranging. https://pastebin.com/cS9vv56W 2
Recommended Posts