Fix merge
This commit is contained in:
parent
2b01a1fbe5
commit
638b01db24
@ -19,20 +19,11 @@ void setup() {
|
|||||||
randomSeed(analogRead(0));
|
randomSeed(analogRead(0));
|
||||||
pinMode(A2, INPUT);
|
pinMode(A2, INPUT);
|
||||||
|
|
||||||
|
|
||||||
<<<<<<< gra_21_morpion_lumineux_code.ino
|
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> gra_21_morpion_lumineux_code.ino
|
|
||||||
if (!cap.begin(0x5B)) {
|
if (!cap.begin(0x5B)) {
|
||||||
Serial.println("MPR121 not found, check wiring?");
|
Serial.println("MPR121 not found, check wiring?");
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
Serial.println("MPR121 found!");
|
Serial.println("MPR121 found!");
|
||||||
<<<<<<< gra_21_morpion_lumineux_code.ino
|
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> gra_21_morpion_lumineux_code.ino
|
|
||||||
|
|
||||||
setupMenu();
|
setupMenu();
|
||||||
}
|
}
|
||||||
@ -61,4 +52,5 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
#include "localMode.h"
|
#include "localMode.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <Adafruit_GFX.h>
|
||||||
|
#include <Adafruit_SH110X.h>
|
||||||
|
|
||||||
|
extern Adafruit_SH1107 display;
|
||||||
|
|
||||||
MechKey keys[] = {
|
MechKey keys[] = {
|
||||||
{0, A0, false, Adafruit_NeoPixel(1, A0, NEO_GRB + NEO_KHZ800)},
|
{0, A0, false, Adafruit_NeoPixel(1, A0, NEO_GRB + NEO_KHZ800)},
|
||||||
@ -23,6 +27,29 @@ int grille[3][3] = {
|
|||||||
bool btns[9] = { false, false, false, false, false, false, false, false, false };
|
bool btns[9] = { false, false, false, false, false, false, false, false, false };
|
||||||
|
|
||||||
bool joueur1 = true;
|
bool joueur1 = true;
|
||||||
|
bool isBtnSet = false;
|
||||||
|
|
||||||
|
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) {
|
Coord getCo(int key) {
|
||||||
switch(key) {
|
switch(key) {
|
||||||
@ -97,9 +124,7 @@ void localModeDuo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtou
|
|||||||
|
|
||||||
if ((currtouched & _BV(t)) && !(lasttouched & _BV(t))) {
|
if ((currtouched & _BV(t)) && !(lasttouched & _BV(t))) {
|
||||||
Serial.print("Touch "); Serial.print(t); Serial.println(" pressed");
|
Serial.print("Touch "); Serial.print(t); Serial.println(" pressed");
|
||||||
btns[i] = true;
|
|
||||||
|
|
||||||
if(allInit()) {
|
|
||||||
Coord c = getCo(i);
|
Coord c = getCo(i);
|
||||||
if(grille[c.y][c.x] == 0) {
|
if(grille[c.y][c.x] == 0) {
|
||||||
if(joueur1) {
|
if(joueur1) {
|
||||||
@ -119,7 +144,6 @@ void localModeDuo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
lasttouched = currtouched;
|
lasttouched = currtouched;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,14 +153,10 @@ void localModeSolo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currto
|
|||||||
|
|
||||||
for (int i = 0; i < numKeys; i++) {
|
for (int i = 0; i < numKeys; i++) {
|
||||||
uint8_t t = keys[i].touchID;
|
uint8_t t = keys[i].touchID;
|
||||||
keys[i].led.setPixelColor(0, 255); // Bleu
|
|
||||||
keys[i].led.show();
|
|
||||||
|
|
||||||
if ((currtouched & _BV(t)) && !(lasttouched & _BV(t))) {
|
if ((currtouched & _BV(t)) && !(lasttouched & _BV(t))) {
|
||||||
Serial.print("Touch "); Serial.print(t); Serial.println(" pressed");
|
Serial.print("Touch "); Serial.print(t); Serial.println(" pressed");
|
||||||
btns[i] = true;
|
|
||||||
|
|
||||||
if(allInit()) {
|
|
||||||
Coord c = getCo(i);
|
Coord c = getCo(i);
|
||||||
if(grille[c.y][c.x] == 0) {
|
if(grille[c.y][c.x] == 0) {
|
||||||
grille[c.y][c.x] = 1;
|
grille[c.y][c.x] = 1;
|
||||||
@ -159,6 +179,5 @@ void localModeSolo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
lasttouched = currtouched;
|
lasttouched = currtouched;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,12 +27,14 @@ extern const int numKeys;
|
|||||||
extern int grille[3][3];
|
extern int grille[3][3];
|
||||||
extern bool btns[9];
|
extern bool btns[9];
|
||||||
extern bool joueur1;
|
extern bool joueur1;
|
||||||
|
extern bool isBtnSet;
|
||||||
|
|
||||||
Coord getCo(int key);
|
Coord getCo(int key);
|
||||||
bool victoire(int grille[3][3], int joueur);
|
bool victoire(int grille[3][3], int joueur);
|
||||||
bool allInit();
|
bool allInit();
|
||||||
void afficheGrille();
|
void afficheGrille();
|
||||||
void reset();
|
void reset();
|
||||||
|
void setBtn(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched);
|
||||||
|
|
||||||
void localModeDuo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched);
|
void localModeDuo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched);
|
||||||
void localModeSolo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched);
|
void localModeSolo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user