Merge branch 'dev' into audioreactive-prototype
This commit is contained in:
commit
26793c8428
3
.vscode/extensions.json
vendored
3
.vscode/extensions.json
vendored
@ -3,5 +3,8 @@
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
],
|
||||
"unwantedRecommendations": [
|
||||
"ms-vscode.cpptools-extension-pack"
|
||||
]
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth, esp32s
|
||||
; default_envs = wemos_shield_esp32
|
||||
; default_envs = m5atom
|
||||
; default_envs = esp32_eth
|
||||
; default_envs = esp32dev_qio80
|
||||
; default_envs = esp32_eth_ota1mapp
|
||||
; default_envs = esp32s2_saola
|
||||
|
||||
@ -330,6 +331,18 @@ lib_deps = ${esp32.lib_deps}
|
||||
monitor_filters = esp32_exception_decoder
|
||||
board_build.partitions = ${esp32.default_partitions}
|
||||
|
||||
[env:esp32dev_qio80]
|
||||
board = esp32dev
|
||||
platform = ${esp32.platform}
|
||||
platform_packages = ${esp32.platform_packages}
|
||||
build_unflags = ${common.build_unflags}
|
||||
build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32_qio80 #-D WLED_DISABLE_BLYNK #-D WLED_DISABLE_BROWNOUT_DET
|
||||
lib_deps = ${esp32.lib_deps}
|
||||
monitor_filters = esp32_exception_decoder
|
||||
board_build.partitions = ${esp32.default_partitions}
|
||||
board_build.f_flash = 80000000L
|
||||
board_build.flash_mode = qio
|
||||
|
||||
[env:esp32_eth]
|
||||
board = esp32-poe
|
||||
platform = ${esp32.platform}
|
||||
|
@ -1,54 +1,70 @@
|
||||
#
|
||||
# This file is autogenerated by pip-compile
|
||||
# This file is autogenerated by pip-compile with python 3.8
|
||||
# To update, run:
|
||||
#
|
||||
# pip-compile
|
||||
#
|
||||
aiofiles==0.6.0
|
||||
aiofiles==0.8.0
|
||||
# via platformio
|
||||
ajsonrpc==1.1.0
|
||||
ajsonrpc==1.2.0
|
||||
# via platformio
|
||||
bottle==0.12.20
|
||||
anyio==3.6.1
|
||||
# via starlette
|
||||
async-timeout==4.0.2
|
||||
# via zeroconf
|
||||
bottle==0.12.23
|
||||
# via platformio
|
||||
certifi==2020.12.5
|
||||
certifi==2022.6.15
|
||||
# via requests
|
||||
chardet==4.0.0
|
||||
charset-normalizer==2.1.1
|
||||
# via requests
|
||||
click==7.1.2
|
||||
click==8.1.3
|
||||
# via
|
||||
# platformio
|
||||
# uvicorn
|
||||
colorama==0.4.4
|
||||
# via platformio
|
||||
h11==0.12.0
|
||||
colorama==0.4.5
|
||||
# via
|
||||
# click
|
||||
# platformio
|
||||
h11==0.13.0
|
||||
# via
|
||||
# uvicorn
|
||||
# wsproto
|
||||
idna==2.10
|
||||
# via requests
|
||||
ifaddr==0.1.7
|
||||
idna==3.3
|
||||
# via
|
||||
# anyio
|
||||
# requests
|
||||
ifaddr==0.2.0
|
||||
# via zeroconf
|
||||
marshmallow==3.11.1
|
||||
marshmallow==3.17.0
|
||||
# via platformio
|
||||
platformio==5.1.1
|
||||
packaging==21.3
|
||||
# via marshmallow
|
||||
platformio==6.1.4
|
||||
# via -r requirements.in
|
||||
pyelftools==0.27
|
||||
pyelftools==0.29
|
||||
# via platformio
|
||||
pyparsing==3.0.9
|
||||
# via packaging
|
||||
pyserial==3.5
|
||||
# via platformio
|
||||
requests==2.25.1
|
||||
requests==2.28.1
|
||||
# via platformio
|
||||
semantic-version==2.8.5
|
||||
semantic-version==2.10.0
|
||||
# via platformio
|
||||
starlette==0.14.2
|
||||
sniffio==1.2.0
|
||||
# via anyio
|
||||
starlette==0.20.4
|
||||
# via platformio
|
||||
tabulate==0.8.9
|
||||
tabulate==0.8.10
|
||||
# via platformio
|
||||
urllib3==1.26.5
|
||||
typing-extensions==4.3.0
|
||||
# via starlette
|
||||
urllib3==1.26.11
|
||||
# via requests
|
||||
uvicorn==0.13.4
|
||||
uvicorn==0.18.2
|
||||
# via platformio
|
||||
wsproto==1.0.0
|
||||
wsproto==1.1.0
|
||||
# via platformio
|
||||
zeroconf==0.28.8
|
||||
zeroconf==0.39.0
|
||||
# via platformio
|
||||
|
@ -135,7 +135,7 @@ class PWMFanUsermod : public Usermod {
|
||||
}
|
||||
|
||||
void updateFanSpeed(uint8_t pwmValue){
|
||||
if (pwmPin < 0) return;
|
||||
if (!enabled || pwmPin < 0) return;
|
||||
|
||||
#ifdef ESP8266
|
||||
analogWrite(pwmPin, pwmValue);
|
||||
|
269
wled00/FX.cpp
269
wled00/FX.cpp
@ -566,16 +566,14 @@ static const char _data_FX_MODE_SAW[] PROGMEM = "Saw@!,Width;!,!,;!;1d";
|
||||
* Inspired by www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
|
||||
*/
|
||||
uint16_t mode_twinkle(void) {
|
||||
const uint16_t cols = strip.isMatrix ? SEGMENT.virtualWidth() : SEGMENT.virtualLength();
|
||||
const uint16_t rows = SEGMENT.virtualHeight();
|
||||
|
||||
SEGMENT.fill(SEGCOLOR(1));
|
||||
//SEGMENT.fill(SEGCOLOR(1));
|
||||
SEGMENT.fade_out(224);
|
||||
|
||||
uint32_t cycleTime = 20 + (255 - SEGMENT.speed)*5;
|
||||
uint32_t it = strip.now / cycleTime;
|
||||
if (it != SEGENV.step)
|
||||
{
|
||||
uint16_t maxOn = map(SEGMENT.intensity, 0, 255, 1, cols*rows-1); // make sure at least one LED is on
|
||||
uint16_t maxOn = map(SEGMENT.intensity, 0, 255, 1, SEGLEN); // make sure at least one LED is on
|
||||
if (SEGENV.aux0 >= maxOn)
|
||||
{
|
||||
SEGENV.aux0 = 0;
|
||||
@ -587,20 +585,17 @@ uint16_t mode_twinkle(void) {
|
||||
|
||||
uint16_t PRNG16 = SEGENV.aux1;
|
||||
|
||||
for (int i = 0; i < SEGENV.aux0; i++)
|
||||
for (uint16_t i = 0; i < SEGENV.aux0; i++)
|
||||
{
|
||||
PRNG16 = (uint16_t)(PRNG16 * 2053) + 13849; // next 'random' number
|
||||
uint32_t p = ((uint32_t)cols*rows * (uint32_t)PRNG16) >> 16;
|
||||
uint16_t j = p % cols;
|
||||
uint16_t k = p / cols;
|
||||
uint32_t col = SEGMENT.color_from_palette(map(p, 0, cols*rows, 0, 255), false, PALETTE_SOLID_WRAP, 0);
|
||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(j, k, col);
|
||||
else SEGMENT.setPixelColor(j, col);
|
||||
uint32_t p = (uint32_t)SEGLEN * (uint32_t)PRNG16;
|
||||
uint16_t j = p >> 16;
|
||||
SEGMENT.setPixelColor(j, SEGMENT.color_from_palette(j, true, PALETTE_SOLID_WRAP, 0));
|
||||
}
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_TWINKLE[] PROGMEM = "Twinkle@!,;!,!,;!;1d,2d"; //pixels
|
||||
static const char _data_FX_MODE_TWINKLE[] PROGMEM = "Twinkle@!,;!,!,;!;mp12=0,1d"; //pixels
|
||||
|
||||
|
||||
/*
|
||||
@ -671,15 +666,13 @@ uint16_t mode_sparkle(void) {
|
||||
if (it != SEGENV.step)
|
||||
{
|
||||
SEGENV.aux0 = random16(SEGLEN); // aux0 stores the random led index
|
||||
SEGENV.aux1 = random16(0,SEGMENT.virtualHeight()-1);
|
||||
SEGENV.step = it;
|
||||
}
|
||||
|
||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(SEGENV.aux0, SEGENV.aux1, SEGCOLOR(0));
|
||||
else SEGMENT.setPixelColor(SEGENV.aux0, SEGCOLOR(0));
|
||||
SEGMENT.setPixelColor(SEGENV.aux0, SEGCOLOR(0));
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_SPARKLE[] PROGMEM = "Sparkle@!,;!,!,;!;1d,2d";
|
||||
static const char _data_FX_MODE_SPARKLE[] PROGMEM = "Sparkle@!,;!,!,;!;mp12=0,1d";
|
||||
|
||||
|
||||
/*
|
||||
@ -687,21 +680,20 @@ static const char _data_FX_MODE_SPARKLE[] PROGMEM = "Sparkle@!,;!,!,;!;1d,2d";
|
||||
* Inspired by www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
|
||||
*/
|
||||
uint16_t mode_flash_sparkle(void) {
|
||||
for (int i = 0; i < SEGLEN; i++) {
|
||||
for(uint16_t i = 0; i < SEGLEN; i++) {
|
||||
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
|
||||
}
|
||||
|
||||
if (strip.now - SEGENV.aux0 > SEGENV.step) {
|
||||
if(random8((255-SEGMENT.intensity) >> 4) == 0) {
|
||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(random16(SEGLEN), random16(0,SEGMENT.virtualHeight()-1), SEGCOLOR(1));
|
||||
else SEGMENT.setPixelColor(random16(SEGLEN), SEGCOLOR(1)); //flash
|
||||
SEGMENT.setPixelColor(random16(SEGLEN), SEGCOLOR(1)); //flash
|
||||
}
|
||||
SEGENV.step = strip.now;
|
||||
SEGENV.aux0 = 255-SEGMENT.speed;
|
||||
}
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_FLASH_SPARKLE[] PROGMEM = "Sparkle Dark@!,!;Bg,Fx,;!;1d,2d";
|
||||
static const char _data_FX_MODE_FLASH_SPARKLE[] PROGMEM = "Sparkle Dark@!,!;Bg,Fx,;!;mp12=0,1d";
|
||||
|
||||
|
||||
/*
|
||||
@ -716,8 +708,7 @@ uint16_t mode_hyper_sparkle(void) {
|
||||
if (strip.now - SEGENV.aux0 > SEGENV.step) {
|
||||
if (random8((255-SEGMENT.intensity) >> 4) == 0) {
|
||||
for (int i = 0; i < MAX(1, SEGLEN/3); i++) {
|
||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(random16(SEGLEN), random16(0,SEGMENT.virtualHeight()), SEGCOLOR(1));
|
||||
else SEGMENT.setPixelColor(random16(SEGLEN), SEGCOLOR(1));
|
||||
SEGMENT.setPixelColor(random16(SEGLEN), SEGCOLOR(1));
|
||||
}
|
||||
}
|
||||
SEGENV.step = strip.now;
|
||||
@ -725,7 +716,7 @@ uint16_t mode_hyper_sparkle(void) {
|
||||
}
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_HYPER_SPARKLE[] PROGMEM = "Sparkle+@!,!;Bg,Fx,;!;1d,2d";
|
||||
static const char _data_FX_MODE_HYPER_SPARKLE[] PROGMEM = "Sparkle+@!,!;Bg,Fx,;!;mp12=0,1d";
|
||||
|
||||
|
||||
/*
|
||||
@ -2209,19 +2200,14 @@ static const char _data_FX_MODE_NOISE16_4[] PROGMEM = "Noise 4@!,!;!,!,!;!;1d";
|
||||
//based on https://gist.github.com/kriegsman/5408ecd397744ba0393e
|
||||
uint16_t mode_colortwinkle()
|
||||
{
|
||||
const uint16_t cols = strip.isMatrix ? SEGMENT.virtualWidth() : 1;
|
||||
const uint16_t rows = strip.isMatrix ? SEGMENT.virtualHeight() : SEGMENT.virtualLength();
|
||||
|
||||
uint16_t dataSize = (cols*rows+7) >> 3; //1 bit per LED
|
||||
uint16_t dataSize = (SEGLEN+7) >> 3; //1 bit per LED
|
||||
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
||||
|
||||
CRGB fastled_col, prev;
|
||||
fract8 fadeUpAmount = strip.getBrightness()>28 ? 8 + (SEGMENT.speed>>2) : 68-strip.getBrightness();
|
||||
fract8 fadeDownAmount = strip.getBrightness()>28 ? 8 + (SEGMENT.speed>>3) : 68-strip.getBrightness();
|
||||
|
||||
for (int i = 0; i < rows*cols; i++) {
|
||||
uint16_t j = i % cols, k = i / cols;
|
||||
fastled_col = CRGB(strip.isMatrix ? SEGMENT.getPixelColorXY(j, k) : SEGMENT.getPixelColor(i)); // TODO
|
||||
for (uint16_t i = 0; i < SEGLEN; i++) {
|
||||
fastled_col = SEGMENT.getPixelColor(i);
|
||||
prev = fastled_col;
|
||||
uint16_t index = i >> 3;
|
||||
uint8_t bitNum = i & 0x07;
|
||||
@ -2235,36 +2221,28 @@ uint16_t mode_colortwinkle()
|
||||
if (fastled_col.red == 255 || fastled_col.green == 255 || fastled_col.blue == 255) {
|
||||
bitWrite(SEGENV.data[index], bitNum, false);
|
||||
}
|
||||
SEGMENT.setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
||||
|
||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(j, k, fastled_col);
|
||||
else SEGMENT.setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
||||
|
||||
uint32_t col = strip.isMatrix ? SEGMENT.getPixelColorXY(j, k) : SEGMENT.getPixelColor(i); // TODO
|
||||
if (CRGB(col) == prev) { //fix "stuck" pixels
|
||||
if (SEGMENT.getPixelColor(i) == RGBW32(prev.r, prev.g, prev.b, 0)) { //fix "stuck" pixels
|
||||
fastled_col += fastled_col;
|
||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(j, k, fastled_col);
|
||||
else SEGMENT.setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
||||
SEGMENT.setPixelColor(i, fastled_col);
|
||||
}
|
||||
} else {
|
||||
fastled_col.nscale8(255 - fadeDownAmount);
|
||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(j, k, fastled_col);
|
||||
else SEGMENT.setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
||||
SEGMENT.setPixelColor(i, fastled_col);
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j <= rows*cols / 50; j++) {
|
||||
for (uint16_t j = 0; j <= SEGLEN / 50; j++) {
|
||||
if (random8() <= SEGMENT.intensity) {
|
||||
for (size_t times = 0; times < 5; times++) { //attempt to spawn a new pixel 5 times
|
||||
uint16_t i = random16(rows*cols);
|
||||
uint16_t j = i % cols, k = i / cols;
|
||||
uint32_t col = strip.isMatrix ? SEGMENT.getPixelColorXY(j, k) : SEGMENT.getPixelColor(i); // TODO
|
||||
if (col == 0) {
|
||||
for (uint8_t times = 0; times < 5; times++) { //attempt to spawn a new pixel 5 times
|
||||
int i = random16(SEGLEN);
|
||||
if (SEGMENT.getPixelColor(i) == 0) {
|
||||
fastled_col = ColorFromPalette(SEGPALETTE, random8(), 64, NOBLEND);
|
||||
uint16_t index = i >> 3;
|
||||
uint8_t bitNum = i & 0x07;
|
||||
bitWrite(SEGENV.data[index], bitNum, true);
|
||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(j, k, fastled_col);
|
||||
else SEGMENT.setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
||||
SEGMENT.setPixelColor(i, fastled_col);
|
||||
break; //only spawn 1 new pixel per frame per 50 LEDs
|
||||
}
|
||||
}
|
||||
@ -2272,7 +2250,7 @@ uint16_t mode_colortwinkle()
|
||||
}
|
||||
return FRAMETIME_FIXED;
|
||||
}
|
||||
static const char _data_FX_MODE_COLORTWINKLE[] PROGMEM = "Colortwinkles@Fade speed,Spawn speed;1,2,3;!;1d,2d"; //pixels
|
||||
static const char _data_FX_MODE_COLORTWINKLE[] PROGMEM = "Colortwinkles@Fade speed,Spawn speed;1,2,3;!;mp12=0,1d"; //pixels
|
||||
|
||||
|
||||
//Calm effect, like a lake at night
|
||||
@ -2651,13 +2629,13 @@ static const char _data_FX_MODE_TWINKLECAT[] PROGMEM = "Twinklecat";
|
||||
|
||||
|
||||
//inspired by https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/#LEDStripEffectBlinkingHalloweenEyes
|
||||
#define HALLOWEEN_EYE_SPACE (2*MAX(1,SEGLEN>>5))
|
||||
#define HALLOWEEN_EYE_WIDTH MAX(1,SEGLEN>>5)
|
||||
|
||||
uint16_t mode_halloween_eyes()
|
||||
{
|
||||
const uint16_t maxWidth = strip.isMatrix ? SEGMENT.virtualWidth() : SEGLEN;
|
||||
const uint16_t HALLOWEEN_EYE_SPACE = MAX(2, strip.isMatrix ? SEGMENT.virtualWidth()>>4: SEGLEN>>5);
|
||||
const uint16_t HALLOWEEN_EYE_WIDTH = HALLOWEEN_EYE_SPACE/2;
|
||||
uint16_t eyeLength = (2*HALLOWEEN_EYE_WIDTH) + HALLOWEEN_EYE_SPACE;
|
||||
if (eyeLength > SEGLEN) return mode_static(); //bail if segment too short
|
||||
if (eyeLength >= maxWidth) return mode_static(); //bail if segment too short
|
||||
|
||||
SEGMENT.fill(SEGCOLOR(1)); //fill background
|
||||
|
||||
@ -2666,7 +2644,7 @@ uint16_t mode_halloween_eyes()
|
||||
if (stateTime == 0) stateTime = 2000;
|
||||
|
||||
if (state == 0) { //spawn eyes
|
||||
SEGENV.aux0 = random16(0, SEGLEN - eyeLength); //start pos
|
||||
SEGENV.aux0 = random16(0, maxWidth - eyeLength - 1); //start pos
|
||||
SEGENV.aux1 = random8(); //color
|
||||
if (strip.isMatrix) SEGMENT.offset = random16(SEGMENT.virtualHeight()-1); // a hack: reuse offset since it is not used in matrices
|
||||
state = 1;
|
||||
@ -2696,9 +2674,9 @@ uint16_t mode_halloween_eyes()
|
||||
if (state > 2) state = 0;
|
||||
|
||||
if (state < 2) {
|
||||
stateTime = 100 + (255 - SEGMENT.intensity)*10; //eye fade time
|
||||
stateTime = 100 + SEGMENT.intensity*10; //eye fade time
|
||||
} else {
|
||||
uint16_t eyeOffTimeBase = (255 - SEGMENT.speed)*10;
|
||||
uint16_t eyeOffTimeBase = (256 - SEGMENT.speed)*10;
|
||||
stateTime = eyeOffTimeBase + random16(eyeOffTimeBase);
|
||||
}
|
||||
SEGENV.step = strip.now;
|
||||
@ -2818,43 +2796,49 @@ typedef struct Ball {
|
||||
*/
|
||||
uint16_t mode_bouncing_balls(void) {
|
||||
//allocate segment data
|
||||
uint16_t maxNumBalls = 16;
|
||||
const uint16_t strips = SEGMENT.nrOfVStrips(); // adapt for 2D
|
||||
const size_t maxNumBalls = 16;
|
||||
uint16_t dataSize = sizeof(ball) * maxNumBalls;
|
||||
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
||||
if (!SEGENV.allocateData(dataSize * strips)) return mode_static(); //allocation failed
|
||||
|
||||
Ball* balls = reinterpret_cast<Ball*>(SEGENV.data);
|
||||
|
||||
SEGMENT.fill(SEGCOLOR(2) ? BLACK : SEGCOLOR(1));
|
||||
|
||||
// virtualStrip idea by @ewowi (Ewoud Wijma)
|
||||
// requires virtual strip # to be embedded into upper 16 bits of index in setPixelColor()
|
||||
// the following functions will not work on virtual strips: fill(), fade_out(), fadeToBlack(), blur()
|
||||
struct virtualStrip {
|
||||
static void runStrip(size_t stripNr, Ball* balls) {
|
||||
// number of balls based on intensity setting to max of 7 (cycles colors)
|
||||
// non-chosen color is a random color
|
||||
uint8_t numBalls = int(((SEGMENT.intensity * (maxNumBalls - 0.8f)) / 255) + 1);
|
||||
|
||||
float gravity = -9.81; // standard value of gravity
|
||||
float impactVelocityStart = sqrt( -2 * gravity);
|
||||
|
||||
unsigned long time = millis();
|
||||
uint16_t numBalls = (SEGMENT.intensity * (maxNumBalls - 1)) / 255 + 1; // minimum 1 ball
|
||||
const float gravity = -9.81; // standard value of gravity
|
||||
const bool hasCol2 = SEGCOLOR(2);
|
||||
const unsigned long time = millis();
|
||||
|
||||
if (SEGENV.call == 0) {
|
||||
for (size_t i = 0; i < maxNumBalls; i++) balls[i].lastBounceTime = time;
|
||||
}
|
||||
|
||||
bool hasCol2 = SEGCOLOR(2);
|
||||
SEGMENT.fill(hasCol2 ? BLACK : SEGCOLOR(1));
|
||||
|
||||
for (size_t i = 0; i < numBalls; i++) {
|
||||
float timeSinceLastBounce = (time - balls[i].lastBounceTime)/((255-SEGMENT.speed)*8/256 +1);
|
||||
float timeSinceLastBounce = (time - balls[i].lastBounceTime)/((255-SEGMENT.speed)/64 +1);
|
||||
float timeSec = timeSinceLastBounce/1000.0f;
|
||||
balls[i].height = 0.5 * gravity * (timeSec * timeSec) + balls[i].impactVelocity * timeSec; // avoid use pow(x, 2) - its extremely slow !
|
||||
balls[i].height = (0.5f * gravity * timeSec + balls[i].impactVelocity) * timeSec; // avoid use pow(x, 2) - its extremely slow !
|
||||
|
||||
if (balls[i].height < 0) { //start bounce
|
||||
balls[i].height = 0;
|
||||
if (balls[i].height <= 0.0f) {
|
||||
balls[i].height = 0.0f;
|
||||
//damping for better effect using multiple balls
|
||||
float dampening = 0.90 - float(i)/(float(numBalls) * float(numBalls)); // avoid use pow(x, 2) - its extremely slow !
|
||||
float dampening = 0.9f - float(i)/float(numBalls * numBalls); // avoid use pow(x, 2) - its extremely slow !
|
||||
balls[i].impactVelocity = dampening * balls[i].impactVelocity;
|
||||
balls[i].lastBounceTime = time;
|
||||
|
||||
if (balls[i].impactVelocity < 0.015) {
|
||||
if (balls[i].impactVelocity < 0.015f) {
|
||||
float impactVelocityStart = sqrt(-2 * gravity) * random8(5,11)/10.0f; // randomize impact velocity
|
||||
balls[i].impactVelocity = impactVelocityStart;
|
||||
}
|
||||
} else if (balls[i].height > 1.0f) {
|
||||
continue; // do not draw OOB ball
|
||||
}
|
||||
|
||||
uint32_t color = SEGCOLOR(0);
|
||||
@ -2864,13 +2848,19 @@ uint16_t mode_bouncing_balls(void) {
|
||||
color = SEGCOLOR(i % NUM_COLORS);
|
||||
}
|
||||
|
||||
uint16_t pos = roundf(balls[i].height * (SEGLEN - 1));
|
||||
SEGMENT.setPixelColor(pos, color);
|
||||
int pos = roundf(balls[i].height * (SEGLEN - 1));
|
||||
if (SEGLEN<32) SEGMENT.setPixelColor(pos | int((stripNr+1)<<16), color); // encode virtual strip into index
|
||||
else SEGMENT.setPixelColor(balls[i].height + (stripNr+1)*10.0f, color);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (int stripNr=0; stripNr<strips; stripNr++)
|
||||
virtualStrip::runStrip(stripNr, &balls[stripNr * maxNumBalls]);
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_BOUNCINGBALLS[] PROGMEM = "Bouncing Balls@Gravity,# of balls;!,!,;!;mp12=2,1d"; //circle
|
||||
static const char _data_FX_MODE_BOUNCINGBALLS[] PROGMEM = "Bouncing Balls@Gravity,# of balls;!,!,!;!;mp12=1,1d"; //bar
|
||||
|
||||
|
||||
/*
|
||||
@ -2933,18 +2923,14 @@ uint16_t mode_glitter()
|
||||
{
|
||||
mode_palette();
|
||||
|
||||
if (strip.isMatrix) {
|
||||
uint16_t height = SEGMENT.virtualHeight();
|
||||
uint16_t width = SEGMENT.virtualWidth();
|
||||
for (int i = 0; i<height; i++) {
|
||||
if (SEGMENT.intensity > random8()) SEGMENT.setPixelColorXY(random16(width-1), i, ULTRAWHITE);
|
||||
if (SEGMENT.intensity > random8())
|
||||
{
|
||||
SEGMENT.setPixelColor(random16(SEGLEN), ULTRAWHITE);
|
||||
}
|
||||
} else
|
||||
if (SEGMENT.intensity > random8()) SEGMENT.setPixelColor(random16(SEGLEN), ULTRAWHITE);
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_GLITTER[] PROGMEM = "Glitter@,!;!,!,!;!;1d,2d"; //pixels
|
||||
static const char _data_FX_MODE_GLITTER[] PROGMEM = "Glitter@,!;!,!,!;!;mp12=0,1d"; //pixels
|
||||
|
||||
|
||||
//each needs 19 bytes
|
||||
@ -3480,66 +3466,86 @@ static const char _data_FX_MODE_DRIP[] PROGMEM = "Drip@Gravity,# of drips;!,!;!;
|
||||
* Tetris or Stacking (falling bricks) Effect
|
||||
* by Blaz Kristan (AKA blazoncek) (https://github.com/blazoncek, https://blaz.at/home)
|
||||
*/
|
||||
//12 bytes
|
||||
//20 bytes
|
||||
typedef struct Tetris {
|
||||
float pos;
|
||||
float speed;
|
||||
uint32_t col;
|
||||
uint16_t aux0; // 2D-fication of SEGENV.aux0 (brick size)
|
||||
uint16_t aux1; // 2D-fication of SEGENV.aux1 (stack size)
|
||||
uint32_t step; // 2D-fication of SEGENV.step (state)
|
||||
} tetris;
|
||||
|
||||
uint16_t mode_tetrix(void) {
|
||||
|
||||
uint16_t strips = SEGMENT.nrOfVStrips(); // allow running on virtual strips (columns in 2D segment)
|
||||
uint16_t dataSize = sizeof(tetris);
|
||||
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
||||
Tetris* drop = reinterpret_cast<Tetris*>(SEGENV.data);
|
||||
if (!SEGENV.allocateData(dataSize * strips)) return mode_static(); //allocation failed
|
||||
Tetris* drops = reinterpret_cast<Tetris*>(SEGENV.data);
|
||||
|
||||
if (SEGENV.call == 0) SEGMENT.fill(SEGCOLOR(1)); // will fill entire segment (1D or 2D)
|
||||
|
||||
// virtualStrip idea by @ewowi (Ewoud Wijma)
|
||||
// requires virtual strip # to be embedded into upper 16 bits of index in setPixelcolor()
|
||||
// the following functions will not work on virtual strips: fill(), fade_out(), fadeToBlack(), blur()
|
||||
struct virtualStrip {
|
||||
static void runStrip(size_t stripNr, Tetris *drop) {
|
||||
// initialize dropping on first call or segment full
|
||||
if (SEGENV.call == 0 /*|| SEGENV.aux1 >= SEGLEN*/) {
|
||||
SEGENV.aux1 = 0; // reset brick stack size
|
||||
SEGENV.step = 0;
|
||||
SEGMENT.fill(SEGCOLOR(1));
|
||||
//return 250; // short wait
|
||||
if (SEGENV.call == 0) {
|
||||
drop->aux1 = 0; // reset brick stack size
|
||||
drop->step = 0;
|
||||
//for (int i=0; i<SEGLEN; i++) SEGMENT.setPixelColor(i | int((stripNr+1)<<16), SEGCOLOR(1)); // will fill virtual strip only
|
||||
}
|
||||
|
||||
if (SEGENV.step == 0) { // init brick
|
||||
drop->speed = 0.0238 * (SEGMENT.speed ? (SEGMENT.speed>>2)+1 : random8(6,64)); // set speed
|
||||
if (drop->step == 0) { // init brick
|
||||
// speed calcualtion: a single brick should reach bottom of strip in X seconds
|
||||
// if the speed is set to 1 this should take 5s and at 255 it should take 0.25s
|
||||
// as this is dependant on SEGLEN it should be taken into account and the fact that effect runs every FRAMETIME s
|
||||
int speed = SEGMENT.speed ? SEGMENT.speed : random8(1,255);
|
||||
speed = map(speed, 1, 255, 5000, 250); // time taken for full (SEGLEN) drop
|
||||
drop->speed = float(SEGLEN * FRAMETIME) / float(speed); // set speed
|
||||
drop->pos = SEGLEN; // start at end of segment (no need to subtract 1)
|
||||
drop->col = SEGMENT.color_from_palette(random8(0,15)<<4,false,false,0); // limit color choices so there is enough HUE gap
|
||||
SEGENV.step = 1; // drop state (0 init, 1 forming, 2 falling)
|
||||
SEGENV.aux0 = (SEGMENT.intensity ? (SEGMENT.intensity>>5)+1 : random8(1,5)) * (1+(SEGLEN>>6)); // size of brick
|
||||
drop->step = 1; // drop state (0 init, 1 forming, 2 falling)
|
||||
drop->aux0 = (SEGMENT.intensity ? (SEGMENT.intensity>>5)+1 : random8(1,5)) * (1+(SEGLEN>>6)); // size of brick
|
||||
}
|
||||
|
||||
if (SEGENV.step == 1) { // forming
|
||||
if (drop->step == 1) { // forming
|
||||
if (random8()>>6) { // random drop
|
||||
SEGENV.step = 2; // fall
|
||||
drop->step = 2; // fall
|
||||
}
|
||||
}
|
||||
|
||||
if (SEGENV.step == 2) { // falling
|
||||
if (drop->pos > SEGENV.aux1) { // fall until top of stack
|
||||
if (drop->step == 2) { // falling
|
||||
if (drop->pos > drop->aux1) { // fall until top of stack
|
||||
drop->pos -= drop->speed; // may add gravity as: speed += gravity
|
||||
if (uint16_t(drop->pos) < SEGENV.aux1) drop->pos = SEGENV.aux1;
|
||||
for (int i=int(drop->pos); i<SEGLEN; i++) SEGMENT.setPixelColor(i,i<int(drop->pos)+SEGENV.aux0 ? drop->col : SEGCOLOR(1));
|
||||
if (uint16_t(drop->pos) < drop->aux1) drop->pos = drop->aux1;
|
||||
for (int i=int(drop->pos); i<SEGLEN; i++) SEGMENT.setPixelColor(i | int((stripNr+1)<<16), i<int(drop->pos)+drop->aux0 ? drop->col : SEGCOLOR(1));
|
||||
} else { // we hit bottom
|
||||
SEGENV.step = 0; // proceed with next brick, go back to init
|
||||
SEGENV.aux1 += SEGENV.aux0; // increase the stack size
|
||||
if (SEGENV.aux1 >= SEGLEN) SEGENV.step = millis() + 2500; // fade out stack
|
||||
drop->step = 0; // proceed with next brick, go back to init
|
||||
drop->aux1 += drop->aux0; // increase the stack size
|
||||
if (drop->aux1 >= SEGLEN) drop->step = millis() + 2000; // fade out stack
|
||||
}
|
||||
}
|
||||
|
||||
if (SEGENV.step > 2) {
|
||||
SEGENV.aux0 = 0; // reset brick size (no more growing)
|
||||
if (SEGENV.step > millis()) {
|
||||
SEGMENT.fade_out(24); // fade out stack
|
||||
if (drop->step > 2) {
|
||||
drop->aux0 = 0; // reset brick size (no more growing)
|
||||
if (drop->step > millis()) {
|
||||
// allow fading of virtual strip
|
||||
for (int i=0; i<SEGLEN; i++) SEGMENT.blendPixelColor(i | int((stripNr+1)<<16), SEGCOLOR(1), 25); // 10% blend
|
||||
} else {
|
||||
SEGENV.aux1 = 0; // reset brick stack size
|
||||
SEGENV.step = 0; // proceed with next brick
|
||||
drop->aux1 = 0; // reset brick stack size
|
||||
drop->step = 0; // proceed with next brick
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (int stripNr=0; stripNr<strips; stripNr++)
|
||||
virtualStrip::runStrip(stripNr, &drops[stripNr]);
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_TETRIX[] PROGMEM = "Tetrix@!,Width;!,!,;!;sx=224,ix=0,pal=11,mp12=1,1d"; //vertical
|
||||
static const char _data_FX_MODE_TETRIX[] PROGMEM = "Tetrix@!,Width;!,!,;!;sx=0,ix=0,pal=11,mp12=1,1d";
|
||||
|
||||
|
||||
/*
|
||||
@ -3574,7 +3580,8 @@ static const char _data_FX_MODE_PLASMA[] PROGMEM = "Plasma@Phase,;1,2,3;!;1d";
|
||||
*/
|
||||
uint16_t mode_percent(void) {
|
||||
|
||||
uint8_t percent = MAX(0, MIN(200, SEGMENT.intensity));
|
||||
uint8_t percent = SEGMENT.intensity;
|
||||
percent = constrain(percent, 0, 200);
|
||||
uint16_t active_leds = (percent < 100) ? SEGLEN * percent / 100.0
|
||||
: SEGLEN * (200 - percent) / 100.0;
|
||||
|
||||
@ -3769,18 +3776,14 @@ uint16_t mode_solid_glitter()
|
||||
{
|
||||
SEGMENT.fill(SEGCOLOR(0));
|
||||
|
||||
if (strip.isMatrix) {
|
||||
uint16_t height = SEGMENT.virtualHeight();
|
||||
uint16_t width = SEGMENT.virtualWidth();
|
||||
for (int i = 0; i<height; i++) {
|
||||
if (SEGMENT.intensity > random8()) SEGMENT.setPixelColorXY(random16(width-1), i, ULTRAWHITE);
|
||||
if (SEGMENT.intensity > random8())
|
||||
{
|
||||
SEGMENT.setPixelColor(random16(SEGLEN), ULTRAWHITE);
|
||||
}
|
||||
} else
|
||||
if (SEGMENT.intensity > random8()) SEGMENT.setPixelColor(random16(SEGLEN), ULTRAWHITE);
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_SOLID_GLITTER[] PROGMEM = "Solid Glitter@,!;!,,;0;1d,2d";
|
||||
static const char _data_FX_MODE_SOLID_GLITTER[] PROGMEM = "Solid Glitter@,!;!,,;0;mp12=0,1d";
|
||||
|
||||
|
||||
/*
|
||||
@ -3878,24 +3881,18 @@ static const char _data_FX_MODE_PHASEDNOISE[] PROGMEM = "Phased Noise";
|
||||
|
||||
|
||||
uint16_t mode_twinkleup(void) { // A very short twinkle routine with fade-in and dual controls. By Andrew Tuline.
|
||||
const uint16_t cols = strip.isMatrix ? SEGMENT.virtualWidth() : 1;
|
||||
const uint16_t rows = strip.isMatrix ? SEGMENT.virtualHeight() : SEGMENT.virtualLength();
|
||||
|
||||
random16_set_seed(535); // The randomizer needs to be re-set each time through the loop in order for the same 'random' numbers to be the same each time through.
|
||||
|
||||
for (int i = 0; i<rows*cols; i++) {
|
||||
uint16_t j = i % rows, k = i / rows;
|
||||
for (int i = 0; i<SEGLEN; i++) {
|
||||
uint8_t ranstart = random8(); // The starting value (aka brightness) for each pixel. Must be consistent each time through the loop for this to work.
|
||||
uint8_t pixBri = sin8(ranstart + 16 * strip.now/(256-SEGMENT.speed));
|
||||
if (random8() > SEGMENT.intensity) pixBri = 0;
|
||||
uint32_t col = color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(random8() + strip.now/100, false, PALETTE_SOLID_WRAP, 0), pixBri);
|
||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(j, k, col);
|
||||
else SEGMENT.setPixelColor(i, col);
|
||||
SEGMENT.setPixelColor(i, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(random8()+strip.now/100, false, PALETTE_SOLID_WRAP, 0), pixBri));
|
||||
}
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_TWINKLEUP[] PROGMEM = "Twinkleup@!,Intensity;!,!,;!;1d,2d";
|
||||
static const char _data_FX_MODE_TWINKLEUP[] PROGMEM = "Twinkleup@!,Intensity;!,!,;!;mp12=0,1d";
|
||||
|
||||
|
||||
// Peaceful noise that's slow and with gradually changing palettes. Does not support WLED palettes or default colours or controls.
|
||||
@ -4003,7 +4000,8 @@ static const char _data_FX_MODE_FLOW[] PROGMEM = "Flow@!,!;!,!,!;!;mp12=1,1d"; /
|
||||
*/
|
||||
uint16_t mode_chunchun(void)
|
||||
{
|
||||
SEGMENT.fill(SEGCOLOR(1));
|
||||
//SEGMENT.fill(SEGCOLOR(1));
|
||||
SEGMENT.fade_out(254); // add a bit of trail
|
||||
uint16_t counter = strip.now * (6 + (SEGMENT.speed >> 4));
|
||||
uint16_t numBirds = 2 + (SEGLEN >> 3); // 2 + 1/8 of a segment
|
||||
uint16_t span = (SEGMENT.intensity << 8) / numBirds;
|
||||
@ -4014,6 +4012,7 @@ uint16_t mode_chunchun(void)
|
||||
uint16_t megumin = sin16(counter) + 0x8000;
|
||||
uint16_t bird = uint32_t(megumin * SEGLEN) >> 16;
|
||||
uint32_t c = SEGMENT.color_from_palette((i * 255)/ numBirds, false, false, 0); // no palette wrapping
|
||||
bird = constrain(bird, 0, SEGLEN-1);
|
||||
SEGMENT.setPixelColor(bird, c);
|
||||
}
|
||||
return FRAMETIME;
|
||||
@ -4941,7 +4940,7 @@ uint16_t mode_2DHiphotic() { // By: ldirko https://edit
|
||||
|
||||
const uint16_t cols = SEGMENT.virtualWidth();
|
||||
const uint16_t rows = SEGMENT.virtualHeight();
|
||||
const uint32_t a = strip.now / 8;
|
||||
const uint32_t a = strip.now / ((SEGMENT.custom3>>1)+1);
|
||||
|
||||
for (int x = 0; x < cols; x++) {
|
||||
for (int y = 0; y < rows; y++) {
|
||||
@ -4951,7 +4950,7 @@ uint16_t mode_2DHiphotic() { // By: ldirko https://edit
|
||||
|
||||
return FRAMETIME;
|
||||
} // mode_2DHiphotic()
|
||||
static const char _data_FX_MODE_2DHIPHOTIC[] PROGMEM = "Hiphotic@X scale,Y scale;;!;2d";
|
||||
static const char _data_FX_MODE_2DHIPHOTIC[] PROGMEM = "Hiphotic@X scale,Y scale,,,Speed;;!;2d";
|
||||
|
||||
|
||||
/////////////////////////
|
||||
|
@ -339,9 +339,9 @@
|
||||
|
||||
typedef enum mapping1D2D {
|
||||
M12_Pixels = 0,
|
||||
M12_VerticalBar = 1,
|
||||
M12_Circle = 2,
|
||||
M12_Block = 3
|
||||
M12_pBar = 1,
|
||||
M12_pArc = 2,
|
||||
M12_pCorner = 3
|
||||
} mapping1D2D_t;
|
||||
|
||||
// segment, 72 bytes
|
||||
@ -551,7 +551,7 @@ typedef struct Segment {
|
||||
void setPixelColor(float i, uint32_t c, bool aa = true);
|
||||
void setPixelColor(float i, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0, bool aa = true) { setPixelColor(i, RGBW32(r,g,b,w), aa); }
|
||||
void setPixelColor(float i, CRGB c, bool aa = true) { setPixelColor(i, RGBW32(c.r,c.g,c.b,0), aa); }
|
||||
uint32_t getPixelColor(uint16_t i);
|
||||
uint32_t getPixelColor(int i);
|
||||
// 1D support functions (some implement 2D as well)
|
||||
void blur(uint8_t);
|
||||
void fill(uint32_t c);
|
||||
@ -570,6 +570,7 @@ typedef struct Segment {
|
||||
// 2D matrix
|
||||
uint16_t virtualWidth(void) const;
|
||||
uint16_t virtualHeight(void) const;
|
||||
uint16_t nrOfVStrips(void) const;
|
||||
#ifndef WLED_DISABLE_2D
|
||||
uint16_t XY(uint16_t x, uint16_t y); // support function to get relative index within segment (for leds[])
|
||||
void setPixelColorXY(int x, int y, uint32_t c); // set relative pixel within segment with color
|
||||
|
@ -209,10 +209,10 @@ void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa)
|
||||
uint16_t xR = roundf(fX+0.49f);
|
||||
uint16_t yT = roundf(fY-0.49f);
|
||||
uint16_t yB = roundf(fY+0.49f);
|
||||
float dL = fX - xL;
|
||||
float dR = xR - fX;
|
||||
float dT = fY - yT;
|
||||
float dB = yB - fY;
|
||||
float dL = (fX - xL)*(fX - xL);
|
||||
float dR = (xR - fX)*(xR - fX);
|
||||
float dT = (fY - yT)*(fY - yT);
|
||||
float dB = (yB - fY)*(yB - fY);
|
||||
uint32_t cXLYT = getPixelColorXY(xL, yT);
|
||||
uint32_t cXRYT = getPixelColorXY(xR, yT);
|
||||
uint32_t cXLYB = getPixelColorXY(xL, yB);
|
||||
|
@ -196,9 +196,93 @@ void Segment::setUpLeds() {
|
||||
#else
|
||||
leds = &Segment::_globalLeds[start];
|
||||
#endif
|
||||
else if (!leds)
|
||||
else if (!leds) {
|
||||
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
|
||||
if (psramFound())
|
||||
leds = (CRGB*)ps_malloc(sizeof(CRGB)*length());
|
||||
else
|
||||
#endif
|
||||
leds = (CRGB*)malloc(sizeof(CRGB)*length());
|
||||
}
|
||||
}
|
||||
|
||||
CRGBPalette16 &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
|
||||
static unsigned long _lastPaletteChange = 0; // perhaps it should be per segment
|
||||
byte tcp[72];
|
||||
if (pal < 245 && pal > GRADIENT_PALETTE_COUNT+13) pal = 0;
|
||||
if (pal > 245 && (strip.customPalettes.size() == 0 || 255U-pal > strip.customPalettes.size()-1)) pal = 0;
|
||||
//default palette. Differs depending on effect
|
||||
if (pal == 0) switch (mode) {
|
||||
case FX_MODE_FIRE_2012 : pal = 35; break; // heat palette
|
||||
case FX_MODE_COLORWAVES : pal = 26; break; // landscape 33
|
||||
case FX_MODE_FILLNOISE8 : pal = 9; break; // ocean colors
|
||||
case FX_MODE_NOISE16_1 : pal = 20; break; // Drywet
|
||||
case FX_MODE_NOISE16_2 : pal = 43; break; // Blue cyan yellow
|
||||
case FX_MODE_NOISE16_3 : pal = 35; break; // heat palette
|
||||
case FX_MODE_NOISE16_4 : pal = 26; break; // landscape 33
|
||||
case FX_MODE_GLITTER : pal = 11; break; // rainbow colors
|
||||
case FX_MODE_SUNRISE : pal = 35; break; // heat palette
|
||||
case FX_MODE_FLOW : pal = 6; break; // party
|
||||
}
|
||||
switch (pal) {
|
||||
case 0: //default palette. Exceptions for specific effects above
|
||||
targetPalette = PartyColors_p; break;
|
||||
case 1: //periodically replace palette with a random one. Doesn't work with multiple FastLED segments
|
||||
if (millis() - _lastPaletteChange > 5000 /*+ ((uint32_t)(255-intensity))*100*/) {
|
||||
targetPalette = CRGBPalette16(
|
||||
CHSV(random8(), 255, random8(128, 255)),
|
||||
CHSV(random8(), 255, random8(128, 255)),
|
||||
CHSV(random8(), 192, random8(128, 255)),
|
||||
CHSV(random8(), 255, random8(128, 255)));
|
||||
_lastPaletteChange = millis();
|
||||
} break;
|
||||
case 2: {//primary color only
|
||||
CRGB prim = strip.gammaCorrectCol ? gamma32(colors[0]) : colors[0];
|
||||
targetPalette = CRGBPalette16(prim); break;}
|
||||
case 3: {//primary + secondary
|
||||
CRGB prim = strip.gammaCorrectCol ? gamma32(colors[0]) : colors[0];
|
||||
CRGB sec = strip.gammaCorrectCol ? gamma32(colors[1]) : colors[1];
|
||||
targetPalette = CRGBPalette16(prim,prim,sec,sec); break;}
|
||||
case 4: {//primary + secondary + tertiary
|
||||
CRGB prim = strip.gammaCorrectCol ? gamma32(colors[0]) : colors[0];
|
||||
CRGB sec = strip.gammaCorrectCol ? gamma32(colors[1]) : colors[1];
|
||||
CRGB ter = strip.gammaCorrectCol ? gamma32(colors[2]) : colors[2];
|
||||
targetPalette = CRGBPalette16(ter,sec,prim); break;}
|
||||
case 5: {//primary + secondary (+tert if not off), more distinct
|
||||
CRGB prim = strip.gammaCorrectCol ? gamma32(colors[0]) : colors[0];
|
||||
CRGB sec = strip.gammaCorrectCol ? gamma32(colors[1]) : colors[1];
|
||||
if (colors[2]) {
|
||||
CRGB ter = strip.gammaCorrectCol ? gamma32(colors[2]) : colors[2];
|
||||
targetPalette = CRGBPalette16(prim,prim,prim,prim,prim,sec,sec,sec,sec,sec,ter,ter,ter,ter,ter,prim);
|
||||
} else {
|
||||
targetPalette = CRGBPalette16(prim,prim,prim,prim,prim,prim,prim,prim,sec,sec,sec,sec,sec,sec,sec,sec);
|
||||
}
|
||||
break;}
|
||||
case 6: //Party colors
|
||||
targetPalette = PartyColors_p; break;
|
||||
case 7: //Cloud colors
|
||||
targetPalette = CloudColors_p; break;
|
||||
case 8: //Lava colors
|
||||
targetPalette = LavaColors_p; break;
|
||||
case 9: //Ocean colors
|
||||
targetPalette = OceanColors_p; break;
|
||||
case 10: //Forest colors
|
||||
targetPalette = ForestColors_p; break;
|
||||
case 11: //Rainbow colors
|
||||
targetPalette = RainbowColors_p; break;
|
||||
case 12: //Rainbow stripe colors
|
||||
targetPalette = RainbowStripeColors_p; break;
|
||||
default: //progmem palettes
|
||||
if (pal>245) {
|
||||
targetPalette = strip.customPalettes[255-pal]; // we checked bounds above
|
||||
} else {
|
||||
memcpy_P(tcp, (byte*)pgm_read_dword(&(gGradientPalettes[pal-13])), 72);
|
||||
targetPalette.loadDynamicGradientPalette(tcp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return targetPalette;
|
||||
}
|
||||
|
||||
void Segment::startTransition(uint16_t dur) {
|
||||
if (transitional || _t) return; // already in transition no need to store anything
|
||||
@ -251,84 +335,6 @@ uint32_t Segment::currentColor(uint8_t slot, uint32_t colorNew) {
|
||||
return transitional && _t ? color_blend(_t->_colorT[slot], colorNew, progress(), true) : colorNew;
|
||||
}
|
||||
|
||||
CRGBPalette16 &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
|
||||
static unsigned long _lastPaletteChange = 0; // perhaps it should be per segment
|
||||
byte tcp[72];
|
||||
if (pal < 245 && pal > GRADIENT_PALETTE_COUNT+13) pal = 0;
|
||||
if (pal > 245 && (strip.customPalettes.size() == 0 || 255U-pal > strip.customPalettes.size()-1)) pal = 0;
|
||||
//default palette. Differs depending on effect
|
||||
if (pal == 0) switch (mode) {
|
||||
case FX_MODE_FIRE_2012 : pal = 35; break; // heat palette
|
||||
case FX_MODE_COLORWAVES : pal = 26; break; // landscape 33
|
||||
case FX_MODE_FILLNOISE8 : pal = 9; break; // ocean colors
|
||||
case FX_MODE_NOISE16_1 : pal = 20; break; // Drywet
|
||||
case FX_MODE_NOISE16_2 : pal = 43; break; // Blue cyan yellow
|
||||
case FX_MODE_NOISE16_3 : pal = 35; break; // heat palette
|
||||
case FX_MODE_NOISE16_4 : pal = 26; break; // landscape 33
|
||||
case FX_MODE_GLITTER : pal = 11; break; // rainbow colors
|
||||
case FX_MODE_SUNRISE : pal = 35; break; // heat palette
|
||||
case FX_MODE_FLOW : pal = 6; break; // party
|
||||
}
|
||||
switch (pal) {
|
||||
case 0: //default palette. Exceptions for specific effects above
|
||||
targetPalette = PartyColors_p; break;
|
||||
case 1: {//periodically replace palette with a random one. Doesn't work with multiple FastLED segments
|
||||
if (millis() - _lastPaletteChange > 1000 + ((uint32_t)(255-intensity))*100) {
|
||||
targetPalette = CRGBPalette16(
|
||||
CHSV(random8(), 255, random8(128, 255)),
|
||||
CHSV(random8(), 255, random8(128, 255)),
|
||||
CHSV(random8(), 192, random8(128, 255)),
|
||||
CHSV(random8(), 255, random8(128, 255)));
|
||||
_lastPaletteChange = millis();
|
||||
} break;}
|
||||
case 2: {//primary color only
|
||||
CRGB prim = strip.gammaCorrectCol ? gamma32(colors[0]) : colors[0];
|
||||
targetPalette = CRGBPalette16(prim); break;}
|
||||
case 3: {//primary + secondary
|
||||
CRGB prim = strip.gammaCorrectCol ? gamma32(colors[0]) : colors[0];
|
||||
CRGB sec = strip.gammaCorrectCol ? gamma32(colors[1]) : colors[1];
|
||||
targetPalette = CRGBPalette16(prim,prim,sec,sec); break;}
|
||||
case 4: {//primary + secondary + tertiary
|
||||
CRGB prim = strip.gammaCorrectCol ? gamma32(colors[0]) : colors[0];
|
||||
CRGB sec = strip.gammaCorrectCol ? gamma32(colors[1]) : colors[1];
|
||||
CRGB ter = strip.gammaCorrectCol ? gamma32(colors[2]) : colors[2];
|
||||
targetPalette = CRGBPalette16(ter,sec,prim); break;}
|
||||
case 5: {//primary + secondary (+tert if not off), more distinct
|
||||
CRGB prim = strip.gammaCorrectCol ? gamma32(colors[0]) : colors[0];
|
||||
CRGB sec = strip.gammaCorrectCol ? gamma32(colors[1]) : colors[1];
|
||||
if (colors[2]) {
|
||||
CRGB ter = strip.gammaCorrectCol ? gamma32(colors[2]) : colors[2];
|
||||
targetPalette = CRGBPalette16(prim,prim,prim,prim,prim,sec,sec,sec,sec,sec,ter,ter,ter,ter,ter,prim);
|
||||
} else {
|
||||
targetPalette = CRGBPalette16(prim,prim,prim,prim,prim,prim,prim,prim,sec,sec,sec,sec,sec,sec,sec,sec);
|
||||
}
|
||||
break;}
|
||||
case 6: //Party colors
|
||||
targetPalette = PartyColors_p; break;
|
||||
case 7: //Cloud colors
|
||||
targetPalette = CloudColors_p; break;
|
||||
case 8: //Lava colors
|
||||
targetPalette = LavaColors_p; break;
|
||||
case 9: //Ocean colors
|
||||
targetPalette = OceanColors_p; break;
|
||||
case 10: //Forest colors
|
||||
targetPalette = ForestColors_p; break;
|
||||
case 11: //Rainbow colors
|
||||
targetPalette = RainbowColors_p; break;
|
||||
case 12: //Rainbow stripe colors
|
||||
targetPalette = RainbowStripeColors_p; break;
|
||||
default: //progmem palettes
|
||||
if (pal>245) {
|
||||
targetPalette = strip.customPalettes[255-pal]; // we checked bounds above
|
||||
} else {
|
||||
memcpy_P(tcp, (byte*)pgm_read_dword(&(gGradientPalettes[pal-13])), 72);
|
||||
targetPalette.loadDynamicGradientPalette(tcp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return targetPalette;
|
||||
}
|
||||
|
||||
CRGBPalette16 &Segment::currentPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
|
||||
loadPalette(targetPalette, pal);
|
||||
if (transitional && _t && progress() < 0xFFFFU) {
|
||||
@ -400,19 +406,33 @@ uint16_t Segment::virtualHeight() const {
|
||||
return vHeight;
|
||||
}
|
||||
|
||||
uint16_t Segment::nrOfVStrips() const {
|
||||
uint16_t vLen = 1;
|
||||
#ifndef WLED_DISABLE_2D
|
||||
if (is2D()) {
|
||||
switch (map1D2D) {
|
||||
case M12_pBar:
|
||||
vLen = virtualWidth();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return vLen;
|
||||
}
|
||||
|
||||
// 1D strip
|
||||
uint16_t Segment::virtualLength() const {
|
||||
#ifndef WLED_DISABLE_2D
|
||||
if (is2D()) {
|
||||
uint16_t vW = virtualWidth();
|
||||
uint16_t vH = virtualHeight();
|
||||
uint32_t vLen = vW * vH; // use all pixels from segment
|
||||
uint16_t vLen = vW * vH; // use all pixels from segment
|
||||
switch (map1D2D) {
|
||||
case M12_VerticalBar:
|
||||
vLen = vW; // segment width since it is used in getPixelColor()
|
||||
case M12_pBar:
|
||||
vLen = vH;
|
||||
break;
|
||||
case M12_Block:
|
||||
case M12_Circle:
|
||||
case M12_pCorner:
|
||||
case M12_pArc:
|
||||
vLen = max(vW,vH); // get the longest dimension
|
||||
break;
|
||||
}
|
||||
@ -427,6 +447,11 @@ uint16_t Segment::virtualLength() const {
|
||||
|
||||
void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
|
||||
{
|
||||
int vStrip = i>>16; // hack to allow running on virtual strips (2D segment columns/rows)
|
||||
i &= 0xFFFF;
|
||||
|
||||
if (i >= virtualLength() || i<0) return; // if pixel would fall out of segment just exit
|
||||
|
||||
#ifndef WLED_DISABLE_2D
|
||||
if (is2D()) { // if this does not work use strip.isMatrix
|
||||
uint16_t vH = virtualHeight(); // segment height in logical pixels
|
||||
@ -436,16 +461,17 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
|
||||
// use all available pixels as a long strip
|
||||
setPixelColorXY(i % vW, i / vW, col);
|
||||
break;
|
||||
case M12_VerticalBar:
|
||||
// expand 1D effect vertically
|
||||
for (int y = 0; y < vH; y++) setPixelColorXY(i, y, col);
|
||||
case M12_pBar:
|
||||
// expand 1D effect vertically or have it play on virtual strips
|
||||
if (vStrip>0) setPixelColorXY(vStrip - 1, vH - i - 1, col);
|
||||
else for (int x = 0; x < vW; x++) setPixelColorXY(x, vH - i - 1, col);
|
||||
break;
|
||||
case M12_Circle:
|
||||
case M12_pArc:
|
||||
// expand in circular fashion from center
|
||||
if (i==0)
|
||||
setPixelColorXY(0, 0, col);
|
||||
else {
|
||||
float step = HALF_PI / (2*i);
|
||||
float step = HALF_PI / (2.85f*i);
|
||||
for (float rad = 0.0f; rad <= HALF_PI+step/2; rad += step) {
|
||||
// may want to try float version as well (with or without antialiasing)
|
||||
int x = roundf(sin_t(rad) * i);
|
||||
@ -454,22 +480,22 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case M12_Block:
|
||||
case M12_pCorner:
|
||||
for (int x = 0; x <= i; x++) setPixelColorXY(x, i, col);
|
||||
for (int y = 0; y < i; y++) setPixelColorXY(i, y, col);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
} else if (width()==1 && height()>1) {
|
||||
// we have a vertical 1D segment
|
||||
setPixelColorXY(0, i, col); // transpose
|
||||
} else if (width()>1 && height()==1) {
|
||||
// we have a horizontal 1D segment
|
||||
setPixelColorXY(i, 0, col);
|
||||
} else if (strip.isMatrix && (width()==1 || height()==1)) { // TODO remove this hack
|
||||
// we have a vertical or horizontal 1D segment (WARNING: virtual...() may be transposed)
|
||||
int x = 0, y = 0;
|
||||
if (virtualHeight()>1) y = i;
|
||||
if (virtualWidth() >1) x = i;
|
||||
setPixelColorXY(x, y, col);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (i >= virtualLength() || i<0) return; // if pixel would fall out of segment just exit
|
||||
if (leds) leds[i] = col;
|
||||
|
||||
uint16_t len = length();
|
||||
@ -513,34 +539,40 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
|
||||
// anti-aliased normalized version of setPixelColor()
|
||||
void Segment::setPixelColor(float i, uint32_t col, bool aa)
|
||||
{
|
||||
int vStrip = int(i/10.0f); // hack to allow running on virtual strips (2D segment columns/rows)
|
||||
i -= int(i);
|
||||
|
||||
if (i<0.0f || i>1.0f) return; // not normalized
|
||||
|
||||
float fC = i * (virtualLength()-1);
|
||||
if (aa) {
|
||||
uint16_t iL = roundf(fC-0.49f);
|
||||
uint16_t iR = roundf(fC+0.49f);
|
||||
float dL = fC - iL;
|
||||
float dR = iR - fC;
|
||||
uint32_t cIL = getPixelColor(iL);
|
||||
uint32_t cIR = getPixelColor(iR);
|
||||
float dL = (fC - iL)*(fC - iL);
|
||||
float dR = (iR - fC)*(iR - fC);
|
||||
uint32_t cIL = getPixelColor(iL | (vStrip<<16));
|
||||
uint32_t cIR = getPixelColor(iR | (vStrip<<16));
|
||||
if (iR!=iL) {
|
||||
// blend L pixel
|
||||
cIL = color_blend(col, cIL, uint8_t(dL*255.0f));
|
||||
setPixelColor(iL, cIL);
|
||||
setPixelColor(iL | (vStrip<<16), cIL);
|
||||
// blend R pixel
|
||||
cIR = color_blend(col, cIR, uint8_t(dR*255.0f));
|
||||
setPixelColor(iR, cIR);
|
||||
setPixelColor(iR | (vStrip<<16), cIR);
|
||||
} else {
|
||||
// exact match (x & y land on a pixel)
|
||||
setPixelColor(iL, col);
|
||||
setPixelColor(iL | (vStrip<<16), col);
|
||||
}
|
||||
} else {
|
||||
setPixelColor(uint16_t(roundf(fC)), col);
|
||||
setPixelColor(uint16_t(roundf(fC)) | (vStrip<<16), col);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Segment::getPixelColor(uint16_t i)
|
||||
uint32_t Segment::getPixelColor(int i)
|
||||
{
|
||||
int vStrip = i>>16;
|
||||
i &= 0xFFFF;
|
||||
|
||||
#ifndef WLED_DISABLE_2D
|
||||
if (is2D()) { // if this does not work use strip.isMatrix
|
||||
uint16_t vH = virtualHeight(); // segment height in logical pixels
|
||||
@ -549,11 +581,12 @@ uint32_t Segment::getPixelColor(uint16_t i)
|
||||
case M12_Pixels:
|
||||
return getPixelColorXY(i % vW, i / vW);
|
||||
break;
|
||||
case M12_VerticalBar:
|
||||
return getPixelColorXY(i, 0);
|
||||
case M12_pBar:
|
||||
if (vStrip>0) return getPixelColorXY(vStrip - 1, vH - i -1);
|
||||
else return getPixelColorXY(0, vH - i -1);
|
||||
break;
|
||||
case M12_Circle:
|
||||
case M12_Block:
|
||||
case M12_pArc:
|
||||
case M12_pCorner:
|
||||
// use longest dimension
|
||||
return vW>vH ? getPixelColorXY(i, 0) : getPixelColorXY(0, i);
|
||||
break;
|
||||
@ -1406,7 +1439,7 @@ void WS2812FX::setTransitionMode(bool t)
|
||||
void WS2812FX::printSize()
|
||||
{
|
||||
size_t size = 0;
|
||||
for (const Segment seg : _segments) size += seg.getSize();
|
||||
for (const Segment &seg : _segments) size += seg.getSize();
|
||||
DEBUG_PRINTF("Segments: %d -> %uB\n", _segments.size(), size);
|
||||
DEBUG_PRINTF("Modes: %d*%d=%uB\n", sizeof(mode_ptr), _mode.size(), (_mode.capacity()*sizeof(mode_ptr)));
|
||||
DEBUG_PRINTF("Data: %d*%d=%uB\n", sizeof(const char *), _modeData.size(), (_modeData.capacity()*sizeof(const char *)));
|
||||
|
@ -197,10 +197,10 @@ void handleAnalog(uint8_t b)
|
||||
// otherwise use "double press" for segment selection
|
||||
Segment& seg = strip.getSegment(macroDoublePress[b]);
|
||||
if (aRead == 0) {
|
||||
seg.on = false; // off
|
||||
seg.setOption(SEG_OPTION_ON, false); // off (use transition)
|
||||
} else {
|
||||
seg.setOpacity(aRead);
|
||||
seg.on = true;
|
||||
seg.setOption(SEG_OPTION_ON, true); // on (use transition)
|
||||
}
|
||||
// this will notify clients of update (websockets,mqtt,etc)
|
||||
updateInterfaces(CALL_MODE_BUTTON);
|
||||
|
@ -283,11 +283,13 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
||||
JsonArray hw_if_spi = hw[F("if")][F("spi-pin")];
|
||||
CJSON(spi_mosi, hw_if_spi[0]);
|
||||
CJSON(spi_sclk, hw_if_spi[1]);
|
||||
PinManagerPinType spi[3] = { { spi_mosi, true }, { spi_sclk, true } };
|
||||
if (spi_mosi >= 0 && spi_sclk >= 0 && pinManager.allocateMultiplePins(spi, 2, PinOwner::HW_SPI)) {
|
||||
CJSON(spi_miso, hw_if_spi[2]);
|
||||
PinManagerPinType spi[3] = { { spi_mosi, true }, { spi_miso, true }, { spi_sclk, true } };
|
||||
if (spi_mosi >= 0 && spi_sclk >= 0 && pinManager.allocateMultiplePins(spi, 3, PinOwner::HW_SPI)) {
|
||||
// do not initialise bus here
|
||||
} else {
|
||||
spi_mosi = -1;
|
||||
spi_miso = -1;
|
||||
spi_sclk = -1;
|
||||
}
|
||||
|
||||
@ -746,6 +748,7 @@ void serializeConfig() {
|
||||
JsonArray hw_if_spi = hw_if.createNestedArray("spi-pin");
|
||||
hw_if_spi.add(spi_mosi);
|
||||
hw_if_spi.add(spi_sclk);
|
||||
hw_if_spi.add(spi_miso);
|
||||
|
||||
//JsonObject hw_status = hw.createNestedObject("status");
|
||||
//hw_status["pin"] = -1;
|
||||
|
@ -384,6 +384,9 @@
|
||||
#if defined(ESP8266) && defined(HW_PIN_DATASPI)
|
||||
#undef HW_PIN_DATASPI
|
||||
#endif
|
||||
#if defined(ESP8266) && defined(HW_PIN_MISOSPI)
|
||||
#undef HW_PIN_MISOSPI
|
||||
#endif
|
||||
#if defined(ESP8266) && defined(HW_PIN_CSSPI)
|
||||
#undef HW_PIN_CSSPI
|
||||
#endif
|
||||
@ -394,6 +397,9 @@
|
||||
#ifndef HW_PIN_DATASPI
|
||||
#define HW_PIN_DATASPI MOSI
|
||||
#endif
|
||||
#ifndef HW_PIN_MISOSPI
|
||||
#define HW_PIN_MISOSPI MISO
|
||||
#endif
|
||||
#ifndef HW_PIN_CSSPI
|
||||
#define HW_PIN_CSSPI SS
|
||||
#endif
|
||||
|
@ -1219,6 +1219,12 @@ TD .checkmark, TD .radiomark {
|
||||
filter: grayscale(100%);
|
||||
}
|
||||
|
||||
.lbl-l {
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.lbl-s {
|
||||
display: inline-block;
|
||||
/* margin: 10px 4px 0 0; */
|
||||
|
@ -714,7 +714,7 @@ function populateSegments(s)
|
||||
}
|
||||
let map2D = `<div id="seg${i}map2D" data-map="map2D" class="lbl-s hide">Expand 1D FX<br>
|
||||
<div class="sel-p"><select class="sel-p" id="seg${i}mp12" onchange="setMp12(${i})">
|
||||
<option value="0" ${inst.mp12==0?' selected':''}>None</option>
|
||||
<option value="0" ${inst.mp12==0?' selected':''}>Pxels</option>
|
||||
<option value="1" ${inst.mp12==1?' selected':''}>Bar</option>
|
||||
<option value="2" ${inst.mp12==2?' selected':''}>Arc</option>
|
||||
<option value="3" ${inst.mp12==3?' selected':''}>Corner</option>
|
||||
@ -774,7 +774,7 @@ function populateSegments(s)
|
||||
${!isM?rvXck:''}
|
||||
${isM&&stoY-staY>1&&stoX-staX>1?map2D:''}
|
||||
${s.AudioReactive && s.AudioReactive.on ? "" : sndSim}
|
||||
<label class="check revchkl">
|
||||
<label class="check revchkl" id="seg${i}lbtm">
|
||||
${isM?'Transpose':'Mirror effect'}
|
||||
<input type="checkbox" id="seg${i}${isM?'tp':'mi'}" onchange="${(isM?'setTp(':'setMi(')+i})" ${isM?(inst.tp?"checked":""):(inst.mi?"checked":"")}>
|
||||
<span class="checkmark"></span>
|
||||
@ -826,7 +826,7 @@ function populateEffects()
|
||||
});
|
||||
|
||||
for (let ef of effects) {
|
||||
// WLEDSR: add slider and color control to setX (used by requestjson)
|
||||
// WLEDSR: add slider and color control to setFX (used by requestjson)
|
||||
let id = ef.id;
|
||||
let nm = ef.name+" ";
|
||||
let fd = "";
|
||||
@ -845,7 +845,7 @@ function populateEffects()
|
||||
if (r.substring(0,2)=="fr") nm += "♫"; // frequency effects
|
||||
}
|
||||
}
|
||||
html += generateListItemHtml('fx',id,nm,'setX','',fd);
|
||||
html += generateListItemHtml('fx',id,nm,'setFX','',fd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1035,17 +1035,28 @@ function updateLen(s)
|
||||
var stop = parseInt(gId(`seg${s}e`).value);
|
||||
var len = stop - (cfg.comp.seglen?0:start);
|
||||
if (isM) {
|
||||
// matrix setup
|
||||
let startY = parseInt(gId(`seg${s}sY`).value);
|
||||
let stopY = parseInt(gId(`seg${s}eY`).value);
|
||||
len *= (stopY-(cfg.comp.seglen?0:startY));
|
||||
let tPL = gId(`seg${s}lbtm`);
|
||||
if (stop-start>1 && stopY-startY>1) {
|
||||
// 2D segment
|
||||
tPL.classList.remove("hide"); // unhide transpose checkbox
|
||||
let sE = gId('fxlist').querySelector(`.lstI[data-id="${selectedFx}"]`);
|
||||
if (sE) {
|
||||
let sN = sE.querySelector(".lstIname").innerText;
|
||||
let seg = gId(`seg${s}map2D`);
|
||||
if (seg && sN.indexOf("\u25A6")<0) seg.classList.remove("hide"); else seg.classList.add("hide");
|
||||
if (seg) {
|
||||
if(sN.indexOf("\u25A6")<0) seg.classList.remove("hide"); // unhide mapping for 1D effects (| in name)
|
||||
else seg.classList.add("hide"); // hide mapping otherwise
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 1D segment in 2D set-up
|
||||
tPL.classList.add("hide"); // hide transpose checkbox
|
||||
gId(`seg${s}tp`).checked = false; // and uncheck it
|
||||
}
|
||||
}
|
||||
var out = "(delete)";
|
||||
if (len > 1) {
|
||||
@ -1394,7 +1405,7 @@ function setEffectParameters(idx)
|
||||
let top = parseInt(getComputedStyle(gId("sliders")).height);
|
||||
top += 5;
|
||||
let sel = d.querySelector('#fxlist .selected');
|
||||
if (sel) sel.style.bottom = top + "px"; // we will need to remove this when unselected (in setX())
|
||||
if (sel) sel.style.bottom = top + "px"; // we will need to remove this when unselected (in setFX())
|
||||
},750);
|
||||
// set html color items on/off
|
||||
var cslLabel = '';
|
||||
@ -1803,9 +1814,9 @@ ${makePlSel(plJson[i].end?plJson[i].end:0, true)}
|
||||
<span class="checkmark"></span>
|
||||
</label>`;
|
||||
if (Array.isArray(lastinfo.maps) && lastinfo.maps.length>0) {
|
||||
content += `<div class="sel">Ledmap: <select class="sel-p" id="p${i}lmp"><option value="">None</option>`;
|
||||
content += `<div class="lbl-l">Ledmap: <div class="sel-p"><select class="sel-p" id="p${i}lmp"><option value="">None</option>`;
|
||||
for (const k of (lastinfo.maps||[])) content += `<option value="${k}"${(i>0 && pJson[i].ledmap==k)?" selected":""}>${k}</option>`;
|
||||
content += "</select></div>";
|
||||
content += "</select></div></div>";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1821,13 +1832,8 @@ ${makePlSel(plJson[i].end?plJson[i].end:0, true)}
|
||||
<span class="checkmark"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="po2" id="p${i}o2">
|
||||
API command<br>
|
||||
<textarea class="apitxt" id="p${i}api"></textarea>
|
||||
</div>
|
||||
<div class="po1" id="p${i}o1">
|
||||
${content}
|
||||
</div>
|
||||
<div class="po2" id="p${i}o2">API command<br><textarea class="apitxt" id="p${i}api"></textarea></div>
|
||||
<div class="po1" id="p${i}o1">${content}</div>
|
||||
<div class="c">Save to ID <input class="noslide" id="p${i}id" type="number" oninput="checkUsed(${i})" max=250 min=1 value=${(i>0)?i:getLowestUnusedP()}></div>
|
||||
<div class="c">
|
||||
<button class="btn btn-p" onclick="saveP(${i},${pl})"><i class="icons btn-icon"></i>Save</button>
|
||||
@ -1843,6 +1849,10 @@ function makePUtil()
|
||||
p.classList.remove('staybot');
|
||||
p.classList.add('pres');
|
||||
p.innerHTML = `<div class="presin expanded">${makeP(0)}</div>`;
|
||||
let pTx = gId('p0txt');
|
||||
pTx.focus();
|
||||
pTx.value = eJson.find((o)=>{return o.id==selectedFx}).name;
|
||||
pTx.select();
|
||||
p.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'center'
|
||||
@ -1850,7 +1860,8 @@ function makePUtil()
|
||||
gId('psFind').classList.remove('staytop');
|
||||
}
|
||||
|
||||
function makePlEntry(p,i) {
|
||||
function makePlEntry(p,i)
|
||||
{
|
||||
return `<div class="plentry">
|
||||
<div class="hrz"></div>
|
||||
<table>
|
||||
@ -1886,6 +1897,7 @@ function makePlUtil()
|
||||
p.classList.remove('staybot');
|
||||
p.innerHTML = `<div class="pres"><div class="segin expanded" id="seg100">${makeP(0,true)}</div></div>`;
|
||||
refreshPlE(0);
|
||||
gId('p0txt').focus();
|
||||
p.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'center'
|
||||
@ -1913,7 +1925,11 @@ function tglCs(i)
|
||||
function tglSegn(s)
|
||||
{
|
||||
let t = gId(s<100?`seg${s}t`:`p${s-100}txt`);
|
||||
if (t) t.classList.toggle("show");
|
||||
if (t) {
|
||||
t.classList.toggle("show");
|
||||
t.focus();
|
||||
t.select();
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
@ -1979,6 +1995,7 @@ function setSeg(s)
|
||||
var stopY = parseInt(gId(`seg${s}eY`).value);
|
||||
obj.seg.startY = startY;
|
||||
obj.seg.stopY = (cfg.comp.seglen?startY:0)+stopY;
|
||||
obj.seg.tp = gId(`seg${s}tp`).checked;
|
||||
}
|
||||
if (gId(`seg${s}grp`)) {
|
||||
var grp = parseInt(gId(`seg${s}grp`).value);
|
||||
@ -2075,24 +2092,15 @@ function tglFreeze(s=null)
|
||||
requestJson(obj);
|
||||
}
|
||||
|
||||
function setX(ind = null)
|
||||
function setFX(ind = null)
|
||||
{
|
||||
if (ind === null) {
|
||||
ind = parseInt(d.querySelector('#fxlist input[name="fx"]:checked').value);
|
||||
} else {
|
||||
d.querySelector(`#fxlist input[name="fx"][value="${ind}"]`).checked = true;
|
||||
}
|
||||
/*
|
||||
// this code also in updateSelectedFx
|
||||
var selElement = d.querySelector('#fxlist .selected');
|
||||
if (selElement) {
|
||||
selElement.classList.remove('selected');
|
||||
selElement.style.bottom = null; // remove element style added in slider handling
|
||||
}
|
||||
|
||||
d.querySelector(`#fxlist .lstI[data-id="${ind}"]`).classList.add('selected');
|
||||
*/
|
||||
var obj = {"seg": {"fx": parseInt(ind)}};
|
||||
var obj = {"seg": {"fx": parseInt(ind),"fxdef":1}}; // fxdef sets effect parameters to default values, TODO add client setting
|
||||
requestJson(obj);
|
||||
}
|
||||
|
||||
@ -2103,13 +2111,7 @@ function setPalette(paletteId = null)
|
||||
} else {
|
||||
d.querySelector(`#pallist input[name="palette"][value="${paletteId}"]`).checked = true;
|
||||
}
|
||||
/*
|
||||
var selElement = d.querySelector('#pallist .selected');
|
||||
if (selElement) {
|
||||
selElement.classList.remove('selected')
|
||||
}
|
||||
d.querySelector(`#pallist .lstI[data-id="${paletteId}"]`).classList.add('selected');
|
||||
*/
|
||||
|
||||
var obj = {"seg": {"pal": paletteId}};
|
||||
requestJson(obj);
|
||||
}
|
||||
|
@ -211,7 +211,7 @@
|
||||
<i class="icons search-icon"></i>
|
||||
</div>
|
||||
<div id="fxlist" class="list">
|
||||
<div class="lstI" data-id="0" onClick="setX(0)"><a href="#0" onClick="setX(0)">Solid</a></div>
|
||||
<div class="lstI" data-id="0" onClick="setEffect(0)"><a href="#0" onClick="setEffect(0)">Solid</a></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="palDropdown" class="dd-content">
|
||||
|
@ -1124,7 +1124,7 @@ function setSegBri(s)
|
||||
function setEffect(ind = 0)
|
||||
{
|
||||
tglFxDropdown();
|
||||
var obj = {"seg": {"fx": parseInt(ind)}};
|
||||
var obj = {"seg": {"fx": parseInt(ind), "fxdef":true}}; // fxdef sets effect parameters to default values, TODO add client setting
|
||||
requestJson(obj);
|
||||
}
|
||||
|
||||
|
2239
wled00/html_simple.h
2239
wled00/html_simple.h
File diff suppressed because it is too large
Load Diff
3740
wled00/html_ui.h
3740
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@ -189,7 +189,7 @@ void sendImprovInfoResponse() {
|
||||
out[11] = 4; //Firmware len ("WLED")
|
||||
out[12] = 'W'; out[13] = 'L'; out[14] = 'E'; out[15] = 'D';
|
||||
uint8_t lengthSum = 17;
|
||||
uint8_t vlen = sprintf_P(out+lengthSum,PSTR("0.13.2-bl0/%i"),VERSION);
|
||||
uint8_t vlen = sprintf_P(out+lengthSum,PSTR("0.14.0-b0/%i"),VERSION);
|
||||
out[16] = vlen; lengthSum += vlen;
|
||||
uint8_t hlen = 7;
|
||||
#ifdef ESP8266
|
||||
|
@ -102,12 +102,12 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
byte segbri = seg.opacity;
|
||||
if (getVal(elem["bri"], &segbri)) {
|
||||
if (segbri > 0) seg.setOpacity(segbri);
|
||||
seg.on = segbri;
|
||||
seg.setOption(SEG_OPTION_ON, segbri); // use transition
|
||||
}
|
||||
|
||||
bool on = elem["on"] | seg.on;
|
||||
if (elem["on"].is<const char*>() && elem["on"].as<const char*>()[0] == 't') on = !on;
|
||||
seg.on = on;
|
||||
seg.setOption(SEG_OPTION_ON, on); // use transition
|
||||
bool frz = elem["frz"] | seg.freeze;
|
||||
if (elem["frz"].is<const char*>() && elem["frz"].as<const char*>()[0] == 't') frz = !seg.freeze;
|
||||
seg.freeze = frz;
|
||||
@ -178,14 +178,11 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
seg.startTransition(strip.getTransition()); // set effect transitions
|
||||
//seg.markForReset();
|
||||
seg.mode = fx;
|
||||
// load default values from effect string if effect is selected without
|
||||
// any other effect parameter (i.e. effect clicked in UI)
|
||||
if ( elem[F("sx")].isNull()
|
||||
&& elem[F("ix")].isNull()
|
||||
&& elem["pal"].isNull()
|
||||
&& elem[F("c1")].isNull()
|
||||
&& elem[F("c2")].isNull()
|
||||
&& elem[F("c3")].isNull() )
|
||||
}
|
||||
}
|
||||
|
||||
// load default values from effect string
|
||||
if (elem[F("fxdef")])
|
||||
{
|
||||
int16_t sOpt;
|
||||
sOpt = extractModeDefaults(fx, SET_F("sx")); if (sOpt >= 0) seg.speed = sOpt;
|
||||
@ -207,8 +204,6 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//getVal also supports inc/decrementing and random
|
||||
getVal(elem[F("sx")], &seg.speed);
|
||||
|
@ -502,23 +502,27 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
i2c_scl = -1;
|
||||
}
|
||||
int8_t hw_mosi_pin = !request->arg(F("MOSI")).length() ? -1 : max(-1,min(33,(int)request->arg(F("MOSI")).toInt()));
|
||||
int8_t hw_miso_pin = !request->arg(F("MISO")).length() ? -1 : max(-1,min(33,(int)request->arg(F("MISO")).toInt()));
|
||||
int8_t hw_sclk_pin = !request->arg(F("SCLK")).length() ? -1 : max(-1,min(33,(int)request->arg(F("SCLK")).toInt()));
|
||||
#ifdef ESP8266
|
||||
// cannot change pins on ESP8266
|
||||
if (hw_mosi_pin >= 0 && hw_mosi_pin != HW_PIN_DATASPI) hw_mosi_pin = HW_PIN_DATASPI;
|
||||
if (hw_miso_pin >= 0 && hw_miso_pin != HW_PIN_MISOSPI) hw_mosi_pin = HW_PIN_MISOSPI;
|
||||
if (hw_sclk_pin >= 0 && hw_sclk_pin != HW_PIN_CLOCKSPI) hw_sclk_pin = HW_PIN_CLOCKSPI;
|
||||
#endif
|
||||
PinManagerPinType spi[2] = { { hw_mosi_pin, true }, { hw_sclk_pin, true } };
|
||||
if (hw_mosi_pin >= 0 && hw_sclk_pin >= 0 && pinManager.allocateMultiplePins(spi, 2, PinOwner::HW_SPI)) {
|
||||
PinManagerPinType spi[3] = { { hw_mosi_pin, true }, { hw_miso_pin, true }, { hw_sclk_pin, true } };
|
||||
if (hw_mosi_pin >= 0 && hw_sclk_pin >= 0 && pinManager.allocateMultiplePins(spi, 3, PinOwner::HW_SPI)) {
|
||||
spi_mosi = hw_mosi_pin;
|
||||
spi_miso = hw_miso_pin;
|
||||
spi_sclk = hw_sclk_pin;
|
||||
// no bus initialisation
|
||||
} else {
|
||||
//SPI.end();
|
||||
DEBUG_PRINTLN(F("Could not allocate SPI pins."));
|
||||
uint8_t spi[2] = { spi_mosi, spi_sclk };
|
||||
pinManager.deallocateMultiplePins(spi, 2, PinOwner::HW_SPI); // just in case deallocation of old pins
|
||||
uint8_t spi[3] = { spi_mosi, spi_miso, spi_sclk };
|
||||
pinManager.deallocateMultiplePins(spi, 3, PinOwner::HW_SPI); // just in case deallocation of old pins
|
||||
spi_mosi = -1;
|
||||
spi_miso = -1;
|
||||
spi_sclk = -1;
|
||||
}
|
||||
|
||||
@ -713,7 +717,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
||||
pos = req.indexOf(F("SB=")); //Segment brightness/opacity
|
||||
if (pos > 0) {
|
||||
byte segbri = getNumVal(&req, pos);
|
||||
selseg.on = segbri;
|
||||
selseg.setOption(SEG_OPTION_ON, segbri); // use transition
|
||||
if (segbri) {
|
||||
selseg.setOpacity(segbri);
|
||||
}
|
||||
@ -722,9 +726,9 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
||||
pos = req.indexOf(F("SW=")); //segment power
|
||||
if (pos > 0) {
|
||||
switch (getNumVal(&req, pos)) {
|
||||
case 0: selseg.on = false; break;
|
||||
case 1: selseg.on = true; break;
|
||||
default: selseg.on = !selseg.on; break;
|
||||
case 0: selseg.setOption(SEG_OPTION_ON, false); break; // use transition
|
||||
case 1: selseg.setOption(SEG_OPTION_ON, true); break; // use transition
|
||||
default: selseg.setOption(SEG_OPTION_ON, !selseg.on); break; // use transition
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2208222
|
||||
#define VERSION 2208301
|
||||
|
||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||
//#define WLED_USE_MY_CONFIG
|
||||
@ -51,8 +51,8 @@
|
||||
|
||||
#ifndef WLED_WATCHDOG_TIMEOUT
|
||||
// 3 seconds should be enough to detect a lockup
|
||||
// define WLED_WATCHDOG_TIMEOUT=0 to disable watchdog
|
||||
#define WLED_WATCHDOG_TIMEOUT 3
|
||||
// define WLED_WATCHDOG_TIMEOUT=0 to disable watchdog, default
|
||||
#define WLED_WATCHDOG_TIMEOUT 0
|
||||
#endif
|
||||
|
||||
//optionally disable brownout detector on ESP32.
|
||||
@ -647,6 +647,7 @@ WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
|
||||
WLED_GLOBAL int8_t i2c_sda _INIT(-1); // global I2C SDA pin [HW_PIN_SDA] (used for usermods)
|
||||
WLED_GLOBAL int8_t i2c_scl _INIT(-1); // global I2C SCL pin [HW_PIN_SCL] (used for usermods)
|
||||
WLED_GLOBAL int8_t spi_mosi _INIT(-1); // global SPI DATA/MOSI pin [HW_PIN_DATASPI] (used for usermods)
|
||||
WLED_GLOBAL int8_t spi_miso _INIT(-1); // global SPI DATA/MISO pin [HW_PIN_MISOSPI] (used for usermods)
|
||||
WLED_GLOBAL int8_t spi_sclk _INIT(-1); // global SPI CLOCK/SCLK pin [HW_PIN_CLOCKSPI] (used for usermods)
|
||||
|
||||
// global ArduinoJson buffer
|
||||
|
@ -425,7 +425,7 @@ void deEEP() {
|
||||
for (byte j = 0; j < strip.getMaxSegments(); j++)
|
||||
{
|
||||
strip.getSegment(j).opacity = 255;
|
||||
strip.getSegment(j).on = true;
|
||||
strip.getSegment(j).setOption(SEG_OPTION_ON, true); // use transistion
|
||||
}
|
||||
}
|
||||
serializeState(pObj, true, false, true);
|
||||
|
@ -636,6 +636,7 @@ void getSettingsJS(byte subPage, char* dest)
|
||||
sappend('v',SET_F("SDA"),i2c_sda);
|
||||
sappend('v',SET_F("SCL"),i2c_scl);
|
||||
sappend('v',SET_F("MOSI"),spi_mosi);
|
||||
sappend('v',SET_F("MISO"),spi_miso);
|
||||
sappend('v',SET_F("SCLK"),spi_sclk);
|
||||
oappend(SET_F("addInfo('SDA','")); oappendi(HW_PIN_SDA); oappend(SET_F("');"));
|
||||
oappend(SET_F("addInfo('SCL','")); oappendi(HW_PIN_SCL); oappend(SET_F("');"));
|
||||
|
Loading…
Reference in New Issue
Block a user