-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindicator.cpp
48 lines (38 loc) · 1.16 KB
/
indicator.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
// indicator.cpp
// github.com/jacoblukewood/ems
// Copyright 2020 Jacob Wood
#include "indicator.h"
#include <Arduino.h>
#include "utility.h"
Indicator::Indicator(unsigned int const flash_rate, unsigned int const pin_output)
: kFlashCycle(MILLISECONDS_PER_MINUTE / (flash_rate * 2))
, Light(pin_output)
{ }
void Indicator::On(void) {
state_ = true;
Refresh();
// TODO: Add something to start cycling the lights.
}
void Indicator::Off(void) {
state_ = false;
Refresh();
}
void Indicator::Refresh(void) {
if(IsOn()) {
if(millis() > (timeLastChanged_ + kFlashCycle)) {
Light::On();
}
} else {
Light::Off();
}
// if (motorcycle_.GetSpeed() > kIndicatorAutoOffSpeed && utility::IntervalPassed(Output::GetTimestampModified(), 10000))
// {
// Output::SetState(state);
// // TODO: this whole if needs fixing beause this check wont run unless the button has been pushed making it useless
// }
// else if (utility::IntervalPassed(Indicator::GetTimestampCycled(), kFlashCycle_))
// {
// digitalWrite(Indicator::GetPinOutput(), utility::GetInputState(Indicator::GetPinOutput()));
// Indicator::SetTimestampCycled(millis());
// }
}