-
Notifications
You must be signed in to change notification settings - Fork 71
/
Sensors.h
74 lines (64 loc) · 1.94 KB
/
Sensors.h
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
63
64
65
66
67
68
69
70
71
72
73
74
//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++
// 2018-01-07 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
//- -----------------------------------------------------------------------------------------------------------------------
#ifndef SENSORS_H_
#define SENSORS_H_
namespace as {
class Sensor {
protected:
bool _present;
public:
Sensor () : _present(false) {}
void init () {}
bool present () { return _present; }
void measure (__attribute__((unused)) bool async=false) {}
};
class Brightness : public virtual Sensor {
protected:
uint32_t _brightness;
public:
Brightness () : _brightness(0) {}
// TODO - define value range for brightness
uint32_t brightness () { return _brightness; }
};
class Temperature : public virtual Sensor {
protected:
int16_t _temperature;
public:
Temperature () : _temperature(0) {}
// temperature value multiplied by 10
int16_t temperature () { return _temperature; }
};
class Humidity : public virtual Sensor {
protected:
uint8_t _humidity;
public:
Humidity () : _humidity(0) {}
// humidity value
uint8_t humidity () { return _humidity; }
};
class Pressure : public virtual Sensor {
protected:
uint16_t _pressure;
public:
Pressure () : _pressure(0) {}
// pressure value
uint16_t pressure () { return _pressure; }
};
class Position : public virtual Sensor {
public:
enum State { NoPos=0, PosA, PosB, PosC };
protected:
uint8_t _position;
public:
Position () : _position(NoPos) {}
// return the last measured position
uint8_t position () { return _position; }
// remap the state before send to central
uint8_t remap (uint8_t state) { return state; }
// return the measure interval in sysclock ticks
uint32_t interval () { return seconds2ticks(1); }
};
} // end namespace
#endif