Flickerfree display

hello i have a question i have a code and how can i write it so that the display is flicker free sorry but i am using google translate

my code :
< CODE/ >
#include <DHT.h>
#include <TFT_eSPI.h>
#include "homero2.h"
#include "para2.h"
#define DHT_PIN 22 // DHT22 érzékelő pinje
#define TFT_CS 15 // TFT kijelző chip kiválasztó pin
#define TFT_DC 2 // TFT kijelző adat vagy parancs módját vezérlő pin
#define TFT_RST 12 // Reset pin (opcionális, -1, ha nincs használatban)
#define TEXT "aA MWyz~12" // Text that will be printed on screen in any font
#include <FlickerFreePrint.h>
#include "Free_Fonts.h"
// The font names are arrays references, thus must NOT be in quotes ""
#define AA_FONT_SMALL NotoSansBold15
#define AA_FONT_LARGE NotoSansBold36

DHT dht(DHT_PIN, DHT22);
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite screen = TFT_eSprite(&tft);

void setup() {
Serial.begin(115200);
tft.setSwapBytes(true);
// TFT kijelző inicializálása
tft.init();
tft.setRotation(1);
tft.fillScreen(TFT_BLACK);
// DHT érzékelő inicializálása
dht.begin();
// Flicker Free könyvtár inicializálása

;
// Háttérvilágítás vezérlés
ledcAttachPin(TFT_BL, 1); // TFT_BL pin csatolása a PWM kimenethez (1-es csatorna)
ledcSetup(1, 5000, 8); // 5000 Hz-es frekvencia, 8 bites felbontás
ledcWrite(1, 255); // 0 és 255 közötti érték a fényerő beállításához // 0 és 255 közötti érték a fényerő beállításához

}
void loop() {

tft.setFreeFont(FF24);
// Hőmérséklet és páratartalom lekérdezése
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();

// Kijelző törlése
tft.fillScreen(TFT_BLACK);

// Hőmérséklet és páratartalom megjelenítése, ha a hőmérő csatlakoztatva van
if (!isnan(temperature) && !isnan(humidity)) {
// Hőmérséklet megjelenítése
tft.setFreeFont(FF24);
ledcWrite(1, 255);
tft.setTextSize(2);
tft.pushImage(210,90,64,64,homero2);
tft.setTextColor(TFT_YELLOW);
tft.setCursor(10, 150);
tft.printf(" %.1f", temperature);

delay(2000);
tft.fillScreen(TFT_BLACK);

// Páratartalom megjelenítése

ledcWrite(1, 255);
tft.setTextSize(2);
tft.pushImage(210,90,72,72,para2);
tft.setTextColor(TFT_YELLOW);
tft.setCursor(10, 150);
tft.printf(" %.1f%", humidity);

delay(2000);

} else {

tft.setFreeFont(FF21);
tft.setTextSize(1);;
tft.fillScreen(TFT_BLACK);
tft.drawLine(10, 150, 310, 150, TFT_YELLOW);
tft.drawLine(10, 100, 310, 100, TFT_YELLOW);

tft.setTextColor(TFT_RED);
tft.setCursor(40,130);
tft.print("homero nincs csatlakoztatva");

delay(3000);

}

}

< CODE/ >
there are some unnecessary things at the beginning but don't look at that

valaki át írná vagy segítene az megköszönném :slight_smile:

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use [color = red]code tags[/color] (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

How could it be flicker free when you keep turning it black and writing new data to it ?

It might be better if you just wrote over the previously printed data in black to erase it before printing the new data. That way only a portion of the screen would change ?

could you show me an example I am still very beginner

I will explain how you do it but not write it for you

In the sketch you write a value to the screen then delay() a while. After the delay you need to set the text colour to black, position the cursor again and print the same value as you did previously to erase it. Then you change the text colour to yellow, position the cursor and print the next value and so on

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.