ECV56_Polten Posted August 13, 2020 Posted August 13, 2020 Hi guys, I want to do something simple. The goal here is to show the speed on a LCD 16x2; for that, I have this code: #define DCSBIOS_DEFAULT_SERIAL #include <LiquidCrystal_I2C.h> #include "DcsBios.h" LiquidCrystal_I2C lcd(0x27, 16, 2); void setup() { // put your setup code here, to run once: lcd.init(); lcd.backlight(); lcd.clear(); lcd.setCursor(0,0); lcd.print("kmh"); DcsBios::setup(); } void loop() { DcsBios::loop(); } void onIasEuIntChange(unsigned int newValue) { /* your code here */ lcd.setCursor(0,1); lcd.print(newValue); } DcsBios::IntegerBuffer iasEuIntBuffer(0x042a, 0xffff, 0, onIasEuIntChange); The LCD only shows the "kmh" legend on the first row, but nothing is shown on the second row as intended. I checked the connection on DCS-BIOS web console and all is working fine, so I am guessing it has to be something in the code, probably a misplaced line of code. I am using an Arduino Uno board and a LCD 1602 I2C (PCF8574) :helpsmilie: Intel i5-7600K @3,80 (4,9 OC) + Corsair Vengeance 16GB DDR4@3200 XMP 2.0 + Cooler Master Hyper 212 LED + Asus MAXIMUS IX HERO + Thermaltake Chaser A31 Snow Edition Geforce RTX 2060 6GB SSD Samsung 850 EVO 500GB + HDD WDC WD500 500GB Saitek X-52 Pro & Thrustmaster T.Flight Rudder Pedals & TrackIR 5 & Kingston HyperX Alloy FPS Oh, yeah, also the Sony PlayStation 4 :happy:
No1sonuk Posted August 13, 2020 Posted August 13, 2020 Double-check this address: DcsBios::IntegerBuffer iasEuIntBuffer([u]0x042a[/u], 0xffff, 0, onIasEuIntChange); My control reference says this should be 0x0424.
ECV56_Polten Posted August 13, 2020 Author Posted August 13, 2020 I changed the address to 0x0424, and now it shows values on the LCD, but the incorrect ones, unless an F-14B can fly at speeds exceding Mach 10 :unsure: It shows values in the range of 12000 to 14000+ Intel i5-7600K @3,80 (4,9 OC) + Corsair Vengeance 16GB DDR4@3200 XMP 2.0 + Cooler Master Hyper 212 LED + Asus MAXIMUS IX HERO + Thermaltake Chaser A31 Snow Edition Geforce RTX 2060 6GB SSD Samsung 850 EVO 500GB + HDD WDC WD500 500GB Saitek X-52 Pro & Thrustmaster T.Flight Rudder Pedals & TrackIR 5 & Kingston HyperX Alloy FPS Oh, yeah, also the Sony PlayStation 4 :happy:
dracosb Posted August 14, 2020 Posted August 14, 2020 Display Problem Hi ECV56_Polten I currently have 11 Oled screens displaying things for the F18. I found I always had problems trying to directly print the newValue out so after several trys I found a solution that works for me. I'm reasonably new to this as well so there may be better ways to do it. I modified your code .. so give it a try. It might work. #include "DcsBios.h" LiquidCrystal_I2C lcd(0x27, 16, 2); unsigned int Speed; // create global variable visible in all the program void setup() { // put your setup code here, to run once: ScreenSetup(); DcsBios::setup(); } void loop() { DisplayScreen(); DcsBios::loop(); } void onIasEuIntChange(unsigned int newValue) { /* your code here */ Speed = newValue; // copy to the global variable } DcsBios::IntegerBuffer iasEuIntBuffer(0x042a, 0xffff, 0, onIasEuIntChange); void DisplayScreen(void) { lcd.setCursor(0,1); lcd.print(Speed); // print to screen } void ScreenSetup(void){ lcd.init(); lcd.backlight(); lcd.clear(); lcd.setCursor(0,0); lcd.print("kmh"); }
ECV56_Polten Posted August 15, 2020 Author Posted August 15, 2020 I tried your code dracosb but it keeps showing odd values Intel i5-7600K @3,80 (4,9 OC) + Corsair Vengeance 16GB DDR4@3200 XMP 2.0 + Cooler Master Hyper 212 LED + Asus MAXIMUS IX HERO + Thermaltake Chaser A31 Snow Edition Geforce RTX 2060 6GB SSD Samsung 850 EVO 500GB + HDD WDC WD500 500GB Saitek X-52 Pro & Thrustmaster T.Flight Rudder Pedals & TrackIR 5 & Kingston HyperX Alloy FPS Oh, yeah, also the Sony PlayStation 4 :happy:
dracosb Posted August 17, 2020 Posted August 17, 2020 Hi ECV56_Polten... I just tried the Speed displayed to a little 2 inch SPI TFT I have. The code is below. #define DCSBIOS_IRQ_SERIAL #include "SPI.h" #include "Adafruit_GFX.h" #include "Adafruit_ST7789.h" #include "DcsBios.h" #define TFT_DC 9 #define TFT_CS 10 #define TFT_RST 8 #define TFT_MOSI 11 #define TFT_SCLK 13 #define TFT_MISO 12 Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST); #define WHITE 0xFFFF // colors for Adafruit_GFX #define BLACK 0x0000 // colors for Adafruit_GFX unsigned int KMH; unsigned int KNOTS; /* paste code snippets from the reference documentation here */ void onIasEuIntChange(unsigned int newValue) { /* your code here */ KMH = newValue; } DcsBios::IntegerBuffer iasEuIntBuffer(0x042a, 0xffff, 0, onIasEuIntChange); void onIasUsIntChange(unsigned int newValue) { /* your code here */ KNOTS = newValue; } DcsBios::IntegerBuffer iasUsIntBuffer(0x042c, 0xffff, 0, onIasUsIntChange); void setup() { ScreenSetup(); DcsBios::setup(); } void loop() { DisplayScreen(); DcsBios::loop(); } void ScreenSetup(void) { tft.init(240, 320); // Init ST7789 320x240 tft.setRotation(3); tft.fillScreen(BLACK); tft.setTextColor( WHITE, BLACK); } void DisplayScreen(void) { tft.setCursor(15, 30); tft.setTextSize(3); tft.println(" Speed Test"); tft.setCursor(15, 60); tft.print(" KMH : "); tft.print(KMH); tft.setCursor(15, 90); tft.print(" Knots : "); tft.print(KNOTS); } Although the update was a little slow and slighlty different from the HUD speed (in Knots, F18C). I was getting about 6 Knots fast on the knots reading, and as I said a slow update speed of once every few seconds. not sure about the actual KMH as the F18 doesn't show it on the HUD. I tried the above DCS BIOS commands and the variants that use a char* instead of the unsigned int. All worked. Hope this helps you out.
ECV56_Polten Posted August 17, 2020 Author Posted August 17, 2020 There seems to be a problem on the onIasEuIntChange and onIasUsIntChange, or maybe a bug in DCS (never happened before, right?) I changed the code to use onIasEuChange and onIasUsChange, and a char array to int conversion, and it works; here's the code I used: #define DCSBIOS_DEFAULT_SERIAL #include <LiquidCrystal_I2C.h> #include "DcsBios.h" LiquidCrystal_I2C lcd(0x27, 16, 2); unsigned int SpeedEu; unsigned int SpeedUs; void setup() { // put your setup code here, to run once: ScreenSetup(); DcsBios::setup(); } void loop() { DisplayScreen(); DcsBios::loop(); } void ScreenSetup() { lcd.init(); lcd.backlight(); lcd.clear(); lcd.setCursor(0,0); lcd.print("kmh"); lcd.setCursor(8, 0); lcd.print("Knots"); } void DisplayScreen() { lcd.setCursor(0, 1); lcd.print(SpeedEu); lcd.setCursor(8, 1); lcd.print(SpeedUs); } void onIasUsChange(char* newValue) { SpeedUs = atoi(newValue); } DcsBios::StringBuffer<4> iasUsBuffer(0x0426, onIasUsChange); void onIasEuChange(char* newValue) { SpeedEu = atoi(newValue); } DcsBios::StringBuffer<4> iasEuBuffer(0x0422, onIasEuChange); Image shown below displaying an F-14 speed in Km/h and Knots. I also tried the same on Ka-50, no issues so far. Intel i5-7600K @3,80 (4,9 OC) + Corsair Vengeance 16GB DDR4@3200 XMP 2.0 + Cooler Master Hyper 212 LED + Asus MAXIMUS IX HERO + Thermaltake Chaser A31 Snow Edition Geforce RTX 2060 6GB SSD Samsung 850 EVO 500GB + HDD WDC WD500 500GB Saitek X-52 Pro & Thrustmaster T.Flight Rudder Pedals & TrackIR 5 & Kingston HyperX Alloy FPS Oh, yeah, also the Sony PlayStation 4 :happy:
dracosb Posted August 18, 2020 Posted August 18, 2020 Glad you solved it ECV56_Polten. Don't know why I didn't think of that because I used the atoi function when I was doing my RPM code for the F18C IFEI display.
Recommended Posts