Merge branch 'feature/resetBtn' into 'main'

Feature/reset btn

See merge request SAE_203_2025/grA_21_Morpion_lumineaux/gra_21_morpion_lumineux_code!5
This commit is contained in:
T'JAMPENS QUENTIN p2406187 2025-06-17 08:21:34 +00:00
commit 4cf77bd42f
4 changed files with 23 additions and 4 deletions

View File

@ -17,6 +17,7 @@ uint16_t currtouched = 0;
void setup() {
Serial.begin(115200);
randomSeed(analogRead(0));
pinMode(A2, INPUT);
if (!cap.begin(0x5B)) {

View File

@ -1,8 +1,6 @@
#include "localMode.h"
#include <Arduino.h>
uint8_t color_pos = 16;
MechKey keys[] = {
{0, A0, false, Adafruit_NeoPixel(1, A0, 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) {
currtouched = cap.touched();
reset();
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");
@ -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) {
currtouched = cap.touched();
reset();
for (int i = 0; i < numKeys; i++) {
uint8_t t = keys[i].touchID;

View File

@ -3,6 +3,7 @@
#include <Adafruit_MPR121.h>
#include <Adafruit_NeoPixel.h>
#include "pin.h"
#ifndef _BV
#define _BV(bit) (1 << (bit))
@ -31,6 +32,7 @@ Coord getCo(int key);
bool victoire(int grille[3][3], int joueur);
bool allInit();
void afficheGrille();
void reset();
void localModeDuo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched);
void localModeSolo(Adafruit_MPR121& cap, uint16_t& lasttouched, uint16_t& currtouched);

View File

@ -3,6 +3,8 @@
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
extern Adafruit_SH1107 display;
// Utilisateurs du réseau
const char *ssid = "morpion-SAE";
const char *password = "12345678";