add reset btn
This commit is contained in:
parent
05469e9b81
commit
16d812f924
@ -17,6 +17,7 @@ uint16_t currtouched = 0;
|
|||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
randomSeed(analogRead(0));
|
randomSeed(analogRead(0));
|
||||||
|
pinMode(A2, INPUT);
|
||||||
|
|
||||||
|
|
||||||
if (!cap.begin(0x5B)) {
|
if (!cap.begin(0x5B)) {
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
#include "localMode.h"
|
#include "localMode.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
uint8_t color_pos = 16;
|
|
||||||
|
|
||||||
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)},
|
||||||
{1, 25, false, Adafruit_NeoPixel(1, 25, NEO_GRB + NEO_KHZ800)},
|
{1, 25, false, Adafruit_NeoPixel(1, 25, NEO_GRB + NEO_KHZ800)},
|
||||||
@ -74,13 +72,28 @@ void afficheGrille() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
if(digitalRead(A2) == HIGH) {
|
||||||
|
Serial.println("Reset");
|
||||||
|
|
||||||
|
for(int i = 0; i < 3; i++) {
|
||||||
|
for(int j = 0; j < 3; j++) {
|
||||||
|
grille[i][j] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
joueur1 = true;
|
||||||
|
|
||||||
|
afficheGrille();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void localModeDuo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched) {
|
void localModeDuo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched) {
|
||||||
currtouched = cap.touched();
|
currtouched = cap.touched();
|
||||||
|
reset();
|
||||||
|
|
||||||
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");
|
||||||
@ -112,6 +125,7 @@ void localModeDuo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtou
|
|||||||
|
|
||||||
void localModeSolo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched) {
|
void localModeSolo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched) {
|
||||||
currtouched = cap.touched();
|
currtouched = cap.touched();
|
||||||
|
reset();
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <Adafruit_MPR121.h>
|
#include <Adafruit_MPR121.h>
|
||||||
#include <Adafruit_NeoPixel.h>
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
#include "pin.h"
|
||||||
|
|
||||||
#ifndef _BV
|
#ifndef _BV
|
||||||
#define _BV(bit) (1 << (bit))
|
#define _BV(bit) (1 << (bit))
|
||||||
@ -31,6 +32,7 @@ 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 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