From 8c69a4cb7a981d7f9cb62df7aeb695dc2972e2a1 Mon Sep 17 00:00:00 2001 From: recliq Date: Sun, 19 Jan 2020 12:53:44 +0100 Subject: [PATCH 1/3] added support for 21-key remote --- wled00/html_settings.h | 2 +- wled00/ir_codes.h | 23 +++++++++++++++++++++++ wled00/wled20_ir.ino | 30 ++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/wled00/html_settings.h b/wled00/html_settings.h index e99c03c5..d6cf7490 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 dda33e7b..8c42126c 100644 --- a/wled00/ir_codes.h +++ b/wled00/ir_codes.h @@ -170,6 +170,29 @@ #define IR44_FADE3 0xFF609F // #define IR44_FADE7 0xFFE01F // +//Infrared codes for 21-key remote https://images-na.ssl-images-amazon.com/images/I/51NMA0XucnL.jpg +#define IR21_BRIGHTER 0xFFE01F +#define IR21_DARKER 0xFFA857 +#define IR21_OFF 0xFF629D +#define IR21_ON 0xFFA25D +#define IR21_RED 0xFF6897 +#define IR21_REDDISH 0xFF30CF +#define IR21_ORANGE 0xFF10EF +#define IR21_YELLOWISH 0xFF42BD +#define IR21_GREEN 0xFF9867 +#define IR21_GREENISH 0xFF18E7 +#define IR21_TURQUOISE 0xFF38C7 +#define IR21_CYAN 0xFF4AB5 +#define IR21_BLUE 0xFFB04F +#define IR21_DEEPBLUE 0xFF7A85 +#define IR21_PURPLE 0xFF5AA5 +#define IR21_PINK 0xFF52AD +#define IR21_WHITE 0xFF906F +#define IR21_FLASH 0xFFE21D +#define IR21_STROBE 0xFF22DD +#define IR21_FADE 0xFF02FD +#define IR21_SMOOTH 0xFFC23D + #define COLOR_RED 0xFF0000 #define COLOR_REDDISH 0xFF7800 #define COLOR_ORANGE 0xFFA000 diff --git a/wled00/wled20_ir.ino b/wled00/wled20_ir.ino index d602e4e1..d645ef2d 100644 --- a/wled00/wled20_ir.ino +++ b/wled00/wled20_ir.ino @@ -83,6 +83,7 @@ void decodeIR(uint32_t code) case 2: decodeIR24CT(code); break; // white 24-key remote with CW, WW, CT+ and CT- keys 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 default: return; } } @@ -315,6 +316,35 @@ void decodeIR44(uint32_t code) colorUpdated(2); //for notifier, IR is considered a button input } +void decodeIR21(uint32_t code) +{ + switch (code) { + case IR21_BRIGHTER: relativeChange(&bri, 10); break; + case IR21_DARKER: relativeChange(&bri, -10, 5); break; + case IR21_OFF: briLast = bri; bri = 0; break; + case IR21_ON: bri = briLast; break; + case IR21_RED: colorFromUint32(COLOR_RED); break; + case IR21_REDDISH: colorFromUint32(COLOR_REDDISH); break; + case IR21_ORANGE: colorFromUint32(COLOR_ORANGE); break; + case IR21_YELLOWISH: colorFromUint32(COLOR_YELLOWISH); break; + case IR21_GREEN: colorFromUint32(COLOR_GREEN); break; + case IR21_GREENISH: colorFromUint32(COLOR_GREENISH); break; + case IR21_TURQUOISE: colorFromUint32(COLOR_TURQUOISE); break; + case IR21_CYAN: colorFromUint32(COLOR_CYAN); break; + case IR21_BLUE: colorFromUint32(COLOR_BLUE); break; + case IR21_DEEPBLUE: colorFromUint32(COLOR_DEEPBLUE); break; + case IR21_PURPLE: colorFromUint32(COLOR_PURPLE); break; + case IR21_PINK: colorFromUint32(COLOR_PINK); break; + case IR21_WHITE: colorFromUint32(COLOR_WHITE); effectCurrent = 0; break; + case IR21_FLASH: if (!applyPreset(1)) effectCurrent = FX_MODE_COLORTWINKLE; break; + case IR21_STROBE: if (!applyPreset(2)) effectCurrent = FX_MODE_RAINBOW_CYCLE; break; + case IR21_FADE: if (!applyPreset(3)) effectCurrent = FX_MODE_BREATH; break; + case IR21_SMOOTH: if (!applyPreset(4)) effectCurrent = FX_MODE_RAINBOW; break; + default: return; + } + lastValidCode = code; + colorUpdated(2); //for notifier, IR is considered a button input +} void initIR() { From e49b9cff6770f791dea844b0290cb3eddb8cba6e Mon Sep 17 00:00:00 2001 From: recliq Date: Sun, 19 Jan 2020 13:51:49 +0100 Subject: [PATCH 2/3] Added percent display effect. --- wled00/FX.cpp | 28 ++++++++++++++++++++++++++++ wled00/FX.h | 10 ++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 14a46b53..0c82f4ab 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -2976,3 +2976,31 @@ uint16_t WS2812FX::mode_plasma(void) { return FRAMETIME; } + +/* + * Percentage display + * Intesity values from 0-100 turn on the leds. + */ +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) { + 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)); + } + } + + return FRAMETIME; +} \ No newline at end of file diff --git a/wled00/FX.h b/wled00/FX.h index 2ed1f2f4..d4bf4ff5 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -91,7 +91,7 @@ #define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE ) #define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED ) -#define MODE_COUNT 98 +#define MODE_COUNT 99 #define FX_MODE_STATIC 0 #define FX_MODE_BLINK 1 @@ -191,7 +191,7 @@ #define FX_MODE_POPCORN 95 #define FX_MODE_DRIP 96 #define FX_MODE_PLASMA 97 - +#define FX_MODE_PERCENT 98 class WS2812FX { typedef uint16_t (WS2812FX::*mode_ptr)(void); @@ -378,6 +378,7 @@ class WS2812FX { _mode[FX_MODE_POPCORN] = &WS2812FX::mode_popcorn; _mode[FX_MODE_DRIP] = &WS2812FX::mode_drip; _mode[FX_MODE_PLASMA] = &WS2812FX::mode_plasma; + _mode[FX_MODE_PERCENT] = &WS2812FX::mode_percent; _brightness = DEFAULT_BRIGHTNESS; currentPalette = CRGBPalette16(CRGB::Black); @@ -560,7 +561,8 @@ class WS2812FX { mode_sinelon_rainbow(void), mode_popcorn(void), mode_drip(void), - mode_plasma(void); + mode_plasma(void), + mode_percent(void); private: @@ -640,7 +642,7 @@ const char JSON_mode_names[] PROGMEM = R"=====([ "Scanner Dual","Stream 2","Oscillate","Pride 2015","Juggle","Palette","Fire 2012","Colorwaves","Bpm","Fill Noise", "Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Meteor Smooth","Railway","Ripple", "Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Solid Pattern Tri","Spots","Spots Fade","Glitter","Candle","Fireworks Starburst", -"Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma" +"Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma","Percent" ])====="; From d9d45f86cb08d8f294069ad1d9e002c2e130cf64 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sun, 19 Jan 2020 15:20:40 +0100 Subject: [PATCH 3/3] Fix PIO --- platformio.ini | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/platformio.ini b/platformio.ini index e584623d..84e75627 100644 --- a/platformio.ini +++ b/platformio.ini @@ -30,15 +30,10 @@ build_flags = #build_flags for the IRremoteESP8266 library (enabled decoders have to appear here) -D _IR_ENABLE_DEFAULT_=false -D DECODE_HASH=true - -D DECODE_NEC=true -D DECODE_SONY=true - -D DECODE_PANASONIC=true - -D DECODE_JVC=true -D DECODE_SAMSUNG=true -D DECODE_LG=true - -D DECODE_SANYO=true - -D DECODE_SHARP=true - -D DECODE_DENON=true + # TODO replace libs in /lib with managed libs in here if possible. # If they are not changed it's just a matter of setting the correct version and change the import statement lib_deps_external = @@ -52,8 +47,7 @@ lib_deps_external = Esp Async WebServer@1.2.0 #ArduinoJson@5.13.5 #IRremoteESP8266@2.7.2 - #For saving 20k program space the brnach "compile_flags" will be used: - https://github.com/crankyoldgit/IRremoteESP8266.git#compile_flags + https://github.com/crankyoldgit/IRremoteESP8266.git #Time@1.5 #Timezone@1.2.1 #For use SSD1306 0.91" OLED display uncomment following