master
Auguste FLEURY 12 months ago
parent 42149fdc1a
commit 3eb03ba5fa

@ -4,18 +4,25 @@
TFT_eSPI tft; TFT_eSPI tft;
RTC_SAMD51 rtc; RTC_SAMD51 rtc;
unsigned int affluence = 0;
unsigned int visiteurs = 0; /*########################################################*/
const unsigned short maxAffluence = 10;
int resetTime;
DateTime now = DateTime(F(__DATE__), F(__TIME__)); DateTime now = DateTime(F(__DATE__), F(__TIME__));
short minute; short minute;
short hour; short hour;
short second = 0; short second = 0;
unsigned int actuel = 0;
unsigned int visiteurs = 0;
const unsigned short maxAffluence = 15;
int resetTime;
String minuteString; String minuteString;
String hourString; String hourString;
/*########################################################*/
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
@ -23,18 +30,15 @@ void setup() {
rtc.adjust(now); rtc.adjust(now);
now = rtc.now(); now = rtc.now();
second = now.second() + 5; //Il y a un décalage de 5 secondes entre les secondes réelles et celles de la librairy. second = now.second();
minute = now.minute(); minute = now.minute();
hour = now.hour(); hour = now.hour();
tft.begin(); tft.begin();
tft.setRotation(3); tft.setRotation(3);
tft.setTextColor(TFT_BLACK); tft.setTextColor(TFT_BLACK);
tft.setTextSize(3); tft.setTextSize(3);
while (!Serial){
while (!Serial)
{
tft.fillScreen(TFT_GREEN); tft.fillScreen(TFT_GREEN);
tft.drawString("Need serial com", 10, 10); tft.drawString("Need serial com", 10, 10);
} }
@ -46,22 +50,25 @@ void setup() {
tft.fillRect(0,0,320,40,TFT_BLUE); // BANDEAU DU HAUT tft.fillRect(0,0,320,40,TFT_BLUE); // BANDEAU DU HAUT
tft.drawString("+ - RAZ",5,10); tft.drawString("+ - raz",5,10);
if (now.minute() < 10) if (now.minute() < 10){
minuteString = "0" + String(now.minute()); minuteString = "0" + String(now.minute());
else }
else{
minuteString = String(now.minute()); minuteString = String(now.minute());
if (now.hour() < 10) }
if (now.hour() < 10){
hourString = "0" + String(now.hour()); hourString = "0" + String(now.hour());
else }
else{
hourString = String(now.hour()); hourString = String(now.hour());
}
tft.drawString(hourString + ":" + minuteString,230,10); tft.drawString(hourString + ":" + minuteString,230,10);
tft.fillRect(0,41,320,240,TFT_GREEN); // Carré du bas tft.fillRect(0,41,320,240,TFT_GREEN); // Carré du bas
tft.drawString("affluence: " + String(affluence), 10, 75); tft.drawString("affluence: " + String(actuel), 20, 75);
tft.drawString("visiteurs: " + String(visiteurs), 10, 100); tft.drawString("visiteurs: " + String(visiteurs), 20, 100);
attachInterrupt(WIO_KEY_C, add, FALLING); attachInterrupt(WIO_KEY_C, add, FALLING);
attachInterrupt(WIO_KEY_B, substract, FALLING); attachInterrupt(WIO_KEY_B, substract, FALLING);
@ -69,59 +76,38 @@ void setup() {
attachInterrupt(WIO_5S_PRESS, reset, FALLING); attachInterrupt(WIO_5S_PRESS, reset, FALLING);
} }
void loop() {
delay(1000);
second++;
Serial.println(second);
if (second%60 == 0)
{
minute++;
if (minute%60 == 0)
hour++;
if (hour == 24)
hour = 0;
tft.fillRect(0,0,320,40,TFT_BLUE); // BANDEAU DU HAUT
tft.drawString("+ - RAZ",5,10);
if (now.minute() < 10)
minuteString = "0" + String(minute);
else
minuteString = String(minute);
if (now.hour() < 10)
hourString = "0" + String(hour);
else
hourString = String(hour);
tft.drawString(hourString + ":" + minuteString,230,10);
}
}
void add() void add()
{ {
visiteurs++; visiteurs++;
affluence++; actuel++;
if (affluence <= maxAffluence) if (actuel <= maxAffluence){
tft.fillRect(0,41,320,240,TFT_GREEN); tft.fillRect(0,41,320,240,TFT_GREEN);
else }
else{
tft.fillRect(0,41,320,240,TFT_RED); tft.fillRect(0,41,320,240,TFT_RED);
tft.drawString("affluence: " + String(affluence), 10, 75); }
tft.drawString("visiteurs: " + String(visiteurs), 10, 100); tft.drawString("affluence: " + String(actuel), 20, 75);
tft.drawString("visiteurs: " + String(visiteurs), 20, 100);
} }
void substract() void substract()
{ {
if (affluence != 0) if (actuel != 0)
{ {
affluence--; actuel--;
if (affluence <= maxAffluence) if (actuel <= maxAffluence){
tft.fillRect(0,41,320,240,TFT_GREEN); tft.fillRect(0,41,320,240,TFT_GREEN);
else }
else{
tft.fillRect(0,41,320,240,TFT_RED); tft.fillRect(0,41,320,240,TFT_RED);
tft.drawString("affluence: " + String(affluence), 10, 75); tft.drawString("affluence: " + String(actuel), 20, 75);
tft.drawString("visiteurs: " + String(visiteurs), 10, 100); tft.drawString("visiteurs: " + String(visiteurs), 20, 100);
}
} }
} }
@ -136,12 +122,42 @@ void reset()
Serial.println("RESET"); Serial.println("RESET");
if (millis() - resetTime <= 5000) if (millis() - resetTime <= 5000)
{ {
affluence = 0; actuel = 0;
visiteurs = 0; visiteurs = 0;
tft.fillRect(0,41,320,240,TFT_GREEN); tft.fillRect(0,41,320,240,TFT_GREEN);
tft.drawString("affluence: " + String(affluence), 10, 75); tft.drawString("affluence: " + String(actuel), 20, 75);
tft.drawString("visiteurs: " + String(visiteurs), 10, 100); tft.drawString("visiteurs: " + String(visiteurs), 20, 100);
resetTime = 0; resetTime = 0;
} }
} }
void bar(){
tft.fillRect(0,0,320,40,TFT_BLUE);
tft.drawString("+ - raz",5,10);
if (now.minute() < 10)
minuteString = "0" + String(minute);
else
minuteString = String(minute);
if (now.hour() < 10)
hourString = "0" + String(hour);
else
hourString = String(hour);
tft.drawString(hourString + ":" + minuteString,230,10);
}
void loop() {
delay(1000);
second++;
Serial.println(second);
if (second%60 == 0)
{
minute++;
if (minute%60 == 0)
hour++;
if (hour == 24)
hour = 0;
bar();
}
}
Loading…
Cancel
Save