Voici mon code:
#include <Arduino.h>
#include <Adafruit_GFX.h> // graphics library
#include <Adafruit_ST7789.h> // library for this display
#include <SPI.h>
#define TFT_CS 10 // if your display has CS pin
#define TFT_RST 8 // reset pin
#define TFT_DC 9 // data pin
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
float Temp_frigoD;
float Temp_frigoG;
float Temp_Fan;
void setup() {
tft.init(240, 240, SPI_MODE2);
tft.setRotation(1); // rotates the screen
tft.fillScreen(ST77XX_BLACK); // fills the screen with black colour
tft.setCursor(10, 10); // starts to write text at y10 x10
tft.setTextColor(ST77XX_WHITE); // text colour to white you can use hex codes like 0xDAB420 too
tft.setTextSize(3); // sets font size
tft.setTextWrap(true);
tft.print("FRIGO");
tft.setCursor(10, 200); // starts to write text at y10 x10
tft.print("FAN");
tft.setTextColor(ST77XX_RED);
tft.setTextSize(5); // sets font size
tft.setCursor(10, 50); // starts to write text at y10 x10
tft.print("G");
tft.setCursor(10, 120); // starts to write text at y10 x10
tft.print("D");
tft.setTextColor(ST77XX_BLUE);
tft.setTextSize(5); // sets font size
tft.setCursor(70, 50); // starts to write text at y10 x10
tft.print("88,8");
tft.setCursor(70, 120); // starts to write text at y10 x10
tft.print("88,8");
tft.setTextSize(3); // sets font size
tft.setTextColor(ST77XX_RED);
tft.setCursor(80, 200); // starts to write text at y10 x10
tft.print("OFF");
Temp_frigoD = 8.24;
Temp_frigoG = 7.9;
Temp_Fan = 18.9245;
}
void write_Display(){
tft.fillScreen(ST77XX_BLACK); // fills the screen with black colour
tft.setCursor(10, 10); // starts to write text at y10 x10
tft.setTextColor(ST77XX_WHITE); // text colour to white you can use hex codes like 0xDAB420 too
tft.setTextSize(3); // sets font size
tft.setTextWrap(true);
tft.print("FRIGO");
tft.setCursor(10, 200); // starts to write text at y10 x10
tft.print("FAN");
tft.setTextColor(ST77XX_RED);
tft.setTextSize(5); // sets font size
tft.setCursor(10, 50); // starts to write text at y10 x10
tft.print("G");
tft.setCursor(10, 120); // starts to write text at y10 x10
tft.print("D");
tft.setTextSize(3); // sets font size
tft.setTextColor(ST77XX_RED);
tft.setCursor(80, 200); // starts to write text at y10 x10
tft.print("OFF");
}
void write_Temp(float T_D, float T_G, float T_F) {
char buff[10];
tft.fillRect(70, 50, 130, 40, ST77XX_BLACK);
tft.setTextColor(ST77XX_BLUE);
tft.setTextSize(5); // sets font size
tft.setCursor(70, 50);
dtostrf(T_D, 4, 1, buff);
tft.print(buff);
tft.fillRect(70, 120, 130, 40, ST77XX_BLACK);
tft.setCursor(70, 120);
dtostrf(T_G, 4, 1, buff);
tft.print(buff);
tft.fillRect(150, 200, 80, 21, ST77XX_BLACK);
tft.setTextSize(3); // sets font size
tft.setCursor(150, 200);
dtostrf(T_F, 4, 1, buff);
tft.print(buff);
}
void loop() {
delay(1000);
Temp_frigoD = Temp_frigoD + 0.01;
Temp_Fan = Temp_Fan + 0.1;
// write_Display();
write_Temp(Temp_frigoD, Temp_frigoG, Temp_Fan);
}