-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput.cpp
49 lines (38 loc) · 828 Bytes
/
output.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
// output.cpp
// github.com/jacoblukewood/ems
// Copyright 2020 Jacob Wood
#include "output.h"
#include <Arduino.h>
Output::Output(unsigned int const pin_output)
: kPinOutput(pin_output)
, state_(false)
{
pinMode(kPinOutput, OUTPUT);
}
bool Output::IsOn(void) const {
return state_;
}
void Output::On(void) {
if(!IsLocked()) {
digitalWrite(kPinOutput, HIGH);
timeLastChanged_ = millis();
}
}
void Output::Off(void) {
if(!IsLocked()) {
digitalWrite(kPinOutput, LOW);
timeLastChanged_ = millis();
}
}
void Output::Lock(void) {
allow_state_modification_ = false;
}
void Output::Unlock(void) {
allow_state_modification_ = true;
}
bool Output::IsLocked(void) {
return allow_state_modification_;
}
int Output::GetPinOutput(void) {
return kPinOutput;
}