51 lines
No EOL
1,004 B
C++
51 lines
No EOL
1,004 B
C++
#include "bouton.h"
|
|
#include "rgb_lcd.h"
|
|
bouton:: bouton() :capteur(),etat(0){}
|
|
bouton::bouton(int pin) : capteur(pin), etat(0) {}
|
|
|
|
bool bouton::lire_etat(){
|
|
bool res;
|
|
int buttonState = digitalRead(this->getpin());
|
|
if (buttonState == HIGH) res=1;
|
|
else res=0;
|
|
return res;
|
|
}
|
|
|
|
/*
|
|
Renvoie 1 si bouton relief et renvoie 0 si bouton plat
|
|
*/
|
|
bool choix_bouton(bouton &Brelief,bouton &Bplat){
|
|
|
|
Serial.println("A");
|
|
|
|
while (Brelief.lire_etat() == 1 || Bplat.lire_etat() == 1) {
|
|
delay(10);
|
|
}
|
|
|
|
Serial.println("A");
|
|
|
|
while (Brelief.lire_etat() == 0 && Bplat.lire_etat() == 0) {
|
|
delay(10);
|
|
}
|
|
|
|
bool reliefPresse = Brelief.lire_etat();
|
|
bool platPresse = Bplat.lire_etat();
|
|
|
|
Serial.println("A");
|
|
|
|
if (reliefPresse) {
|
|
Serial.println("A");
|
|
while (Brelief.lire_etat() == 1) {
|
|
delay(10);
|
|
}
|
|
return 1;
|
|
}
|
|
else if (platPresse) {
|
|
Serial.println("A");
|
|
while (Bplat.lire_etat() == 1) {
|
|
delay(10);
|
|
}
|
|
return 0;
|
|
}
|
|
return 0;
|
|
}; |