Voici le code complet, c'est le code d'essais pour la mise en page de l'écran :
#include <Wire.h>
#include <config.h>
#include <ds3231.h>
#include <SPI.h>
#include <RA8875.h>
#define RA8875_INT 7
#define RA8875_CS 10
#define RA8875_RESET 9
RA8875 tft = RA8875(RA8875_CS, RA8875_RESET);
struct ts t; // Pour DS3231
const char *strJdlS[] = {"Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"};
const char *strMois[] = {"Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre"};
int couleurRect, couleurRect1, x, etatAir, etatChauff, etatCO2;
// Affichage de l'heure et de la date
void affichDateHeure() {
// Date
tft.changeMode(TEXT); tft.setFontScale(1); tft.setTextColor(RA8875_WHITE, RA8875_BLACK);
tft.setCursor(50, 0); tft.print(strJdlS[t.wday - 1]); tft.print(" ");
tft.print(t.mday); tft.print(" ");
tft.print(strMois[t.mon - 1]); tft.print(" "); tft.print(t.year);
// Heure
tft.setCursor(180, 28);
if ((t.hour) < 10) {
tft.print(" ");
}
tft.print(t.hour);
tft.print(":");
if ((t.min) < 10) {
tft.print("0");
}
tft.print(t.min);
tft.print(":");
if ((t.sec) < 10) {
tft.print("0");
}
tft.print(t.sec);
tft.changeMode(GRAPHIC);
tft.drawLine(0, 60, 480, 60, RA8875_CYAN);
}
void affichEclPPSec() {
tft.changeMode(TEXT); tft.setFontScale(1); tft.setTextColor(RA8875_WHITE, RA8875_BLACK);
tft.setCursor(0, 70); tft.print("Eclairage PP");
x = 202; void rectVert();
tft.setTextColor(RA8875_WHITE, RA8875_BLACK);
tft.setCursor(280, 70); tft.print("Second."); tft.changeMode(GRAPHIC);
tft.drawRect(410, 68, 50, 40, couleurRect1); tft.setCursor(419, 70); tft.print("NO");
}
void affichEclLed() {
tft.changeMode(TEXT); tft.setFontScale(1); tft.setTextColor(RA8875_WHITE, RA8875_BLACK);
tft.setCursor(0, 115); tft.print("Ecl LED"); tft.changeMode(GRAPHIC);
tft.drawCircle(182, 132, 10, RA8875_WHITE); tft.fillCircle(182, 132, 8, RA8875_RED);
tft.drawRect(202, 113, 50, 40, couleurRect); tft.setCursor(211, 115);
tft.changeMode(TEXT); tft.print("OK"); tft.changeMode(GRAPHIC);
tft.drawCircle(286, 132, 10, RA8875_WHITE); tft.fillCircle(286, 132, 8, RA8875_GREEN);
tft.drawRect(306, 113, 50, 40, couleurRect); tft.setCursor(315, 115);
tft.changeMode(TEXT); tft.print("OK"); tft.changeMode(GRAPHIC);
tft.drawCircle(390, 132, 10, RA8875_WHITE); tft.fillCircle(390, 132, 8, RA8875_BLUE);
tft.drawRect(410, 113, 50, 40, couleurRect1); tft.setCursor(419, 115);
tft.changeMode(TEXT); tft.print("NO");
}
void rectVert() {
tft.changeMode(GRAPHIC);
tft.drawRect(x, 68, 50, 40, couleurRect); tft.setCursor(x+9, 70); tft.print("OK");
tft.changeMode(TEXT);
}
void affichAirChauff() {
tft.changeMode(TEXT); tft.setTextColor(RA8875_WHITE, RA8875_BLACK);
tft.setCursor(0, 160); tft.print("Chauffage");
tft.print(etatAir); tft.print("Air");
tft.print(etatChauff);
}
// Affichage des états CO2 et chauffage Jour/Nuit
void affichCO2Chauff() {
tft.setCursor(0, 192); tft.print("Chauffage");
tft.print(etatCO2); tft.print("CO2");
tft.print(etatChauff);
}
void setup()
{
Serial.begin(9600);
Wire.begin();
tft.begin(RA8875_480x272);
tft.touchBegin(7);
tft.touchEnable(true);
tft.fillScreen(RA8875_BLACK);
tft.PWMout(1, 150);
}
void loop()
{
DS3231_get(&t);
couleurRect = RA8875_GREEN;
couleurRect1 = RA8875_RED;
affichDateHeure();
affichEclPPSec();
affichEclLed();
affichAirChauff();
affichCO2Chauff();
}