Electrovanne terminee et fonctionelle

This commit is contained in:
Cameron Bray 2020-05-20 11:44:55 +02:00
parent f99ea9a83d
commit 3b04428c7f
8 changed files with 31 additions and 88 deletions

View file

@ -7,7 +7,7 @@
int AnalogSensorManometre::alea = -1;
AnalogSensorManometre::AnalogSensorManometre(int val, int temps):AnalogDevice(val,temps){
AnalogSensorManometre::alea=-1;
AnalogSensorManometre::alea = -1;
}
void AnalogSensorManometre::run(){

View file

@ -5,19 +5,14 @@
#include "../../../include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h"
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
DigitalActuatorElectrovanne::DigitalActuatorElectrovanne(int temps, float thresholdHigh, float thresholdLow) : DigitalActuator(temps),
thresholdHigh(thresholdHigh), thresholdLow(thresholdLow) {}
void DigitalActuatorElectrovanne::activate() {
DigitalDevice::state = HIGH;
}
DigitalActuatorElectrovanne::DigitalActuatorElectrovanne(int temps) : DigitalActuator(temps){}
void DigitalActuatorElectrovanne::run() {
int previousState = LOW;
while (1){
state = *ptrmem;
if ((state != previousState)&&(state == HIGH)){
AnalogSensorManometre::setAlea(1);
AnalogSensorManometre::setAlea(5);
previousState = HIGH;
} else if((state != previousState)&&(state == LOW)) {
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;
}

View file

@ -4,13 +4,7 @@
#include "../../../include/DigitalDevices/DigitalActuators/DigitalActuatorRadiator.h"
DigitalActuatorRadiator::DigitalActuatorRadiator(int temps, float thresholdHigh, float thresholdLow) : DigitalActuator(temps),
thresholdHigh(thresholdHigh), thresholdLow(thresholdLow) {}
void DigitalActuatorRadiator::activate() {
DigitalDevice::state = HIGH;
}
DigitalActuatorRadiator::DigitalActuatorRadiator(int temps) : DigitalActuator(temps){}
void DigitalActuatorRadiator::run() {
int previousState = LOW;
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;
}

View file

@ -6,6 +6,7 @@
#include "include/DigitalDevices/DigitalSensors/ExternalDigitalSensorButton.h"
#include "include/AnalogDevices/AnalogSensors/AnalogSensorManometre.h"
#include "include/DigitalDevices/DigitalActuators/DigitalActuatorRadiator.h"
#include "include/DigitalDevices/DigitalActuators/DigitalActuatorElectrovanne.h"
int main(){
// creation d'une board
@ -17,14 +18,15 @@ int main(){
I2CActuatorScreen screen;
AnalogSensorLuminosity luminosite(DELAY);
ExternalDigitalSensorButton button(DELAY);
AnalogSensorManometre manometre(4,DELAY);
DigitalActuatorRadiator radiator(DELAY, THRESHOLDHIGH, THRESHOLDLOW);
AnalogSensorManometre manometre(PRESSURE,DELAY);
DigitalActuatorRadiator radiator(DELAY);
DigitalActuatorElectrovanne electrovanne(DELAY);
// branchement des capteurs actionneurs
esp8266.pin(1,temperature);
//esp8266.pin(0,led1);
esp8266.pin(2, luminosite);
esp8266.pin(2, electrovanne);
esp8266.i2c(1,screen);
esp8266.pin(4, button);
esp8266.pin(5, manometre);

View file

@ -8,13 +8,12 @@
#define DELAY 3
#define TEMP 17
#define PRESSURE 2995
#define HIGH 1
#define LOW 0
#define MAX_I2C_DEVICES 4
#define I2C_BUFFER_SIZE 1024
#define MAX_IO_PIN 6
#define THRESHOLDHIGH 25
#define THRESHOLDLOW 20
using namespace std;

View file

@ -9,21 +9,9 @@
#include "../DigitalDevice.h"
class DigitalActuatorElectrovanne : public DigitalActuator{
private:
float thresholdHigh, thresholdLow;
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();
public:
DigitalActuatorElectrovanne(int temps);
void run();
};

View file

@ -10,20 +10,8 @@
#include "../../../include/AnalogDevices/AnalogSensors/AnalogSensorTemperature.h"
class DigitalActuatorRadiator : public DigitalActuator {
private:
float thresholdHigh, thresholdLow;
public:
DigitalActuatorRadiator(int temps, float threshold, float thresholdLow);
float getThresholdHigh() const;
void setThresholdHigh(float threshold);
float getThresholdLow() const;
void setThresholdLow(float thresholdLow);
void activate();
DigitalActuatorRadiator(int temps);
void run();
};

View file

@ -17,15 +17,11 @@ void Board::setup(){
Serial.begin(9600);
// on fixe les pin en entree et en sorite en fonction des capteurs/actionneurs mis sur la carte
pinMode(1, INPUT);
pinMode(0, OUTPUT);
pinMode(2, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(0, OUTPUT);
pinMode(2, OUTPUT);
digitalWrite(0,LOW);
//pinMode(6, OUTPUT);
@ -57,11 +53,24 @@ void Board::loop(){
// lecture sur la pin 2 : capteur de temperature
val = analogRead(2);
sprintf(buf, "luminosite %d", val);
pressure.setValue(analogRead(5));
sprintf(buf, "pressure %f", pressure.getValue());
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){
// tous les 5 fois on affiche sur l ecran la temperature
sprintf(buf,"%d",val1);