Electrovanne terminee et fonctionelle
This commit is contained in:
parent
f99ea9a83d
commit
3b04428c7f
8 changed files with 31 additions and 88 deletions
|
@ -7,7 +7,7 @@
|
||||||
int AnalogSensorManometre::alea = -1;
|
int AnalogSensorManometre::alea = -1;
|
||||||
|
|
||||||
AnalogSensorManometre::AnalogSensorManometre(int val, int temps):AnalogDevice(val,temps){
|
AnalogSensorManometre::AnalogSensorManometre(int val, int temps):AnalogDevice(val,temps){
|
||||||
AnalogSensorManometre::alea=-1;
|
AnalogSensorManometre::alea = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnalogSensorManometre::run(){
|
void AnalogSensorManometre::run(){
|
||||||
|
|
|
@ -5,19 +5,14 @@
|
||||||
#include "../../../include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h"
|
#include "../../../include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h"
|
||||||
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
|
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
|
||||||
|
|
||||||
DigitalActuatorElectrovanne::DigitalActuatorElectrovanne(int temps, float thresholdHigh, float thresholdLow) : DigitalActuator(temps),
|
DigitalActuatorElectrovanne::DigitalActuatorElectrovanne(int temps) : DigitalActuator(temps){}
|
||||||
thresholdHigh(thresholdHigh), thresholdLow(thresholdLow) {}
|
|
||||||
|
|
||||||
void DigitalActuatorElectrovanne::activate() {
|
|
||||||
DigitalDevice::state = HIGH;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DigitalActuatorElectrovanne::run() {
|
void DigitalActuatorElectrovanne::run() {
|
||||||
int previousState = LOW;
|
int previousState = LOW;
|
||||||
while (1){
|
while (1){
|
||||||
state = *ptrmem;
|
state = *ptrmem;
|
||||||
if ((state != previousState)&&(state == HIGH)){
|
if ((state != previousState)&&(state == HIGH)){
|
||||||
AnalogSensorManometre::setAlea(1);
|
AnalogSensorManometre::setAlea(5);
|
||||||
previousState = HIGH;
|
previousState = HIGH;
|
||||||
} else if((state != previousState)&&(state == LOW)) {
|
} else if((state != previousState)&&(state == LOW)) {
|
||||||
AnalogSensorManometre::setAlea(-1);
|
AnalogSensorManometre::setAlea(-1);
|
||||||
|
@ -25,19 +20,3 @@ void DigitalActuatorElectrovanne::run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float DigitalActuatorElectrovanne::getThresholdLow() const {
|
|
||||||
return thresholdLow;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DigitalActuatorElectrovanne::setThresholdLow(float thresholdLow) {
|
|
||||||
DigitalActuatorElectrovanne::thresholdLow = thresholdLow;
|
|
||||||
}
|
|
||||||
|
|
||||||
float DigitalActuatorElectrovanne::getThresholdHigh() const {
|
|
||||||
return thresholdHigh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DigitalActuatorElectrovanne::setThresholdHigh(float threshold) {
|
|
||||||
DigitalActuatorElectrovanne::thresholdHigh = threshold;
|
|
||||||
}
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -9,20 +9,8 @@
|
||||||
#include "../DigitalDevice.h"
|
#include "../DigitalDevice.h"
|
||||||
|
|
||||||
class DigitalActuatorElectrovanne : public DigitalActuator{
|
class DigitalActuatorElectrovanne : public DigitalActuator{
|
||||||
private:
|
public:
|
||||||
float thresholdHigh, thresholdLow;
|
DigitalActuatorElectrovanne(int temps);
|
||||||
|
|
||||||
public:
|
|
||||||
DigitalActuatorElectrovanne(int temps, float threshold, float thresholdLow);
|
|
||||||
|
|
||||||
float getThresholdHigh() const;
|
|
||||||
void setThresholdHigh(float threshold);
|
|
||||||
|
|
||||||
float getThresholdLow() const;
|
|
||||||
|
|
||||||
void setThresholdLow(float thresholdLow);
|
|
||||||
|
|
||||||
void activate();
|
|
||||||
void run();
|
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