-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathled.h
56 lines (41 loc) · 975 Bytes
/
led.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
/*
*
*
*/
#ifndef LED_H
#define LED_H
#include <Arduino.h>
/*
* Enumerates the different kinds of patterns for LED control.
*/
enum mode_t {
BLINK, // Simple ON/OFF cycle
FLASH, // Blink a certain number of times, pause, then repeat
PULSE, // Gradually 'breathe' ON/OFF
SOLID, // Continuous ON
STOP // Continuous OFF
};
class led {
public:
led(int ledPin);
led(int ledPin, int pwmMax);
void loop();
bool isOn();
void setMode(mode_t mode);
void setMode(mode_t mode, uint32_t period);
void setMode(mode_t mode, uint32_t period,
int flashes, uint32_t wait);
void setOff();
void phaseInvert();
private:
void ledInit(int ledPin, int pwmMax);
uint32_t period;
uint32_t timer;
uint32_t wait;
mode_t mode;
int ledPin;
int pwmMax;
int flashes;
int duty;
};
#endif