This repository has been archived by the owner on Jul 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLEDStrip.h
154 lines (142 loc) · 5.89 KB
/
LEDStrip.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/**
* LEDStrip
* @author Curt Henrichs
* @date 1-15-18
*
* LEDStrip enumerates and documents the IR code interface to a RGB LED strip.
* Rational for sending IR codes as opposed to hacking the controller box is
* two-fold. First hacking the box would make compatibility with the original
* remote more of a chore. Second, the LED strip used is an outdoor model with
* waterproofing and operates the LEDs at 120v. Thus to hack the hardware would
* be counterproductive relative to the IR API already established.
*
* The IR LED interface determined after recording the remote's transmitted data
* is noted in the following tables. Note that all commands follow a NEC
* encoding.
*
* Address is 0x00.
*
* Hex Value | Name
* ----------|----------------
* 0x04 | Brightness-Down
* 0x05 | Brightness-Up
* 0x06 | Off
* 0x07 | On
* 0x08 | ~Green
* 0x09 | ~Red
* 0x0A | ~Blue
* 0x0B | ~White
* 0x0C | ~Pea Green
* 0x0D | ~Orange
* 0x0E | ~Dark Orchid
* 0x0F | Flash Function
* 0x10 | ~Cyan
* 0x11 | ~Dark Yellow
* 0x12 | ~Magenta
* 0x13 | Fade Function
* 0x14 | ~Light Blue
* 0x15 | ~Yellow
* 0x16 | ~Pink
* 0x17 | Strobe Function
* 0x18 | ~Sky Blue
* 0x19 | ~Light Yellow
* 0x1A | ~Purple
* 0x1B | Smooth Function
*
* Special functions have a unique property depending if one send the command
* after it is already in the selected mode. The following lists describes this
* behavior.
* - Pressing Flash once does same action as smooth
* - Pressing Flash twice strobes between color transitions of flash 1 (unsure
* which entity knows that a second press has happend)
* - Pressing Strobe once strobes currently displayed color
* - Pressing Strobe twice smoothly changes brightness of static color (unsure
* which entity knows that a second press has happend)
* - Pressing fade once fades between all colors
* - Pressing fade twice fades only an rgb single cycling them (unsure which
* entity knows that a second press has happend)
* - Pressing smooth once transitions between all colors abruptly (irony)
* - Pressing smooth twice flashes only an rgb single cycling them (unsure
* which entity knows that a second press has happend)
*
* Brightness adjustment is measured in ticks. To move from brightest to least
* will take 9 ticks.
*
* Brightness adjustment will act as expected for static colors. However when
* running a special function the brightness adjustment will alter the
* transition speed of the current function.
* - During Flash increases/decreases transition speed (9 ticks)
* - During Strobe increases/decreases transition speed (9 ticks)
* - During Fade increases/decreases transition speed (9 ticks)
* - During Smooth increases/decreases transition speed (9 ticks)
*
* Note that after searching all possible command space, no other codes exist.
* It is also unlikely that other code combinations exist.
*/
#ifndef LEDSTRIP_H
#define LEDSTRIP_H
//==============================================================================
// Libraries
//==============================================================================
#include <stdint.h>
//==============================================================================
// Constant and Macro Definitions
//==============================================================================
/**
* Enumeration of LED controller's power state
*/
typedef enum LEDPowerState {
LED_ON_CMD = 0x07, //! Turns the LED driver on
LED_OFF_CMD = 0x06 //! Turns the LED driver off
} LEDPowerState_e;
/**
* Enumeration of LED controller's brightness adjust commands
*/
typedef enum LEDBrightnessAdjust {
LED_BRIGHTNESS_UP = 0x05, //! Moves the brightness up one tick
LED_BRIGHTNESS_DOWN = 0x04 //! Moves the brightness down one tick
} LEDBrightnessAdjust_e;
/**
* Enumeration of LED controller's static colors
*/
typedef enum LEDColor {
LED_COLOR_WHITE = 0x0B, //! Static Color RGB
LED_COLOR_RED = 0x09, //! Static Color RGB
LED_COLOR_ORANGE = 0x0D, //! Static Color Table
LED_COLOR_DARK_YELLOW = 0x11, //! Static Color Table
LED_COLOR_YELLOW = 0x15, //! Static Color Table
LED_COLOR_LIGHT_YELLOW = 0x19, //! Static Color Table
LED_COLOR_GREEN = 0x08, //! Static Color RGB
LED_COLOR_PEA_GREEN = 0x0C, //! Static Color Table
LED_COLOR_CYAN = 0x10, //! Static Color Table
LED_COLOR_LIGHT_BLUE = 0x14, //! Static Color Table
LED_COLOR_SKY_BLUE = 0x18, //! Static Color Table
LED_COLOR_BLUE = 0x0A, //! Static Color RGB
LED_COLOR_DARK_ORCHID = 0x0E, //! Static Color Table
LED_COLOR_PURPLE = 0x1A, //! Static Color Table
LED_COLOR_MAGENTA = 0x12, //! Static Color Table
LED_COLOR_PINK = 0x16 //! Static Color Table
} LEDColor_e;
/**
* Enumeration of LED controller's special function buttons
*/
typedef enum LEDCommand {
LED_FLASH_CMD = 0x0F, //! "Flashes" instantly or via strobe
LED_STROBE_CMD = 0x17, //! "Strobe" flashes or fades preset color
LED_FADE_CMD = 0x13, //! "Fade" rainbows or rgb cycles color
LED_SMOOTH_CMD = 0x1B //! "Smooth" switchs mutlitple or rgb colors
} LEDCommand_e;
//==============================================================================
// Public Function Prototypes
//==============================================================================
/**
* Initialize LED Strip communication IR transmitter.
*/
void led_init(void);
/**
* Set a raw command to LED strip controller. Note that all data is transmitted
* as a NEC command to controller.
* @param cmd as a byte of data to transmit.
*/
void led_send_value(uint8_t cmd);
#endif