tp1812fin
This commit is contained in:
parent
62b5e6323a
commit
baa82893ad
33 changed files with 302 additions and 100 deletions
|
|
@ -29,4 +29,4 @@ void Application::run(void)
|
|||
{
|
||||
// Code
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
@ -12,4 +12,4 @@ void loop()
|
|||
{
|
||||
// put your main code here, to run repeatedly:
|
||||
myApplication.run();
|
||||
}
|
||||
}
|
||||
64
BE c/projet/Application.cpp
Normal file
64
BE c/projet/Application.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*********************************************************************
|
||||
* @file Apllication.cpp
|
||||
* @author <mettre l'adresse mail ou nom prenom>
|
||||
* @brief Fichier source de l'application
|
||||
*********************************************************************/
|
||||
#include "Application.h"
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
#include "ecran.h"
|
||||
#include "bdd.h"
|
||||
#include "bouton.h"
|
||||
const int buttonPin = D8; // the number of the pushbutton pin
|
||||
const int ledPin = D7; // the number of the LED pin
|
||||
int buttonState = 0;
|
||||
ecran lcd;
|
||||
|
||||
|
||||
|
||||
const int colorR = 255;
|
||||
const int colorG = 100;
|
||||
const int colorB = 100;
|
||||
Application::Application()
|
||||
{
|
||||
// Code
|
||||
;
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
// Code
|
||||
;
|
||||
}
|
||||
|
||||
void Application::init(void)
|
||||
{
|
||||
pinMode(ledPin, OUTPUT);
|
||||
pinMode(buttonPin, INPUT);
|
||||
bouton Bouton1(buttonPin);
|
||||
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(32, 16);
|
||||
|
||||
lcd.setRGB(colorR, colorG, colorB);
|
||||
|
||||
// Print a message to the LCD.
|
||||
lcd.print("On commence a jouer?");
|
||||
|
||||
delay(1000);
|
||||
listequestions_init(lcd);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Application::run(void)
|
||||
{
|
||||
|
||||
// set the cursor to column 0, line 1
|
||||
// (note: line 1 is the second row, since counting begins with 0):
|
||||
//lcd.setCursor(0, 1);
|
||||
// print the number of seconds since reset:
|
||||
//lcd.print(millis() / 1000);
|
||||
|
||||
delay(100);
|
||||
}
|
||||
37
BE c/projet/Application.h
Normal file
37
BE c/projet/Application.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*********************************************************************
|
||||
* @file Apllication.h
|
||||
* @author <mettre l'adresse mail ou nom prenom>
|
||||
* @brief Fichier header de l'application
|
||||
*********************************************************************/
|
||||
#ifndef APPLICATION_H_
|
||||
#define APPLICATION_H_
|
||||
|
||||
/**
|
||||
* @class Application
|
||||
* @brief Classe Application
|
||||
*/
|
||||
class Application
|
||||
{
|
||||
public :
|
||||
/**
|
||||
* @fn Application();
|
||||
* @brief Constructeur par defaut
|
||||
*/
|
||||
Application();
|
||||
/**
|
||||
* @fn Application();
|
||||
* @brief Destructeur
|
||||
*/
|
||||
~Application();
|
||||
/**
|
||||
* @fn void init(void)
|
||||
* @brief Fonction d'initialisation de l'application
|
||||
*/
|
||||
void init(void);
|
||||
/**
|
||||
* @fn void run(void)
|
||||
* @brief Fonction de lancement de l'application
|
||||
*/
|
||||
void run(void);
|
||||
};
|
||||
#endif
|
||||
2
BE c/projet/actionneur.cpp
Normal file
2
BE c/projet/actionneur.cpp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#include "actionneur.h"
|
||||
|
||||
11
BE c/projet/actionneur.h
Normal file
11
BE c/projet/actionneur.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef actionneur_H
|
||||
#define actionneur_H
|
||||
#include "peripherique.h"
|
||||
class actionneur : public periph {
|
||||
private:
|
||||
|
||||
public:
|
||||
actionneur():periph(){};
|
||||
};
|
||||
|
||||
#endif
|
||||
60
BE c/projet/bdd.cpp
Normal file
60
BE c/projet/bdd.cpp
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#include "bdd.h"
|
||||
#include "ecran.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include "string.h"
|
||||
using namespace std;
|
||||
void listequestions_init(ecran& lcd){
|
||||
list<string> listeQ;
|
||||
list<string>::iterator it;
|
||||
listeQ.push_back("1 Disney");
|
||||
listeQ.push_back("2 Geographie");
|
||||
lcd.clear();
|
||||
lcd.print("Thematiques : ");
|
||||
delay(3000);
|
||||
lcd.clear();
|
||||
int nbT=0;
|
||||
for(it=listeQ.begin();it!=listeQ.end();it++) {
|
||||
|
||||
lcd.setCursor(0, nbT++);
|
||||
lcd.print((*it).c_str());
|
||||
|
||||
|
||||
}//cout<<*it<<" ";
|
||||
delay(5000);
|
||||
|
||||
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 ?");
|
||||
|
||||
for(it=Questions_Disney.begin();it!=Questions_Disney.end();it++) {
|
||||
lcd.clear();
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print((*it).c_str());
|
||||
|
||||
// Fait défiler le texte vers la gauche
|
||||
for(int i = 0; i < (*it).length(); i++) {
|
||||
lcd.scrollDisplayLeft();
|
||||
delay(300);
|
||||
}
|
||||
delay(2000);
|
||||
|
||||
}
|
||||
|
||||
/*cout<<endl;
|
||||
cout<<"Questions_Disney : "<<endl;
|
||||
for(it=Questions_Disney.begin();it!=Questions_Disney.end();it++) {cout<<*it<<" ";cout<<endl;}
|
||||
cout<<endl;*/
|
||||
|
||||
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 ?");
|
||||
/*cout<<"Questions_Géographie : "<<endl;
|
||||
|
||||
for(it=Questions_Disney.begin();it!=Questions_Disney.end();it++) {cout<<*it<<" ";cout<<endl;}
|
||||
*/
|
||||
}
|
||||
6
BE c/projet/bdd.h
Normal file
6
BE c/projet/bdd.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef bdd_H
|
||||
#define bdd_H
|
||||
#include "ecran.h"
|
||||
void listequestions_init(ecran& lcd);
|
||||
|
||||
#endif
|
||||
12
BE c/projet/bouton.cpp
Normal file
12
BE c/projet/bouton.cpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include "bouton.h"
|
||||
|
||||
bouton:: bouton() :capteur(),etat(0){}
|
||||
bouton::bouton(int pin) : capteur(pin), etat(0) {}
|
||||
|
||||
bool bouton::lire_etat(bouton& B){
|
||||
bool res;
|
||||
int buttonState = digitalRead(B.getpin());
|
||||
if (buttonState == HIGH) res=1;
|
||||
else res=0;
|
||||
return res;
|
||||
}
|
||||
14
BE c/projet/bouton.h
Normal file
14
BE c/projet/bouton.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef bouton_H
|
||||
#define bouton_H
|
||||
#include "capteur.h"
|
||||
class bouton : public capteur {
|
||||
private:
|
||||
bool etat;
|
||||
public:
|
||||
bouton();
|
||||
bouton(int pin);
|
||||
bool lire_etat(bouton& B);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
16
BE c/projet/capteur.cpp
Normal file
16
BE c/projet/capteur.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include "capteur.h"
|
||||
|
||||
capteur:: capteur() :periph(),pin(0){}
|
||||
|
||||
|
||||
capteur::capteur(int p) : periph(), pin(p) {
|
||||
pinMode(pin, INPUT); // Configure directement le pin
|
||||
}
|
||||
|
||||
void capteur::init(){
|
||||
pinMode(pin, INPUT);
|
||||
|
||||
}
|
||||
int capteur::getpin(){
|
||||
return pin;
|
||||
}
|
||||
14
BE c/projet/capteur.h
Normal file
14
BE c/projet/capteur.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef capteur_H
|
||||
#define capteur_H
|
||||
#include "peripherique.h"
|
||||
class capteur : public periph {
|
||||
private:
|
||||
int pin;
|
||||
public:
|
||||
capteur();
|
||||
capteur(int p);
|
||||
void init(void);
|
||||
int getpin();
|
||||
};
|
||||
|
||||
#endif
|
||||
12
BE c/projet/ecran.h
Normal file
12
BE c/projet/ecran.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef ecran_H
|
||||
#define ecran_H
|
||||
#include "actionneur.h"
|
||||
#include "rgb_lcd.h"
|
||||
class ecran : public actionneur, public rgb_lcd {
|
||||
private:
|
||||
|
||||
public:
|
||||
ecran():actionneur(),rgb_lcd(){};
|
||||
};
|
||||
|
||||
#endif
|
||||
9
BE c/projet/led.cpp
Normal file
9
BE c/projet/led.cpp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include "led.h"
|
||||
|
||||
|
||||
led:: led() :actionneur(),pin(0),etat(0){}
|
||||
|
||||
void led::init(){
|
||||
pinMode(pin, OUTPUT);
|
||||
|
||||
}
|
||||
14
BE c/projet/led.h
Normal file
14
BE c/projet/led.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef led_H
|
||||
#define led_H
|
||||
#include "actionneur.h"
|
||||
|
||||
class led : public actionneur{
|
||||
private:
|
||||
int pin;
|
||||
bool etat;
|
||||
public:
|
||||
led();
|
||||
void init(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
3
BE c/projet/peripherique.cpp
Normal file
3
BE c/projet/peripherique.cpp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#include "peripherique.h"
|
||||
|
||||
periph::periph() : id(0) {}
|
||||
11
BE c/projet/peripherique.h
Normal file
11
BE c/projet/peripherique.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef periph_H
|
||||
#define periph_H
|
||||
#include "Arduino.h"
|
||||
class periph {
|
||||
private:
|
||||
char id;
|
||||
public:
|
||||
periph();
|
||||
};
|
||||
|
||||
#endif
|
||||
15
BE c/projet/projet.ino
Normal file
15
BE c/projet/projet.ino
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#include "Application.h"
|
||||
|
||||
Application myApplication;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
myApplication.init();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// put your main code here, to run repeatedly:
|
||||
myApplication.run();
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
Hello World.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
#include "ecran.h"
|
||||
ecran lcd;
|
||||
|
||||
const int colorR = 255;
|
||||
const int colorG = 20;
|
||||
const int colorB = 147;
|
||||
|
||||
void setup() {
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(16, 2);
|
||||
|
||||
lcd.setRGB(colorR, colorG, colorB);
|
||||
|
||||
// Print a message to the LCD.
|
||||
lcd.print("Je t'aime Raph");
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// set the cursor to column 0, line 1
|
||||
// (note: line 1 is the second row, since counting begins with 0):
|
||||
lcd.setCursor(0, 1);
|
||||
// print the number of seconds since reset:
|
||||
lcd.print(millis() / 1000);
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
|
|
@ -1 +0,0 @@
|
|||
ma forumle magique
|
||||
39
td5.cpp
39
td5.cpp
|
|
@ -1,39 +0,0 @@
|
|||
#include <iostream>
|
||||
#include "string.h"
|
||||
using namespace std;
|
||||
|
||||
class capteur{
|
||||
protected:
|
||||
char id;
|
||||
bool actif;
|
||||
int pin;
|
||||
|
||||
public:
|
||||
capteur() : id('0'), actif(true), pin(0) {}
|
||||
capteur(int pin) : id('0'), actif(true), pin(pin) {}
|
||||
capteur(char id,int pin): id(id), actif(true), pin(pin) {}
|
||||
~capteur(){}
|
||||
|
||||
};
|
||||
|
||||
class bouton: public capteur{
|
||||
protected:
|
||||
bool etatbouton;
|
||||
public:
|
||||
bouton():capteur(){}
|
||||
bouton(bool etat) : capteur(), etatbouton(etat) {}
|
||||
bouton(int pin, bool etat) : capteur(pin), etatbouton(etat) {}
|
||||
bouton(char id, int pin, bool etat) : capteur(id, pin), etatbouton(etat) {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
bouton boutonA('A',1,true);
|
||||
bouton boutonB('B',2,true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in a new issue