Compare commits
3 commits
6aa5733c3d
...
3b04428c7f
Author | SHA1 | Date | |
---|---|---|---|
3b04428c7f | |||
f99ea9a83d | |||
9527f1004b |
9 changed files with 69 additions and 64 deletions
|
@ -4,18 +4,22 @@
|
||||||
|
|
||||||
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
|
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
|
||||||
|
|
||||||
AnalogSensorManometre::AnalogSensorManometre(float val, int temps):AnalogSensor(val,temps){ alea = 1;}
|
int AnalogSensorManometre::alea = -1;
|
||||||
|
|
||||||
|
AnalogSensorManometre::AnalogSensorManometre(int val, int temps):AnalogDevice(val,temps){
|
||||||
|
AnalogSensorManometre::alea = -1;
|
||||||
|
}
|
||||||
|
|
||||||
void AnalogSensorManometre::run(){
|
void AnalogSensorManometre::run(){
|
||||||
int cpt = 0;
|
|
||||||
while(1){
|
while(1){
|
||||||
if(ptrmem!=NULL){
|
if(ptrmem!=NULL) {
|
||||||
if(cpt == 5){
|
*ptrmem = val + AnalogSensorManometre::alea;
|
||||||
*ptrmem = val - alea;
|
val = val + AnalogSensorManometre::alea;
|
||||||
val = val - alea;
|
|
||||||
cpt = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sleep(temps);
|
sleep(temps);
|
||||||
cpt++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnalogSensorManometre::setAlea(int alea) {
|
||||||
|
AnalogSensorManometre::alea = alea;
|
||||||
|
}
|
||||||
|
|
|
@ -3,3 +3,20 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../../../include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h"
|
#include "../../../include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h"
|
||||||
|
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
|
||||||
|
|
||||||
|
DigitalActuatorElectrovanne::DigitalActuatorElectrovanne(int temps) : DigitalActuator(temps){}
|
||||||
|
|
||||||
|
void DigitalActuatorElectrovanne::run() {
|
||||||
|
int previousState = LOW;
|
||||||
|
while (1){
|
||||||
|
state = *ptrmem;
|
||||||
|
if ((state != previousState)&&(state == HIGH)){
|
||||||
|
AnalogSensorManometre::setAlea(5);
|
||||||
|
previousState = HIGH;
|
||||||
|
} else if((state != previousState)&&(state == LOW)) {
|
||||||
|
AnalogSensorManometre::setAlea(-1);
|
||||||
|
previousState = LOW;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,13 +4,7 @@
|
||||||
|
|
||||||
#include "../../../include/DigitalDevices/DigitalActuators/DigitalActuatorRadiator.h"
|
#include "../../../include/DigitalDevices/DigitalActuators/DigitalActuatorRadiator.h"
|
||||||
|
|
||||||
DigitalActuatorRadiator::DigitalActuatorRadiator(int temps, float thresholdHigh, float thresholdLow) : DigitalActuator(temps),
|
DigitalActuatorRadiator::DigitalActuatorRadiator(int temps) : DigitalActuator(temps){}
|
||||||
thresholdHigh(thresholdHigh), thresholdLow(thresholdLow) {}
|
|
||||||
|
|
||||||
void DigitalActuatorRadiator::activate() {
|
|
||||||
DigitalDevice::state = HIGH;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DigitalActuatorRadiator::run() {
|
void DigitalActuatorRadiator::run() {
|
||||||
int previousState = LOW;
|
int previousState = LOW;
|
||||||
while (1){
|
while (1){
|
||||||
|
@ -24,19 +18,3 @@ void DigitalActuatorRadiator::run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float DigitalActuatorRadiator::getThresholdLow() const {
|
|
||||||
return thresholdLow;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DigitalActuatorRadiator::setThresholdLow(float thresholdLow) {
|
|
||||||
DigitalActuatorRadiator::thresholdLow = thresholdLow;
|
|
||||||
}
|
|
||||||
|
|
||||||
float DigitalActuatorRadiator::getThresholdHigh() const {
|
|
||||||
return thresholdHigh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DigitalActuatorRadiator::setThresholdHigh(float threshold) {
|
|
||||||
DigitalActuatorRadiator::thresholdHigh = threshold;
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "include/DigitalDevices/DigitalSensors/ExternalDigitalSensorButton.h"
|
#include "include/DigitalDevices/DigitalSensors/ExternalDigitalSensorButton.h"
|
||||||
#include "include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
|
#include "include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
|
||||||
#include "include/DigitalDevices/DigitalActuators/DigitalActuatorRadiator.h"
|
#include "include/DigitalDevices/DigitalActuators/DigitalActuatorRadiator.h"
|
||||||
|
#include "include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h"
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
// creation d'une board
|
// creation d'une board
|
||||||
|
@ -17,14 +18,15 @@ int main(){
|
||||||
I2CActuatorScreen screen;
|
I2CActuatorScreen screen;
|
||||||
AnalogSensorLuminosity luminosite(DELAY);
|
AnalogSensorLuminosity luminosite(DELAY);
|
||||||
ExternalDigitalSensorButton button(DELAY);
|
ExternalDigitalSensorButton button(DELAY);
|
||||||
AnalogSensorManometre manometre(4,DELAY);
|
AnalogSensorManometre manometre(PRESSURE,DELAY);
|
||||||
DigitalActuatorRadiator radiator(DELAY, THRESHOLDHIGH, THRESHOLDLOW);
|
DigitalActuatorRadiator radiator(DELAY);
|
||||||
|
DigitalActuatorElectrovanne electrovanne(DELAY);
|
||||||
|
|
||||||
|
|
||||||
// branchement des capteurs actionneurs
|
// branchement des capteurs actionneurs
|
||||||
esp8266.pin(1,temperature);
|
esp8266.pin(1,temperature);
|
||||||
//esp8266.pin(0,led1);
|
//esp8266.pin(0,led1);
|
||||||
esp8266.pin(2, luminosite);
|
esp8266.pin(2, electrovanne);
|
||||||
esp8266.i2c(1,screen);
|
esp8266.i2c(1,screen);
|
||||||
esp8266.pin(4, button);
|
esp8266.pin(4, button);
|
||||||
esp8266.pin(5, manometre);
|
esp8266.pin(5, manometre);
|
||||||
|
|
|
@ -8,13 +8,12 @@
|
||||||
|
|
||||||
#define DELAY 3
|
#define DELAY 3
|
||||||
#define TEMP 17
|
#define TEMP 17
|
||||||
|
#define PRESSURE 2995
|
||||||
#define HIGH 1
|
#define HIGH 1
|
||||||
#define LOW 0
|
#define LOW 0
|
||||||
#define MAX_I2C_DEVICES 4
|
#define MAX_I2C_DEVICES 4
|
||||||
#define I2C_BUFFER_SIZE 1024
|
#define I2C_BUFFER_SIZE 1024
|
||||||
#define MAX_IO_PIN 6
|
#define MAX_IO_PIN 6
|
||||||
#define THRESHOLDHIGH 25
|
|
||||||
#define THRESHOLDLOW 20
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,15 @@
|
||||||
//#include <fstream>
|
//#include <fstream>
|
||||||
#include "../AnalogDevice.h"
|
#include "../AnalogDevice.h"
|
||||||
|
|
||||||
class AnalogSensorManometre : public AnalogSensor{
|
class AnalogSensorManometre: public AnalogDevice {
|
||||||
private:
|
|
||||||
int alea;
|
|
||||||
public:
|
public:
|
||||||
AnalogSensorManometre(float val, int t); //
|
static int alea;
|
||||||
|
public:
|
||||||
|
// fait osciller la valeur du cpateur de 1
|
||||||
|
//constructeur ne pas oublier d'initialiser la classe mere
|
||||||
|
AnalogSensorManometre(int d,int t);
|
||||||
|
static void setAlea(int alea);
|
||||||
|
// thread representant le capteur et permettant de fonctionner independamment de la board
|
||||||
virtual void run();
|
virtual void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,12 @@
|
||||||
#define PROJET_VICTORAVECUNK_DIGITALACTUATORELECTROVANNE_H
|
#define PROJET_VICTORAVECUNK_DIGITALACTUATORELECTROVANNE_H
|
||||||
|
|
||||||
|
|
||||||
class DigitalActuatorElectrovanne {
|
#include "../DigitalDevice.h"
|
||||||
|
|
||||||
|
class DigitalActuatorElectrovanne : public DigitalActuator{
|
||||||
|
public:
|
||||||
|
DigitalActuatorElectrovanne(int temps);
|
||||||
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,20 +10,8 @@
|
||||||
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorTemperature.h"
|
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorTemperature.h"
|
||||||
|
|
||||||
class DigitalActuatorRadiator : public DigitalActuator {
|
class DigitalActuatorRadiator : public DigitalActuator {
|
||||||
private:
|
|
||||||
float thresholdHigh, thresholdLow;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DigitalActuatorRadiator(int temps, float threshold, float thresholdLow);
|
DigitalActuatorRadiator(int temps);
|
||||||
|
|
||||||
float getThresholdHigh() const;
|
|
||||||
void setThresholdHigh(float threshold);
|
|
||||||
|
|
||||||
float getThresholdLow() const;
|
|
||||||
|
|
||||||
void setThresholdLow(float thresholdLow);
|
|
||||||
|
|
||||||
void activate();
|
|
||||||
void run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,15 +17,11 @@ void Board::setup(){
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
// on fixe les pin en entree et en sorite en fonction des capteurs/actionneurs mis sur la carte
|
// on fixe les pin en entree et en sorite en fonction des capteurs/actionneurs mis sur la carte
|
||||||
pinMode(1, INPUT);
|
pinMode(1, INPUT);
|
||||||
pinMode(0, OUTPUT);
|
|
||||||
pinMode(2, INPUT);
|
|
||||||
pinMode(4, INPUT);
|
pinMode(4, INPUT);
|
||||||
pinMode(5, INPUT);
|
pinMode(5, INPUT);
|
||||||
|
|
||||||
|
pinMode(0, OUTPUT);
|
||||||
|
pinMode(2, OUTPUT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
digitalWrite(0,LOW);
|
digitalWrite(0,LOW);
|
||||||
//pinMode(6, OUTPUT);
|
//pinMode(6, OUTPUT);
|
||||||
|
@ -57,11 +53,24 @@ void Board::loop(){
|
||||||
|
|
||||||
|
|
||||||
// lecture sur la pin 2 : capteur de temperature
|
// lecture sur la pin 2 : capteur de temperature
|
||||||
val = analogRead(2);
|
pressure.setValue(analogRead(5));
|
||||||
sprintf(buf, "luminosite %d", val);
|
sprintf(buf, "pressure %f", pressure.getValue());
|
||||||
Serial.println(buf);
|
Serial.println(buf);
|
||||||
|
|
||||||
|
if ((pressure.is2Low()) && (terrarium.getTapState() == LOW)) {
|
||||||
|
digitalWrite(2, HIGH);
|
||||||
|
terrarium.setTapState(HIGH);
|
||||||
|
}
|
||||||
|
else if ((pressure.is2High() ) && (terrarium.getTapState() == HIGH)) {
|
||||||
|
digitalWrite(2, LOW);
|
||||||
|
terrarium.setTapState(LOW);
|
||||||
|
}
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if(cpt%5==0){
|
// if(cpt%5==0){
|
||||||
// tous les 5 fois on affiche sur l ecran la temperature
|
// tous les 5 fois on affiche sur l ecran la temperature
|
||||||
sprintf(buf,"%d",val1);
|
sprintf(buf,"%d",val1);
|
||||||
|
|
Loading…
Reference in a new issue