-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSensors.cpp
62 lines (45 loc) · 1.43 KB
/
Sensors.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "Sensors.h"
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*
Agregar metodos para sensores nuevos
*/
/*
Se agrega sensor de ultrasonido
*/
int Sensor::addUltrasonic(int echo, int trig) {
Ultrasonic_class.init(echo, trig);
this->sensor_type = "ULTRASONIC";
}
/*
Se agrega sensor PIR
*/
int Sensor::addPir( int pin) {
pir_class.init(pin);
this->sensor_type = "PIR";
}
int Sensor::addInfrarrojo( int pin) {
Infrarrojo_class.init(pin);
this->sensor_type = "Infrarrojo";
}
int Sensor::addGenerico( int pin) {
Generico_class.init(pin);
this->sensor_type = "Generico";
}
/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*
Leé los datos de los sensores mediante una asbtracción generalizada
*/
float Sensor::readdata() {
if (this->sensor_type == "ULTRASONIC") {
return Ultrasonic_class.dist();
}
else if (this->sensor_type == "PIR") {
return pir_class.readmotion();
}
else if (this->sensor_type == "Infrarrojo") {
return Infrarrojo_class.readmotion();
}
else if (this->sensor_type == "Generico") {
return Generico_class.readmotion();
}
}