5 inch TFT font questions

All, I have a 5 inch TFT running with an Uno board which is working as a central Display Unit (CDU) for my A10C cockpit simulator. It works very well, however there are a couple of admittedly minor niggles that I would like to try and resolve.

Essentially I believe it to be an issue with the font. Most characters are displayed perfectly, however a couple of symbols are wrong, presumably because of different characters called out in the font. I wanted to go in and change those two characters if I can, or even try a different font to see if that resolves it. However I am unable to identify where the font is called out or how to specify a different one.

This is the sketch

#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"
#include <SPI.h>
#include <RA8875.h>


//Arduino DUE,Arduino mega2560,Arduino UNO
#define RA8875_INT 4
#define RA8875_CS 10
#define RA8875_RST 9

// RA8875 tft = RA8875(RA8875_CS,RA8875_RST);
RA8875 tft = RA8875(RA8875_CS, RA8875_RST);


// CDU line 1
void onCduLine0Change(char* newValue) {
  tft.setCursor(20, 4);
  tft.setFontScale(6.5);
  tft.setFontSpacing(7);
  tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine0Buffer(0x11c0, onCduLine0Change);

// CDU line 2
void onCduLine1Change(char* newValue) {
  tft.setCursor(20, 48);
  //tft.setFontScale(6);
  tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine1Buffer(0x11d8, onCduLine1Change);

// CDU line 3
void onCduLine2Change(char* newValue) {
  tft.setCursor(20, 92);
  //tft.setFontScale(6);
  tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine2Buffer(0x11f0, onCduLine2Change);

// CDU line 4
void onCduLine3Change(char* newValue) {
  tft.setCursor(20, 136);
  //tft.setFontScale(6);
  tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine3Buffer(0x1208, onCduLine3Change);

// CDU line 5
void onCduLine4Change(char* newValue) {
  tft.setCursor(20, 188);
  //tft.setFontScale(6);
  tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine4Buffer(0x1220, onCduLine4Change);

// CDU line 6
void onCduLine5Change(char* newValue) {
  tft.setCursor(20, 232);
  //tft.setFontScale(6);
  tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine5Buffer(0x1238, onCduLine5Change);

// CDU line 7
void onCduLine6Change(char* newValue) {
  tft.setCursor(20, 276);
  //tft.setFontScale(6);
  tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine6Buffer(0x1250, onCduLine6Change);

// CDU line 8
void onCduLine7Change(char* newValue) {
  tft.setCursor(20, 320);
  //tft.setFontScale(6);
  tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine7Buffer(0x1268, onCduLine7Change);

// CDU line 9
void onCduLine8Change(char* newValue) {
  tft.setCursor(20, 364);
  //tft.setFontScale(6);
  tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine8Buffer(0x1280, onCduLine8Change);

// CDU line 10
void onCduLine9Change(char* newValue) {
  tft.setCursor(20, 408);
  //tft.setFontScale(6);
  tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine9Buffer(0x1298, onCduLine9Change);



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

  SPI.begin();
  tft.begin(RA8875_800x480);


}

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

So what is happening is that the TFT is displaying the " i " character whenever the " " symbol appears (to clarify the line gets prefaced by the two square brackets next to each other with nothing between).

It also is changing the blinking cursor box that appears on the monitor version to a tab symbol - if I could change that to a non blinking box I would be perfectly happy.

The last issue is that when you type into the command line, the characters appear corrupted, but if you recycle the power to the Arduino, they then appear correctly - it looks like the characters overwrite what is already there and the old characters are not being refreshed.

For info, if you use the Adafruit RA8875 library it will not work, hence the callout of the standard RA8875.h library.

So if there is a way of modifying the font (or changing it) and adding some kind or screen refresh this would add the last 1% to this

Thanks for looking

Cheers

Les

When you build the project you will get a Memory Use report e.g.

Sketch uses 25756 bytes (79%) of program storage space. Maximum is 32256 bytes.
Global variables use 1036 bytes (50%) of dynamic memory, leaving 1012 bytes for local variables. Maximum is 2048 bytes.

I suspect that you are using too much SRAM (dynamic memory)
Please copy-paste your Memory Use report

David.

I think this is what you mean?

Sketch uses 12702 bytes (39%) of program storage space. Maximum is 32256 bytes. Global variables use 979 bytes (47%) of dynamic memory, leaving 1069 bytes for local variables. Maximum is 2048 bytes.

Cheers

Les

Adafruit_RA8875 is the only library supported by the IDE Library Manager.

Where did you get “RA8875” from ?

Anyway, leaving 1069 bytes for local variables should be pretty safe. Unless DCSBios allocates SRAM at runtime.

You can check the “short of SRAM” theory by commenting out several of your callback functions and associated objects. If your suspect function starts to work this would confirm my suspicion.

David.

Right, gave that a go, got the memory usage down

Sketch uses 12480 bytes (38%) of program storage space. Maximum is 32256 bytes.
Global variables use 731 bytes (35%) of dynamic memory, leaving 1317 bytes for local variables. Maximum is 2048 bytes.

Same behaviour for all aspects

Cheers

Les

I had another few goes at this, but couldn’t make any difference to it unfortunately, no matter how much I commented out.

From what I know of DCS BIOS, all it does is output a signal, and listen for inputs. It from what I gather is just a communication protocol, it doesn’t actually use the arduinos itself.

So to come back to the original question, what is actually setting the font in this? And is there a way to change it? I’ve attached the two referenced libraries

Cheers

Les

RA8875.cpp (173 KB)

RA8875.h (34.7 KB)

Lesthegringo: The last issue is that when you type into the command line, the characters appear corrupted, but if you recycle the power to the Arduino, they then appear correctly - it looks like the characters overwrite what is already there and the old characters are not being refreshed.

I was looking at a thread using a tft device a few days ago and noticed a peculiarity in the code whereby it was overwriting the text written in black before putting new text in place. It sounds like yours needs to work the same if you're getting data on top of what was already there.

I suggest you write a little test sketch without any of the DCS stuff to verify how the thing functions.

RA8875 has built in font. But it can also use external font chips e.g. from Genitop. Or you embed fonts in your software library e.g. Adafruit_GFX.

Sumotoy's library is not perfect. There are lots of features. But hey-ho, RA8875 silicon has several features too !!

I suggest that you post a link rather than attach code. Then we know where you got it from.

Where did you get your 5 inch screen? e.g. link Did you buy the Adapter shield? e.g. link Or have you hand-wired level shifters? e.g. post schematic

David.

Sure, that's logical.

The TFT is the 5 inch screen from Buydisplay, and the shield is the dedicated one that comes with it for the UNO

It is this one https://www.buydisplay.com/serial-spi-arduino-5-inch-tft-lcd-touch-shield-ra8875-for-mega-due-uno

The library is the one in the examples that you download from the same page

I suppose if I can tell it to use a different font, I can either find a font that is correct for it or maybe manipulate certain characters to suit

Cheers

Les

Your callback functions look like this:

// CDU line 1
void onCduLine0Change(char* newValue) {
  tft.setCursor(20, 4);
  tft.setFontScale(6.5);
  tft.setFontSpacing(7);
  tft.print(newValue);
}
DcsBios::StringBuffer<24> cduLine0Buffer(0x11c0, onCduLine0Change);

Obviously you need to check that these class methods are working correctly. e.g. FontScale(), FontSpacing()
And you must be sure that any “message” that is passed in *newValue contains good data.

It looks as if you do not have a memory problem. I do not know how robust the DcsBios stuff is. Surely there must be other DcsBios punters and possibly a DcsBios Forum somewhere.

As I said in #7. The silicon has “features” and the RA8875 library has “features”.
You need to check that things actually work.
Apparently the Adafruit_RA8875 code has even more “features” but I haver never tried it.

I would check the DcsBios operation with proven hardware and proven libraries first.
e.g. Adafruit_ILI9341
Bear in mind that there are 100000 people in the world using Adafruit_ILI9341 but probably a few 10s people using RA8875.

David.

Unfortunately the Adafruit 5 inch screen doesn't have an Arduino shield, which makes packaging of the display more difficult when trying to integrate it into the CDU panel. That was the reason for choosing it

Interestingly, I have a 3.5 inch TFT on a shield for an uno from a company called MCU friend, and the sketch works fine with that (once the correct resolution is called out). It seems that the Buydisplay stuff eschews the standard libraries, something that a newbie like me would not realise until it's too late

Oh well, I'll probably have to live with the minor niggles!

Thanks again for the help

Les

If it works ok on the Uno shield, please describe which callback is going wrong. And what message it should display.

I have not looked at the RA8875 library for a long time.

David.

I contacted the seller of this TFT about how to change the font, and this was their response

"The LCD has only one type of font fixed and doesn't support to change"

Oh well, live and learn. Live at any rate....

Cheers

Les

I posses a Uno and the same RA8875 + Adapter as you.

If you answer my questions I would assemble the hardware and offer you a solution.

I am not going to waste my time with guesswork. If I had bought hardware for a project I would want it to work. Even if it cost 10 minutes of my life to answer a few questions on a Forum.

David.

There is no need to be sarcastic - you state "If it works ok on the Uno shield, please describe which callback is going wrong. And what message it should display."

However I am saying that when the text output should show the symbol " [] " it shows an " i " instead. It also is replacing the cursor symbol with a tab symbol like this " ¶ ". I don't have sufficient knowledge of what the callback is other than it is supposed to print a certain string of text, and it is not showing up exactly as it is supposed to (there is the on screen version to refer to). However I did describe the phenomena in the first post.

And the shield for the 3.5 TFT is a different one to the Buydisplay unit, each one has a built in shield. Unfortunately I didn't realise when I bought the 5" Buydisplay version that it was not able to have alternative fonts, assuming (incorrectly) that it would behave in a similar fashion to the 3.5 " unit I had tested with and got running.

Cheers

Les

However I am saying that when the text output should show the symbol " " it shows an " i " instead.

What do you mean?
Do you want to see , , , ?
Or do you want to see a single symbol that looks like a square ?
Or something else ?

What is a cursor symbol ?

Ascii characters are only 0 - 127. Many fonts only display 32 - 126.
Most Arduino graphics libraries can print 0 - 255 if these characters are present in the font.

Languages like Greek, Arabic, Chinese, … have characters in the 256 - 65535 range.
This Forum and your Internet Browser will use UFT-8 text. Which is why you can see Chinese, Cyrillic, … messages.

If we knew what your problem was, we could show you how to fix it.

David.

Here you can see a screenshot of what is supposed to be displayed. The red rings show the mis-represented characters, hopefully both photos can appear on the same post

edit second image showing screenshot transferred to second post

Cheers

Les

Second post to include screenshot

So you can see that the characters are being swapped, but the definition of the characters is set by the sim, and that ( I believe) is beyond the bounds of ardiuno stuff. As this particular TFT has a fixed font that can’t be changed I think it needs either a means changing the characters in the font (which means finding out what it is getting the font data from) or swapping the specific characters with bitmaps without affecting the rest of the text.

Both are currently (sadly) beyond my limited skills

Cheers

There are several non-ascii characters i.e. out of the 32-126 printable range. e.g. the +- and the degree symbol.

I would like to know what is sent by the DcsBios ? You must have some idea which callback function is printing at which coordinates on the screen. And could send debug information to the Serial Terminal. e.g. the hex value of each character in the string.

Where did the xxxx230.jpg come from?

David.

I’m trying to think of a way of getting the raw output from DCS BIOS for you, its output is read as a text string, and each line is defined in the original sketch, in this case called “CDU line 5” and “CDU line 7”. I need to see if the guys who wrote the DCS BIOS program can advise on that. The arduino part just prints the output as a string of text, not sure how that is internally processed

The picture in the first post is the TFT screen, with the red rings showing the two items I am asking about. The picture in the second post ( xxx230.jpg) is a photo of the in-game screen showing the cockpit image of the CDU screen. The intention is that the on-screen view is changed to just show the outside world, with the TFT showing the CDU screen with the buttons on it being the interface - simulator style.

As you can see from the in-game screen image, the TFT CDU is not accurately reflecting the correct characters

Let’s see what the guys come back with on the hex values

Cheers

Les