-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLEDs.h
61 lines (50 loc) · 1.83 KB
/
LEDs.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
57
58
59
60
61
// LED Strip update and writing code header
// COLORS = RRGGBB
// WHITE = 0xFFFFFF
// RED = 0xFF0000
// GREEN = 0x00FF00
// BLUE = 0x0000FF
// YELLOW = 0xF08000
// MAGENTA = 0xFF005E
// BLACK = 0x000000
#include <stdint.h>
#include <SPI.h>
// Required defines for the code
#define N_LEDS (8) // The number of LEDS in the strip
// COLORS = RRGGBB
#define WHITE (0xFFFFFF)
#define RED (0xFF0000)
#define GREEN (0x00FF00)
#define BLUE (0x0000FF)
#define YELLOW (0xF08000)
#define MAGENTA (0xFF005E)
#define BLACK (0x000000) // Turns the LED OFF
// LED purpose
#define SYSTEM_ON_LED (0)
#define SYSTEM_ON_LED_ALT (7)
#define NET_ARM_LED (1)
#define NET_ARM_LED_ALT (6)
#define SOFTWARE_ARM_LED (2)
#define SOFTWARE_ARM_LED_ALT (5)
#define USER_PROGRAMMABLE_LED (3)
#define USER_PROGRAMMABLE_LED_ALT (4)
// LED Strip class that contains the LED value arrays as parameters and functions for writing and updating the LED Strip
class LED_Strip{
private:
// LED Value Arrays
uint8_t reds[N_LEDS]; // Holds the red value data for every LED in the strip
uint8_t greens[N_LEDS]; // Holds the green value data for every LED in the strip
uint8_t blues[N_LEDS]; // Holds the blue value data for every LED in the strip
public:
// LED Write and Update Function Declarations
// Configures the RGB values for a specified LED based on a passed-in 24-bit value in RGB format
void set_One(int led, uint32_t value);
// Configures the RGB Passes in an array of all the LED values and updates all the LEDs in the array at once
void set_All(uint32_t value);
// Transmits the signals to the LEDs necessary for them to recognize the 1s and 0s as 1s and 0s
void write_LED(uint8_t r, uint8_t g, uint8_t b);
// Sends the data required to write to the LEDs
void update_LEDs();
// Turns off all the LEDs on the strip
void reset_strip();
};