From 9839cc638627a7f99d16082feb625c026dd77e37 Mon Sep 17 00:00:00 2001 From: fishbone-git Date: Sat, 15 Feb 2020 14:42:09 +0100 Subject: [PATCH 01/12] port multi-comet to use the memory allocation method --- wled00/FX.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 479714fe..b9e202a3 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1451,13 +1451,14 @@ uint16_t WS2812FX::mode_tricolor_fade(void) */ uint16_t WS2812FX::mode_multi_comet(void) { - uint32_t cycleTime = 20 + (2 * (uint32_t)(255 - SEGMENT.speed)); + uint32_t cycleTime = 10 + (uint32_t)(255 - SEGMENT.speed); uint32_t it = now / cycleTime; if (SEGENV.step == it) return FRAMETIME; - + if (!SEGENV.allocateData(sizeof(uint16_t) * 8)) return mode_static(); //allocation failed + fade_out(SEGMENT.intensity); - - static uint16_t comets[] = {UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX}; + + uint16_t* comets = reinterpret_cast(SEGENV.data); for(uint8_t i=0; i < 8; i++) { if(comets[i] < SEGLEN) { From ffd958a1b3818cd42937369b3103eaed1ed7b42c Mon Sep 17 00:00:00 2001 From: Aircoookie Date: Sat, 15 Feb 2020 16:18:06 +0100 Subject: [PATCH 02/12] Quick color selectors --- wled00/data/index.htm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/wled00/data/index.htm b/wled00/data/index.htm index 1cc88083..0c9864ca 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -103,7 +103,7 @@ td { .slider-icon { - transform: translateY(2px); + transform: translateY(3px); color: #ddd; } @@ -141,7 +141,7 @@ td { .tab { background-color: #222; color: #ddd; - filter: drop-shadow(0px 0px 2px #000); + //filter: drop-shadow(0px 0px 2px #000); } .bot { @@ -1337,12 +1337,28 @@ function selectSlot(b) { updateTrail(d.getElementById('sliderW')); } +var lasth = 0; +function pC(col) +{ + if (col == "rnd") + { + col = {h: 0, s: 0, v: 100}; + col.s = Math.floor((Math.random() * 50) + 50); + do { + col.h = Math.floor(Math.random() * 360); + } while (Math.abs(col.h - lasth) < 50); + lasth = col.h; + } + cpick.color.set(col); + setColor(false); +} + function setColor(fromPicker) { var cd = d.getElementById('csl').children; if (fromPicker && cd[csel].style.backgroundColor == 'rgb(0, 0, 0)') cpick.color.setChannel('hsv', 'v', 100); cd[csel].style.backgroundColor = cpick.color.rgbString; whites[csel] = d.getElementById('sliderW').value; - col = cpick.color.rgb; + var col = cpick.color.rgb; var obj = {"seg": {"col": [[col.r, col.g, col.b, whites[csel]],[],[]]}}; if (csel == 1) { obj = {"seg": {"col": [[],[col.r, col.g, col.b, whites[csel]],[]]}}; From 92a9d7d26a5be56fe42200e7e2682a7f69f9cc9b Mon Sep 17 00:00:00 2001 From: Aircoookie Date: Sat, 15 Feb 2020 16:42:05 +0100 Subject: [PATCH 03/12] Attempt to fix travis --- platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio.ini b/platformio.ini index 84200955..cb1e42e8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -80,6 +80,7 @@ arduino_core_2_6_2 = espressif8266@2.3.1 arduino_core_stage = https://github.com/platformio/platform-espressif8266.git#feature/stage platform = ${common:esp8266.arduino_core_2_6_2} build_flags = + -D ESP8266 -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH -Wl,-Teagle.flash.4m1m.ld ;;;; Required for core > v2.5.0 or staging version 4MB Flash 3MB SPIFFs From d0b9f53d8c4d486284102f0975c80209bf0fb8fe Mon Sep 17 00:00:00 2001 From: fishbone-git Date: Sat, 15 Feb 2020 20:07:15 +0100 Subject: [PATCH 04/12] water ripple effect with a dimmed rainbow background --- wled00/FX.cpp | 32 +++++++++++++++++++++++++++++--- wled00/FX.h | 10 +++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 479714fe..53843fe1 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -2133,7 +2133,7 @@ typedef struct Ripple { uint16_t pos; } ripple; -uint16_t WS2812FX::mode_ripple() +uint16_t WS2812FX::ripple_base(bool rainbow) { uint16_t maxRipples = 1 + (SEGLEN >> 2); if (maxRipples > 100) maxRipples = 100; @@ -2143,8 +2143,25 @@ uint16_t WS2812FX::mode_ripple() Ripple* ripples = reinterpret_cast(SEGENV.data); - fill(SEGCOLOR(1)); - + // ranbow background or chosen background, all very dim. + if (rainbow) { + if (SEGENV.call ==0) { + SEGENV.aux0 = random8(); + SEGENV.aux1 = random8(); + } + if (SEGENV.aux0 == SEGENV.aux1) { + SEGENV.aux1 = random8(); + } + else if (SEGENV.aux1 > SEGENV.aux0) { + SEGENV.aux0++; + } else { + SEGENV.aux0--; + } + fill(color_blend(color_wheel(SEGENV.aux0),BLACK,235)); + } else { + fill(SEGCOLOR(1)); + } + //draw wave for (uint16_t i = 0; i < maxRipples; i++) { @@ -2188,6 +2205,15 @@ uint16_t WS2812FX::mode_ripple() return FRAMETIME; } +uint16_t WS2812FX::mode_ripple(void) { + return ripple_base(false); +} + +uint16_t WS2812FX::mode_ripple_rainbow(void) { + return ripple_base(true); +} + + // TwinkleFOX by Mark Kriegsman: https://gist.github.com/kriegsman/756ea6dcae8e30845b5a // diff --git a/wled00/FX.h b/wled00/FX.h index d4bf4ff5..998c546b 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 99 +#define MODE_COUNT 100 #define FX_MODE_STATIC 0 #define FX_MODE_BLINK 1 @@ -192,6 +192,7 @@ #define FX_MODE_DRIP 96 #define FX_MODE_PLASMA 97 #define FX_MODE_PERCENT 98 +#define FX_MODE_RIPPLE_RAINBOW 99 class WS2812FX { typedef uint16_t (WS2812FX::*mode_ptr)(void); @@ -379,6 +380,7 @@ class WS2812FX { _mode[FX_MODE_DRIP] = &WS2812FX::mode_drip; _mode[FX_MODE_PLASMA] = &WS2812FX::mode_plasma; _mode[FX_MODE_PERCENT] = &WS2812FX::mode_percent; + _mode[FX_MODE_RIPPLE_RAINBOW] = &WS2812FX::mode_ripple_rainbow; _brightness = DEFAULT_BRIGHTNESS; currentPalette = CRGBPalette16(CRGB::Black); @@ -562,7 +564,8 @@ class WS2812FX { mode_popcorn(void), mode_drip(void), mode_plasma(void), - mode_percent(void); + mode_percent(void), + mode_ripple_rainbow(void); private: @@ -607,6 +610,7 @@ class WS2812FX { dissolve(uint32_t), chase(uint32_t, uint32_t, uint32_t, bool), gradient_base(bool), + ripple_base(bool), police_base(uint32_t, uint32_t), running(uint32_t, uint32_t), tricolor_chase(uint32_t, uint32_t), @@ -642,7 +646,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","Percent" +"Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma","Percent", "Ripple Rainbow" ])====="; From 3b52770a1b013422c8757db0c9716123cc953ce9 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sun, 16 Feb 2020 17:34:28 +0100 Subject: [PATCH 05/12] Fix segments when reverse --- wled00/FX_fcn.cpp | 5 ++++- wled00/wled00.ino | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 7c87a292..c1ee11af 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -125,9 +125,12 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w) /* Set all the pixels in the group, ensuring _skipFirstMode is honored */ bool reversed = reverseMode ^ IS_REVERSE; uint16_t realIndex = realPixelIndex(i); + for (uint16_t j = 0; j < SEGMENT.grouping; j++) { int16_t indexSet = realIndex + (reversed ? -j : j); - if (indexSet >= SEGMENT.start && indexSet < SEGMENT.stop) bus->SetPixelColor(indexSet + skip, col); + int16_t indexSetRev = indexSet; + if (reverseMode) indexSetRev = _length - 1 - indexSet; + if (indexSetRev >= SEGMENT.start && indexSetRev < SEGMENT.stop) bus->SetPixelColor(indexSet + skip, col); } } else { //live data, etc. if (reverseMode) i = _length - 1 - i; diff --git a/wled00/wled00.ino b/wled00/wled00.ino index f186f5e8..245ba3a3 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -90,7 +90,7 @@ #endif //version code in format yymmddb (b = daily build) -#define VERSION 2002021 +#define VERSION 2002161 char versionString[] = "0.9.1"; From 0b7e0e166c42e629fae9db80ed6c7e12802a1ed7 Mon Sep 17 00:00:00 2001 From: fishbone-git <53238640+fishbone-git@users.noreply.github.com> Date: Mon, 17 Feb 2020 10:18:36 +0100 Subject: [PATCH 06/12] pio workaround for pio4.2.0 (#688) --- platformio.ini | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/platformio.ini b/platformio.ini index cb1e42e8..dd9bb0bc 100644 --- a/platformio.ini +++ b/platformio.ini @@ -128,6 +128,8 @@ build_flags = ${common:esp8266.build_flags} lib_deps = ${common.lib_deps_external} +lib_compat_mode = strict +lib_ignore = AsynTCP [env:d1_mini] board = d1_mini @@ -140,6 +142,8 @@ build_flags = ${common:esp8266.build_flags} lib_deps = ${common.lib_deps_external} +lib_compat_mode = strict +lib_ignore = AsynTCP [env:esp01_1m] board = esp01_1m @@ -154,6 +158,8 @@ build_flags = -D WLED_DISABLE_INFRARED lib_deps = ${common.lib_deps_external} +lib_compat_mode = strict +lib_ignore = AsynTCP [env:esp01] board = esp01 @@ -167,6 +173,8 @@ build_flags = -D WLED_DISABLE_INFRARED lib_deps = ${common.lib_deps_external} +lib_compat_mode = strict +lib_ignore = AsynTCP [env:esp07] board = esp07 @@ -179,6 +187,8 @@ build_flags = ${common:esp8266.build_flags} lib_deps = ${common.lib_deps_external} +lib_compat_mode = strict +lib_ignore = AsynTCP # see: http://docs.platformio.org/en/latest/platforms/espressif32.html [env:esp32dev] @@ -194,6 +204,7 @@ lib_deps = ${common.lib_deps_external} lib_ignore = ESPAsyncUDP +lib_compat_mode = strict [env:esp8285_4CH_MagicHome] board = esp8285 @@ -208,6 +219,8 @@ build_flags = -D WLED_USE_ANALOG_LEDS lib_deps = ${common.lib_deps_external} +lib_compat_mode = strict +lib_ignore = AsynTCP [env:esp8285_4CH_H801] board = esp8285 @@ -223,6 +236,8 @@ build_flags = -D WLED_USE_H801 lib_deps = ${common.lib_deps_external} +lib_compat_mode = strict +lib_ignore = AsynTCP [env:esp8285_5CH_H801] board = esp8285 @@ -239,4 +254,6 @@ build_flags = -D WLED_ENABLE_5CH_LEDS lib_deps = ${common.lib_deps_external} +lib_compat_mode = strict +lib_ignore = AsynTCP From 5befcd24b526cb5822f0dec3de071ba44af6fe2e Mon Sep 17 00:00:00 2001 From: Def3nder <33399267+Def3nder@users.noreply.github.com> Date: Mon, 17 Feb 2020 11:01:05 +0100 Subject: [PATCH 07/12] Effect "Heartbeat" (#680) --- wled00/FX.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ wled00/FX.h | 6 +++++- wled00/NpbWrapper.h | 9 +++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 36dcecc6..bb290038 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -3119,4 +3119,44 @@ uint16_t WS2812FX::mode_percent(void) { } return FRAMETIME; +} + +uint16_t WS2812FX::mode_heartbeat(void) { + static unsigned long lastBeat = 0; + static bool secondBeatActive = false; + + uint8_t bpm = 40 + (SEGMENT.speed >> 4); + uint32_t msPerBeat = (60000 / bpm); + uint32_t secondBeat = (msPerBeat / 3); + + // Get and translate the segment's size option + uint8_t size = 2 << ((SEGMENT.options >> 1) & 0x03); // 2,4,8,16 + + // copy pixels from the middle of the segment to the edges + uint16_t bytesPerPixelBlock = size * 4; + uint16_t centerOffset = (SEGLEN / 2) * 4; + uint16_t byteCount = centerOffset - bytesPerPixelBlock; + memmove(bus->GetPixels(), bus->GetPixels() + bytesPerPixelBlock, byteCount); + memmove(bus->GetPixels() + centerOffset + bytesPerPixelBlock, bus->GetPixels() + centerOffset, byteCount); + + fade_out(255 - SEGMENT.intensity); + + unsigned long beatTimer = millis() - lastBeat; + if((beatTimer > secondBeat) && !secondBeatActive) { // time for the second beat? + uint16_t startLed = (SEGLEN / 2) - size; + for (uint16_t i = startLed; i < startLed + (size * 2); i++) { + setPixelColor(i, SEGMENT.colors[0]); + } + secondBeatActive = 1; + } + if(beatTimer > msPerBeat) { // time to reset the beat timer? + uint16_t startLed = (SEGLEN / 2) - size; + for (uint16_t i = startLed; i < startLed + (size * 2); i++) { + setPixelColor(i, SEGMENT.colors[0]); + } + secondBeatActive = 0; + lastBeat = millis(); + } + + return FRAMETIME; } \ No newline at end of file diff --git a/wled00/FX.h b/wled00/FX.h index 998c546b..79629ece 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -193,6 +193,7 @@ #define FX_MODE_PLASMA 97 #define FX_MODE_PERCENT 98 #define FX_MODE_RIPPLE_RAINBOW 99 +#define FX_MODE_HEARTBEAT 100 class WS2812FX { typedef uint16_t (WS2812FX::*mode_ptr)(void); @@ -380,6 +381,7 @@ class WS2812FX { _mode[FX_MODE_DRIP] = &WS2812FX::mode_drip; _mode[FX_MODE_PLASMA] = &WS2812FX::mode_plasma; _mode[FX_MODE_PERCENT] = &WS2812FX::mode_percent; + _mode[FX_MODE_HEARTBEAT] = &WS2812FX::mode_heartbeat; _mode[FX_MODE_RIPPLE_RAINBOW] = &WS2812FX::mode_ripple_rainbow; _brightness = DEFAULT_BRIGHTNESS; @@ -565,6 +567,7 @@ class WS2812FX { mode_drip(void), mode_plasma(void), mode_percent(void), + mode_heartbeat(void); mode_ripple_rainbow(void); @@ -646,7 +649,8 @@ 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","Percent", "Ripple Rainbow" +"Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma","Percent","Ripple Rainbow", +"Heartbeat" ])====="; diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index 9f391556..54d21ac1 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -287,6 +287,15 @@ public: return 0; } + uint8_t* GetPixels(void) + { + switch (_type) { + case NeoPixelType_Grb: return _pGrb->Pixels(); break; + case NeoPixelType_Grbw: return _pGrbw->Pixels(); break; + } + return 0; + } + private: NeoPixelType _type; From b42847c135ae94729127b3b21ab22857164aba0f Mon Sep 17 00:00:00 2001 From: Aircoookie Date: Mon, 17 Feb 2020 11:12:39 +0100 Subject: [PATCH 08/12] Fix compilation --- wled00/FX.h | 2 +- wled00/wled00.ino | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/FX.h b/wled00/FX.h index 79629ece..149476e3 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -567,8 +567,8 @@ class WS2812FX { mode_drip(void), mode_plasma(void), mode_percent(void), + mode_ripple_rainbow(void), mode_heartbeat(void); - mode_ripple_rainbow(void); private: diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 245ba3a3..2edc101a 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -90,7 +90,7 @@ #endif //version code in format yymmddb (b = daily build) -#define VERSION 2002161 +#define VERSION 2002171 char versionString[] = "0.9.1"; From 3062786bb3072225ef7b34913e7d0b7231877aa5 Mon Sep 17 00:00:00 2001 From: Aircoookie Date: Mon, 17 Feb 2020 18:02:14 +0100 Subject: [PATCH 09/12] Corrected effect mode count --- wled00/FX.h | 2 +- wled00/wled00.ino | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/FX.h b/wled00/FX.h index 149476e3..aac07b68 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 100 +#define MODE_COUNT 101 #define FX_MODE_STATIC 0 #define FX_MODE_BLINK 1 diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 2edc101a..43cfe83c 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -90,7 +90,7 @@ #endif //version code in format yymmddb (b = daily build) -#define VERSION 2002171 +#define VERSION 2002172 char versionString[] = "0.9.1"; From 9e62db52370e0c952656573d64095f17ec0b62e7 Mon Sep 17 00:00:00 2001 From: Aircoookie Date: Tue, 18 Feb 2020 14:22:20 +0100 Subject: [PATCH 10/12] Update html with PC mode --- wled00/data/index.htm | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/wled00/data/index.htm b/wled00/data/index.htm index 0c9864ca..0391645d 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -658,6 +658,12 @@ input[type=number]::-webkit-outer-spin-button { float: none; } } + +@media all and (max-width: 1250px) { + #buttonPcm { + display: none; + } +} @@ -673,6 +679,7 @@ input[type=number]::-webkit-outer-spin-button { +

Brightness

@@ -833,6 +840,7 @@ var savedPresets = 0; var currentPreset = -1; var lastUpdate = 0; var segCount = 0, ledCount = 0, lowestUnused = 0, maxSeg = 0; +var pcMode = false; var d = document; const ranges = RangeTouch.setup('input[type="range"]', {}); @@ -872,10 +880,12 @@ function updateTablinks(tabI) for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } + if (pcMode) return; tablinks[tabI].className += " active"; } function openTab(tabI) { + if (pcMode) return; var i, tabcontent, tablinks; iSlide = tabI; _C.classList.toggle('smooth', false); @@ -1035,7 +1045,7 @@ function requestJson(command, verbose = true) { e1 = d.getElementById('fxlist'); e2 = d.getElementById('selectPalette'); - url = command ? 'http://10.10.1.26/json/state':'http://10.10.1.26/json'; + url = command ? '/json/state':'/json'; type = command ? 'post':'get'; if (command) @@ -1394,17 +1404,18 @@ let iSlide = 0, x0 = null, y0 = null, scrollS = 0, locked = false, w; function unify(e) { return e.changedTouches ? e.changedTouches[0] : e } function lock(e) { + if (pcMode) return; var l = e.target.classList; if (l.contains('noslide') || l.contains('iro__wheel__saturation') || l.contains('iro__slider__value') || l.contains('iro__slider')) return; x0 = unify(e).clientX; y0 = unify(e).clientY; scrollS = d.getElementsByClassName("tabcontent")[iSlide].scrollTop; - _C.classList.toggle('smooth', !(locked = true)) + _C.classList.toggle('smooth', !(locked = true)) } function drag(e) { - if (!locked) return; + if (!locked || pcMode) return; if (d.getElementsByClassName("tabcontent")[iSlide].scrollTop != scrollS) { move(e); return; } @@ -1417,7 +1428,7 @@ function drag(e) { } function move(e) { - if(!locked) return; + if(!locked || pcMode) return; var dx = unify(e).clientX - x0, s = Math.sign(dx), f = +(s*dx/w).toFixed(2); @@ -1437,6 +1448,23 @@ function size() { w = window.innerWidth; _C.style.setProperty('--tp', d.getElementById('top').clientHeight + "px"); _C.style.setProperty('--bt', d.getElementById('bot').clientHeight + "px"); + if (w < 1250) togglePcMode(); +} + +function togglePcMode() +{ + if (w < 1250 && !pcMode) return; + openTab(0); + pcMode = !pcMode; + if (w < 1250) pcMode = false; + updateTablinks(0); + d.getElementById('buttonPcm').className = (pcMode) ? "active":""; + if (pcMode) + { + _C.style.width = '100%'; + } else { + _C.style.width = '400%'; + } } size(); From 1fd0383f693fc9b80c27a8ff47f952e9ffb8bbc9 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Tue, 18 Feb 2020 18:52:47 +0100 Subject: [PATCH 11/12] Various improvements UI Quick color selectors UI PC mode Different Heartbeat effect PoliceAll improvements Clarified sync settings --- wled00/FX.cpp | 94 +- wled00/FX.h | 4 +- wled00/data/index.htm | 1970 +++++++++++++-------------- wled00/html_settings.h | 27 +- wled00/html_ui.h | 2937 ++++++++++++++++++++-------------------- wled00/wled00.ino | 2 +- 6 files changed, 2547 insertions(+), 2487 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index bb290038..680c7724 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1219,11 +1219,10 @@ 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 WS2812FX::police_base(uint32_t color1, uint32_t color2, bool all) { uint16_t counter = now * ((SEGMENT.speed >> 2) +1); uint16_t idexR = (counter * SEGLEN) >> 16; - uint8_t size = 1 + SEGMENT.intensity >> 3; if (idexR >= SEGLEN) idexR = 0; uint16_t topindex = SEGLEN >> 1; @@ -1231,19 +1230,31 @@ uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2) if (SEGENV.call == 0) SEGENV.aux0 = idexR; if (idexB >= SEGLEN) idexB = 0; //otherwise overflow on odd number of LEDs - for (uint8_t i=0; i <= size; i++) { - setPixelColor(idexR+i, color1); - setPixelColor(idexB+i, color2); - } - if (SEGENV.aux0 != idexR) { - 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); + if (all) { //different algo, ensuring immediate fill + if (idexB > idexR) { + fill(color2); + for (uint16_t i = idexR; i < idexB; i++) setPixelColor(i, color1); + } else { + fill(color1); + for (uint16_t i = idexB; i < idexR; i++) setPixelColor(i, color2); + } + } else { //regular dot-only mode + uint8_t size = 1 + SEGMENT.intensity >> 3; + if (size > SEGLEN/2) size = 1+ SEGLEN/2; + for (uint8_t i=0; i <= size; i++) { + setPixelColor(idexR+i, color1); + setPixelColor(idexB+i, color2); + } + if (SEGENV.aux0 != idexR) { + 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; } - SEGENV.aux0 = idexR; } return FRAMETIME; @@ -1253,7 +1264,7 @@ uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2) //American Police Light with all LEDs Red and Blue uint16_t WS2812FX::mode_police_all() { - return police_base(RED, BLUE); + return police_base(RED, BLUE, true); } @@ -1262,14 +1273,14 @@ uint16_t WS2812FX::mode_police() { fill(SEGCOLOR(1)); - return police_base(RED, BLUE); + return police_base(RED, BLUE, false); } //Police All with custom colors uint16_t WS2812FX::mode_two_areas() { - return police_base(SEGCOLOR(0), SEGCOLOR(1)); + return police_base(SEGCOLOR(0), SEGCOLOR(1), true); } @@ -1279,7 +1290,7 @@ uint16_t WS2812FX::mode_two_dots() fill(SEGCOLOR(2)); uint32_t color2 = (SEGCOLOR(1) == SEGCOLOR(2)) ? SEGCOLOR(0) : SEGCOLOR(1); - return police_base(SEGCOLOR(0), color2); + return police_base(SEGCOLOR(0), color2, false); } @@ -3087,8 +3098,8 @@ uint16_t WS2812FX::mode_percent(void) { uint16_t active_leds = (percent < 100) ? SEGLEN * percent / 100.0 : SEGLEN * (200 - percent) / 100.0; - if (SEGENV.call == 0) SEGENV.step = 0; - uint8_t size = (1 + ((SEGMENT.speed * SEGLEN) >> 11)) & 0xFF ; + uint8_t size = (1 + ((SEGMENT.speed * SEGLEN) >> 11)); + if (SEGMENT.speed == 255) size = 255; if (percent < 100) { for (uint16_t i = 0; i < SEGLEN; i++) { @@ -3122,41 +3133,28 @@ uint16_t WS2812FX::mode_percent(void) { } uint16_t WS2812FX::mode_heartbeat(void) { - static unsigned long lastBeat = 0; - static bool secondBeatActive = false; - uint8_t bpm = 40 + (SEGMENT.speed >> 4); uint32_t msPerBeat = (60000 / bpm); uint32_t secondBeat = (msPerBeat / 3); - // Get and translate the segment's size option - uint8_t size = 2 << ((SEGMENT.options >> 1) & 0x03); // 2,4,8,16 + uint32_t bri_lower = SEGENV.aux1; + bri_lower = bri_lower * 2042 / (2048 + SEGMENT.intensity); + SEGENV.aux1 = bri_lower; - // copy pixels from the middle of the segment to the edges - uint16_t bytesPerPixelBlock = size * 4; - uint16_t centerOffset = (SEGLEN / 2) * 4; - uint16_t byteCount = centerOffset - bytesPerPixelBlock; - memmove(bus->GetPixels(), bus->GetPixels() + bytesPerPixelBlock, byteCount); - memmove(bus->GetPixels() + centerOffset + bytesPerPixelBlock, bus->GetPixels() + centerOffset, byteCount); - - fade_out(255 - SEGMENT.intensity); - - unsigned long beatTimer = millis() - lastBeat; - if((beatTimer > secondBeat) && !secondBeatActive) { // time for the second beat? - uint16_t startLed = (SEGLEN / 2) - size; - for (uint16_t i = startLed; i < startLed + (size * 2); i++) { - setPixelColor(i, SEGMENT.colors[0]); - } - secondBeatActive = 1; + unsigned long beatTimer = millis() - SEGENV.step; + if((beatTimer > secondBeat) && !SEGENV.aux0) { // time for the second beat? + SEGENV.aux1 = UINT16_MAX; //full bri + SEGENV.aux0 = 1; } if(beatTimer > msPerBeat) { // time to reset the beat timer? - uint16_t startLed = (SEGLEN / 2) - size; - for (uint16_t i = startLed; i < startLed + (size * 2); i++) { - setPixelColor(i, SEGMENT.colors[0]); - } - secondBeatActive = 0; - lastBeat = millis(); + SEGENV.aux1 = UINT16_MAX; //full bri + SEGENV.aux0 = 0; + SEGENV.step = millis(); + } + + for (uint16_t i = 0; i < SEGLEN; i++) { + setPixelColor(i, color_blend(color_from_palette(i, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), 255 - (SEGENV.aux1 >> 8))); } return FRAMETIME; -} \ No newline at end of file +} diff --git a/wled00/FX.h b/wled00/FX.h index aac07b68..abfc11d3 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -381,8 +381,8 @@ class WS2812FX { _mode[FX_MODE_DRIP] = &WS2812FX::mode_drip; _mode[FX_MODE_PLASMA] = &WS2812FX::mode_plasma; _mode[FX_MODE_PERCENT] = &WS2812FX::mode_percent; - _mode[FX_MODE_HEARTBEAT] = &WS2812FX::mode_heartbeat; _mode[FX_MODE_RIPPLE_RAINBOW] = &WS2812FX::mode_ripple_rainbow; + _mode[FX_MODE_HEARTBEAT] = &WS2812FX::mode_heartbeat; _brightness = DEFAULT_BRIGHTNESS; currentPalette = CRGBPalette16(CRGB::Black); @@ -614,7 +614,7 @@ class WS2812FX { chase(uint32_t, uint32_t, uint32_t, bool), gradient_base(bool), ripple_base(bool), - police_base(uint32_t, uint32_t), + police_base(uint32_t, uint32_t, bool), running(uint32_t, uint32_t), tricolor_chase(uint32_t, uint32_t), twinklefox_base(bool), diff --git a/wled00/data/index.htm b/wled00/data/index.htm index 0391645d..d9d1ccc9 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -1,668 +1,668 @@ - - - - - - WLED - + + + + + +WLED + @@ -672,144 +672,144 @@ input[type=number]::-webkit-outer-spin-button {
-
-
- - - - - - -
-
-

Brightness

-
- -
- -
-
-
-
- -
+
+
+ + + + + + +
+
+

Brightness

+
+ +
+ +
+
+
+
+ +
-
-
-
-

White channel

-
- -
-
-
-
-
-
-
-
-
-

-
-
-
-
-
R
-
-
- - - -
-

Color palette

-
- - -
-
+
+
+
+

White channel

+
+ +
+
+
+
+
+
+
+
+
+

+
+
+
+
+
R
+
+
+ + + +
+

Color palette

+
+ + +
+
-
-

Effect speed

-
- -
- -
-
-
-

Effect intensity

-
- -
- -
-
-
-

Effect mode

-
- -
-
- Loading... -
-
-
- -
-
- Loading... -
-
- -
-
+
+

Effect speed

+
+ +
+ +
+
+
+

Effect intensity

+
+ +
+ +
+
+
+

Effect mode

+
+ +
+
+Loading... +
+
+
-
-

Load from slot

- - - -
- - - -
- - - -
- - - -
-
- Slot 16 can save all segments.

-
- First preset:
- Last preset:
- Time per preset: s
- Transition: s -
+
+
+Loading... +
+
+ +
+
+ +
+

Load from slot

+ + + +
+ + + +
+ + + +
+ + + +
+
+Slot 16 can save all segments.

+
+First preset:
+Last preset:
+Time per preset: s
+Transition: s +
- - - - + + + +
@@ -817,16 +817,16 @@ input[type=number]::-webkit-outer-spin-button {