New library for Mega and low cost HX8357B/C and ILI9481 480 x 320 displays

Hello. I use the TFT_HX8357 library in my voltmeter project. I use the font free fonts. However, when the value of the measured voltage is changed, the numbers are overwritten and the value of the measured voltage is blurred becomes illegible. On basic fonts everything is fine. what is the problem and is there any way to eliminate it

FreeFonts are always transparent. At least on Adafruit_GFX style libraries.

I think that Bodmer supports rubout mode on all the Fonts that he supports.

Just try tft.setTextColor(TFT_WHITE, TFT_BLACK);
i.e. just like you would for the Adafruit 7x5 font

But it is not difficult to draw a fresh background when you use a transparent font.

David.

I tried it but it doesn't work on free fonts

In which case use a different Font.
Or learn how to draw a fresh background.

David.

homer2009:
I tried it but it doesn't work on free fonts

It does work if you use drawString or drawNumber functions, see the Free_Font_Demo example included in the library, in particular these lines.

From Free_Font_Demo.ino example

#include <TFT_HX8357.h> // Hardware-specific library

#include "Free_Fonts.h" // Include the header file attached to this sketch

TFT_HX8357 tft = TFT_HX8357();       // Invoke custom library

I suggest that you run all the examples that come with your library.

If and when you have a problem, you can quote the library by version number, example by name.

Bodmer's TFT_eSPI library certainly demonstrates FreeFonts with background.

David.

Works. Thank you for your help

Hello. I downloaded a free font demo from the library and changed the font in one example to my made freefont converter according to the author's instructions from yutube. The height of the font background is very large as in the picture. Is there any way to reduce it?
In the tft.setTextPadding function it is possible to change the width or something similar to change the height?

Look at gfxfont.h

/// Data stored for FONT AS A WHOLE
typedef struct {
  uint8_t *bitmap;  ///< Glyph bitmaps, concatenated
  GFXglyph *glyph;  ///< Glyph array
  uint8_t first;    ///< ASCII extents (first char)
  uint8_t last;     ///< ASCII extents (last char)
  uint8_t yAdvance; ///< Newline distance (y axis)
} GFXfont;

yAdvance shows where the next line will be printed. For individual glyphs, yOffset is an int8_t. Which means you can't really have fonts more than about 128 pixels above the baseline i.e. -128

Seriously. If you want monster digits, you might just as well treat them as pictures.

Life is much simpler if you say what you really want to do. with real numbers for size, quantity, ...

David.

I want to make a meter for the power supply on the arduino mega and a 3.5 inch display on the ILI 9486. This meter is to show the measurement of the current of the battery capacity voltage I want it to be readable arduino. It looks just like the picture, just the problem with overwriting the numbers, as I wrote earlier

I would like to know if the function can be modified
draw_num () to make numbers scroll from right to left instead of how they do now

From TFT_HX8357.h

  int16_t  drawChar(uint16_t uniCode, int16_t x, int16_t y, int16_t font),
           drawNumber(int32_t long_num,int16_t poX, int16_t poY, int16_t font),
           drawFloat(float floatNumber,int16_t decimal,int16_t poX, int16_t poY, int16_t font),

           drawString(char *string, int16_t poX, int16_t poY, int16_t font),
           drawCentreString(char *string, int16_t dX, int16_t poY, int16_t font),
           drawRightString(char *string, int16_t dX, int16_t poY, int16_t font),

So you have class methods for most occasions.

There does not seem to be a draw_num() method but you can write your own function to format numbers e.g. with sprintf() and tft.drawRightString()

If draw_num() comes from a library example sketch, please say which example by name.

If you use dtostrf() for formatting it gives a lot of ways to present an attractive display

I have assumed that numbers scroll was a typo/translation.
If you want the numbers to move across the screen, please describe exactly how you want it to look.

David.

perdon para empezar la funcion es drawNumber(),, con esa funcion los numeros van apareciendo digamos cuando llegas al 10 de izquierda a derecha.. lo que necesitaria es que aparezcan de derecha a izquierda

Please use English on this Forum

Google Translate says:

sorry to start the function is drawNumber () ,, with that function the numbers will appear, say when you get to 10 from left to right .. what you would need is for them to appear from right to left

Use sprintf() or dtostrf() to create ascii text in a buffer array.
Then use drawRightString() to display the text.

David.

Sorry for my bad english.
I created a new font, using fontconvert, to use the characters "òàèùìé".
The new font works for characters from 0 to 127 but for characters from 128 to 255 it prints incorrect characters.

  tft.setFreeFont(FB18);//new font create
  tft.drawString("ò à è é ù ì", xPos, yPos, GFXFF);
  tft.drawString(dataTemp, xPos, yPos + 80, GFXFF);

I insert a photo with the print of "à è é ì ù ò"
Thanks for the possible solution.
Vittorio

When you type into your Browser the text is stored as UTF-8 sequences. This allows the Browser to display Chinese, Arabic, Greek, ... text.

Likewise your Arduino IDE stores "extended characters" as UTF-8.

However Adafruit_GFX only accepts chars from 0-255. And the standard Free Fonts only contain letters 32-127
If you want to print char(0xB0) you must use an escape e.g.

     tft.print("\260");
     tft.print("\xB0");
     tft.print(char(0xB0));

This is not too bad for just showing a degree symbol in a temperature display.
But it is painful to read regular French or German text with escape sequences instead of accented letters.

Install U8g2_for_Adafruit_GFX library. Then you can display readable text in any font.

David.

david_prentice:
Install U8g2_for_Adafruit_GFX library. Then you can display readable text in any font.

Is it possible to connect the library U8g2_for_Adafruit_GFX together with TFT_HX8357? If possible, then how.

TFT_HX8357 works fine on Mega2560 and https://www.aliexpress.com/item/4000126450233.html?spm=a2g0s.9042311.0.0.249e33edtvhO63 (16 Bit). But I need to display cyrillic characters.

Another question: how can I display сyrillic characters using FONT4?