|
|
|
@ -1,8 +1,16 @@
|
|
|
|
|
#include "TFT_eSPI.h"
|
|
|
|
|
#include "RTC_SAMD51.h"
|
|
|
|
|
#include "DateTime.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RTC_SAMD51 rtc;
|
|
|
|
|
TFT_eSPI tft;
|
|
|
|
|
// nous incluons ici toutes les librairies necessaires pour le bon fonctionnement du projet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int X_MAX = 320;
|
|
|
|
|
int Y_MAX = 240;
|
|
|
|
|
TFT_eSPI tft;
|
|
|
|
|
int visit_total = 0; // Initialize visit_total to 0
|
|
|
|
|
int affluence = 0; // Initialize affluence to 0
|
|
|
|
|
int ancien_visit_total = 0;
|
|
|
|
@ -10,37 +18,43 @@ int ancien_affluence = 0;
|
|
|
|
|
int y = Y_MAX/5;
|
|
|
|
|
int background = TFT_GREEN;
|
|
|
|
|
|
|
|
|
|
int etatmessage15 = 0;
|
|
|
|
|
|
|
|
|
|
unsigned long myTimeInSec;
|
|
|
|
|
unsigned long myTimeInMin;
|
|
|
|
|
unsigned long hour;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTime now = DateTime(F(__DATE__), F(__TIME__));
|
|
|
|
|
//toutes les variables globales utiliser durant le projet
|
|
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
|
rtc.begin();
|
|
|
|
|
tft.begin();
|
|
|
|
|
tft.setRotation(3); // Set the screen orientation
|
|
|
|
|
tft.fillScreen(background); // Green background
|
|
|
|
|
tft.setRotation(3); // Orientation de l'écran
|
|
|
|
|
tft.fillScreen(background); // Fond d'écran de couleure verte au départ
|
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
while (!Serial)
|
|
|
|
|
while (!Serial) // attente de la communication série
|
|
|
|
|
{
|
|
|
|
|
tft.setTextColor(TFT_BLACK);
|
|
|
|
|
tft.setTextSize(3);
|
|
|
|
|
tft.drawString("Need Serial Com", 10, 100);
|
|
|
|
|
}
|
|
|
|
|
tft.setTextColor(TFT_GREEN);
|
|
|
|
|
tft.drawString("Need Serial Com", 10, 100);
|
|
|
|
|
tft.drawString("Need Serial Com", 10, 100); // On enlève le message
|
|
|
|
|
pinMode(WIO_KEY_A, INPUT_PULLUP);
|
|
|
|
|
pinMode(WIO_KEY_B, INPUT_PULLUP);
|
|
|
|
|
pinMode(WIO_KEY_C, INPUT_PULLUP);
|
|
|
|
|
pinMode(WIO_5S_PRESS, INPUT_PULLUP);
|
|
|
|
|
affiche();
|
|
|
|
|
affBandeauBleu();
|
|
|
|
|
affHeure();
|
|
|
|
|
pinMode(WIO_5S_UP, INPUT_PULLUP);
|
|
|
|
|
affiche(); // fonction qui affiche les visiteurs totaux et le nombre actuel
|
|
|
|
|
affBandeauBleu(); // fonction qui affiche le bandeau bleu
|
|
|
|
|
affHeure(); // fonction qui affiche l'heure sur le bandeau bleu
|
|
|
|
|
rtc.adjust(now); // utile pour l'heure
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
|
void loop() { // appel en continue afin de mettre à jour le nombre de visiteur,
|
|
|
|
|
// puis pour modifier l'heure
|
|
|
|
|
// et enfin pour afficher le message qui s'affiche toutes les 15 minutes
|
|
|
|
|
visiteur();
|
|
|
|
|
affHeure();
|
|
|
|
|
message15();
|
|
|
|
|
message();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -56,18 +70,51 @@ void affBandeauBleu() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void affHeure() {
|
|
|
|
|
//tft.setTextColor(TFT_BLUE);
|
|
|
|
|
//tft.drawNumber(hour, 240, 10);
|
|
|
|
|
//tft.drawNumber(myTimeInMin, 285, 10);
|
|
|
|
|
tft.setTextColor(TFT_BLUE);
|
|
|
|
|
tft.drawNumber(now.hour(), 240, 10);
|
|
|
|
|
tft.drawNumber(now.minute(), 285, 10);
|
|
|
|
|
now = rtc.now();
|
|
|
|
|
tft.setTextColor(TFT_BLACK);
|
|
|
|
|
tft.drawNumber(now.hour(), 240, 10);
|
|
|
|
|
tft.drawNumber(now.minute(), 285, 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
myTimeInSec = millis()/1000;
|
|
|
|
|
myTimeInMin = myTimeInSec%60;
|
|
|
|
|
hour = myTimeInMin%60+12;
|
|
|
|
|
void message15(){
|
|
|
|
|
if(now.minute() == 0 || now.minute() == 15 || now.minute() == 30 || now.minute() == 45 || now.minute() == 60){
|
|
|
|
|
if(etatmessage15 == 0 ){
|
|
|
|
|
Serial.println("--------");
|
|
|
|
|
Serial.print("heure : ");
|
|
|
|
|
Serial.print(now.hour());
|
|
|
|
|
Serial.print(":");
|
|
|
|
|
Serial.println(now.minute());
|
|
|
|
|
|
|
|
|
|
Serial.print("visiteur : ");
|
|
|
|
|
Serial.println(visit_total);
|
|
|
|
|
|
|
|
|
|
Serial.print("affluence : ");
|
|
|
|
|
Serial.println(affluence);
|
|
|
|
|
|
|
|
|
|
Serial.println("--------");
|
|
|
|
|
|
|
|
|
|
etatmessage15 = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(now.minute() != 0 && now.minute() != 15 && now.minute() != 30 && now.minute() != 45 && now.minute() != 60 ){
|
|
|
|
|
etatmessage15 = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void message(){
|
|
|
|
|
String val;
|
|
|
|
|
val = Serial.readString();
|
|
|
|
|
Serial.print(val);
|
|
|
|
|
if(val != NULL){
|
|
|
|
|
tft.setTextColor(TFT_BLACK);
|
|
|
|
|
tft.drawNumber(hour, 240, 10);
|
|
|
|
|
tft.drawNumber(myTimeInMin, 285, 10);
|
|
|
|
|
delay(1000);
|
|
|
|
|
tft.setTextSize(3);
|
|
|
|
|
tft.drawString("Nouveau Message !", 10, 50);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void visiteur() {
|
|
|
|
@ -76,11 +123,9 @@ void visiteur() {
|
|
|
|
|
ancien_affluence = affluence;
|
|
|
|
|
affluence = affluence -1; // Decrease affluence
|
|
|
|
|
if(affluence < 0){
|
|
|
|
|
Serial.println("impossible d'être négatif !");
|
|
|
|
|
affluence = 0;
|
|
|
|
|
}
|
|
|
|
|
if(affluence <= 10){
|
|
|
|
|
Serial.println("attention l'affluence à dépassé 10 !");
|
|
|
|
|
background = TFT_GREEN;
|
|
|
|
|
tft.fillScreen(background); // Green background
|
|
|
|
|
affiche();
|
|
|
|
@ -89,33 +134,24 @@ void visiteur() {
|
|
|
|
|
}
|
|
|
|
|
efface();
|
|
|
|
|
affiche();
|
|
|
|
|
Serial.print("visit_total = ");
|
|
|
|
|
Serial.println(visit_total);
|
|
|
|
|
Serial.print("affluence = ");
|
|
|
|
|
Serial.println(affluence);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (digitalRead(WIO_KEY_C) == LOW) {
|
|
|
|
|
ancien();
|
|
|
|
|
affluence = affluence +1; // Increase affluence
|
|
|
|
|
visit_total = visit_total +1; // Increment visit_total
|
|
|
|
|
affluence = affluence +1; // incrémente l'affluence
|
|
|
|
|
visit_total = visit_total +1; // Incrémente visit_total
|
|
|
|
|
if(affluence == 11)
|
|
|
|
|
tone(WIO_BUZZER, 442);
|
|
|
|
|
tone(WIO_BUZZER, 442); // buzzer dès qu'il monte à 11, pas quand il redescend
|
|
|
|
|
if(affluence > 10){
|
|
|
|
|
Serial.println("attention l'affluence à dépassé 10 !");
|
|
|
|
|
background = TFT_RED;
|
|
|
|
|
tft.fillScreen(background); // Green background
|
|
|
|
|
background = TFT_RED; // background rouge
|
|
|
|
|
tft.fillScreen(background); // background vert
|
|
|
|
|
affiche();
|
|
|
|
|
affBandeauBleu();
|
|
|
|
|
noTone(WIO_BUZZER);
|
|
|
|
|
affHeure();
|
|
|
|
|
affBandeauBleu(); // réaffiche le bandeau bleu
|
|
|
|
|
noTone(WIO_BUZZER); // arrêt du buzzer
|
|
|
|
|
affHeure(); //réaffiche l'heure
|
|
|
|
|
}
|
|
|
|
|
efface();
|
|
|
|
|
affiche();
|
|
|
|
|
Serial.print("visit_total = ");
|
|
|
|
|
Serial.println(visit_total);
|
|
|
|
|
Serial.print("affluence = ");
|
|
|
|
|
Serial.println(affluence);
|
|
|
|
|
efface(); // efface le nombre précédent
|
|
|
|
|
affiche(); // affiche le nouveau nombre
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (digitalRead(WIO_KEY_A) == LOW) {
|
|
|
|
@ -128,6 +164,20 @@ void visiteur() {
|
|
|
|
|
visit_total = 0;
|
|
|
|
|
affluence = 0;
|
|
|
|
|
etat = 0;
|
|
|
|
|
Serial.println("remise à 0 !!! ");
|
|
|
|
|
Serial.println("--------");
|
|
|
|
|
Serial.print("heure : ");
|
|
|
|
|
Serial.print(now.hour());
|
|
|
|
|
Serial.print(":");
|
|
|
|
|
Serial.println(now.minute());
|
|
|
|
|
|
|
|
|
|
Serial.print("visiteur : ");
|
|
|
|
|
Serial.println(visit_total);
|
|
|
|
|
|
|
|
|
|
Serial.print("affluence : ");
|
|
|
|
|
Serial.println(affluence);
|
|
|
|
|
|
|
|
|
|
Serial.println("--------");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
tft.setTextColor(background);
|
|
|
|
@ -135,10 +185,11 @@ void visiteur() {
|
|
|
|
|
tft.drawString("Confirmez ?", 110, 200);
|
|
|
|
|
efface();
|
|
|
|
|
affiche();
|
|
|
|
|
Serial.print("visit_total = ");
|
|
|
|
|
Serial.println(visit_total);
|
|
|
|
|
Serial.print("affluence = ");
|
|
|
|
|
Serial.println(affluence);
|
|
|
|
|
background = TFT_GREEN;
|
|
|
|
|
tft.fillScreen(background); // Green background
|
|
|
|
|
affiche();
|
|
|
|
|
affBandeauBleu();
|
|
|
|
|
affHeure();
|
|
|
|
|
}
|
|
|
|
|
delay(200);
|
|
|
|
|
}
|
|
|
|
@ -172,7 +223,6 @@ int compteur(){
|
|
|
|
|
int i = 5;
|
|
|
|
|
while( i > 0){
|
|
|
|
|
delay(1000);
|
|
|
|
|
Serial.println(i);
|
|
|
|
|
i--;
|
|
|
|
|
if(digitalRead(WIO_5S_PRESS) == LOW){
|
|
|
|
|
return 1;
|
|
|
|
|