ASMESDC2018
/home/swerve/Github/sdc_2018/omni_robot/LED.h
Go to the documentation of this file.
1 
8 #ifndef LED_H_
9 #define LED_H_
10 
11 #define COMMON_ANODE // comment if not using a common anode LED
12 
13 #define COLOR_NONE 0
14 #define COLOR_RED 1
15 #define COLOR_YELLOW 2
16 #define COLOR_GREEN 3
17 #define MIN_STATE_VAL 0
18 #define MAX_STATE_VAL 3
19 
20 #define MIN_COLOR_VALUE 0
21 #define MAX_COLOR_VALUE 255
22 
23 #define BLINK_OFF 0
24 #define BLINK_ON 1
25 #define BLINK_SPEED 250 // speed at which to blink in miliseconds
26 
27 #define SIDE_BOTH 0
28 #define SIDE_LEFT 1
29 #define SIDE_RIGHT 2
30 
31 struct LEDState {
32  int led;
33  int red;
34  int green;
35  int blue;
36  int side;
37  bool is_blink;
38  bool blink;
39  uint32_t blink_start;
40 };
41 
42 struct LEDPins {
49 };
50 
51 class LED {
52 public:
53  LED(int, int, int, int, int, int);
54 
55  void setup(int, int, int, int, int, int);
56  void setState(int, bool blink = false, int side = SIDE_BOTH);
57  void getState(void);
58 
59 protected:
62 
63 private:
64  void _updateState(void);
65  void _updateBlink(void);
66  void _setColor(int, int, int, int);
67 
68 };
69 
70 #endif /* LED_H_ */
71 
72 
int side
Definition: LED.h:36
int PIN_RIGHT_RED
Definition: LED.h:46
uint32_t blink_start
Definition: LED.h:39
#define SIDE_BOTH
Definition: LED.h:27
int red
Definition: LED.h:33
int green
Definition: LED.h:34
Definition: LED.h:42
Definition: LED.h:51
int PIN_RIGHT_GREEN
Definition: LED.h:47
int PIN_LEFT_RED
Definition: LED.h:43
int led
Definition: LED.h:32
int PIN_LEFT_BLUE
Definition: LED.h:45
int PIN_RIGHT_BLUE
Definition: LED.h:48
LEDState state
Definition: LED.h:60
Definition: LED.h:31
int PIN_LEFT_GREEN
Definition: LED.h:44
bool is_blink
Definition: LED.h:37
LEDPins pins
Definition: LED.h:61
int blue
Definition: LED.h:35
bool blink
Definition: LED.h:38