Jump to content

Recommended Posts

Posted

Well I've started making larger bits of A-10 cockpit.

Here's the beginning of my CDU:
3w5ujMv.png

 

The design is based on plans from here:

 

And Robinmli's work here:

 

I have a 3.5inch TFT shield run by an Arduino.  I'm planning to have a separate one for the keys.

Currently running an Uno, but there's a bit of lag.

Any ideas on a faster Arduino that's Uno-compatible?  The Mega I tried was glacially slow.

 

Here's the display code.

 

/*
  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 <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>

MCUFRIEND_kbv tft;

#define BLACK   0x0000
#define GREEN   0x07E0

// Text position adjustments numbers found by experimentation.
#define LineHeight 31  // 8 x text size
#define LeftEdge 48 // left line margin start point
#define TopEdge 12  // Top line margin start point

/* paste code snippets from the reference documentation here */


void onCduLine0Change(char* newValue) {
    tft.setCursor(LeftEdge, (LineHeight * 0)+TopEdge);  //h,v in pixels
    tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine0Buffer(0x11c0, onCduLine0Change);

void onCduLine1Change(char* newValue) {
    tft.setCursor(LeftEdge, (LineHeight * 1)+TopEdge);  //h,v in pixels
    tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine1Buffer(0x11d8, onCduLine1Change);

void onCduLine2Change(char* newValue) {
    tft.setCursor(LeftEdge, (LineHeight * 2)+TopEdge);  //h,v in pixels
    tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine2Buffer(0x11f0, onCduLine2Change);

void onCduLine3Change(char* newValue) {
    tft.setCursor(LeftEdge, (LineHeight * 3)+TopEdge);  //h,v in pixels
    tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine3Buffer(0x1208, onCduLine3Change);

void onCduLine4Change(char* newValue) {
    tft.setCursor(LeftEdge, (LineHeight * 4)+TopEdge);  //h,v in pixels
    tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine4Buffer(0x1220, onCduLine4Change);

void onCduLine5Change(char* newValue) {
    tft.setCursor(LeftEdge, (LineHeight * 5)+TopEdge);  //h,v in pixels
    tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine5Buffer(0x1238, onCduLine5Change);

void onCduLine6Change(char* newValue) {
    tft.setCursor(LeftEdge, (LineHeight * 6)+TopEdge);  //h,v in pixels
    tft.print(newValue);
}

DcsBios::StringBuffer<24> cduLine6Buffer(0x1250, onCduLine6Change);

void onCduLine7Change(char* newValue) {
    tft.setCursor(LeftEdge, (LineHeight * 7)+TopEdge);  //h,v in pixels
    tft.print(newValue);
}

DcsBios::StringBuffer<24> cduLine7Buffer(0x1268, onCduLine7Change);

void onCduLine8Change(char* newValue) {
    tft.setCursor(LeftEdge, (LineHeight * 8)+TopEdge);  //h,v in pixels
    tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine8Buffer(0x1280, onCduLine8Change);

void onCduLine9Change(char* newValue) {
    tft.setCursor(LeftEdge, (LineHeight * 9)+TopEdge);  //h,v in pixels
    tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine9Buffer(0x1298, onCduLine9Change);





void setup() {
  DcsBios::setup();

      tft.reset();
    uint16_t identifier = tft.readID();
    if (identifier == 0xEFEF) identifier = 0x9486;
    tft.begin(identifier);
      tft.fillScreen(0x0000);


tft.setRotation(1); // Landscape


splashScreen();  // Show power-up splash screen

tft.setTextSize(3); // Characters are 5x7 +1 right and bottom
tft.setTextColor(GREEN,BLACK);  // text colour,background
}

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


void splashScreen() //Simple "splash screen" on power-up
{
      tft.setCursor(LeftEdge, (LineHeight * 0)+TopEdge);  //h,v in pixels
      tft.setTextSize(6); // Characters are 5x7 +1 right and bottom
          tft.print("A-10 CDU");
          delay(2000);
                tft.fillScreen(0x0000);
}

 

 

 

  • Like 1
Posted

good luck on your project!
i'm stlll planning on 3.5" analog screen (out of automotive rear view monitor) driven RPi for my CDU. Result was very responsive
I lost the code from five years ago but I plan to revisit and recreate from the below


 

Anton.

 

My pit build thread .

Simple and cheap UFC project

Posted

I think, the slow response of the display is caused by the DCS-BIOS connection. It is even more slower if going the RS485 way. So it's better to stay with USB.

Personally I use a NANO for my 4" CDU-Display, it has the same chip like the UNO but is smaller and  cheaper. The keypad matrix is driven by a second NANO, connected via RS485 bus.

 

Regards, Vinc

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted
On 7/20/2021 at 6:37 PM, agrasyuk said:

good luck on your project!
i'm stlll planning on 3.5" analog screen (out of automotive rear view monitor) driven RPi for my CDU. Result was very responsive
I lost the code from five years ago but I plan to revisit and recreate from the below
 

I'm running DCS on a laptop, so I want minimum PC overheads - I've also got a MFCD planned.
 

10 hours ago, Vinc_Vega said:

I think, the slow response of the display is caused by the DCS-BIOS connection. It is even more slower if going the RS485 way. So it's better to stay with USB.

Personally I use a NANO for my 4" CDU-Display, it has the same chip like the UNO but is smaller and  cheaper. The keypad matrix is driven by a second NANO, connected via RS485 bus.

 

Regards, Vinc

I've tried 3 Arduinos so far - all "uno shield compatible" because that's how my LCD works.
Uno - "fastest"

Leonardo "middle" - I had to use the "default" type as the "IRQ" one wouldn't compile.
Mega2560 "GLACIALLY SLOW!" - In fact, it was so slow it was pointless.

I've got some Nanos, but no conversion board to try it out.

 

WRT the keypad, I was considering using a 32u4 unit like a Leonard or Pro Micro set up as an HID keyboard.
Would the "direct" DCS-BIOS route have an advantage beyond the price of the devices?

Posted
2 hours ago, agrasyuk said:

I don't see how a server for RPi export has that impact. 

2 things:
1) What interface does it use between the PC and the RPi?
2) I've never used RPis, so I'd need to start from scratch.  Including, I assume, buying a new display. I have Arduinos already...

Posted

None of these 2 points are PC overheads.

1. Connectivity is via LAN (or wifi). You will open corresponding port on your host PC in the DCSBIOS script. I think it's ideal.

 

2. That is true, new hardware purchase and new (untriviall ) skillset to learn. 

 

It's your call on how you want to accomplish the faster CDU display you desire, your reservations are understandable.  Good luck !

Anton.

 

My pit build thread .

Simple and cheap UFC project

Posted
vor 19 Stunden schrieb No1sonuk:

I've got some Nanos, but no conversion board to try it out.

 

Just (jump) wire the display to the Nano and use the same pin numbers like at the Uno. Both boards are pin compatible.

 

Regards, Vinc

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted

Great work and a huge thank you for the code.

 

I Can Design in 3d

CNC all types of stuff

laser cut and engrave

BUT programming is not my cup of tea

 

The code you have provided works very well with the mega ( Thank you )

but I am having trouble with the strange fonts on the display as pictured

Have you any idea Where I could implement a different type of font

Thanks in AdvanceIMG_8290.JPG 

Screen Shot 2021-07-28 at 20.57.02.png

Posted
14 hours ago, LAURRENCE2021 said:

Great work and a huge thank you for the code.

 

I Can Design in 3d

CNC all types of stuff

laser cut and engrave

BUT programming is not my cup of tea

 

The code you have provided works very well with the mega ( Thank you )

but I am having trouble with the strange fonts on the display as pictured

Have you any idea Where I could implement a different type of font

Thanks in Advance 

 

IF you look in RobinMli's thread I linked to above, he has a link to Github which includes a modified font file.

 

To use it, you replace the file in the adafruit GFX library folder (rename the old one), then recompile the arduino program.
NOTE: To save you the multiple hours it took me to find out:  You need to replace the file in the main program library structure, NOT the one under the "documents" structure.

 

When you've recompiled it, the display should show the new characters.
Having written this, I realised I might have used a modified version, but try that first.

THEN, you might still have some characters wrong...
IIRC, this is due to an extra character definition that needs to be commented out.

Get back to me if you have a problem.  I'll look at my files when I get home from work.

Posted

I've added the file to this message.
If you look at the file in a text editor, you can see on line 198 where I commented out a character to fix the display of characters following that one in the font.

The file goes in the Adafruit_GFX library folder.
On my computer, the correct folder is here:  C:\Program Files (x86)\Arduino\libraries\Adafruit_GFX

Rename the old glcdfont.c file and put the one from this zip in its place, then recompile the sketch.

glcdfont.zip

  • Thanks 1
Posted

Interesting stuff.

uploaded the new glcdfont to the gfx library recompiled the sketch and noticed that the flashing square curser on the CDU screen Had changed into some funny flashing symbol

reverted back to the original and works perfect

 

Strange

 

working code I am using

 

 

 

#include <Adafruit_GFX.h>
#include <Adafruit_GrayOLED.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>
#include <Adafruit_GrayOLED.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>

/*
  Tell DCS-BIOS to use a serial connection and use the default Arduino Serial
  library. This will work on the vast majority of Arduino-compatible boards,
  but you can get corrupted data if you have too many or too slow outputs
  (e.g. when you have multiple character displays), because the receive
  buffer can fill up if the sketch spends too much time updating them.
  
  If you can, use the IRQ Serial connection instead.
*/
#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"
#include <Adafruit_GFX.h>
#include <UTFTGLUE.h>

UTFTGLUE myGLCD(0x9488,A2,A1,A3,A4,A0);

void printChar(int row, int col, unsigned char c) {
  int16_t x = 13 + col * 19;
  int16_t y = row * 32 + 6;
  myGLCD.drawChar(x, y, c, 0x07E0, 0x0, 3);

/* paste code snippets from the reference documentation here */
void onCduLine0Change(char* newValue) {
  for(int i = 0; i < 24; i++){
    printChar(0, i, newValue[i]);
  }
}
DcsBios::StringBuffer<24> cduLine0Buffer(0x11c0, onCduLine0Change);

void onCduLine1Change(char* newValue) {
  for(int i = 0; i < 24; i++){
    printChar(1, i, newValue[i]);
  }
}
DcsBios::StringBuffer<24> cduLine1Buffer(0x11d8, onCduLine1Change);

void onCduLine2Change(char* newValue) {
  for(int i = 0; i < 24; i++){
    printChar(2, i, newValue[i]);
  }
}
DcsBios::StringBuffer<24> cduLine2Buffer(0x11f0, onCduLine2Change);

void onCduLine3Change(char* newValue) {
  for(int i = 0; i < 24; i++){
    printChar(3, i, newValue[i]);
  }
}
DcsBios::StringBuffer<24> cduLine3Buffer(0x1208, onCduLine3Change);

void onCduLine4Change(char* newValue) {
  for(int i = 0; i < 24; i++){
    printChar(4, i, newValue[i]);
  }
}
DcsBios::StringBuffer<24> cduLine4Buffer(0x1220, onCduLine4Change);

void onCduLine5Change(char* newValue) {
  for(int i = 0; i < 24; i++){
    printChar(5, i, newValue[i]);
  }
}
DcsBios::StringBuffer<24> cduLine5Buffer(0x1238, onCduLine5Change);

void onCduLine6Change(char* newValue) {
  for(int i = 0; i < 24; i++){
    printChar(6, i, newValue[i]);
  }
}
DcsBios::StringBuffer<24> cduLine6Buffer(0x1250, onCduLine6Change);

void onCduLine7Change(char* newValue) {
  for(int i = 0; i < 24; i++){
    printChar(7, i, newValue[i]);
  }
}
DcsBios::StringBuffer<24> cduLine7Buffer(0x1268, onCduLine7Change);

void onCduLine8Change(char* newValue) {
  for(int i = 0; i < 24; i++){
    printChar(8, i, newValue[i]);
  }
}
DcsBios::StringBuffer<24> cduLine8Buffer(0x1280, onCduLine8Change);

void onCduLine9Change(char* newValue) {
  for(int i = 0; i < 24; i++){
    printChar(9, i, newValue[i]);
  }
}
DcsBios::StringBuffer<24> cduLine9Buffer(0x1298, onCduLine9Change);
 
void setup() {
  DcsBios::setup();

  // Setup the LCD
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myGLCD.setTextSize(3);
  myGLCD.setColor(0, 0, 255);
  myGLCD.drawRect(10, 0, 469, 319);
}

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

  • Like 1
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...