Merge pull request #13 from Aircoookie/master

Update
This commit is contained in:
srg74 2020-01-19 11:59:13 -05:00 committed by GitHub
commit d7879d8853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 90 additions and 13 deletions

View File

@ -30,15 +30,10 @@ build_flags =
#build_flags for the IRremoteESP8266 library (enabled decoders have to appear here) #build_flags for the IRremoteESP8266 library (enabled decoders have to appear here)
-D _IR_ENABLE_DEFAULT_=false -D _IR_ENABLE_DEFAULT_=false
-D DECODE_HASH=true -D DECODE_HASH=true
-D DECODE_NEC=true
-D DECODE_SONY=true -D DECODE_SONY=true
-D DECODE_PANASONIC=true
-D DECODE_JVC=true
-D DECODE_SAMSUNG=true -D DECODE_SAMSUNG=true
-D DECODE_LG=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. # 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 # If they are not changed it's just a matter of setting the correct version and change the import statement
lib_deps_external = lib_deps_external =
@ -52,8 +47,7 @@ lib_deps_external =
Esp Async WebServer@1.2.0 Esp Async WebServer@1.2.0
#ArduinoJson@5.13.5 #ArduinoJson@5.13.5
#IRremoteESP8266@2.7.2 #IRremoteESP8266@2.7.2
#For saving 20k program space the brnach "compile_flags" will be used: https://github.com/crankyoldgit/IRremoteESP8266.git
https://github.com/crankyoldgit/IRremoteESP8266.git#compile_flags
#Time@1.5 #Time@1.5
#Timezone@1.2.1 #Timezone@1.2.1
#For use SSD1306 0.91" OLED display uncomment following #For use SSD1306 0.91" OLED display uncomment following

View File

@ -2976,3 +2976,31 @@ uint16_t WS2812FX::mode_plasma(void) {
return FRAMETIME; 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;
}

View File

@ -91,7 +91,7 @@
#define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE ) #define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE )
#define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED ) #define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED )
#define MODE_COUNT 98 #define MODE_COUNT 99
#define FX_MODE_STATIC 0 #define FX_MODE_STATIC 0
#define FX_MODE_BLINK 1 #define FX_MODE_BLINK 1
@ -191,7 +191,7 @@
#define FX_MODE_POPCORN 95 #define FX_MODE_POPCORN 95
#define FX_MODE_DRIP 96 #define FX_MODE_DRIP 96
#define FX_MODE_PLASMA 97 #define FX_MODE_PLASMA 97
#define FX_MODE_PERCENT 98
class WS2812FX { class WS2812FX {
typedef uint16_t (WS2812FX::*mode_ptr)(void); typedef uint16_t (WS2812FX::*mode_ptr)(void);
@ -378,6 +378,7 @@ class WS2812FX {
_mode[FX_MODE_POPCORN] = &WS2812FX::mode_popcorn; _mode[FX_MODE_POPCORN] = &WS2812FX::mode_popcorn;
_mode[FX_MODE_DRIP] = &WS2812FX::mode_drip; _mode[FX_MODE_DRIP] = &WS2812FX::mode_drip;
_mode[FX_MODE_PLASMA] = &WS2812FX::mode_plasma; _mode[FX_MODE_PLASMA] = &WS2812FX::mode_plasma;
_mode[FX_MODE_PERCENT] = &WS2812FX::mode_percent;
_brightness = DEFAULT_BRIGHTNESS; _brightness = DEFAULT_BRIGHTNESS;
currentPalette = CRGBPalette16(CRGB::Black); currentPalette = CRGBPalette16(CRGB::Black);
@ -560,7 +561,8 @@ class WS2812FX {
mode_sinelon_rainbow(void), mode_sinelon_rainbow(void),
mode_popcorn(void), mode_popcorn(void),
mode_drip(void), mode_drip(void),
mode_plasma(void); mode_plasma(void),
mode_percent(void);
private: 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", "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", "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", "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"
])====="; ])=====";

View File

@ -189,7 +189,7 @@ const char PAGE_settings_sync[] PROGMEM = R"=====(<!DOCTYPE html>
<h2>Sync setup</h2> <h2>Sync setup</h2>
<h3>Button setup</h3> <h3>Button setup</h3>
On/Off button enabled: <input type="checkbox" name="BT"><br> On/Off button enabled: <input type="checkbox" name="BT"><br>
Infrared receiver type (0 = disabled): <input name="IR" type="number" min="0" max="4" required><br> Infrared receiver type (0 = disabled): <input name="IR" type="number" min="0" max="5" required><br>
<a href="https://github.com/Aircoookie/WLED/wiki/Infrared-Control" target="_blank">IR info</a> <a href="https://github.com/Aircoookie/WLED/wiki/Infrared-Control" target="_blank">IR info</a>
<h3>WLED Broadcast</h3> <h3>WLED Broadcast</h3>
UDP Port: <input name="UP" type="number" min="1" max="65535" required><br> UDP Port: <input name="UP" type="number" min="1" max="65535" required><br>

View File

@ -170,6 +170,29 @@
#define IR44_FADE3 0xFF609F // #define IR44_FADE3 0xFF609F //
#define IR44_FADE7 0xFFE01F // #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_RED 0xFF0000
#define COLOR_REDDISH 0xFF7800 #define COLOR_REDDISH 0xFF7800
#define COLOR_ORANGE 0xFFA000 #define COLOR_ORANGE 0xFFA000

View File

@ -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 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 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 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; default: return;
} }
} }
@ -315,6 +316,35 @@ void decodeIR44(uint32_t code)
colorUpdated(2); //for notifier, IR is considered a button input 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() void initIR()
{ {