Skip to content

Commit 6e88bd1

Browse files
committed
40 keys IR Remote
Added IR remote with 40 keys to use with RGBW stripes.
1 parent 734b8d3 commit 6e88bd1

File tree

6 files changed

+166
-25
lines changed

6 files changed

+166
-25
lines changed

platformio.ini

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
[platformio]
55
src_dir = ./wled00
66
data_dir = ./wled00/data
7-
lib_extra_dirs = ./wled00/src
7+
;lib_extra_dirs = ./wled00/src
8+
lib_dir = ./wled00/src
89
; Please uncomment one of the 5 lines below to select your board
910
; env_default = nodemcuv2
1011
; env_default = esp01
@@ -96,6 +97,7 @@ build_flags =
9697
-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
9798
-D ARDUINO_ARCH_ESP32
9899
-D WLED_DISABLE_INFRARED
100+
-D WLED_DISABLE_ANALOG_LEDS
99101

100102
# see: http://docs.platformio.org/en/latest/platforms/espressif8266.html
101103
[env:nodemcuv2]
@@ -122,6 +124,22 @@ build_flags =
122124
lib_deps =
123125
${common.lib_deps_external}
124126

127+
[env:esp8285]
128+
board = esp8285
129+
platform = ${common:esp8266.platform}
130+
monitor_speed = ${common.monitor_speed}
131+
upload_speed = ${common.upload_speed}
132+
framework = ${common.framework}
133+
build_flags =
134+
${common.build_flags}
135+
${common:esp8266.build_flags}
136+
-D WLED_DISABLE_BLYNK
137+
-D WLED_DISABLE_CRONIXIE
138+
-D WLED_DISABLE_HUESYNC
139+
-D WLED_DEBUG
140+
lib_deps =
141+
${common.lib_deps_external}
142+
125143
[env:esp01_1m]
126144
board = esp01_1m
127145
platform = ${common:esp8266_1M.platform}

wled00/NpbWrapper.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#define LEDPIN 2 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos)
77
//#define USE_APA102 // Uncomment for using APA102 LEDs.
88
#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended)
9-
#define IR_PIN 4 //infrared pin (-1 to disable)
10-
#define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,...
9+
#define IR_PIN 3 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 3
10+
#define RLYPIN -1 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,...
1111
#define AUXPIN -1 //debug auxiliary output pin (-1 to disable)
1212

1313
#define RLYMDE 1 //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on
@@ -21,11 +21,18 @@
2121
#endif
2222

2323
#ifndef WLED_DISABLE_ANALOG_LEDS
24-
//PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller
24+
/*PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller
2525
#define RPIN 5 //R pin for analog LED strip
2626
#define GPIN 12 //G pin for analog LED strip
2727
#define BPIN 13 //B pin for analog LED strip
2828
#define WPIN 15 //W pin for analog LED strip
29+
*/
30+
//PWM pins - PINs 15,13,12,14 are used with H801 Wifi LED Controller
31+
#define RPIN 15 //R pin for analog LED strip
32+
#define GPIN 13 //G pin for analog LED strip
33+
#define BPIN 12 //B pin for analog LED strip
34+
#define WPIN 14 //W pin for analog LED
35+
//
2936
#endif
3037

3138
//automatically uses the right driver method for each platform

wled00/ir_codes.h

Lines changed: 63 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,48 @@
3030
#define IR24_FADE 0xF7C837
3131
#define IR24_SMOOTH 0xF7E817
3232

33+
// 40-key defs for blue remote control
34+
#define IR44_BPLUS 0xFF3AC5 //
35+
#define IR44_BMINUS 0xFFBA45 //
36+
#define IR44_OFF 0xFF827D //
37+
#define IR44_ON 0xFF02FD //
38+
#define IR44_RED 0xFF1AE5 //
39+
#define IR44_GREEN 0xFF9A65 //
40+
#define IR44_BLUE 0xFFA25D //
41+
#define IR44_WHITE 0xFF22DD // natural white
42+
#define IR44_REDDISH 0xFF2AD5 //
43+
#define IR44_GREENISH 0xFFAA55 //
44+
#define IR44_DEEPBLUE 0xFF926D //
45+
#define IR44_WARMWHITE2 0xFF12ED // warmest white
46+
#define IR44_ORANGE 0xFF0AF5 //
47+
#define IR44_TURQUOISE 0xFF8A75 //
48+
#define IR44_PURPLE 0xFFB24D //
49+
#define IR44_WARMWHITE 0xFF32CD // warm white
50+
#define IR44_YELLOWISH 0xFF38C7 //
51+
#define IR44_CYAN 0xFFB847 //
52+
#define IR44_MAGENTA 0xFF7887 //
53+
#define IR44_COLDWHITE 0xFFF807 // cold white
54+
#define IR44_YELLOW 0xFF18E7 //
55+
#define IR44_AQUA 0xFF9867 //
56+
#define IR44_PINK 0xFF58A7 //
57+
#define IR44_COLDWHITE2 0xFFD827 // coldest white
58+
#define IR44_WPLUS 0xFF28D7 // white chanel bright plus
59+
#define IR44_WMINUS 0xFFA857 // white chanel bright minus
60+
#define IR44_WOFF 0xFF6897 // white chanel on
61+
#define IR44_WON 0xFFE817 // white chanel off
62+
#define IR44_W25 0xFF08F7 // white chanel 25%
63+
#define IR44_W50 0xFF8877 // white chanel 50%
64+
#define IR44_W75 0xFF48B7 // white chanel 75%
65+
#define IR44_W100 0xFFC837 // white chanel 100%
66+
#define IR44_JUMP3 0xFF30CF // JUMP3
67+
#define IR44_FADE3 0xFFB04F // FADE3
68+
#define IR44_JUMP7 0xFF708F // JUMP7
69+
#define IR44_QUICK 0xFFF00F // QUICK
70+
#define IR44_FADE7 0xFF10EF // FADE7
71+
#define IR44_FLASH 0xFF906F // FLASH
72+
#define IR44_AUTO 0xFF50AF // AUTO
73+
#define IR44_SLOW 0xFFD02F // SLOW
74+
3375
/* 44-key defs, to be done later
3476
#define IR44_BPlus 0xFF3AC5 //
3577
#define IR44_BMinus 0xFFBA45 //
@@ -77,19 +119,24 @@
77119
#define IR44_FADE7 0xFFE01F //
78120
*/
79121

80-
#define COLOR_RED 0xFF0000
81-
#define COLOR_REDDISH 0xFF7800
82-
#define COLOR_ORANGE 0xFFA000
83-
#define COLOR_YELLOWISH 0xFFC800
84-
#define COLOR_YELLOW 0xFFFF00
85-
#define COLOR_GREEN 0x00FF00
86-
#define COLOR_GREENISH 0x00FF78
87-
#define COLOR_TURQUOISE 0x00FFA0
88-
#define COLOR_CYAN 0x00FFDC
89-
#define COLOR_AQUA 0x00C8FF
90-
#define COLOR_BLUE 0x00A0FF
91-
#define COLOR_DEEPBLUE 0x0000FF
92-
#define COLOR_PURPLE 0xAA00FF
93-
#define COLOR_MAGENTA 0xFF00DC
94-
#define COLOR_PINK 0xFF00A0
95-
#define COLOR_WHITE 0xFFFFDC
122+
#define COLOR_RED 0xFF0000
123+
#define COLOR_REDDISH 0xFF7800
124+
#define COLOR_ORANGE 0xFFA000
125+
#define COLOR_YELLOWISH 0xFFC800
126+
#define COLOR_YELLOW 0xFFFF00
127+
#define COLOR_GREEN 0x00FF00
128+
#define COLOR_GREENISH 0x00FF78
129+
#define COLOR_TURQUOISE 0x00FFA0
130+
#define COLOR_CYAN 0x00FFDC
131+
#define COLOR_AQUA 0x00C8FF
132+
#define COLOR_BLUE 0x00A0FF
133+
#define COLOR_DEEPBLUE 0x0000FF
134+
#define COLOR_PURPLE 0xAA00FF
135+
#define COLOR_MAGENTA 0xFF00DC
136+
#define COLOR_PINK 0xFF00A0
137+
#define COLOR_WHITE 0xFFFFDC
138+
#define COLOR_WARMWHITE2 0xFFFF9900
139+
#define COLOR_WARMWHITE 0xFF825A00
140+
#define COLOR_NEUTRALWHITE 0xFF000000
141+
#define COLOR_COLDWHITE 0xFF7F7F7F
142+
#define COLOR_COLDWHITE2 0xFFFFFFFF

wled00/wled00.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ bool useHSBDefault = useHSB;
172172

173173
//Sync CONFIG
174174
bool buttonEnabled = true;
175-
bool irEnabled = false; //Infrared receiver
175+
bool irEnabled = true; //Infrared receiver
176176

177177
uint16_t udpPort = 21324; //WLED notifier default port
178178
uint16_t udpRgbPort = 19446; //Hyperion port
@@ -301,6 +301,8 @@ byte briOld = 0;
301301
byte briT = 0;
302302
byte briIT = 0;
303303
byte briLast = 127; //brightness before turned off. Used for toggle function
304+
byte white = 0;
305+
byte whiteLast = 0; //white level before turned off. Used for toggle function
304306

305307
//button
306308
bool buttonPressedBefore = false;

wled00/wled14_colors.ino

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ void colorFromUint32(uint32_t in)
1010
col[2] = in & 0xFF;
1111
}
1212

13+
void colorFromUint24(uint32_t in)
14+
{
15+
col[0] = in >> 16 & 0xFF;
16+
col[1] = in >> 8 & 0xFF;
17+
col[2] = in & 0xFF;
18+
}
19+
20+
//relatively change white brightness, minumum A=5
21+
void relativeChangeWhite(int8_t amount, byte lowerBoundary =0)
22+
{
23+
int16_t new_val = (int16_t) col[3] + amount;
24+
if (new_val > 0xFF) new_val = 0xFF;
25+
else if (new_val < lowerBoundary) new_val = lowerBoundary;
26+
col[3] = new_val;
27+
}
28+
1329
void colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb
1430
{
1531
float h = ((float)hue)/65535.0;

wled00/wled20_ir.ino

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,23 @@ void decodeIR(uint32_t code)
4848
if (code == 0xFFFFFFFF) //repeated code, continue brightness up/down
4949
{
5050
irTimesRepeated++;
51-
if (lastValidCode == IR24_BRIGHTER)
51+
if (lastValidCode == IR24_BRIGHTER | lastValidCode == IR44_BPLUS )
5252
{
5353
relativeChange(&bri, 10); colorUpdated(2);
5454
}
55-
else if (lastValidCode == IR24_DARKER)
55+
else if (lastValidCode == IR24_DARKER | lastValidCode == IR44_BMINUS )
5656
{
5757
relativeChange(&bri, -10, 5); colorUpdated(2);
5858
}
59-
else if (lastValidCode == IR24_ON && irTimesRepeated > 7)
59+
if (lastValidCode == IR44_WPLUS)
60+
{
61+
relativeChangeWhite(10); colorUpdated(2);
62+
}
63+
else if (lastValidCode == IR44_WMINUS)
64+
{
65+
relativeChangeWhite(-10, 5); colorUpdated(2);
66+
}
67+
else if ((lastValidCode == IR24_ON | lastValidCode == IR44_ON) && irTimesRepeated > 7 )
6068
{
6169
nightlightActive = true;
6270
nightlightStartTime = millis();
@@ -110,7 +118,50 @@ void decodeIR24(uint32_t code)
110118

111119
void decodeIR44(uint32_t code)
112120
{
113-
//not implemented for now
121+
switch (code) {
122+
case IR44_BPLUS : relativeChange(&bri, 10); break;
123+
case IR44_BMINUS : relativeChange(&bri, -10, 5); break;
124+
case IR44_OFF : briLast = bri; bri = 0; break;
125+
case IR44_ON : bri = briLast; break;
126+
case IR44_RED : colorFromUint24(COLOR_RED); break;
127+
case IR44_REDDISH : colorFromUint24(COLOR_REDDISH); break;
128+
case IR44_ORANGE : colorFromUint24(COLOR_ORANGE); break;
129+
case IR44_YELLOWISH : colorFromUint24(COLOR_YELLOWISH); break;
130+
case IR44_YELLOW : colorFromUint24(COLOR_YELLOW); break;
131+
case IR44_GREEN : colorFromUint24(COLOR_GREEN); break;
132+
case IR44_GREENISH : colorFromUint24(COLOR_GREENISH); break;
133+
case IR44_TURQUOISE : colorFromUint24(COLOR_TURQUOISE); break;
134+
case IR44_CYAN : colorFromUint24(COLOR_CYAN); break;
135+
case IR44_AQUA : colorFromUint24(COLOR_AQUA); break;
136+
case IR44_BLUE : colorFromUint24(COLOR_BLUE); break;
137+
case IR44_DEEPBLUE : colorFromUint24(COLOR_DEEPBLUE); break;
138+
case IR44_PURPLE : colorFromUint24(COLOR_PURPLE); break;
139+
case IR44_MAGENTA : colorFromUint24(COLOR_MAGENTA); break;
140+
case IR44_PINK : colorFromUint24(COLOR_PINK); break;
141+
case IR44_WARMWHITE2 : colorFromUint32(COLOR_WARMWHITE2); effectCurrent = 0; break;
142+
case IR44_WARMWHITE : colorFromUint32(COLOR_WARMWHITE); effectCurrent = 0; break;
143+
case IR44_WHITE : colorFromUint32(COLOR_NEUTRALWHITE); effectCurrent = 0; break;
144+
case IR44_COLDWHITE : colorFromUint32(COLOR_COLDWHITE); effectCurrent = 0; break;
145+
case IR44_COLDWHITE2 : colorFromUint32(COLOR_COLDWHITE2); effectCurrent = 0; break;
146+
case IR44_WPLUS : relativeChangeWhite(10); break;
147+
case IR44_WMINUS : relativeChangeWhite(-10, 5); break;
148+
case IR44_WOFF : whiteLast = col[3]; col[3] = 0; break;
149+
case IR44_WON : col[3] = whiteLast; break;
150+
case IR44_W25 : bri = 63; break;
151+
case IR44_W50 : bri = 127; break;
152+
case IR44_W75 : bri = 191; break;
153+
case IR44_W100 : bri = 255; break;
154+
case IR44_QUICK : relativeChange(&effectSpeed, 10); break;
155+
case IR44_SLOW : relativeChange(&effectSpeed, -10, 5); break;
156+
case IR44_JUMP7 : relativeChange(&effectIntensity, 10); break;
157+
case IR44_AUTO : relativeChange(&effectIntensity, -10, 5); break;
158+
case IR44_JUMP3 : if (!applyPreset(1)) effectCurrent = FX_MODE_STATIC; break;
159+
case IR44_FADE3 : if (!applyPreset(2)) effectCurrent = FX_MODE_BREATH; break;
160+
case IR44_FADE7 : if (!applyPreset(3)) effectCurrent = FX_MODE_FIRE_FLICKER; break;
161+
case IR44_FLASH : if (!applyPreset(4)) effectCurrent = FX_MODE_RAINBOW; break;
162+
}
163+
lastValidCode = code;
164+
colorUpdated(2); //for notifier, IR is considered a button input
114165
}
115166

116167

0 commit comments

Comments
 (0)