forked from c-devine/OctoPrint-PanTilt-ESP8266-Firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLed.cpp
49 lines (41 loc) · 716 Bytes
/
Led.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
#include "Led.h"
#include "math.h"
Led::Led(uint8_t pin) {
_on = false;
_pin = pin;
pinMode(_pin, OUTPUT);
digitalWrite(_pin, HIGH);
}
Led::~Led() {
// TODO Auto-generated destructor stub
}
void Led::toggle() {
if (_on) {
off();
} else {
on();
}
}
void Led::on() {
digitalWrite(_pin, LOW);
_on = true;
}
void Led::off() {
digitalWrite(_pin, HIGH);
_on = false;
}
void Led::flash(uint16_t count, uint32_t delayMs) {
for (uint32_t i = 0; i< count; i++)
{
on();
delay(delayMs);
off();
delay(delayMs);
}
}
//void Led::breath(uint32_t millis) {
// float val = (exp(sin(millis/2000.0*PI)) - 0.36787944)*108.0;
//analogWrite(_pin, val);
// delay(30);
//Serial.println(val);
//}