forked from SamZorSec/Arilux_AL-LC0X
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArilux.h
139 lines (131 loc) · 4.03 KB
/
Arilux.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
#pragma once
#ifndef _ARILUX_H_
#define _ARILUX_H_
#include <ESP8266WiFi.h> // https://github.com/esp8266/Arduino
//lc08
//#define RGBWW
//lc02 lc04
//#define RGBW
//lc03
#if defined(RGBWW)
#define ARILUX_RED_PIN 5
#define ARILUX_GREEN_PIN 4
#define ARILUX_BLUE_PIN 14
#define ARILUX_WHITE1_PIN 12
#define ARILUX_WHITE2_PIN 13
#define ARILUX_IR_PIN
#define ARILUX_COLOSTRING "RGBWW"
#elif defined(RGBW)
#define ARILUX_RED_PIN 14
#define ARILUX_GREEN_PIN 5
#define ARILUX_BLUE_PIN 12
#define ARILUX_WHITE1_PIN 13
#define ARILUX_IR_PIN 4
#define ARILUX_COLOSTRING "RGBW"
#else
#define ARILUX_RED_PIN 14
#define ARILUX_GREEN_PIN 5
#define ARILUX_BLUE_PIN 12
#define ARILUX_IR_PIN 4
#define ARILUX_COLOSTRING "RGB"
#endif
#define ARILUX_PWM_RANGE 255
#define ARILUX_PWM_FREQUENCY 500
#define ARILUX_BRIGHTNESS_STEP 25
/*
* IR Remote
* Encoding: NEC
* +------+------+------+------+
* | UP | Down | OFF | ON |
* +------+------+------+------+
* | R | G | B | W |
* +------+------+------+------+
* | 1 | 2 | 3 |FLASH |
* +------+------+------+------+
* | 4 | 5 | 6 |STROBE|
* +------+------+------+------+
* | 7 | 8 | 9 | FADE |
* +------+------+------+------+
* | 10 | 11 | 12 |SMOOTH|
* +------+------+------+------+
*/
#ifdef IR_REMOTE
#define ARILUX_IR_CODE_KEY_UP 0xFF906F
#define ARILUX_IR_CODE_KEY_DOWN 0xFFB847
#define ARILUX_IR_CODE_KEY_OFF 0xFFF807
#define ARILUX_IR_CODE_KEY_ON 0xFFB04F
#define ARILUX_IR_CODE_KEY_R 0xFF9867
#define ARILUX_IR_CODE_KEY_G 0xFFD827
#define ARILUX_IR_CODE_KEY_B 0xFF8877
#define ARILUX_IR_CODE_KEY_W 0xFFA857
#define ARILUX_IR_CODE_KEY_1 0xFFE817
#define ARILUX_IR_CODE_KEY_2 0xFF48B7
#define ARILUX_IR_CODE_KEY_3 0xFF6897
#define ARILUX_IR_CODE_KEY_FLASH 0xFFB24D
#define ARILUX_IR_CODE_KEY_4 0xFF02FD
#define ARILUX_IR_CODE_KEY_5 0xFF32CD
#define ARILUX_IR_CODE_KEY_6 0xFF20DF
#define ARILUX_IR_CODE_KEY_STROBE 0xFF00FF
#define ARILUX_IR_CODE_KEY_7 0xFF50AF
#define ARILUX_IR_CODE_KEY_8 0xFF7887
#define ARILUX_IR_CODE_KEY_9 0xFF708F
#define ARILUX_IR_CODE_KEY_FADE 0xFF58A7
#define ARILUX_IR_CODE_KEY_10 0xFF38C7
#define ARILUX_IR_CODE_KEY_11 0xFF28D7
#define ARILUX_IR_CODE_KEY_12 0xFFF00F
#define ARILUX_IR_CODE_KEY_SMOOTH 0xFF30CF
#endif
enum {
ARILUX_CMD_NOT_DEFINED,
ARILUX_CMD_STATE_CHANGED,
ARILUX_CMD_BRIGHTNESS_CHANGED,
ARILUX_CMD_COLOR_CHANGED,
ARILUX_CMD_WHITE_CHANGED,
ARILUX_CMD_PING
};
typedef struct Color {
uint8_t red;
uint8_t green;
uint8_t blue;
uint8_t white1;
uint8_t white2;
};
class Arilux {
public:
Arilux(void);
uint8_t init(void);
uint8_t getState(void);
uint8_t turnOn(void);
uint8_t turnOff(void);
uint8_t getBrightness(void);
uint8_t increaseBrightness(void);
uint8_t decreaseBrightness(void);
uint8_t setBrightness(uint8_t p_brightness);
uint8_t getRedValue(void);
uint8_t getGreenValue(void);
uint8_t getBlueValue(void);
uint8_t getWhite1Value(void);
uint8_t getWhite2Value(void);
char * getColorString(void);
uint8_t setColor(uint8_t p_red, uint8_t p_green, uint8_t p_blue);
uint8_t setAll(uint8_t p_red, uint8_t p_green, uint8_t p_blue, uint8_t p_white1, uint8_t p_white2);
uint8_t setWhite(uint8_t p_white1, uint8_t p_white2);
private:
uint8_t m_redPin;
uint8_t m_greenPin;
uint8_t m_bluePin;
#ifdef RGBW
uint8_t m_white1Pin;
#ifdef RGBWW
uint8_t m_white2Pin;
#endif
#endif
uint8_t m_state;
uint8_t m_brightness;
Color m_color;
uint8_t setState(uint8_t p_state);
uint8_t setColor(uint8_t p_red, uint8_t p_green, uint8_t p_blue, uint8_t p_retain);
uint8_t setAll(uint8_t p_red, uint8_t p_green, uint8_t p_blue, uint8_t p_white1, uint8_t p_white2, uint8_t p_retain);
uint8_t setWhite(uint8_t p_white1, uint8_t p_white2, uint8_t p_retain);
};
#endif