-
Notifications
You must be signed in to change notification settings - Fork 1
/
lamp_controller.h
55 lines (38 loc) · 913 Bytes
/
lamp_controller.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
#ifndef LAMP_CONTROLLER_H
#define LAMP_CONTROLLER_H
#include <Arduino.h>
class LampController {
public:
LampController(int switch_in, int lamp_out);
void begin();
void update();
inline bool getState() const {
return lampState == HIGH;
}
void setState(bool newState);
inline bool getSwitchState() const {
return switchLastState == LOW;
}
inline unsigned int getSwitchLastChange() const {
return lastSwitchChange;
}
void setAntiNoise(bool newState);
void setAntiNoisePulseLen(int pulseLen);
inline bool getAntiNoise() const {
return antiNoise;
}
inline int getAntiNoisePulseLen() const {
return pulseLen;
}
void toggleLamp();
private:
int switch_in;
int lamp_out;
int lampState = HIGH;
int switchLastState = LOW;
unsigned int lastSwitchChange = 0;
unsigned int lastPulse = 0;
bool antiNoise = false;
int pulseLen = 1;
};
#endif