diff --git a/OtherDevices/AnalogDevices/AnalogSensors/AnalogSensorLuminosity.cpp b/OtherDevices/AnalogDevices/AnalogSensors/AnalogSensorLuminosity.cpp index 81f4c36..1f3ec18 100644 --- a/OtherDevices/AnalogDevices/AnalogSensors/AnalogSensorLuminosity.cpp +++ b/OtherDevices/AnalogDevices/AnalogSensors/AnalogSensorLuminosity.cpp @@ -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; } diff --git a/OtherDevices/DigitalDevices/DigitalActuators/IntelligentDigitalActuatorLED.cpp b/OtherDevices/DigitalDevices/DigitalActuators/IntelligentDigitalActuatorLED.cpp index 1689db2..a4e899d 100644 --- a/OtherDevices/DigitalDevices/DigitalActuators/IntelligentDigitalActuatorLED.cpp +++ b/OtherDevices/DigitalDevices/DigitalActuators/IntelligentDigitalActuatorLED.cpp @@ -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,17 +13,17 @@ void IntelligentDigitalActuatorLED::run(){ if(ptrmem!=NULL) { state = *ptrmem; if (state == LOW) { - cout << "((((eteint))))\n"; if (state != previousState) { - luminosite_environnement -= 50; + cout << "((((eteint))))\n"; + Board::luminosite_environnement -= 50; + previousState = state; } - previousState = state; } else { //state == HIGH - cout << "((((allume))))\n"; if (state != previousState) { - luminosite_environnement += 50; + cout << "((((allume))))\n"; + Board::luminosite_environnement += 50; + previousState = state; } - previousState = state; } } sleep(temps); diff --git a/OtherDevices/DigitalDevices/DigitalSensors/ExternalDigitalSensorButton.cpp b/OtherDevices/DigitalDevices/DigitalSensors/ExternalDigitalSensorButton.cpp index b9346dc..203a5ac 100644 --- a/OtherDevices/DigitalDevices/DigitalSensors/ExternalDigitalSensorButton.cpp +++ b/OtherDevices/DigitalDevices/DigitalSensors/ExternalDigitalSensorButton.cpp @@ -14,7 +14,7 @@ int ExternalDigitalSensorButton::getState(){ } void ExternalDigitalSensorButton::setState() { - if (ifstream("D:\\Documents\\Etudes\\INSA\\4A\\BECpp\\Projet_VictorAvecUnK\\src\\on.txt")){ + if (ifstream ("D:\\Documents\\Etudes\\INSA\\4A\\BECpp\\Projet_VictorAvecUnK\\src\\on.txt")){ state = HIGH; } else { state = LOW; diff --git a/core_simulation.cpp b/core_simulation.cpp index 16baa89..581fd33 100644 --- a/core_simulation.cpp +++ b/core_simulation.cpp @@ -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; diff --git a/core_simulation.h b/core_simulation.h index 2dd8a51..58cc60b 100644 --- a/core_simulation.h +++ b/core_simulation.h @@ -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 diff --git a/include/DigitalDevices/DigitalActuators/IntelligentDigitalActuatorLED.h b/include/DigitalDevices/DigitalActuators/IntelligentDigitalActuatorLED.h index f507beb..0b5f092 100644 --- a/include/DigitalDevices/DigitalActuators/IntelligentDigitalActuatorLED.h +++ b/include/DigitalDevices/DigitalActuators/IntelligentDigitalActuatorLED.h @@ -14,7 +14,7 @@ #include "../DigitalDevice.h" -class IntelligentDigitalActuatorLED: public DigitalDevice{ +class IntelligentDigitalActuatorLED: public DigitalActuator{ public: // initialisation du temps de rafraichiisement diff --git a/mydevices.cpp b/mydevices.cpp index 0d8332a..3c372d1 100644 --- a/mydevices.cpp +++ b/mydevices.cpp @@ -1,8 +1,11 @@ #include "mydevices.h" -//int luminosite_environnement = 200; + using namespace std; + + + // classe I2CActuatorScreen I2CActuatorScreen::I2CActuatorScreen ():Device(){} diff --git a/mydevices.h b/mydevices.h index b1568d7..be9ef7f 100644 --- a/mydevices.h +++ b/mydevices.h @@ -8,7 +8,6 @@ #include #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: diff --git a/on.txt.txt b/on.txt similarity index 100% rename from on.txt.txt rename to on.txt diff --git a/sketch_ino.cpp b/sketch_ino.cpp index 9b5c736..49216cd 100644 --- a/sketch_ino.cpp +++ b/sketch_ino.cpp @@ -21,26 +21,27 @@ void Board::loop(){ static int bascule=0; int i=0; for(i=0;i<10;i++){ - // lecture sur la pin 1 : capteur de temperature - val1=analogRead(1); - sprintf(buf,"temperature %d",val1); - Serial.println(buf); - - // lecture sur la pin 2 : capteur de temperature - val=analogRead(2); - sprintf(buf,"luminosite %d",val); - Serial.println(buf); + if (i%3==0) { + // lecture sur la pin 1 : capteur de temperature + val1 = analogRead(1); + sprintf(buf, "temperature %d", val1); + Serial.println(buf); - - if(cpt%5==0){ - // tous les 5 fois on affiche sur l ecran la temperature - sprintf(buf,"%d",val1); - bus.write(1,buf,100); - + // lecture sur la pin 2 : capteur de temperature + val = analogRead(2); + sprintf(buf, "luminosite %d", val); + Serial.println(buf); + } - } - cpt++; - sleep(1); + if(cpt%5==0){ + // tous les 5 fois on affiche sur l ecran la temperature + sprintf(buf,"%d",val1); + bus.write(1,buf,100); + + + } + cpt++; + sleep(1); } // on eteint et on allume la LED if(analogRead(4))