Mise à jour de 'code_remi'

master
Remi NEVEU 1 year ago
parent 36b4a2c73c
commit 39dafeefdf

@ -3,30 +3,44 @@
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;
int ancien_affluence = 0;
int y = Y_MAX/5;
int background = TFT_GREEN;
unsigned long myTimeInSec;
unsigned long myTimeInMin;
unsigned long hour;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(WIO_5S_UP, INPUT_PULLUP);
pinMode(WIO_5S_DOWN, INPUT_PULLUP);
pinMode(WIO_5S_LEFT, INPUT_PULLUP);
pinMode(WIO_5S_RIGHT, INPUT_PULLUP);
pinMode(WIO_5S_PRESS, INPUT_PULLUP);
tft.begin();
tft.setRotation(3);
tft.fillRect(0, y, X_MAX, Y_MAX, TFT_GREEN);
affBandeauBleu();
affHeure();
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);
pinMode(WIO_5S_PRESS, INPUT_PULLUP);
affiche();
affBandeauBleu();
affHeure();
}
void loop() {
//affHeure();
visiteur();
}
@ -54,4 +68,115 @@ void affHeure() {
tft.drawNumber(hour, 240, 10);
tft.drawNumber(myTimeInMin, 285, 10);
delay(1000);
}
void visiteur() {
int etat = 0;
if (digitalRead(WIO_KEY_B) == LOW) {
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();
affBandeauBleu();
affHeure();
}
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
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();
affiche();
Serial.print("visit_total = ");
Serial.println(visit_total);
Serial.print("affluence = ");
Serial.println(affluence);
}
else if (digitalRead(WIO_KEY_A) == LOW) {
tft.setTextColor(TFT_BLACK);
tft.setTextSize(3);
tft.drawString("Confirmez ?", 110, 200);
etat = compteur();
if(etat == 1){
ancien();
visit_total = 0;
affluence = 0;
etat = 0;
}
tft.setTextColor(background);
tft.setTextSize(3);
tft.drawString("Confirmez ?", 110, 200);
efface();
affiche();
Serial.print("visit_total = ");
Serial.println(visit_total);
Serial.print("affluence = ");
Serial.println(affluence);
}
delay(200);
}
void ancien(){
ancien_visit_total = visit_total;
ancien_affluence = affluence;
}
void efface(){
tft.setTextColor(background);
tft.setTextSize(3);
tft.drawString("visit_total", 10, 100);
tft.drawNumber(ancien_visit_total, 250, 100);
tft.drawString("affluence", 10, 150);
tft.drawNumber(ancien_affluence, 250, 150);
}
void affiche(){
tft.setTextColor(TFT_BLACK);
tft.setTextSize(3);
tft.drawString("visit_total", 10, 100);
tft.drawNumber(visit_total, 250, 100);
tft.drawString("affluence", 10, 150);
tft.drawNumber(affluence, 250, 150);
}
int compteur(){
int i = 5;
while( i > 0){
delay(1000);
Serial.println(i);
i--;
if(digitalRead(WIO_5S_PRESS) == LOW){
return 1;
}
}
return 0;
}
Loading…
Cancel
Save