From 373d12be64cf8fb51f14c7f2ba45ec097218431e Mon Sep 17 00:00:00 2001 From: cschwinne Date: Thu, 29 Oct 2020 01:23:04 +0100 Subject: [PATCH] Realtime max. brightness now honors brightness factor (fixes #1271) - Colorful effect now supports palettes - Added C9 2 palette (#1291) - Improved C9 palette brightness by 12% - Disable onboard LED if LEDs are off (PR #1245) - Added optional status LED (PR #1264) - Realtime max. brightness now honors brightness factor (fixes #1271) - Updated ArduinoJSON to 6.17.0 --- CHANGELOG.md | 10 ++++++++++ wled00/FX.cpp | 44 +++++++++++++++++++------------------------- wled00/FX.h | 2 +- wled00/fcn_declare.h | 1 + wled00/led.cpp | 15 +++++++++++---- wled00/palettes.h | 31 ++++++++++++++++++++++--------- wled00/udp.cpp | 2 +- wled00/wled.h | 2 +- 8 files changed, 66 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9acec9914..464e92881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ ### Development versions after the 0.10.2 release +#### Build 2010290 + +- Colorful effect now supports palettes +- Added C9 2 palette (#1291) +- Improved C9 palette brightness by 12% +- Disable onboard LED if LEDs are off (PR #1245) +- Added optional status LED (PR #1264) +- Realtime max. brightness now honors brightness factor (fixes #1271) +- Updated ArduinoJSON to 6.17.0 + #### Build 2010020 - Fixed interaction of `T` and `NL` HTTP API commands (#1214) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index b38884888..ae59d8019 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -802,46 +802,40 @@ uint16_t WS2812FX::mode_chase_rainbow_white(void) { * Red - Amber - Green - Blue lights running */ uint16_t WS2812FX::mode_colorful(void) { - uint32_t cols[]{0x00FF0000,0x00EEBB00,0x0000EE00,0x000077CC,0x00FF0000,0x00EEBB00,0x0000EE00}; - if (SEGMENT.intensity < 127) //pastel (easter) colors + uint8_t numColors = 4; //3, 4, or 5 + uint32_t cols[9]{0x00FF0000,0x00EEBB00,0x0000EE00,0x000077CC}; + if (SEGMENT.intensity > 160 || SEGMENT.palette) { //palette or color + if (!SEGMENT.palette) { + numColors = 3; + for (uint8_t i = 0; i < 3; i++) cols[i] = SEGCOLOR(i); + } else { + uint16_t fac = 80; + if (SEGMENT.palette == 52) {numColors = 5; fac = 61;} //C9 2 has 5 colors + for (uint8_t i = 0; i < numColors; i++) { + cols[i] = color_from_palette(i*fac, false, true, 255); + } + } + } else if (SEGMENT.intensity < 80) //pastel (easter) colors { cols[0] = 0x00FF8040; cols[1] = 0x00E5D241; cols[2] = 0x0077FF77; cols[3] = 0x0077F0F0; - for (uint8_t i = 4; i < 7; i++) cols[i] = cols[i-4]; } + for (uint8_t i = numColors; i < numColors*2 -1; i++) cols[i] = cols[i-numColors]; - uint32_t cycleTime = 50 + (15 * (uint32_t)(255 - SEGMENT.speed)); + uint32_t cycleTime = 50 + (8 * (uint32_t)(255 - SEGMENT.speed)); uint32_t it = now / cycleTime; if (it != SEGENV.step) { if (SEGMENT.speed > 0) SEGENV.aux0++; - if (SEGENV.aux0 > 3) SEGENV.aux0 = 0; + if (SEGENV.aux0 >= numColors) SEGENV.aux0 = 0; SEGENV.step = it; } - uint16_t i = 0; - for (i; i < SEGLEN -3; i+=4) + for (uint16_t i = 0; i < SEGLEN; i+= numColors) { - setPixelColor(i, cols[SEGENV.aux0]); - setPixelColor(i+1, cols[SEGENV.aux0+1]); - setPixelColor(i+2, cols[SEGENV.aux0+2]); - setPixelColor(i+3, cols[SEGENV.aux0+3]); - } - if(i < SEGLEN) - { - setPixelColor(i, cols[SEGENV.aux0]); - - if(i+1 < SEGLEN) - { - setPixelColor(i+1, cols[SEGENV.aux0+1]); - - if(i+2 < SEGLEN) - { - setPixelColor(i+2, cols[SEGENV.aux0+2]); - } - } + for (uint16_t j = 0; j < numColors; j++) setPixelColor(i + j, cols[SEGENV.aux0 + j]); } return FRAMETIME; diff --git a/wled00/FX.h b/wled00/FX.h index 622bda227..e88445510 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -729,7 +729,7 @@ const char JSON_palette_names[] PROGMEM = R"=====([ "Pastel","Sunset 2","Beech","Vintage","Departure","Landscape","Beach","Sherbet","Hult","Hult 64", "Drywet","Jul","Grintage","Rewhi","Tertiary","Fire","Icefire","Cyane","Light Pink","Autumn", "Magenta","Magred","Yelmag","Yelblu","Orange & Teal","Tiamat","April Night","Orangery","C9","Sakura", -"Aurora","Atlantica" +"Aurora","Atlantica","C9 2" ])====="; #endif diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index 4c22152be..bd0f78d92 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -102,6 +102,7 @@ void colorUpdated(int callMode); void updateInterfaces(uint8_t callMode); void handleTransitions(); void handleNightlight(); +byte scaledBri(byte in); //lx_parser.cpp bool parseLx(int lxValue, byte* rgbw); diff --git a/wled00/led.cpp b/wled00/led.cpp index 395cd8493..8dfcea28e 100644 --- a/wled00/led.cpp +++ b/wled00/led.cpp @@ -34,13 +34,20 @@ void toggleOnOff() } +//scales the brightness with the briMultiplier factor +byte scaledBri(byte in) +{ + uint32_t d = in*briMultiplier; + uint32_t val = d/100; + if (val > 255) val = 255; + return (byte)val; +} + + void setAllLeds() { if (!realtimeMode || !arlsForceMaxBri) { - double d = briT*briMultiplier; - int val = d/100; - if (val > 255) val = 255; - strip.setBrightness(val); + strip.setBrightness(scaledBri(briT)); } if (useRGBW && strip.rgbwMode == RGBW_MODE_LEGACY) { diff --git a/wled00/palettes.h b/wled00/palettes.h index 1b95e64b2..4fca9525b 100644 --- a/wled00/palettes.h +++ b/wled00/palettes.h @@ -13,7 +13,7 @@ #ifndef PalettesWLED_h #define PalettesWLED_h -#define GRADIENT_PALETTE_COUNT 39 +#define GRADIENT_PALETTE_COUNT 40 const byte ib_jul01_gp[] PROGMEM = { 0, 194, 1, 1, @@ -551,14 +551,14 @@ const byte Orangery_gp[] PROGMEM = { //inspired by Mark Kriegsman https://gist.github.com/kriegsman/756ea6dcae8e30845b5a const byte C9_gp[] PROGMEM = { - 0, 184, 4, 0, //red - 60, 184, 4, 0, - 65, 144, 44, 2, //amber - 125, 144, 44, 2, - 130, 4, 96, 2, //green - 190, 4, 96, 2, - 195, 7, 7, 88, //blue - 255, 7, 7, 88}; + 0, 255, 5, 0, //red + 60, 255, 5, 0, + 60, 196, 57, 2, //amber (start 61?) + 120, 196, 57, 2, + 120, 6, 126, 2, //green (start 126?) + 180, 6, 126, 2, + 180, 4, 30, 114, //blue (start 191?) + 255, 4, 30, 114}; const byte Sakura_gp[] PROGMEM = { 0, 196, 19, 10, @@ -582,6 +582,18 @@ const byte Atlantica_gp[] PROGMEM = { 150, 12, 95, 82, //#0C5F52 200, 25,190, 95, //#19BE5F 255, 40,170, 80};//#28AA50 + + const byte C9_2_gp[] PROGMEM = { + 0, 6, 126, 2, //green + 45, 6, 126, 2, + 45, 4, 30, 114, //blue + 90, 4, 30, 114, + 90, 255, 5, 0, //red + 135, 255, 5, 0, + 135, 196, 57, 2, //amber + 180, 196, 57, 2, + 180, 137, 85, 2, //yellow + 255, 137, 85, 2}; // Single array of defined cpt-city color palettes. @@ -628,6 +640,7 @@ const byte* const gGradientPalettes[] PROGMEM = { Sakura_gp, //49-36 Sakura Aurora_gp, //50-37 Aurora Atlantica_gp, //51-38 Atlantica + C9_2_gp //52-39 C9 2 }; #endif diff --git a/wled00/udp.cpp b/wled00/udp.cpp index f0f7df9fa..7c9a1839d 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -85,7 +85,7 @@ void realtimeLock(uint32_t timeoutMs, byte md) if (timeoutMs == 255001 || timeoutMs == 65000) realtimeTimeout = UINT32_MAX; realtimeMode = md; - if (arlsForceMaxBri && !realtimeOverride) strip.setBrightness(255); + if (arlsForceMaxBri && !realtimeOverride) strip.setBrightness(scaledBri(255)); } diff --git a/wled00/wled.h b/wled00/wled.h index c6f80731f..4df774037 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2010020 +#define VERSION 2010280 // ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.4.2 and the setting 512K(No SPIFFS).