From ac9a567e1febf3435120b8ad7e30b2e0b8cca1a5 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Tue, 25 Aug 2020 17:23:17 +0200 Subject: [PATCH] Pacifica better speed --- CHANGELOG.md | 7 +++++++ platformio_override.ini.example | 3 +++ wled00/FX.cpp | 10 ++++++++-- wled00/FX.h | 4 ++-- wled00/led.cpp | 6 ++++++ wled00/wled.h | 2 +- 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 074f7b76d..fe3fec07e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ### Development versions after 0.10.0 release +#### Build 2008250 + +- Made `platformio_override.ini` example easier to use by including the `default_envs` property +- FastLED uses `now` as timer, so effects using e.g. `beatsin88()` will sync correctly +- Extended the speed range of Pacifica effect +- Fixed exception on empty MQTT payload (#1101) + #### Build 2008200 - Added segment mirroring to web UI diff --git a/platformio_override.ini.example b/platformio_override.ini.example index 7e87827b0..da024970b 100644 --- a/platformio_override.ini.example +++ b/platformio_override.ini.example @@ -4,6 +4,9 @@ # ------------------------------------------------------------------------------ # Please visit documentation: https://docs.platformio.org/page/projectconf.html +[platformio] +default_envs = esp8266_1m_custom + [env:esp8266_1m_custom] board = esp01_1m platform = ${common.arduino_core_2_4_2} diff --git a/wled00/FX.cpp b/wled00/FX.cpp index c74c113bd..bbf1d007e 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -3240,6 +3240,8 @@ uint16_t WS2812FX::mode_heartbeat(void) { // uint16_t WS2812FX::mode_pacifica() { + uint32_t nowOld = now; + CRGBPalette16 pacifica_palette_1 = { 0x000507, 0x000409, 0x00030B, 0x00030D, 0x000210, 0x000212, 0x000114, 0x000117, 0x000019, 0x00001C, 0x000026, 0x000031, 0x00003B, 0x000046, 0x14554B, 0x28AA50 }; @@ -3260,8 +3262,11 @@ uint16_t WS2812FX::mode_pacifica() // Each is incremented at a different speed, and the speeds vary over time. uint16_t sCIStart1 = SEGENV.aux0, sCIStart2 = SEGENV.aux1, sCIStart3 = SEGENV.step, sCIStart4 = SEGENV.step >> 16; //static uint16_t sCIStart1, sCIStart2, sCIStart3, sCIStart4; - uint32_t deltams = 26 + (SEGMENT.speed >> 3); - + //uint32_t deltams = 26 + (SEGMENT.speed >> 3); + uint32_t deltams = (FRAMETIME >> 2) + ((FRAMETIME * SEGMENT.speed) >> 7); + uint64_t deltat = (now >> 2) + ((now * SEGMENT.speed) >> 7); + now = deltat; + uint16_t speedfactor1 = beatsin16(3, 179, 269); uint16_t speedfactor2 = beatsin16(4, 179, 269); uint32_t deltams1 = (deltams * speedfactor1) / 256; @@ -3306,6 +3311,7 @@ uint16_t WS2812FX::mode_pacifica() setPixelColor(i, c.red, c.green, c.blue); } + now = nowOld; return FRAMETIME; } diff --git a/wled00/FX.h b/wled00/FX.h index 5cfda3509..0c5241b4c 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -31,6 +31,7 @@ #include "const.h" #define FASTLED_INTERNAL //remove annoying pragma messages +#define USE_GET_MILLISECOND_TIMER #include "FastLED.h" #define DEFAULT_BRIGHTNESS (uint8_t)127 @@ -481,6 +482,7 @@ class WS2812FX { triwave16(uint16_t); uint32_t + now, timebase, color_wheel(uint8_t), color_from_palette(uint16_t, bool mapping, bool wrap, uint8_t mcol, uint8_t pbri = 255), @@ -623,7 +625,6 @@ class WS2812FX { CRGBPalette16 currentPalette; CRGBPalette16 targetPalette; - uint32_t now; uint16_t _length, _lengthRaw, _virtualSegmentLength; uint16_t _rand16seed; uint8_t _brightness; @@ -687,7 +688,6 @@ class WS2812FX { uint16_t realPixelIndex(uint16_t i); }; - //10 names per line const char JSON_mode_names[] PROGMEM = R"=====([ "Solid","Blink","Breathe","Wipe","Wipe Random","Random Colors","Sweep","Dynamic","Colorloop","Rainbow", diff --git a/wled00/led.cpp b/wled00/led.cpp index 29baae8a4..2b30d78cc 100644 --- a/wled00/led.cpp +++ b/wled00/led.cpp @@ -299,3 +299,9 @@ void handleNightlight() presetCycledTime = millis(); } } + +//utility for FastLED to use our custom timer +uint32_t get_millisecond_timer() +{ + return strip.now; +} diff --git a/wled00/wled.h b/wled00/wled.h index 6235e6357..0f2ee1f80 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2008200 +#define VERSION 2008250 // 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).