Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
; default_envs = travis_esp8266, travis_esp32

# Release binaries
default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth, esp32s2_saola, esp32c3
; default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth, esp32s2_saola, esp32c3

# Build everything
; default_envs = esp32dev, esp8285_4CH_MagicHome, codm-controller-0.6-rev2, codm-controller-0.6, esp32s2_saola, d1_mini_5CH_Shojo_PCB, d1_mini, sp501e, travis_esp8266, travis_esp32, nodemcuv2, esp32_eth, anavi_miracle_controller, esp07, esp01_1m_full, m5atom, h803wf, d1_mini_ota, heltec_wifi_kit_8, esp8285_H801, d1_mini_debug, wemos_shield_esp32, elekstube_ips
Expand All @@ -27,7 +27,7 @@ default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth, esp32s
; default_envs = heltec_wifi_kit_8
; default_envs = h803wf
; default_envs = d1_mini_debug
; default_envs = d1_mini_ota
default_envs = d1_mini_ota
; default_envs = esp32dev
; default_envs = esp8285_4CH_MagicHome
; default_envs = esp8285_H801
Expand Down Expand Up @@ -405,7 +405,7 @@ lib_deps = ${esp8266.lib_deps}
board = d1_mini
upload_protocol = espota
# exchange for your WLED IP
upload_port = "10.10.1.27"
upload_port = "192.168.178.32"
platform = ${common.platform_wled_default}
platform_packages = ${common.platform_packages}
board_build.ldscript = ${common.ldscript_4m1m}
Expand Down
141 changes: 140 additions & 1 deletion wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4226,4 +4226,143 @@ uint16_t WS2812FX::mode_aurora(void) {
}

return FRAMETIME;
}
}

/*
* Description comming....
*/
uint16_t WS2812FX::mode_thunder_storm(void) {
uint16_t maxData = FAIR_DATA_PER_SEG; //ESP8266: 256 ESP32: 640
uint8_t segs = getActiveSegmentsNum();
if (segs <= (MAX_NUM_SEGMENTS /2)) maxData *= 2; //ESP8266: 512 if <= 8 segs ESP32: 1280 if <= 16 segs
if (segs <= (MAX_NUM_SEGMENTS /4)) maxData *= 2; //ESP8266: 1024 if <= 4 segs ESP32: 2560 if <= 8 segs
int maxSparks = maxData / sizeof(spark); //ESP8266: max. 21/42/85 sparks/seg, ESP32: max. 53/106/213 sparks/seg

uint16_t numSparks = min(2 + (SEGLEN >> 1), maxSparks);
uint16_t dataSize = sizeof(spark) * numSparks;
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed

uint32_t color1 = GREEN;
uint32_t color2 = RED;

fill(BLACK);

bool actuallyReverse = SEGMENT.getOption(SEG_OPTION_REVERSED);
//have bolt start in either direction based on intensity
SEGMENT.setOption(SEG_OPTION_REVERSED, SEGENV.step);

// calculate location of the bolt ending, bolt speed and duration of the running of the bolt
Spark* bolt = reinterpret_cast<Spark*>(SEGENV.data);
float boltspeed = 0.0004 + (SEGMENT.speed/8000.0); // m/s/s
boltspeed *= SEGLEN;
bolt->vel = boltspeed;


if (SEGENV.aux0 < 2) { //Bolt
if (SEGENV.aux0 == 0) { //init bolt
uint16_t boltlength = 100 + random8(155); //0-255
boltlength = (boltlength * (SEGLEN -1)) >> 8;
SEGENV.aux1 = boltlength;
bolt->pos = 0;
bolt->col = 255; //brightness

SEGENV.aux0 = 1;
}

// start
if (bolt->pos < SEGENV.aux1) {
// bolt
setPixelColor(int(bolt->pos),(bolt->col * color_from_palette(bolt->pos, true, PALETTE_SOLID_WRAP, 0)) >> 8); //color_from_palette(i, true, PALETTE_SOLID_WRAP, 0), lum)

for (int i = bolt->pos -1; i > 0; i--)
{
setPixelColor(i,bolt->col >> 4,bolt->col >> 4,bolt->col >> 4);
}

bolt->pos += bolt->vel;
bolt->pos = constrain(bolt->pos, 0, SEGLEN-1);
} else if (bolt->pos >= SEGENV.aux1) {
SEGENV.aux0 = 2;
}
}

else if (SEGENV.aux0 == 2) {
for (int i = SEGENV.aux1; i > 0; i--) {
setPixelColor(i,bolt->col,bolt->col,bolt->col);
}
bolt->col -= (1 + (SEGMENT.speed/8.0));

if (bolt->col < 50) {
SEGENV.aux0 = 3;
}
}

else if (SEGENV.aux0 == 3) {
for (int i = SEGENV.aux1; i > 0; i--) {
setPixelColor(i,bolt->col,bolt->col,bolt->col);
}
bolt->col += (1 + (SEGMENT.speed/8.0));

if (bolt->col > 220) {
SEGENV.aux0 = 4;
}
}

else if (SEGENV.aux0 == 4) {
for (int i = SEGENV.aux1; i > 0; i--) {
setPixelColor(i,bolt->col,bolt->col,bolt->col);
}
bolt->col -= (1 + (SEGMENT.speed/8.0));

if (bolt->col < 35) {
SEGENV.aux0 = 5;
}
}

else if (SEGENV.aux0 == 5) {
fill(BLACK);
SEGENV.aux0 = 10 + random8(30);
}
else {
SEGENV.aux0--;
if (SEGENV.aux0 < 7) {
SEGENV.aux0 = 0; //back to begin
SEGENV.step = actuallyReverse ^ (SEGMENT.intensity > random8());
}
}

return FRAMETIME;
}



/*
// Blinking part #################################
uint16_t WS2812FX::blink(uint32_t color1, uint32_t color2, bool strobe, bool do_palette) {
uint32_t cycleTime = (255 - SEGMENT.speed)*20;
uint32_t onTime = FRAMETIME;
if (!strobe) onTime += ((cycleTime * SEGMENT.intensity) >> 8);
cycleTime += FRAMETIME*2;
uint32_t it = now / cycleTime;
uint32_t rem = now % cycleTime;

bool on = false;
if (it != SEGENV.step //new iteration, force on state for one frame, even if set time is too brief
|| rem <= onTime) {
on = true;
}

SEGENV.step = it; //save previous iteration

uint32_t color = on ? color1 : color2;
if (color == color1 && do_palette)
{
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
}
} else fill(color);

return FRAMETIME;
*/


9 changes: 6 additions & 3 deletions wled00/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
#define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE )
#define IS_SELECTED ((SEGMENT.options & SELECTED ) == SELECTED )

#define MODE_COUNT 118
#define MODE_COUNT 119

#define FX_MODE_STATIC 0
#define FX_MODE_BLINK 1
Expand Down Expand Up @@ -239,6 +239,7 @@
#define FX_MODE_BLENDS 115
#define FX_MODE_TV_SIMULATOR 116
#define FX_MODE_DYNAMIC_SMOOTH 117
#define FX_MODE_THUNDER_STORM 118


class WS2812FX {
Expand Down Expand Up @@ -609,6 +610,7 @@ class WS2812FX {
_mode[FX_MODE_BLENDS] = &WS2812FX::mode_blends;
_mode[FX_MODE_TV_SIMULATOR] = &WS2812FX::mode_tv_simulator;
_mode[FX_MODE_DYNAMIC_SMOOTH] = &WS2812FX::mode_dynamic_smooth;
_mode[FX_MODE_THUNDER_STORM] = &WS2812FX::mode_thunder_storm;

_brightness = DEFAULT_BRIGHTNESS;
currentPalette = CRGBPalette16(CRGB::Black);
Expand Down Expand Up @@ -833,7 +835,8 @@ class WS2812FX {
mode_candy_cane(void),
mode_blends(void),
mode_tv_simulator(void),
mode_dynamic_smooth(void);
mode_dynamic_smooth(void),
mode_thunder_storm(void);

private:
uint32_t crgb_to_col(CRGB fastled);
Expand Down Expand Up @@ -936,7 +939,7 @@ const char JSON_mode_names[] PROGMEM = R"=====([
"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",
"Heartbeat","Pacifica","Candle Multi", "Solid Glitter","Sunrise","Phased","Twinkleup","Noise Pal", "Sine","Phased Noise",
"Flow","Chunchun","Dancing Shadows","Washing Machine","Candy Cane","Blends","TV Simulator","Dynamic Smooth"
"Flow","Chunchun","Dancing Shadows","Washing Machine","Candy Cane","Blends","TV Simulator","Dynamic Smooth","Thunder Storm"
])=====";


Expand Down