Skip to content

Commit

Permalink
Pacifica better speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Aircoookie committed Aug 25, 2020
1 parent 33cd52c commit ac9a567
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions platformio_override.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
10 changes: 8 additions & 2 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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;
Expand Down Expand Up @@ -3306,6 +3311,7 @@ uint16_t WS2812FX::mode_pacifica()
setPixelColor(i, c.red, c.green, c.blue);
}

now = nowOld;
return FRAMETIME;
}

Expand Down
4 changes: 2 additions & 2 deletions wled00/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -623,7 +625,6 @@ class WS2812FX {
CRGBPalette16 currentPalette;
CRGBPalette16 targetPalette;

uint32_t now;
uint16_t _length, _lengthRaw, _virtualSegmentLength;
uint16_t _rand16seed;
uint8_t _brightness;
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions wled00/led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,9 @@ void handleNightlight()
presetCycledTime = millis();
}
}

//utility for FastLED to use our custom timer
uint32_t get_millisecond_timer()
{
return strip.now;
}
2 changes: 1 addition & 1 deletion wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down

0 comments on commit ac9a567

Please sign in to comment.