Template for Collaboration
This commit is contained in:
parent
25d5cfe796
commit
354f1d0a14
10 changed files with 36 additions and 30 deletions
|
@ -9,7 +9,7 @@ AnalogSensorLuminosity::AnalogSensorLuminosity(int temps):AnalogDevice(200, temp
|
|||
|
||||
void AnalogSensorLuminosity::run(){
|
||||
while(1){
|
||||
val = luminosite_environnement;
|
||||
val = Board::luminosite_environnement;
|
||||
if(ptrmem!=NULL){
|
||||
*ptrmem = val;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "../../../include/DigitalDevices/DigitalActuators/IntelligentDigitalActuatorLED.h"
|
||||
|
||||
// IntelligentDigitalActuatorLED //////////////////
|
||||
IntelligentDigitalActuatorLED::IntelligentDigitalActuatorLED(int t):DigitalDevice(t){}
|
||||
IntelligentDigitalActuatorLED::IntelligentDigitalActuatorLED(int t):DigitalActuator(t){}
|
||||
|
||||
void IntelligentDigitalActuatorLED::run(){
|
||||
int previousState = LOW; //initialisee a eteint
|
||||
|
@ -13,19 +13,19 @@ void IntelligentDigitalActuatorLED::run(){
|
|||
if(ptrmem!=NULL) {
|
||||
state = *ptrmem;
|
||||
if (state == LOW) {
|
||||
if (state != previousState) {
|
||||
cout << "((((eteint))))\n";
|
||||
if (state != previousState) {
|
||||
luminosite_environnement -= 50;
|
||||
}
|
||||
Board::luminosite_environnement -= 50;
|
||||
previousState = state;
|
||||
}
|
||||
} else { //state == HIGH
|
||||
cout << "((((allume))))\n";
|
||||
if (state != previousState) {
|
||||
luminosite_environnement += 50;
|
||||
}
|
||||
cout << "((((allume))))\n";
|
||||
Board::luminosite_environnement += 50;
|
||||
previousState = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
sleep(temps);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ bool* I2C::getVide(int addr){
|
|||
}
|
||||
|
||||
// classe generique reprenstant un capteur/actionneur
|
||||
int Board::luminosite_environnement = 200;
|
||||
Device::Device(){
|
||||
ptrtype=NULL;
|
||||
ptrmem=NULL;
|
||||
|
|
|
@ -67,6 +67,7 @@ public:
|
|||
|
||||
// representation generique d'un capteur ou d'un actionneur numerique, analogique ou sur le bue I2C
|
||||
class Device{
|
||||
|
||||
protected:
|
||||
// lien avec la carte pour lire/ecrire une valeur
|
||||
unsigned short *ptrmem;
|
||||
|
@ -90,6 +91,7 @@ public:
|
|||
// classe representant une carte arduino
|
||||
class Board{
|
||||
public:
|
||||
static int luminosite_environnement;
|
||||
// valeur sur les pin
|
||||
unsigned short io[MAX_IO_PIN];
|
||||
// pin d'entree ou de sortie
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "../DigitalDevice.h"
|
||||
|
||||
class IntelligentDigitalActuatorLED: public DigitalDevice{
|
||||
class IntelligentDigitalActuatorLED: public DigitalActuator{
|
||||
|
||||
public:
|
||||
// initialisation du temps de rafraichiisement
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
|
||||
#include "mydevices.h"
|
||||
//int luminosite_environnement = 200;
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
// classe I2CActuatorScreen
|
||||
I2CActuatorScreen::I2CActuatorScreen ():Device(){}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <fstream>
|
||||
#include "core_simulation.h"
|
||||
|
||||
static int luminosite_environnement = 200;
|
||||
// exemple d'actionneur sur le bus I2C permettant d'echanger des tableaux de caracteres : un ecran, ne pas oublier d'heriter de Device
|
||||
class I2CActuatorScreen : public Device{
|
||||
protected:
|
||||
|
|
|
@ -21,6 +21,7 @@ void Board::loop(){
|
|||
static int bascule=0;
|
||||
int i=0;
|
||||
for(i=0;i<10;i++){
|
||||
if (i%3==0) {
|
||||
// lecture sur la pin 1 : capteur de temperature
|
||||
val1 = analogRead(1);
|
||||
sprintf(buf, "temperature %d", val1);
|
||||
|
@ -30,7 +31,7 @@ void Board::loop(){
|
|||
val = analogRead(2);
|
||||
sprintf(buf, "luminosite %d", val);
|
||||
Serial.println(buf);
|
||||
|
||||
}
|
||||
|
||||
if(cpt%5==0){
|
||||
// tous les 5 fois on affiche sur l ecran la temperature
|
||||
|
|
Loading…
Reference in a new issue