From 47be430bc171fbdfda172cc56f5ada6dcd6bf7b5 Mon Sep 17 00:00:00 2001 From: Max Hedge Date: Sat, 25 Jan 2020 16:35:18 +0000 Subject: [PATCH 1/8] Add IR codes for 6-key learning remote https://www.aliexpress.com/item/4000307837886.html This cheap remote has the advantage of being more powerful (longer range) than cheap credit-card remotes "CH" controls brightness, "VOL +" controls effect, "VOL -" controls colour/palette, "MUTE" sets bright plain white. --- wled00/html_settings.h | 2 +- wled00/ir_codes.h | 10 +++++++++ wled00/wled20_ir.ino | 48 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/wled00/html_settings.h b/wled00/html_settings.h index d6cf7490d..c54bf5ffd 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -189,7 +189,7 @@ const char PAGE_settings_sync[] PROGMEM = R"=====(

Sync setup

Button setup

On/Off button enabled:
-Infrared receiver type (0 = disabled):
+Infrared receiver type (0 = disabled):
IR info

WLED Broadcast

UDP Port:
diff --git a/wled00/ir_codes.h b/wled00/ir_codes.h index 8c42126c7..a3988e6d6 100644 --- a/wled00/ir_codes.h +++ b/wled00/ir_codes.h @@ -4,6 +4,16 @@ #define IRCUSTOM_ONOFF 0xA55AEA15 //Pioneer RC-975R "+FAV" button (example) #define IRCUSTOM_MACRO1 0xFFFFFFFF //placeholder, will never be checked for +// Default IR codes for 6-key learning remote https://www.aliexpress.com/item/4000307837886.html +// This cheap remote has the advantage of being more powerful (longer range) than cheap credit-card remotes +#define IR6_POWER 0xFF0FF0 +#define IR6_CHANNEL_UP 0xFF8F70 +#define IR6_CHANNEL_DOWN 0xFF4FB0 +#define IR6_VOLUME_UP 0xFFCF30 +#define IR6_VOLUME_DOWN 0xFF2FD0 +#define IR6_MUTE 0xFFAF50 + + //Infrared codes for 24-key remote from http://woodsgood.ca/projects/2015/02/13/rgb-led-strip-controllers-ir-codes/ #define IR24_BRIGHTER 0xF700FF #define IR24_DARKER 0xF7807F diff --git a/wled00/wled20_ir.ino b/wled00/wled20_ir.ino index 00f13ffc6..4b2411b6d 100644 --- a/wled00/wled20_ir.ino +++ b/wled00/wled20_ir.ino @@ -14,6 +14,7 @@ decode_results results; unsigned long irCheckedTime = 0; uint32_t lastValidCode = 0; uint16_t irTimesRepeated = 0; +uint8_t lastIR6ColourIdx = 0; //Add what your custom IR codes should trigger here. Guide: https://github.com/Aircoookie/WLED/wiki/Infrared-Control @@ -84,6 +85,9 @@ void decodeIR(uint32_t code) case 3: decodeIR40(code); break; // blue 40-key remote with 25%, 50%, 75% and 100% keys case 4: decodeIR44(code); break; // white 44-key remote with color-up/down keys and DIY1 to 6 keys case 5: decodeIR21(code); break; // white 21-key remote + case 6: decodeIR6(code); break; // black 6-key learning remote defaults: "CH" controls brightness, + // "VOL +" controls effect, "VOL -" controls colour/palette, "MUTE" + // sets bright plain white default: return; } } @@ -346,6 +350,50 @@ void decodeIR21(uint32_t code) colorUpdated(2); //for notifier, IR is considered a button input } +void decodeIR6(uint32_t code) +{ + + switch (code) { + case IR6_POWER: toggleOnOff(); break; + case IR6_CHANNEL_UP: relativeChange(&bri, 10); break; + case IR6_CHANNEL_DOWN: relativeChange(&bri, -10, 5); break; + case IR6_VOLUME_UP: /* next effect */ relativeChange(&effectCurrent, 1); break; + case IR6_VOLUME_DOWN: + /* next palette */ + + relativeChange(&effectPalette, 1); + + switch(lastIR6ColourIdx) + { + case 0: colorFromUint32(COLOR_RED); break; + case 1: colorFromUint32(COLOR_REDDISH); break; + case 2:colorFromUint32(COLOR_ORANGE); break; + case 3:colorFromUint32(COLOR_YELLOWISH); break; + case 4:colorFromUint32(COLOR_GREEN); break; + case 5:colorFromUint32(COLOR_GREENISH); break; + case 6:colorFromUint32(COLOR_TURQUOISE); break; + case 7: colorFromUint32(COLOR_CYAN); break; + case 8:colorFromUint32(COLOR_BLUE); break; + case 9:colorFromUint32(COLOR_DEEPBLUE); break; + case 10:colorFromUint32(COLOR_PURPLE); break; + case 11:colorFromUint32(COLOR_PINK); break; + case 12:colorFromUint32(COLOR_WHITE); break; + break; + default:break; + + } + + lastIR6ColourIdx++; + if(lastIR6ColourIdx > 12) lastIR6ColourIdx = 0; + + break; + case IR6_MUTE: effectCurrent = 0; effectPalette = 0; colorFromUint32(COLOR_WHITE); bri=255; break; + } + lastValidCode = code; + colorUpdated(2); //for notifier, IR is considered a button input +} + + void initIR() { if (irEnabled > 0) From 2f8365a790d50dda8cad46ced58fbe29556ac628 Mon Sep 17 00:00:00 2001 From: Max Hedge Date: Sat, 25 Jan 2020 16:53:37 +0000 Subject: [PATCH 2/8] Fix consecutive break statement. --- wled00/wled20_ir.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/wled00/wled20_ir.ino b/wled00/wled20_ir.ino index 4b2411b6d..113b19b53 100644 --- a/wled00/wled20_ir.ino +++ b/wled00/wled20_ir.ino @@ -378,7 +378,6 @@ void decodeIR6(uint32_t code) case 10:colorFromUint32(COLOR_PURPLE); break; case 11:colorFromUint32(COLOR_PINK); break; case 12:colorFromUint32(COLOR_WHITE); break; - break; default:break; } From dc936b63d6f6fb92df71d8e3b1ab7b214506f9bf Mon Sep 17 00:00:00 2001 From: cschwinne Date: Mon, 27 Jan 2020 00:45:30 +0100 Subject: [PATCH 3/8] Various fixes --- wled00/FX_fcn.cpp | 15 ++++++++++++++- wled00/NpbWrapper.h | 2 +- wled00/wled00.ino | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 22625c29a..7c87a2920 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -469,7 +469,19 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping, if (seg.stop) setRange(seg.start, seg.stop -1, 0); //turn old segment range off if (i2 <= i1) //disable segment { - seg.stop = 0; return; + seg.stop = 0; + if (n == mainSegment) //if main segment is deleted, set first active as main segment + { + for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) + { + if (_segments[i].isActive()) { + mainSegment = i; + return; + } + } + mainSegment = 0; //should not happen (always at least one active segment) + } + return; } if (i1 < _length) seg.start = i1; seg.stop = i2; @@ -482,6 +494,7 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping, } void WS2812FX::resetSegments() { + mainSegment = 0; memset(_segments, 0, sizeof(_segments)); //memset(_segment_runtimes, 0, sizeof(_segment_runtimes)); _segment_index = 0; diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index 7648350cb..43eac8321 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -9,7 +9,7 @@ //#define USE_LPD8806 // Uncomment for using LPD8806 //#define WLED_USE_ANALOG_LEDS //Uncomment for using "dumb" PWM controlled LEDs (see pins below, default R: gpio5, G: 12, B: 15, W: 13) //#define WLED_USE_H801 //H801 controller. Please uncomment #define WLED_USE_ANALOG_LEDS as well -//#define WLED_USE_5CH //5 Channel H801 for cold and warm white +//#define WLED_USE_5CH_LEDS //5 Channel H801 for cold and warm white #define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended) #define IR_PIN 4 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 850dcda43..75ef1d7f2 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -535,6 +535,7 @@ void loop() { if (!offMode) strip.service(); } yield(); + MDNS.update(); if (millis() - lastMqttReconnectAttempt > 30000) initMqtt(); //DEBUG serial logging From c5f5532303a7fe6d218f1f574eca882420d0bb44 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Tue, 28 Jan 2020 00:03:29 +0100 Subject: [PATCH 4/8] Bump version ID --- wled00/wled00.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 75ef1d7f2..1ca349126 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -90,7 +90,7 @@ #endif //version code in format yymmddb (b = daily build) -#define VERSION 2001191 +#define VERSION 2001262 char versionString[] = "0.9.0-b2"; From b41dacb6c080c0731a802bb23426b3d1601b43d4 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Tue, 28 Jan 2020 00:45:29 +0100 Subject: [PATCH 5/8] FIx ESP32 compilation --- wled00/wled00.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 1ca349126..f2f941451 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -90,7 +90,7 @@ #endif //version code in format yymmddb (b = daily build) -#define VERSION 2001262 +#define VERSION 2001281 char versionString[] = "0.9.0-b2"; @@ -535,7 +535,9 @@ void loop() { if (!offMode) strip.service(); } yield(); + #ifdef ESP8266 MDNS.update(); + #endif if (millis() - lastMqttReconnectAttempt > 30000) initMqtt(); //DEBUG serial logging From 2b0a38d25d517734fa7cfa37fb08b2dbcb8afdc9 Mon Sep 17 00:00:00 2001 From: Def3nder <33399267+Def3nder@users.noreply.github.com> Date: Tue, 28 Jan 2020 13:47:18 +0100 Subject: [PATCH 6/8] Percent Effect with speed-slider (#637) --- wled00/FX.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index c3b8ed092..5c24efdb4 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -2985,23 +2985,26 @@ uint16_t WS2812FX::mode_plasma(void) { uint16_t WS2812FX::mode_percent(void) { uint8_t percent = max(0, min(100, SEGMENT.intensity)); - - float active_float = SEGLEN * percent / 100.0; - uint16_t active_leds = active_float; - uint16_t active_part = (active_float - active_leds) * 255; - CRGB color; - - for (uint16_t i = 0; i < SEGLEN; i++) { - if (i < active_leds) { + uint16_t active_leds = SEGLEN * percent / 100.0; + + if (SEGENV.call == 0) SEGENV.step = 0; + uint8_t size = (1 + ((SEGMENT.speed * SEGLEN) >> 11)) & 0xFF ; + + for (uint16_t i = 0; i < SEGLEN; i++) { + if (i < SEGENV.step) { setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0)); } - else if (i == active_leds) { - setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0, active_part)); - } else { setPixelColor(i, SEGCOLOR(1)); } - } + } + if(active_leds > SEGENV.step) { + SEGENV.step += size; + if (SEGENV.step > active_leds) SEGENV.step = active_leds; + } else if (active_leds < SEGENV.step) { + SEGENV.step -= size; + if (SEGENV.step < active_leds) SEGENV.step = active_leds; + } - return FRAMETIME; + return FRAMETIME; } \ No newline at end of file From f3b399b31f0defc21228554d397231c61aab8c84 Mon Sep 17 00:00:00 2001 From: Def3nder <33399267+Def3nder@users.noreply.github.com> Date: Tue, 28 Jan 2020 13:48:59 +0100 Subject: [PATCH 7/8] Fix Police All, Sinelon and Lighthouse (Comet) effects (#634) --- wled00/FX.cpp | 51 +++++++++++++++++++++++++++++++++------------ wled00/NpbWrapper.h | 4 ++-- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 5c24efdb4..96880f4d8 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1025,15 +1025,22 @@ uint16_t WS2812FX::larson_scanner(bool dual) { /* - * Firing comets from one end. + * Firing comets from one end. "Lighthouse" */ uint16_t WS2812FX::mode_comet(void) { - uint16_t counter = now * (SEGMENT.speed >>3) +1; + uint16_t counter = now * ((SEGMENT.speed >>2) +1); uint16_t index = counter * SEGLEN >> 16; + if (SEGENV.call == 0) SEGENV.aux0 = index; fade_out(SEGMENT.intensity); setPixelColor( index, color_from_palette(index, true, PALETTE_SOLID_WRAP, 0)); + if (index > SEGENV.aux0) { + for (uint16_t i = SEGENV.aux0; i < index ; i++) { + setPixelColor( i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0)); + } + } + SEGENV.aux0 = index++; return FRAMETIME; } @@ -1172,19 +1179,26 @@ uint16_t WS2812FX::mode_loading(void) { //American Police Light with all LEDs Red and Blue uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2) { - uint16_t counter = now * ((SEGMENT.speed >> 3) +1); + uint16_t counter = now * ((SEGMENT.speed >> 2) +1); uint16_t idexR = (counter * SEGLEN) >> 16; if (idexR >= SEGLEN) idexR = 0; uint16_t topindex = SEGLEN >> 1; uint16_t idexB = idexR + topindex; - + if (SEGENV.call == 0) SEGENV.aux0 = idexR; + if (idexR > topindex) idexB -= SEGLEN; if (idexB >= SEGLEN) idexB = 0; //otherwise overflow on odd number of LEDs - setPixelColor(idexR, color1); - setPixelColor(idexB, color2); - + uint8_t gap = (SEGENV.aux0 < idexR)? idexR - SEGENV.aux0:SEGLEN - SEGENV.aux0 + idexR; + for (uint8_t i = 0; i < gap ; i++) { + if ((idexR - i) < 0) idexR = SEGLEN-1 + i; + if ((idexB - i) < 0) idexB = SEGLEN-1 + i; + setPixelColor(idexR-i, color1); + setPixelColor(idexB-i, color2); + } + SEGENV.aux0 = idexR; + return FRAMETIME; } @@ -2486,22 +2500,33 @@ uint16_t WS2812FX::mode_bouncing_balls(void) { */ uint16_t WS2812FX::sinelon_base(bool dual, bool rainbow=false) { fade_out(SEGMENT.intensity); - int pos = beatsin16(SEGMENT.speed/10,0,SEGLEN-1); - + uint16_t pos = beatsin16(SEGMENT.speed/10,0,SEGLEN-1); + if (SEGENV.call == 0) SEGENV.aux0 = pos; uint32_t color1 = color_from_palette(pos, true, false, 0); + uint32_t color2 = SEGCOLOR(2); if (rainbow) { color1 = color_wheel((pos & 0x07) * 32); } setPixelColor(pos, color1); - if (dual) { - uint32_t color2 = SEGCOLOR(2); - if (!color2) color2 = color_from_palette(pos, true, false, 0); if (rainbow) color2 = color1; //rainbow - setPixelColor(SEGLEN-1-pos, color2); } + if (SEGENV.aux0 != pos) { + if (SEGENV.aux0 < pos) { + for (uint16_t i = SEGENV.aux0; i < pos ; i++) { + setPixelColor(i, color1); + if (dual) setPixelColor(SEGLEN-1-i, color2); + } + } else { + for (uint16_t i = SEGENV.aux0; i > pos ; i--) { + setPixelColor(i, color1); + if (dual) setPixelColor(SEGLEN-1-i, color2); + } + } + SEGENV.aux0 = pos; + } return FRAMETIME; } diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index c5d556f26..9f3915568 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -34,7 +34,7 @@ #define RPIN 15 //R pin for analog LED strip #define GPIN 13 //G pin for analog LED strip #define BPIN 12 //B pin for analog LED strip - #define WPIN 14 //W pin for analog LED strip (W1: 14, W2: 04) + #define WPIN 14 //W pin for analog LED strip #define W2PIN 04 //W2 pin for analog LED strip #undef BTNPIN #undef IR_PIN @@ -44,7 +44,7 @@ #define RPIN 5 //R pin for analog LED strip #define GPIN 12 //G pin for analog LED strip #define BPIN 15 //B pin for analog LED strip - #define WPIN 13 //W pin for analog LED strip (W1: 14, W2: 04) + #define WPIN 13 //W pin for analog LED strip #endif #undef RLYPIN #define RLYPIN -1 //disable as pin 12 is used by analog LEDs From bbf2f6c7de3b04e0d9091b072759137ce9379576 Mon Sep 17 00:00:00 2001 From: fishbone-git Date: Tue, 28 Jan 2020 20:47:37 +0100 Subject: [PATCH 8/8] non-required HUE settings --- wled00/html_settings.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wled00/html_settings.h b/wled00/html_settings.h index c54bf5ffd..44f9842b8 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -234,13 +234,13 @@ Group Topic:
Reboot required to apply changes. MQTT info

Philips Hue

You can find the bridge IP and the light number in the 'About' section of the hue app.
-Poll Hue light every ms:
+Poll Hue light every ms:
Then, receive On/Off, Brightness, and Color
Hue Bridge IP:
- . - . - . -
+ . + . + . +
Press the pushlink button on the bridge, after that save this page!
(when first connecting)
Hue status: Internal ESP Error!