Jump to content

F16 DED with HD44780 LCD plus I2C adapter


Recommended Posts

Hello, happy new year to everyone. I manage to build and connect the landing gear panel to an arduino Mega. Everything worked ok via dcs bios. So I need to represent the DED screen with lcd 20x4 I2c adapter.  With this sketch I manage to see the DED on the screen but I lost one line (the number of the waypoint). How can I add the other lines so i can see it in proper order?

Thanks in advance

 

 

/*
  Tell DCS-BIOS to use a serial connection and use interrupt-driven
  communication. The main program will be interrupted to prioritize
  processing incoming data.
  
  This should work on any Arduino that has an ATMega328 controller
  (Uno, Pro Mini, many others).
 */
#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

DcsBios::IntegerBuffer rfSwBuffer(0x4430, 0x1800, 0, 2);
DcsBios::Switch3Pos rfSw("RF_SW", 2, 3);

DcsBios::Switch2Pos laserArmSw("LASER_ARM_SW", 4);

DcsBios::IntegerBuffer masterArmSwBuffer(0x4424, 0x0030, 0, 2);
DcsBios::Switch3Pos masterArmSw("MASTER_ARM_SW", 5, 6);


DcsBios::Switch2Pos advModeSw("ADV_MODE_SW", 7);

DcsBios::IntegerBuffer apRollSwBuffer(0x4400, 0x0c00, 0, 2);
DcsBios::Switch3Pos apRollSw("AP_ROLL_SW", 8, 9);

DcsBios::IntegerBuffer apPitchSwBuffer(0x4400, 0x0300, 0, 2);
DcsBios::Switch3Pos apPitchSw("AP_PITCH_SW", 10, 11);

DcsBios::Switch2Pos emergStroreJett("EMERG_STRORE_JETT", 12);

DcsBios::Switch2Pos gndJettEnableSw("GND_JETT_ENABLE_SW", A1);

DcsBios::Switch2Pos brakeChanSw("BRAKE_CHAN_SW", A2);

DcsBios::Switch3Pos antiSkidSw("ANTI_SKID_SW", A3, A4);

DcsBios::Switch2Pos storesConfigSw("STORES_CONFIG_SW", A5);

DcsBios::Switch3Pos landTaxiLightSw("LAND_TAXI_LIGHT_SW", A8, A9);


DcsBios::LED lightGearN(0x4474, 0x0200, 13);
DcsBios::LED lightGearL(0x4474, 0x0400, 13);
DcsBios::LED lightGearR(0x4474, 0x0800, 13);
DcsBios::Switch2Pos gearHandle("GEAR_HANDLE", A10);


// Set the LCD address to 0x27 for a 20 chars and 4 line display
LiquidCrystal_I2C lcd(0x27, 20, 4);

void onDedLine1Change(char* newValue)
{
   // initialize the LCD
   lcd.begin();
   lcd.setCursor(0, 0);
   
  
   lcd.backlight();
   lcd.setCursor(0, 0);
   lcd.print(newValue);
}
DcsBios::StringBuffer<25> dedLine1Buffer(0x44fc, onDedLine1Change);


void setup() {

  DcsBios::setup();
  
}

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

ded screen1.jpg

IMG_0902.jpg

Link to post
Share on other sites

you need a different display, as this one supports only 20 characters in with, but you need at least 25 characters.

I did not found any display which fits the needs for a DED. The only thing i found was a reference on a arduino forum to a 40x4 display, but the link was broken.

Sry...

Maybe rethinking to a OLED display!

Link to post
Share on other sites
16 hours ago, GrafRotz said:

you need a different display, as this one supports only 20 characters in with, but you need at least 25 characters.

I did not found any display which fits the needs for a DED. The only thing i found was a reference on a arduino forum to a 40x4 display, but the link was broken.

Sry...

Maybe rethinking to a OLED display!

Hello GrafRotz, thanks for the reply, maybe you are right, but if I open the hello world sketch and change the words to UHF 305.00 SPTP @ 1, they  fit ok. Maybe the dcs bios translates characters differently . Thanks again.

IMG_0910.jpg

Screenshot_1.png

Link to post
Share on other sites

Please compare your two screenshots.

Your "Hello World" and the DCS-BIOS example have different lengh.

The DCS-BIOS has leading spaces and double spaces left an right from the frequency.

You can try to trim them out, but remember that to to this also on the other lines equaly otherwise it will destroy the format. Maybe it is even not possible. For the first row just for that DED Page it may fit, but remember, that other pages like the LIST may need much more characters.

I never tried it, as i only have 20x2 LCDs 😉


Edited by GrafRotz
Link to post
Share on other sites
1 hour ago, GrafRotz said:

Please compare your two screenshots.

Your "Hello World" and the DCS-BIOS example have different lengh.

The DCS-BIOS has leading spaces and double spaces left an right from the frequency.

You can try to trim them out, but remember that to to this also on the other lines equaly otherwise it will destroy the format. Maybe it is even not possible. For the first row just for that DED Page it may fit, but remember, that other pages like the LIST may need much more characters.

I never tried it, as i only have 20x2 LCDs 😉

 

I see.. Thanks a lot buddy!!!

Link to post
Share on other sites

Could you not just trim out some of those extra spaces? Something like:

void onDedLine1Change(char* newValue){
  // initialize the LCD
  lcd.begin();
  lcd.setCursor(0, 0);
  
  newValue.replace(" UHF ","UHF");
  newValue.replace(" VHF ","VHF");
  newValue.replace("  STPT "," STPT");
  
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print(newValue);
}

 

Another way to get an extra space would be to replace "STPT" to "STP". Not authentic but would get the job done.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...