add of setBtn function
This commit is contained in:
parent
de0afba0bf
commit
2062f238ca
@ -18,13 +18,13 @@ uint16_t currtouched = 0;
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
/*
|
||||
|
||||
if (!cap.begin(0x5B)) {
|
||||
Serial.println("MPR121 not found, check wiring?");
|
||||
while (1);
|
||||
}
|
||||
Serial.println("MPR121 found!");
|
||||
*/
|
||||
|
||||
|
||||
setupMenu();
|
||||
}
|
||||
@ -33,7 +33,6 @@ void loop() {
|
||||
readButton();
|
||||
if (!isPlay) {
|
||||
menu();
|
||||
Serial.println("ok");
|
||||
} else {
|
||||
if (!local) {
|
||||
if(!isWebSet){
|
||||
@ -42,9 +41,13 @@ void loop() {
|
||||
}else{
|
||||
loopWeb();
|
||||
}
|
||||
} else {
|
||||
if(!isBtnSet){
|
||||
setBtn(cap, lasttouched, currtouched);
|
||||
}else{
|
||||
// Passe cap, lasttouched, currtouched par référence !
|
||||
localMode(cap, lasttouched, currtouched);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
27
localMode.h
27
localMode.h
@ -52,9 +52,33 @@ bool allInit();
|
||||
|
||||
void localMode(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched);
|
||||
|
||||
bool isBtnSet = false;
|
||||
|
||||
#endif // LOCALMODE_H
|
||||
|
||||
|
||||
void setBtn(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched){
|
||||
display.clearDisplay();
|
||||
display.setCursor(0, 0);
|
||||
display.print("Veuillez rester\nappuye sur chaqu'un\ndes boutons pendant\n3 secondes avant de\nles relacher pour\nles initialiser");
|
||||
display.display();
|
||||
if(allInit()){
|
||||
isBtnSet = true;
|
||||
}else{
|
||||
currtouched = cap.touched();
|
||||
for (int i = 0; i < numKeys; i++) {
|
||||
uint8_t t = keys[i].touchID;
|
||||
keys[i].led.setPixelColor(0, 255); // Bleu
|
||||
keys[i].led.show();
|
||||
if ((currtouched & _BV(t)) && !(lasttouched & _BV(t))) {
|
||||
Serial.print("Touch "); Serial.print(t); Serial.println(" pressed");
|
||||
btns[i] = true;
|
||||
}
|
||||
}
|
||||
lasttouched = currtouched;
|
||||
}
|
||||
}
|
||||
|
||||
Coord getCo(int key) {
|
||||
switch(key) {
|
||||
case 0: return { 0, 0 };
|
||||
@ -107,9 +131,7 @@ void localMode(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouche
|
||||
|
||||
if ((currtouched & _BV(t)) && !(lasttouched & _BV(t))) {
|
||||
Serial.print("Touch "); Serial.print(t); Serial.println(" pressed");
|
||||
btns[i] = true;
|
||||
|
||||
if(allInit()) {
|
||||
Coord c = getCo(i);
|
||||
if(grille[c.y][c.x] == 0) {
|
||||
if(joueur1) {
|
||||
@ -134,6 +156,5 @@ void localMode(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouche
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lasttouched = currtouched;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user