V3
This commit is contained in:
parent
087c7902ee
commit
077992fa7b
16 changed files with 306 additions and 214 deletions
|
|
@ -9,26 +9,25 @@
|
||||||
#include "ecran.h"
|
#include "ecran.h"
|
||||||
#include "bdd.h"
|
#include "bdd.h"
|
||||||
#include "bouton.h"
|
#include "bouton.h"
|
||||||
#define buttonPinRelief D8
|
#define buttonPinRelief D8
|
||||||
#define buttonPinPlat D6
|
#define buttonPinPlat D6
|
||||||
|
|
||||||
Application::Application(): ledPin(D7), colorR(255), colorG(100), colorB(100), boutonRelief(buttonPinRelief), boutonPlat(buttonPinPlat) {}
|
Application::Application()
|
||||||
|
: ledPin(D7), colorR(255), colorG(100), colorB(100), boutonRelief(buttonPinRelief), boutonPlat(buttonPinPlat) {}
|
||||||
|
|
||||||
Application::~Application()
|
Application::~Application() {
|
||||||
{
|
|
||||||
/*if (boutonRelief != nullptr) {
|
/*if (boutonRelief != nullptr) {
|
||||||
delete boutonRelief;
|
delete boutonRelief;
|
||||||
}
|
}
|
||||||
if (boutonPlat != nullptr) {
|
if (boutonPlat != nullptr) {
|
||||||
delete boutonPlat;
|
delete boutonPlat;
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::init(void)
|
void Application::init(void) {
|
||||||
{
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
lcd.begin(32, 16);
|
lcd.begin(32, 16);
|
||||||
lcd.setRGB(colorR, colorG, colorB);
|
lcd.setRGB(colorR, colorG, colorB);
|
||||||
pinMode(ledPin, OUTPUT);
|
pinMode(ledPin, OUTPUT);
|
||||||
pinMode(buttonPinRelief, INPUT);
|
pinMode(buttonPinRelief, INPUT);
|
||||||
pinMode(buttonPinPlat, INPUT);
|
pinMode(buttonPinPlat, INPUT);
|
||||||
|
|
@ -37,8 +36,7 @@ void Application::init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Application::run(void)
|
void Application::run(void) {
|
||||||
{
|
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
lcd.print("On commence a jouer?");
|
lcd.print("On commence a jouer?");
|
||||||
delay(1500);
|
delay(1500);
|
||||||
|
|
|
||||||
|
|
@ -7,41 +7,40 @@
|
||||||
#define APPLICATION_H_
|
#define APPLICATION_H_
|
||||||
#include "rgb_lcd.h"
|
#include "rgb_lcd.h"
|
||||||
#include "ecran.h"
|
#include "ecran.h"
|
||||||
#include "bdd.h"
|
#include "bdd.h"
|
||||||
#include "bouton.h"
|
#include "bouton.h"
|
||||||
/**
|
/**
|
||||||
* @class Application
|
* @class Application
|
||||||
* @brief Classe Application
|
* @brief Classe Application
|
||||||
*/
|
*/
|
||||||
class Application
|
class Application {
|
||||||
{
|
public:
|
||||||
public :
|
const int ledPin;
|
||||||
const int ledPin;
|
const int colorR;
|
||||||
const int colorR;
|
const int colorG;
|
||||||
const int colorG;
|
const int colorB;
|
||||||
const int colorB;
|
ecran lcd;
|
||||||
ecran lcd;
|
bouton boutonRelief;
|
||||||
bouton boutonRelief;
|
bouton boutonPlat;
|
||||||
bouton boutonPlat;
|
/**
|
||||||
/**
|
|
||||||
* @fn Application();
|
* @fn Application();
|
||||||
* @brief Constructeur par defaut
|
* @brief Constructeur par defaut
|
||||||
*/
|
*/
|
||||||
Application();
|
Application();
|
||||||
/**
|
/**
|
||||||
* @fn Application();
|
* @fn Application();
|
||||||
* @brief Destructeur
|
* @brief Destructeur
|
||||||
*/
|
*/
|
||||||
~Application();
|
~Application();
|
||||||
/**
|
/**
|
||||||
* @fn void init(void)
|
* @fn void init(void)
|
||||||
* @brief Fonction d'initialisation de l'application
|
* @brief Fonction d'initialisation de l'application
|
||||||
*/
|
*/
|
||||||
void init(void);
|
void init(void);
|
||||||
/**
|
/**
|
||||||
* @fn void run(void)
|
* @fn void run(void)
|
||||||
* @brief Fonction de lancement de l'application
|
* @brief Fonction de lancement de l'application
|
||||||
*/
|
*/
|
||||||
void run(void);
|
void run(void);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
#include "actionneur.h"
|
#include "actionneur.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
#ifndef actionneur_H
|
#ifndef actionneur_H
|
||||||
#define actionneur_H
|
#define actionneur_H
|
||||||
#include "peripherique.h"
|
#include "peripherique.h"
|
||||||
|
|
||||||
|
//Déclaration de la classe actionneur
|
||||||
class actionneur : public periph {
|
class actionneur : public periph {
|
||||||
private:
|
public:
|
||||||
|
actionneur()
|
||||||
public:
|
: periph(){};
|
||||||
actionneur():periph(){};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -5,126 +5,194 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using namespace std;
|
|
||||||
int reponses_disney[] = {0, 1, 0};
|
|
||||||
int reponses_geographie[] = {0, 1, 1};
|
|
||||||
void defileTexte(ecran &lcd, String texte) {
|
|
||||||
int largeur = 32;
|
|
||||||
texte += " ";
|
|
||||||
int longueur = texte.length();
|
|
||||||
int pos = 0;
|
|
||||||
|
|
||||||
while (pos <= longueur - largeur) {
|
using namespace std;
|
||||||
lcd.clear();
|
|
||||||
lcd.setCursor(0, 0);
|
// Tableau avec les réponses aux questions par catégorie
|
||||||
lcd.print(texte.substring(pos, pos + largeur));
|
// 1 = VRAI et 0 = FAUX
|
||||||
delay(400);
|
int reponses_disney[] = { 0, 1, 0 };
|
||||||
pos++;
|
int reponses_geographie[] = { 0, 1, 1 };
|
||||||
}
|
int reponses_sciences[] = { 1, 0, 1 };
|
||||||
}
|
int reponses_culture[] = { 1, 1, 1 };
|
||||||
void play(ecran &lcd, list<string> Questions, int reponses[], bouton &boutonRelief, bouton &boutonPlat){
|
int reponses_animaux[] = { 0, 0, 1 };
|
||||||
int score = 0;
|
|
||||||
int questionNum = 0;
|
void defileTexte(ecran &lcd, String texte) {
|
||||||
list<string>::iterator it;
|
int largeur = 32;
|
||||||
|
texte += " ";
|
||||||
// Parcourir toutes les questions
|
int longueur = texte.length();
|
||||||
for(it = Questions.begin(); it != Questions.end(); it++) {
|
int pos = 0;
|
||||||
lcd.clear();
|
|
||||||
|
while (pos <= longueur - largeur) {
|
||||||
// Afficher le numéro de la question
|
|
||||||
lcd.setCursor(0, 0);
|
|
||||||
lcd.print("Q");
|
|
||||||
lcd.print(questionNum + 1);
|
|
||||||
lcd.print(": ");
|
|
||||||
delay(1000);
|
|
||||||
|
|
||||||
|
|
||||||
lcd.clear();
|
|
||||||
|
|
||||||
defileTexte(lcd, (*it).c_str());
|
|
||||||
delay(1500);
|
|
||||||
|
|
||||||
|
|
||||||
lcd.clear();
|
|
||||||
lcd.setCursor(0, 0);
|
|
||||||
lcd.print("Relief=Vrai");
|
|
||||||
lcd.setCursor(0, 1);
|
|
||||||
lcd.print("Plat=Faux");
|
|
||||||
delay(1000);
|
|
||||||
|
|
||||||
// Attendre la réponse de l'utilisateur
|
|
||||||
bool reponseUtilisateur = choix_bouton(boutonRelief, boutonPlat);
|
|
||||||
|
|
||||||
// Vérifier la réponse (1 pour boutonRelief/Vrai, 0 pour boutonPlat/Faux)
|
|
||||||
if (reponseUtilisateur == reponses[questionNum]) {
|
|
||||||
lcd.clear();
|
|
||||||
lcd.print("Correct !");
|
|
||||||
score++;
|
|
||||||
} else {
|
|
||||||
lcd.clear();
|
|
||||||
lcd.print("Faux !");
|
|
||||||
}
|
|
||||||
delay(2000);
|
|
||||||
|
|
||||||
questionNum++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Afficher le score final
|
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
lcd.setCursor(0, 0);
|
lcd.setCursor(0, 0);
|
||||||
lcd.print("Score: ");
|
lcd.print(texte.substring(pos, pos + largeur));
|
||||||
lcd.print(score);
|
delay(400);
|
||||||
lcd.print("/");
|
pos++;
|
||||||
lcd.print(questionNum);
|
}
|
||||||
lcd.setCursor(0, 1);
|
|
||||||
lcd.print("Bravo !");
|
|
||||||
delay(5000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void listequestions_init(ecran &lcd, bouton &boutonRelief, bouton &boutonPlat) {
|
||||||
|
list<string> listeQ; //Crée la liste de thèmes
|
||||||
|
list<string>::iterator it; //Déclare un iterateur
|
||||||
|
//Pousse les thème dans une liste
|
||||||
|
listeQ.push_back("Disney");
|
||||||
|
listeQ.push_back("Geographie");
|
||||||
|
listeQ.push_back("Sciences");
|
||||||
|
listeQ.push_back("Culture Generale");
|
||||||
|
listeQ.push_back("Animaux");
|
||||||
|
|
||||||
void listequestions_init(ecran& lcd,bouton &boutonRelief, bouton &boutonPlat){
|
int nbT = listeQ.size();
|
||||||
list<string> listeQ;
|
int TActuel = 0;
|
||||||
list<string>::iterator it;
|
|
||||||
listeQ.push_back("1 Disney");
|
lcd.clear(); //Nettoie l'écran
|
||||||
listeQ.push_back("2 Geographie");
|
|
||||||
lcd.clear();
|
//Affiche les thèmes
|
||||||
lcd.print("Thematiques : ");
|
lcd.print("Thematiques : ");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
lcd.clear();
|
|
||||||
int nbT=0;
|
|
||||||
for(it=listeQ.begin();it!=listeQ.end();it++) {
|
// Navigue dans les thèmes
|
||||||
lcd.setCursor(0, nbT++);
|
bool TChoisi = false;
|
||||||
|
while (!TChoisi) {
|
||||||
|
|
||||||
|
//Affiche le thème actuel
|
||||||
|
it = listeQ.begin();
|
||||||
|
advance(it, TActuel);
|
||||||
|
lcd.setCursor(0, 1);
|
||||||
lcd.print((*it).c_str());
|
lcd.print((*it).c_str());
|
||||||
|
delay(2000);
|
||||||
|
|
||||||
|
//Affiche les instruction par bouton
|
||||||
|
lcd.clear();
|
||||||
|
lcd.setCursor(0, 0);
|
||||||
|
lcd.print(String(TActuel + 1) + (*it).c_str());
|
||||||
|
lcd.setCursor(0, 1);
|
||||||
|
lcd.print("Relief=OK, Plat=>");
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
// Attends la réponse de l'utilisateur
|
||||||
|
bool choixUtilisateur = choix_bouton(boutonRelief, boutonPlat);
|
||||||
|
|
||||||
|
if (choixUtilisateur == 1) {
|
||||||
|
// Bouton Relief = Valider le thème
|
||||||
|
TChoisi = true;
|
||||||
|
} else {
|
||||||
|
// Bouton Plat = Passer au thème suivant
|
||||||
|
TActuel = (TActuel + 1) % nbT; //permet de revenir au premier thème si aucun n'a été choisi
|
||||||
|
}
|
||||||
}
|
}
|
||||||
delay(2000);
|
|
||||||
|
//Banque de questions pour le thème Disney
|
||||||
|
list<string> Questions_Disney;
|
||||||
|
Questions_Disney.push_back("Patrick est le nom du cameleon de Raiponce ?");
|
||||||
|
Questions_Disney.push_back("La robe de Tiana est verte ?");
|
||||||
|
Questions_Disney.push_back("Cendrillon etait le premier disney ?");
|
||||||
|
|
||||||
|
//Banque de questions pour le thème Geographie
|
||||||
|
list<string> Questions_Geographie;
|
||||||
|
Questions_Geographie.push_back("Rio de Janeiro est la capitale du Bresil ?");
|
||||||
|
Questions_Geographie.push_back("L'Inde est le pays le plus peuple ?");
|
||||||
|
Questions_Geographie.push_back("Les Pyrenees Atlantiques ont 64 en numéro de département ?");
|
||||||
|
|
||||||
|
//Banque de questions pour le thème Sciences
|
||||||
|
list<string> Questions_Sciences;
|
||||||
|
Questions_Geographie.push_back("Le corps humain contient assez de fer pour faire un clou ?");
|
||||||
|
Questions_Geographie.push_back("Les cheveux continuent de pousser après la mort ?");
|
||||||
|
Questions_Geographie.push_back("Le cerveau ne ressent pas la douleur?");
|
||||||
|
|
||||||
|
//Banque de questions pour le thème Culture Générale
|
||||||
|
list<string> Questions_Culture_G;
|
||||||
|
Questions_Geographie.push_back("Le Soleil est une étoile ?");
|
||||||
|
Questions_Geographie.push_back("Le français est parlé sur tous les continents ?");
|
||||||
|
Questions_Geographie.push_back("Les Romains utilisaient déjà le béton ?");
|
||||||
|
|
||||||
|
//Banque de questions pour le thème Animaux
|
||||||
|
list<string> Questions_Animaux;
|
||||||
|
Questions_Geographie.push_back("Les requins doivent nager en permanence pour survivre ?");
|
||||||
|
Questions_Geographie.push_back("Les chauves-souris sont aveugles ?");
|
||||||
|
Questions_Geographie.push_back("Les poissons dorment ?");
|
||||||
|
|
||||||
|
// Lance le quiz selon le thème choisi
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
lcd.setCursor(0, 0);
|
switch (TActuel) {
|
||||||
lcd.print("Relief=Disney");
|
case 0:
|
||||||
lcd.setCursor(0, 1);
|
lcd.print("Disney");
|
||||||
lcd.print("Plat=Geographie");
|
|
||||||
delay(1000);
|
|
||||||
|
|
||||||
bool resultat = choix_bouton(boutonRelief, boutonPlat);
|
|
||||||
|
|
||||||
list<string> Questions_Disney;
|
|
||||||
Questions_Disney.push_back("Patrick est le nom du cameleon de Raiponce ?");
|
|
||||||
Questions_Disney.push_back("La robe de Tiana est verte ?");
|
|
||||||
Questions_Disney.push_back("Cendrillon etait le premier disney ?");
|
|
||||||
|
|
||||||
list<string> Questions_Geographie;
|
|
||||||
Questions_Geographie.push_back("Rio de Janeiro est la capitale du Bresil ?");
|
|
||||||
Questions_Geographie.push_back("L'Inde est le pays le plus peuple ?");
|
|
||||||
Questions_Geographie.push_back("Les Pyrenees Atlantiques ont 64 en numéro de département ?");
|
|
||||||
|
|
||||||
lcd.clear();
|
|
||||||
if (resultat == 1) {
|
|
||||||
lcd.print("Theme: Disney");
|
|
||||||
delay(2000);
|
delay(2000);
|
||||||
play(lcd, Questions_Disney, reponses_disney, boutonRelief, boutonPlat);
|
play(lcd, Questions_Disney, reponses_disney, boutonRelief, boutonPlat);
|
||||||
} else {
|
break;
|
||||||
lcd.print("Theme: Geographie");
|
case 1:
|
||||||
|
lcd.print("Geographie");
|
||||||
delay(2000);
|
delay(2000);
|
||||||
play(lcd, Questions_Geographie, reponses_geographie, boutonRelief, boutonPlat);
|
play(lcd, Questions_Geographie, reponses_geographie, boutonRelief, boutonPlat);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
lcd.print("Sciences");
|
||||||
|
delay(2000);
|
||||||
|
play(lcd, Questions_Sciences, reponses_sciences, boutonRelief, boutonPlat);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
lcd.print("Culture Generale");
|
||||||
|
delay(2000);
|
||||||
|
play(lcd, Questions_Culture_G, reponses_culture, boutonRelief, boutonPlat);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
lcd.print("Animaux");
|
||||||
|
delay(2000);
|
||||||
|
play(lcd, Questions_Animaux, reponses_animaux, boutonRelief, boutonPlat);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void play(ecran &lcd, list<string> Questions, int reponses[], bouton &boutonRelief, bouton &boutonPlat) {
|
||||||
|
int score = 0;
|
||||||
|
int questionNum = 0;
|
||||||
|
list<string>::iterator it;
|
||||||
|
|
||||||
|
// Permet de parcourir toutes les questions
|
||||||
|
for (it = Questions.begin(); it != Questions.end(); it++) {
|
||||||
|
lcd.clear(); //Nettoie l'écran
|
||||||
|
|
||||||
|
// Affiche le numéro de la question
|
||||||
|
lcd.setCursor(0, 0);
|
||||||
|
lcd.print("Q" + String(questionNum + 1) + ": ");
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
lcd.clear(); //Nettoie l'écran
|
||||||
|
|
||||||
|
//Faire défiler la question
|
||||||
|
defileTexte(lcd, (*it).c_str());
|
||||||
|
delay(1500);
|
||||||
|
|
||||||
|
// Affiche les choix pour l'utilisateur
|
||||||
|
lcd.clear();
|
||||||
|
lcd.setCursor(0, 0);
|
||||||
|
lcd.print("Relief=Vrai");
|
||||||
|
lcd.setCursor(0, 1);
|
||||||
|
lcd.print("Plat=Faux");
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
// Attends la réponse de l'utilisateur
|
||||||
|
bool reponseUtilisateur = choix_bouton(boutonRelief, boutonPlat);
|
||||||
|
|
||||||
|
// Vérifie la réponse (1 pour boutonRelief/Vrai, 0 pour boutonPlat/Faux)
|
||||||
|
if (reponseUtilisateur == reponses[questionNum]) {
|
||||||
|
lcd.clear();
|
||||||
|
lcd.print("Correct !");
|
||||||
|
score++;
|
||||||
|
} else {
|
||||||
|
lcd.clear();
|
||||||
|
lcd.print("Faux !");
|
||||||
|
}
|
||||||
|
delay(2000);
|
||||||
|
|
||||||
|
questionNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Afficher le score final
|
||||||
|
lcd.clear();
|
||||||
|
lcd.setCursor(0, 0);
|
||||||
|
lcd.print("Score: " + String(score) + "/" + String(questionNum));
|
||||||
|
lcd.setCursor(0, 1);
|
||||||
|
lcd.print("Bravo !");
|
||||||
|
delay(5000);
|
||||||
}
|
}
|
||||||
|
|
@ -4,8 +4,17 @@
|
||||||
#include "bouton.h"
|
#include "bouton.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
//Permet de faire défiler le texte sur l'écran
|
||||||
|
// Paramètres : lcd = écran à utiliser, texte = texte à faire défiler
|
||||||
void defileTexte(ecran &lcd, String texte);
|
void defileTexte(ecran &lcd, String texte);
|
||||||
void listequestions_init(ecran& lcd,bouton &boutonRelief, bouton &boutonPlat);
|
|
||||||
|
// Affiche les thèmes disponibles et lance le quiz correspondant
|
||||||
|
void listequestions_init(ecran &lcd, bouton &boutonRelief, bouton &boutonPlat);
|
||||||
|
|
||||||
|
//Fonction principale pour jouer à un quiz
|
||||||
void play(ecran &lcd, list<string> Questions, int reponses[], bouton &boutonRelief, bouton &boutonPlat);
|
void play(ecran &lcd, list<string> Questions, int reponses[], bouton &boutonRelief, bouton &boutonPlat);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,51 +1,56 @@
|
||||||
#include "bouton.h"
|
#include "bouton.h"
|
||||||
#include "rgb_lcd.h"
|
#include "rgb_lcd.h"
|
||||||
bouton:: bouton() :capteur(),etat(0){}
|
|
||||||
bouton::bouton(int pin) : capteur(pin), etat(0) {}
|
|
||||||
|
|
||||||
bool bouton::lire_etat(){
|
//Constructeur
|
||||||
|
bouton::bouton()
|
||||||
|
: capteur(), etat(0) {}
|
||||||
|
|
||||||
|
bouton::bouton(int pin)
|
||||||
|
: capteur(pin), etat(0) {}
|
||||||
|
|
||||||
|
//ccesseur de etat
|
||||||
|
bool bouton::lire_etat() {
|
||||||
bool res;
|
bool res;
|
||||||
int buttonState = digitalRead(this->getpin());
|
int buttonState = digitalRead(this->getpin());
|
||||||
if (buttonState == HIGH) res=1;
|
if (buttonState == HIGH) res = 1;
|
||||||
else res=0;
|
else res = 0;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
bool choix_bouton(bouton &Brelief, bouton &Bplat) {
|
||||||
Renvoie 1 si bouton relief et renvoie 0 si bouton plat
|
|
||||||
*/
|
|
||||||
bool choix_bouton(bouton &Brelief,bouton &Bplat){
|
|
||||||
|
|
||||||
Serial.println("A");
|
Serial.println("A"); //a enlever
|
||||||
|
|
||||||
|
//Attends que les 2 bouttons soient relachés
|
||||||
while (Brelief.lire_etat() == 1 || Bplat.lire_etat() == 1) {
|
while (Brelief.lire_etat() == 1 || Bplat.lire_etat() == 1) {
|
||||||
delay(10);
|
delay(10);
|
||||||
}
|
}
|
||||||
|
Serial.println("A"); //a enlever
|
||||||
|
|
||||||
Serial.println("A");
|
//Attends que l'un des boutons soit appuyé
|
||||||
|
|
||||||
while (Brelief.lire_etat() == 0 && Bplat.lire_etat() == 0) {
|
while (Brelief.lire_etat() == 0 && Bplat.lire_etat() == 0) {
|
||||||
delay(10);
|
delay(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Stocke l'état des boutons
|
||||||
bool reliefPresse = Brelief.lire_etat();
|
bool reliefPresse = Brelief.lire_etat();
|
||||||
bool platPresse = Bplat.lire_etat();
|
bool platPresse = Bplat.lire_etat();
|
||||||
|
|
||||||
Serial.println("A");
|
Serial.println("A"); //a enlever
|
||||||
|
|
||||||
|
//Boucle qui renvoie 1 si bouton relief et renvoie 0 si bouton plat
|
||||||
if (reliefPresse) {
|
if (reliefPresse) {
|
||||||
Serial.println("A");
|
Serial.println("A");
|
||||||
while (Brelief.lire_etat() == 1) {
|
while (Brelief.lire_etat() == 1) {
|
||||||
delay(10);
|
delay(10);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
} else if (platPresse) {
|
||||||
else if (platPresse) {
|
|
||||||
Serial.println("A");
|
Serial.println("A");
|
||||||
while (Bplat.lire_etat() == 1) {
|
while (Bplat.lire_etat() == 1) {
|
||||||
delay(10);
|
delay(10);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
@ -2,15 +2,17 @@
|
||||||
#define bouton_H
|
#define bouton_H
|
||||||
#include "capteur.h"
|
#include "capteur.h"
|
||||||
#include "rgb_lcd.h"
|
#include "rgb_lcd.h"
|
||||||
|
|
||||||
|
//Déclaration de la classe bouton
|
||||||
class bouton : public capteur {
|
class bouton : public capteur {
|
||||||
private:
|
private:
|
||||||
bool etat;
|
bool etat;
|
||||||
public:
|
public:
|
||||||
bouton();
|
bouton();
|
||||||
bouton(int pin);
|
bouton(int pin);
|
||||||
bool lire_etat();
|
bool lire_etat(); //Accesseur de etat
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
bool choix_bouton(bouton &Brelief,bouton &Bplat);
|
|
||||||
|
//Renvoie 1 si bouton relief et renvoie 0 si bouton plat
|
||||||
|
bool choix_bouton(bouton &Brelief, bouton &Bplat);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,16 +1,20 @@
|
||||||
#include "capteur.h"
|
#include "capteur.h"
|
||||||
|
|
||||||
capteur:: capteur() :periph(),pin(0){}
|
//Constructeur
|
||||||
|
capteur::capteur()
|
||||||
|
: periph(), pin(0) {}
|
||||||
|
|
||||||
|
capteur::capteur(int p)
|
||||||
capteur::capteur(int p) : periph(), pin(p) {
|
: periph(), pin(p) {
|
||||||
pinMode(pin, INPUT); // Configure directement le pin
|
pinMode(pin, INPUT); // Configure directement le pin
|
||||||
}
|
}
|
||||||
|
|
||||||
void capteur::init(){
|
//Initialise le capteur en entrée
|
||||||
|
void capteur::init() {
|
||||||
pinMode(pin, INPUT);
|
pinMode(pin, INPUT);
|
||||||
|
|
||||||
}
|
}
|
||||||
int capteur::getpin(){
|
|
||||||
|
//Accesseur de pin
|
||||||
|
int capteur::getpin() {
|
||||||
return pin;
|
return pin;
|
||||||
}
|
}
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
#ifndef capteur_H
|
#ifndef capteur_H
|
||||||
#define capteur_H
|
#define capteur_H
|
||||||
#include "peripherique.h"
|
#include "peripherique.h"
|
||||||
|
|
||||||
|
//Déclaration de la classe capteur
|
||||||
class capteur : public periph {
|
class capteur : public periph {
|
||||||
private:
|
private:
|
||||||
int pin;
|
int pin;
|
||||||
public:
|
public:
|
||||||
capteur();
|
capteur();
|
||||||
capteur(int p);
|
capteur(int p);
|
||||||
void init(void);
|
void init(void); //Initialise le capteur en entrée
|
||||||
int getpin();
|
int getpin(); //Accesseur de pin
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -2,11 +2,12 @@
|
||||||
#define ecran_H
|
#define ecran_H
|
||||||
#include "actionneur.h"
|
#include "actionneur.h"
|
||||||
#include "rgb_lcd.h"
|
#include "rgb_lcd.h"
|
||||||
|
|
||||||
|
//Déclaration de la classe Ecran
|
||||||
class ecran : public actionneur, public rgb_lcd {
|
class ecran : public actionneur, public rgb_lcd {
|
||||||
private:
|
public:
|
||||||
|
ecran()
|
||||||
public:
|
: actionneur(), rgb_lcd(){};
|
||||||
ecran():actionneur(),rgb_lcd(){};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
|
|
||||||
|
//Constructeur
|
||||||
|
led::led()
|
||||||
|
: actionneur(), pin(0), etat(0) {}
|
||||||
|
|
||||||
led:: led() :actionneur(),pin(0),etat(0){}
|
//Initialise la LED en OUTPUT
|
||||||
|
void led::init() {
|
||||||
void led::init(){
|
|
||||||
pinMode(pin, OUTPUT);
|
pinMode(pin, OUTPUT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,13 +2,14 @@
|
||||||
#define led_H
|
#define led_H
|
||||||
#include "actionneur.h"
|
#include "actionneur.h"
|
||||||
|
|
||||||
class led : public actionneur{
|
//Déclaration de la classe LED
|
||||||
private:
|
class led : public actionneur {
|
||||||
int pin;
|
private:
|
||||||
bool etat;
|
int pin;
|
||||||
public:
|
bool etat;
|
||||||
led();
|
public:
|
||||||
void init(void);
|
led();
|
||||||
|
void init(void); //Initialise la LED en OUTPUT
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
#include "peripherique.h"
|
#include "peripherique.h"
|
||||||
|
|
||||||
periph::periph() : id(0) {}
|
//Constructeur
|
||||||
|
periph::periph()
|
||||||
|
: id(0) {}
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
#ifndef periph_H
|
#ifndef periph_H
|
||||||
#define periph_H
|
#define periph_H
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
//Déclaration de la classe periph
|
||||||
class periph {
|
class periph {
|
||||||
private:
|
private:
|
||||||
char id;
|
char id;
|
||||||
public:
|
public:
|
||||||
periph();
|
periph();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -2,14 +2,12 @@
|
||||||
|
|
||||||
Application myApplication;
|
Application myApplication;
|
||||||
|
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
// setup code ici
|
||||||
// put your setup code here, to run once:
|
|
||||||
myApplication.init();
|
myApplication.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop() {
|
||||||
{
|
// main code ici
|
||||||
// put your main code here, to run repeatedly:
|
|
||||||
myApplication.run();
|
myApplication.run();
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue