From e9239a7792bcd7b4b964aa9347f9b7498d6fec4b Mon Sep 17 00:00:00 2001 From: Adryen DECHANDON Date: Tue, 14 May 2024 16:44:34 +0200 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'sujet'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sujet | 52 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/sujet b/sujet index fbae256..be87e34 100644 --- a/sujet +++ b/sujet @@ -1,5 +1,8 @@ #include "TFT_eSPI.h" +#include "RTC_SAMD51.h" +#include "DateTime.h" +RTC_SAMD51 rtc; int X_MAX = 320; int Y_MAX = 240; TFT_eSPI tft; @@ -10,17 +13,23 @@ int ancien_affluence = 0; int y = Y_MAX/5; int background = TFT_GREEN; - -unsigned long myTimeInSec; -unsigned long myTimeInMin; -unsigned long hour; - +DateTime now = DateTime(F(__DATE__), F(__TIME__)); void setup() { + rtc.begin(); tft.begin(); tft.setRotation(3); // Set the screen orientation tft.fillScreen(background); // Green background + Serial.begin(115200); + while (!Serial) + { + 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); pinMode(WIO_KEY_A, INPUT_PULLUP); pinMode(WIO_KEY_B, INPUT_PULLUP); pinMode(WIO_KEY_C, INPUT_PULLUP); @@ -28,10 +37,12 @@ void setup() { affiche(); affBandeauBleu(); affHeure(); + rtc.adjust(now); } void loop() { visiteur(); + affHeure(); } @@ -47,20 +58,16 @@ void affBandeauBleu() { } void affHeure() { - //tft.setTextColor(TFT_BLUE); - //tft.drawNumber(hour, 240, 10); - //tft.drawNumber(myTimeInMin, 285, 10); - - myTimeInSec = millis()/1000; - myTimeInMin = myTimeInSec%60; - hour = myTimeInMin%60+12; - + 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(hour, 240, 10); - tft.drawNumber(myTimeInMin, 285, 10); - delay(1000); + tft.drawNumber(now.hour(), 240, 10); + tft.drawNumber(now.minute(), 285, 10); } + void visiteur() { int etat = 0; if (digitalRead(WIO_KEY_B) == LOW) { @@ -70,7 +77,7 @@ void visiteur() { Serial.println("impossible d'être négatif !"); affluence = 0; } - if(affluence < 10){ + if(affluence <= 10){ Serial.println("attention l'affluence à dépassé 10 !"); background = TFT_GREEN; tft.fillScreen(background); // Green background @@ -84,16 +91,21 @@ void visiteur() { Serial.println(visit_total); Serial.print("affluence = "); Serial.println(affluence); - } else if (digitalRead(WIO_KEY_C) == LOW) { + } + + else if (digitalRead(WIO_KEY_C) == LOW) { ancien(); affluence = affluence +1; // Increase affluence visit_total = visit_total +1; // Increment visit_total + if(affluence == 11) + tone(WIO_BUZZER, 442); if(affluence > 10){ Serial.println("attention l'affluence à dépassé 10 !"); background = TFT_RED; tft.fillScreen(background); // Green background affiche(); affBandeauBleu(); + noTone(WIO_BUZZER); affHeure(); } efface(); @@ -102,7 +114,9 @@ void visiteur() { Serial.println(visit_total); Serial.print("affluence = "); Serial.println(affluence); - } else if (digitalRead(WIO_KEY_A) == LOW) { + } + + else if (digitalRead(WIO_KEY_A) == LOW) { tft.setTextColor(TFT_BLACK); tft.setTextSize(3); tft.drawString("Confirmez ?", 110, 200);