voici le menu test "Heure et date"
#include "Adafruit_GFX.h"
#include "Adafruit_GC9A01A.h"
#include <Wire.h>
///////////////////////// ECRAN ROND 1,28 " //////////////////
#define BLACK 0x0000
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define Maroon 0x7800
#define TFT_DC 9
#define TFT_CS 10
Adafruit_GC9A01A tft(TFT_CS, TFT_DC);
#include <Fonts/FreeSansBold9pt7b.h>
#include <Fonts/FreeSansBold12pt7b.h>
#include <Fonts/FreeSansBold18pt7b.h>
#include <Fonts/FreeSansBold24pt7b.h>
int An, Mo, Jo, He, Mi, Se, DoW;
int oldAn, oldMo, oldJo, oldHe, oldMi, oldSe, oldDate;
char daysOfTheWeek[7][12] = {"Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"};
char moisannee[][13] = {" ", "Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre"};
void setup() {
Serial.begin(9600); // Initialise la communication série
////////////////// TFT ////////////////////
tft.begin();
tft.fillScreen(GC9A01A_BLACK);
}
void loop() {
ReceptionData();
MenuDateHeure();
}
void ReceptionData() {
if (Serial.available() >= 7 * sizeof(int)) { // + 3 * sizeof(float)) {
Serial.readBytes((byte*)&An, sizeof(An));
Serial.readBytes((byte*)&Mo, sizeof(Mo));
Serial.readBytes((byte*)&Jo, sizeof(Jo));
Serial.readBytes((byte*)&He, sizeof(He));
Serial.readBytes((byte*)&Mi, sizeof(Mi));
Serial.readBytes((byte*)&Se, sizeof(Se));
Serial.readBytes((byte*)&DoW, sizeof(DoW));
}
}
/********************************************************** VOID Menu Date Heure ***********************************************************/
void MenuDateHeure() {
tft.setFont(&FreeSansBold18pt7b);
tft.setTextColor(GREEN);
if (oldDate != Jo) {
tft.fillRect(20, 100, 200, 90, tft.color565(0, 0, 0)); // Gauche, Haut, Longueur, Hauteur
tft.setCursor(45, 135);
tft.print(daysOfTheWeek[DoW]);
tft.setTextColor(CYAN);
tft.setCursor(50, 180);
tft.print(Jo);
// tft.setCursor(86, 180);
// tft.print(Mo);
tft.setCursor(80, 220);
tft.print(An);
oldDate = Jo;
tft.setFont(&FreeSansBold12pt7b);
tft.setCursor(90, 175);
tft.print(moisannee[Mo]);
}
tft.setFont(&FreeSansBold24pt7b);
tft.setTextColor(YELLOW);
tft.setCursor(80, 90);
tft.print(':');
tft.setCursor(150, 90);
tft.print(':');
if (oldHe != He) {
tft.fillRect(20, 54, 60, 40, tft.color565(0, 0, 0)); // carré pour effacer les heures
tft.setCursor(50, 90); // place le curseur pour les unitées d'heures
tft.print(He % 10, DEC); // garde uniquement les unitées d'heures
tft.setCursor(25, 90); // place le curseur pour les dizaines d'heures
tft.print(He / 10, DEC); // garde uniquement les dizaines d'heures
oldHe = He;
}
if (oldMi != Mi) {
tft.fillRect(90, 54, 60, 40, tft.color565(0, 0, 0)); // carré pour effacer les minutes
tft.setCursor(120, 90);
tft.print(Mi % 10, DEC);
tft.setCursor(95, 90);
tft.print(Mi / 10, DEC);
oldMi = Mi;
}
if (oldSe != Se) {
tft.fillRect(160, 54, 60, 40, tft.color565(0, 0, 0)); // carré pour effacer les secondes
tft.setCursor(190, 90);
tft.print(Se % 10, DEC);
tft.setCursor(165, 90);
tft.print(Se / 10, DEC);
oldSe = Se;
}
}