Merge branch 'dev' into audioreactive-prototype
This commit is contained in:
commit
26793c8428
17
.vscode/extensions.json
vendored
17
.vscode/extensions.json
vendored
@ -1,7 +1,10 @@
|
|||||||
{
|
{
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
// for the documentation about the extensions.json format
|
// for the documentation about the extensions.json format
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"platformio.platformio-ide"
|
"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 = wemos_shield_esp32
|
||||||
; default_envs = m5atom
|
; default_envs = m5atom
|
||||||
; default_envs = esp32_eth
|
; default_envs = esp32_eth
|
||||||
|
; default_envs = esp32dev_qio80
|
||||||
; default_envs = esp32_eth_ota1mapp
|
; default_envs = esp32_eth_ota1mapp
|
||||||
; default_envs = esp32s2_saola
|
; default_envs = esp32s2_saola
|
||||||
|
|
||||||
@ -330,6 +331,18 @@ lib_deps = ${esp32.lib_deps}
|
|||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
board_build.partitions = ${esp32.default_partitions}
|
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]
|
[env:esp32_eth]
|
||||||
board = esp32-poe
|
board = esp32-poe
|
||||||
platform = ${esp32.platform}
|
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:
|
# To update, run:
|
||||||
#
|
#
|
||||||
# pip-compile
|
# pip-compile
|
||||||
#
|
#
|
||||||
aiofiles==0.6.0
|
aiofiles==0.8.0
|
||||||
# via platformio
|
# via platformio
|
||||||
ajsonrpc==1.1.0
|
ajsonrpc==1.2.0
|
||||||
# via platformio
|
# 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
|
# via platformio
|
||||||
certifi==2020.12.5
|
certifi==2022.6.15
|
||||||
# via requests
|
# via requests
|
||||||
chardet==4.0.0
|
charset-normalizer==2.1.1
|
||||||
# via requests
|
# via requests
|
||||||
click==7.1.2
|
click==8.1.3
|
||||||
# via
|
# via
|
||||||
# platformio
|
# platformio
|
||||||
# uvicorn
|
# uvicorn
|
||||||
colorama==0.4.4
|
colorama==0.4.5
|
||||||
# via platformio
|
# via
|
||||||
h11==0.12.0
|
# click
|
||||||
|
# platformio
|
||||||
|
h11==0.13.0
|
||||||
# via
|
# via
|
||||||
# uvicorn
|
# uvicorn
|
||||||
# wsproto
|
# wsproto
|
||||||
idna==2.10
|
idna==3.3
|
||||||
# via requests
|
# via
|
||||||
ifaddr==0.1.7
|
# anyio
|
||||||
|
# requests
|
||||||
|
ifaddr==0.2.0
|
||||||
# via zeroconf
|
# via zeroconf
|
||||||
marshmallow==3.11.1
|
marshmallow==3.17.0
|
||||||
# via platformio
|
# via platformio
|
||||||
platformio==5.1.1
|
packaging==21.3
|
||||||
|
# via marshmallow
|
||||||
|
platformio==6.1.4
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
pyelftools==0.27
|
pyelftools==0.29
|
||||||
# via platformio
|
# via platformio
|
||||||
|
pyparsing==3.0.9
|
||||||
|
# via packaging
|
||||||
pyserial==3.5
|
pyserial==3.5
|
||||||
# via platformio
|
# via platformio
|
||||||
requests==2.25.1
|
requests==2.28.1
|
||||||
# via platformio
|
# via platformio
|
||||||
semantic-version==2.8.5
|
semantic-version==2.10.0
|
||||||
# via platformio
|
# via platformio
|
||||||
starlette==0.14.2
|
sniffio==1.2.0
|
||||||
|
# via anyio
|
||||||
|
starlette==0.20.4
|
||||||
# via platformio
|
# via platformio
|
||||||
tabulate==0.8.9
|
tabulate==0.8.10
|
||||||
# via platformio
|
# via platformio
|
||||||
urllib3==1.26.5
|
typing-extensions==4.3.0
|
||||||
|
# via starlette
|
||||||
|
urllib3==1.26.11
|
||||||
# via requests
|
# via requests
|
||||||
uvicorn==0.13.4
|
uvicorn==0.18.2
|
||||||
# via platformio
|
# via platformio
|
||||||
wsproto==1.0.0
|
wsproto==1.1.0
|
||||||
# via platformio
|
# via platformio
|
||||||
zeroconf==0.28.8
|
zeroconf==0.39.0
|
||||||
# via platformio
|
# via platformio
|
||||||
|
@ -135,7 +135,7 @@ class PWMFanUsermod : public Usermod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateFanSpeed(uint8_t pwmValue){
|
void updateFanSpeed(uint8_t pwmValue){
|
||||||
if (pwmPin < 0) return;
|
if (!enabled || pwmPin < 0) return;
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
analogWrite(pwmPin, pwmValue);
|
analogWrite(pwmPin, pwmValue);
|
||||||
|
599
wled00/FX.cpp
599
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/
|
* Inspired by www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
|
||||||
*/
|
*/
|
||||||
uint16_t mode_twinkle(void) {
|
uint16_t mode_twinkle(void) {
|
||||||
const uint16_t cols = strip.isMatrix ? SEGMENT.virtualWidth() : SEGMENT.virtualLength();
|
//SEGMENT.fill(SEGCOLOR(1));
|
||||||
const uint16_t rows = SEGMENT.virtualHeight();
|
SEGMENT.fade_out(224);
|
||||||
|
|
||||||
SEGMENT.fill(SEGCOLOR(1));
|
|
||||||
|
|
||||||
uint32_t cycleTime = 20 + (255 - SEGMENT.speed)*5;
|
uint32_t cycleTime = 20 + (255 - SEGMENT.speed)*5;
|
||||||
uint32_t it = strip.now / cycleTime;
|
uint32_t it = strip.now / cycleTime;
|
||||||
if (it != SEGENV.step)
|
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)
|
if (SEGENV.aux0 >= maxOn)
|
||||||
{
|
{
|
||||||
SEGENV.aux0 = 0;
|
SEGENV.aux0 = 0;
|
||||||
@ -587,20 +585,17 @@ uint16_t mode_twinkle(void) {
|
|||||||
|
|
||||||
uint16_t PRNG16 = SEGENV.aux1;
|
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
|
PRNG16 = (uint16_t)(PRNG16 * 2053) + 13849; // next 'random' number
|
||||||
uint32_t p = ((uint32_t)cols*rows * (uint32_t)PRNG16) >> 16;
|
uint32_t p = (uint32_t)SEGLEN * (uint32_t)PRNG16;
|
||||||
uint16_t j = p % cols;
|
uint16_t j = p >> 16;
|
||||||
uint16_t k = p / cols;
|
SEGMENT.setPixelColor(j, SEGMENT.color_from_palette(j, true, PALETTE_SOLID_WRAP, 0));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FRAMETIME;
|
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
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -663,7 +658,7 @@ static const char _data_FX_MODE_DISSOLVE_RANDOM[] PROGMEM = "Dissolve Rnd@Repeat
|
|||||||
* Inspired by www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
|
* Inspired by www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
|
||||||
*/
|
*/
|
||||||
uint16_t mode_sparkle(void) {
|
uint16_t mode_sparkle(void) {
|
||||||
for (int i = 0; i < SEGLEN; i++) {
|
for(int i = 0; i < SEGLEN; i++) {
|
||||||
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 1));
|
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 1));
|
||||||
}
|
}
|
||||||
uint32_t cycleTime = 10 + (255 - SEGMENT.speed)*2;
|
uint32_t cycleTime = 10 + (255 - SEGMENT.speed)*2;
|
||||||
@ -671,15 +666,13 @@ uint16_t mode_sparkle(void) {
|
|||||||
if (it != SEGENV.step)
|
if (it != SEGENV.step)
|
||||||
{
|
{
|
||||||
SEGENV.aux0 = random16(SEGLEN); // aux0 stores the random led index
|
SEGENV.aux0 = random16(SEGLEN); // aux0 stores the random led index
|
||||||
SEGENV.aux1 = random16(0,SEGMENT.virtualHeight()-1);
|
|
||||||
SEGENV.step = it;
|
SEGENV.step = it;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(SEGENV.aux0, SEGENV.aux1, SEGCOLOR(0));
|
SEGMENT.setPixelColor(SEGENV.aux0, SEGCOLOR(0));
|
||||||
else SEGMENT.setPixelColor(SEGENV.aux0, SEGCOLOR(0));
|
|
||||||
return FRAMETIME;
|
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/
|
* Inspired by www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
|
||||||
*/
|
*/
|
||||||
uint16_t mode_flash_sparkle(void) {
|
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));
|
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strip.now - SEGENV.aux0 > SEGENV.step) {
|
if (strip.now - SEGENV.aux0 > SEGENV.step) {
|
||||||
if(random8((255-SEGMENT.intensity) >> 4) == 0) {
|
if(random8((255-SEGMENT.intensity) >> 4) == 0) {
|
||||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(random16(SEGLEN), random16(0,SEGMENT.virtualHeight()-1), SEGCOLOR(1));
|
SEGMENT.setPixelColor(random16(SEGLEN), SEGCOLOR(1)); //flash
|
||||||
else SEGMENT.setPixelColor(random16(SEGLEN), SEGCOLOR(1)); //flash
|
|
||||||
}
|
}
|
||||||
SEGENV.step = strip.now;
|
SEGENV.step = strip.now;
|
||||||
SEGENV.aux0 = 255-SEGMENT.speed;
|
SEGENV.aux0 = 255-SEGMENT.speed;
|
||||||
}
|
}
|
||||||
return FRAMETIME;
|
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";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -714,10 +706,9 @@ uint16_t mode_hyper_sparkle(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strip.now - SEGENV.aux0 > SEGENV.step) {
|
if (strip.now - SEGENV.aux0 > SEGENV.step) {
|
||||||
if(random8((255-SEGMENT.intensity) >> 4) == 0) {
|
if (random8((255-SEGMENT.intensity) >> 4) == 0) {
|
||||||
for (int i = 0; i < MAX(1, SEGLEN/3); i++) {
|
for (int i = 0; i < MAX(1, SEGLEN/3); i++) {
|
||||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(random16(SEGLEN), random16(0,SEGMENT.virtualHeight()), SEGCOLOR(1));
|
SEGMENT.setPixelColor(random16(SEGLEN), SEGCOLOR(1));
|
||||||
else SEGMENT.setPixelColor(random16(SEGLEN), SEGCOLOR(1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SEGENV.step = strip.now;
|
SEGENV.step = strip.now;
|
||||||
@ -725,7 +716,7 @@ uint16_t mode_hyper_sparkle(void) {
|
|||||||
}
|
}
|
||||||
return FRAMETIME;
|
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";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1350,7 +1341,7 @@ uint16_t police_base(uint32_t color1, uint32_t color2)
|
|||||||
uint32_t it = strip.now / map(SEGMENT.speed, 0, 255, delay<<4, delay);
|
uint32_t it = strip.now / map(SEGMENT.speed, 0, 255, delay<<4, delay);
|
||||||
uint16_t offset = it % SEGLEN;
|
uint16_t offset = it % SEGLEN;
|
||||||
|
|
||||||
uint16_t width = ((SEGLEN*(SEGMENT.intensity+1))>>9); //max width is half the strip
|
uint16_t width = ((SEGLEN*(SEGMENT.intensity+1))>>9); //max width is half the strip
|
||||||
if (!width) width = 1;
|
if (!width) width = 1;
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
uint16_t indexR = (offset + i) % SEGLEN;
|
uint16_t indexR = (offset + i) % SEGLEN;
|
||||||
@ -1389,82 +1380,82 @@ static const char _data_FX_MODE_TWO_DOTS[] PROGMEM = "Two Dots@!,Dot size;1,2,Bg
|
|||||||
typedef struct Flasher {
|
typedef struct Flasher {
|
||||||
uint16_t stateStart;
|
uint16_t stateStart;
|
||||||
uint8_t stateDur;
|
uint8_t stateDur;
|
||||||
bool stateOn;
|
bool stateOn;
|
||||||
} flasher;
|
} flasher;
|
||||||
|
|
||||||
#define FLASHERS_PER_ZONE 6
|
#define FLASHERS_PER_ZONE 6
|
||||||
#define MAX_SHIMMER 92
|
#define MAX_SHIMMER 92
|
||||||
|
|
||||||
uint16_t mode_fairy() {
|
uint16_t mode_fairy() {
|
||||||
//set every pixel to a 'random' color from palette (using seed so it doesn't change between frames)
|
//set every pixel to a 'random' color from palette (using seed so it doesn't change between frames)
|
||||||
uint16_t PRNG16 = 5100 + strip.getCurrSegmentId();
|
uint16_t PRNG16 = 5100 + strip.getCurrSegmentId();
|
||||||
for (int i = 0; i < SEGLEN; i++) {
|
for (int i = 0; i < SEGLEN; i++) {
|
||||||
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; //next 'random' number
|
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; //next 'random' number
|
||||||
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(PRNG16 >> 8, false, false, 0));
|
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(PRNG16 >> 8, false, false, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
//amount of flasher pixels depending on intensity (0: none, 255: every LED)
|
//amount of flasher pixels depending on intensity (0: none, 255: every LED)
|
||||||
if (SEGMENT.intensity == 0) return FRAMETIME;
|
if (SEGMENT.intensity == 0) return FRAMETIME;
|
||||||
uint8_t flasherDistance = ((255 - SEGMENT.intensity) / 28) +1; //1-10
|
uint8_t flasherDistance = ((255 - SEGMENT.intensity) / 28) +1; //1-10
|
||||||
uint16_t numFlashers = (SEGLEN / flasherDistance) +1;
|
uint16_t numFlashers = (SEGLEN / flasherDistance) +1;
|
||||||
|
|
||||||
uint16_t dataSize = sizeof(flasher) * numFlashers;
|
uint16_t dataSize = sizeof(flasher) * numFlashers;
|
||||||
if (!SEGENV.allocateData(dataSize)) return FRAMETIME; //allocation failed
|
if (!SEGENV.allocateData(dataSize)) return FRAMETIME; //allocation failed
|
||||||
Flasher* flashers = reinterpret_cast<Flasher*>(SEGENV.data);
|
Flasher* flashers = reinterpret_cast<Flasher*>(SEGENV.data);
|
||||||
uint16_t now16 = strip.now & 0xFFFF;
|
uint16_t now16 = strip.now & 0xFFFF;
|
||||||
|
|
||||||
//Up to 11 flashers in one brightness zone, afterwards a new zone for every 6 flashers
|
//Up to 11 flashers in one brightness zone, afterwards a new zone for every 6 flashers
|
||||||
uint16_t zones = numFlashers/FLASHERS_PER_ZONE;
|
uint16_t zones = numFlashers/FLASHERS_PER_ZONE;
|
||||||
if (!zones) zones = 1;
|
if (!zones) zones = 1;
|
||||||
uint8_t flashersInZone = numFlashers/zones;
|
uint8_t flashersInZone = numFlashers/zones;
|
||||||
uint8_t flasherBri[FLASHERS_PER_ZONE*2 -1];
|
uint8_t flasherBri[FLASHERS_PER_ZONE*2 -1];
|
||||||
|
|
||||||
for (int z = 0; z < zones; z++) {
|
for (int z = 0; z < zones; z++) {
|
||||||
uint16_t flasherBriSum = 0;
|
uint16_t flasherBriSum = 0;
|
||||||
uint16_t firstFlasher = z*flashersInZone;
|
uint16_t firstFlasher = z*flashersInZone;
|
||||||
if (z == zones-1) flashersInZone = numFlashers-(flashersInZone*(zones-1));
|
if (z == zones-1) flashersInZone = numFlashers-(flashersInZone*(zones-1));
|
||||||
|
|
||||||
for (int f = firstFlasher; f < firstFlasher + flashersInZone; f++) {
|
for (int f = firstFlasher; f < firstFlasher + flashersInZone; f++) {
|
||||||
uint16_t stateTime = now16 - flashers[f].stateStart;
|
uint16_t stateTime = now16 - flashers[f].stateStart;
|
||||||
//random on/off time reached, switch state
|
//random on/off time reached, switch state
|
||||||
if (stateTime > flashers[f].stateDur * 10) {
|
if (stateTime > flashers[f].stateDur * 10) {
|
||||||
flashers[f].stateOn = !flashers[f].stateOn;
|
flashers[f].stateOn = !flashers[f].stateOn;
|
||||||
if (flashers[f].stateOn) {
|
if (flashers[f].stateOn) {
|
||||||
flashers[f].stateDur = 12 + random8(12 + ((255 - SEGMENT.speed) >> 2)); //*10, 250ms to 1250ms
|
flashers[f].stateDur = 12 + random8(12 + ((255 - SEGMENT.speed) >> 2)); //*10, 250ms to 1250ms
|
||||||
} else {
|
} else {
|
||||||
flashers[f].stateDur = 20 + random8(6 + ((255 - SEGMENT.speed) >> 2)); //*10, 250ms to 1250ms
|
flashers[f].stateDur = 20 + random8(6 + ((255 - SEGMENT.speed) >> 2)); //*10, 250ms to 1250ms
|
||||||
}
|
}
|
||||||
//flashers[f].stateDur = 51 + random8(2 + ((255 - SEGMENT.speed) >> 1));
|
//flashers[f].stateDur = 51 + random8(2 + ((255 - SEGMENT.speed) >> 1));
|
||||||
flashers[f].stateStart = now16;
|
flashers[f].stateStart = now16;
|
||||||
if (stateTime < 255) {
|
if (stateTime < 255) {
|
||||||
flashers[f].stateStart -= 255 -stateTime; //start early to get correct bri
|
flashers[f].stateStart -= 255 -stateTime; //start early to get correct bri
|
||||||
flashers[f].stateDur += 26 - stateTime/10;
|
flashers[f].stateDur += 26 - stateTime/10;
|
||||||
stateTime = 255 - stateTime;
|
stateTime = 255 - stateTime;
|
||||||
} else {
|
} else {
|
||||||
stateTime = 0;
|
stateTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stateTime > 255) stateTime = 255; //for flasher brightness calculation, fades in first 255 ms of state
|
if (stateTime > 255) stateTime = 255; //for flasher brightness calculation, fades in first 255 ms of state
|
||||||
//flasherBri[f - firstFlasher] = (flashers[f].stateOn) ? 255-SEGMENT.gamma8((510 - stateTime) >> 1) : SEGMENT.gamma8((510 - stateTime) >> 1);
|
//flasherBri[f - firstFlasher] = (flashers[f].stateOn) ? 255-SEGMENT.gamma8((510 - stateTime) >> 1) : SEGMENT.gamma8((510 - stateTime) >> 1);
|
||||||
flasherBri[f - firstFlasher] = (flashers[f].stateOn) ? stateTime : 255 - (stateTime >> 0);
|
flasherBri[f - firstFlasher] = (flashers[f].stateOn) ? stateTime : 255 - (stateTime >> 0);
|
||||||
flasherBriSum += flasherBri[f - firstFlasher];
|
flasherBriSum += flasherBri[f - firstFlasher];
|
||||||
}
|
}
|
||||||
//dim factor, to create "shimmer" as other pixels get less voltage if a lot of flashers are on
|
//dim factor, to create "shimmer" as other pixels get less voltage if a lot of flashers are on
|
||||||
uint8_t avgFlasherBri = flasherBriSum / flashersInZone;
|
uint8_t avgFlasherBri = flasherBriSum / flashersInZone;
|
||||||
uint8_t globalPeakBri = 255 - ((avgFlasherBri * MAX_SHIMMER) >> 8); //183-255, suitable for 1/5th of LEDs flashers
|
uint8_t globalPeakBri = 255 - ((avgFlasherBri * MAX_SHIMMER) >> 8); //183-255, suitable for 1/5th of LEDs flashers
|
||||||
|
|
||||||
for (int f = firstFlasher; f < firstFlasher + flashersInZone; f++) {
|
for (int f = firstFlasher; f < firstFlasher + flashersInZone; f++) {
|
||||||
uint8_t bri = (flasherBri[f - firstFlasher] * globalPeakBri) / 255;
|
uint8_t bri = (flasherBri[f - firstFlasher] * globalPeakBri) / 255;
|
||||||
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; //next 'random' number
|
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; //next 'random' number
|
||||||
uint16_t flasherPos = f*flasherDistance;
|
uint16_t flasherPos = f*flasherDistance;
|
||||||
SEGMENT.setPixelColor(flasherPos, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(PRNG16 >> 8, false, false, 0), bri));
|
SEGMENT.setPixelColor(flasherPos, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(PRNG16 >> 8, false, false, 0), bri));
|
||||||
for (int i = flasherPos+1; i < flasherPos+flasherDistance && i < SEGLEN; i++) {
|
for (int i = flasherPos+1; i < flasherPos+flasherDistance && i < SEGLEN; i++) {
|
||||||
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; //next 'random' number
|
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; //next 'random' number
|
||||||
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(PRNG16 >> 8, false, false, 0, globalPeakBri));
|
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(PRNG16 >> 8, false, false, 0, globalPeakBri));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FRAMETIME;
|
return FRAMETIME;
|
||||||
}
|
}
|
||||||
static const char _data_FX_MODE_FAIRY[] PROGMEM = "Fairy";
|
static const char _data_FX_MODE_FAIRY[] PROGMEM = "Fairy";
|
||||||
|
|
||||||
@ -1474,46 +1465,46 @@ static const char _data_FX_MODE_FAIRY[] PROGMEM = "Fairy";
|
|||||||
* Warning: Uses 4 bytes of segment data per pixel
|
* Warning: Uses 4 bytes of segment data per pixel
|
||||||
*/
|
*/
|
||||||
uint16_t mode_fairytwinkle() {
|
uint16_t mode_fairytwinkle() {
|
||||||
uint16_t dataSize = sizeof(flasher) * SEGLEN;
|
uint16_t dataSize = sizeof(flasher) * SEGLEN;
|
||||||
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
||||||
Flasher* flashers = reinterpret_cast<Flasher*>(SEGENV.data);
|
Flasher* flashers = reinterpret_cast<Flasher*>(SEGENV.data);
|
||||||
uint16_t now16 = strip.now & 0xFFFF;
|
uint16_t now16 = strip.now & 0xFFFF;
|
||||||
uint16_t PRNG16 = 5100 + strip.getCurrSegmentId();
|
uint16_t PRNG16 = 5100 + strip.getCurrSegmentId();
|
||||||
|
|
||||||
uint16_t riseFallTime = 400 + (255-SEGMENT.speed)*3;
|
uint16_t riseFallTime = 400 + (255-SEGMENT.speed)*3;
|
||||||
uint16_t maxDur = riseFallTime/100 + ((255 - SEGMENT.intensity) >> 2) + 13 + ((255 - SEGMENT.intensity) >> 1);
|
uint16_t maxDur = riseFallTime/100 + ((255 - SEGMENT.intensity) >> 2) + 13 + ((255 - SEGMENT.intensity) >> 1);
|
||||||
|
|
||||||
for (int f = 0; f < SEGLEN; f++) {
|
for (int f = 0; f < SEGLEN; f++) {
|
||||||
uint16_t stateTime = now16 - flashers[f].stateStart;
|
uint16_t stateTime = now16 - flashers[f].stateStart;
|
||||||
//random on/off time reached, switch state
|
//random on/off time reached, switch state
|
||||||
if (stateTime > flashers[f].stateDur * 100) {
|
if (stateTime > flashers[f].stateDur * 100) {
|
||||||
flashers[f].stateOn = !flashers[f].stateOn;
|
flashers[f].stateOn = !flashers[f].stateOn;
|
||||||
bool init = !flashers[f].stateDur;
|
bool init = !flashers[f].stateDur;
|
||||||
if (flashers[f].stateOn) {
|
if (flashers[f].stateOn) {
|
||||||
flashers[f].stateDur = riseFallTime/100 + ((255 - SEGMENT.intensity) >> 2) + random8(12 + ((255 - SEGMENT.intensity) >> 1)) +1;
|
flashers[f].stateDur = riseFallTime/100 + ((255 - SEGMENT.intensity) >> 2) + random8(12 + ((255 - SEGMENT.intensity) >> 1)) +1;
|
||||||
} else {
|
} else {
|
||||||
flashers[f].stateDur = riseFallTime/100 + random8(3 + ((255 - SEGMENT.speed) >> 6)) +1;
|
flashers[f].stateDur = riseFallTime/100 + random8(3 + ((255 - SEGMENT.speed) >> 6)) +1;
|
||||||
}
|
}
|
||||||
flashers[f].stateStart = now16;
|
flashers[f].stateStart = now16;
|
||||||
stateTime = 0;
|
stateTime = 0;
|
||||||
if (init) {
|
if (init) {
|
||||||
flashers[f].stateStart -= riseFallTime; //start lit
|
flashers[f].stateStart -= riseFallTime; //start lit
|
||||||
flashers[f].stateDur = riseFallTime/100 + random8(12 + ((255 - SEGMENT.intensity) >> 1)) +5; //fire up a little quicker
|
flashers[f].stateDur = riseFallTime/100 + random8(12 + ((255 - SEGMENT.intensity) >> 1)) +5; //fire up a little quicker
|
||||||
stateTime = riseFallTime;
|
stateTime = riseFallTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flashers[f].stateOn && flashers[f].stateDur > maxDur) flashers[f].stateDur = maxDur; //react more quickly on intensity change
|
if (flashers[f].stateOn && flashers[f].stateDur > maxDur) flashers[f].stateDur = maxDur; //react more quickly on intensity change
|
||||||
if (stateTime > riseFallTime) stateTime = riseFallTime; //for flasher brightness calculation, fades in first 255 ms of state
|
if (stateTime > riseFallTime) stateTime = riseFallTime; //for flasher brightness calculation, fades in first 255 ms of state
|
||||||
uint8_t fadeprog = 255 - ((stateTime * 255) / riseFallTime);
|
uint8_t fadeprog = 255 - ((stateTime * 255) / riseFallTime);
|
||||||
uint8_t flasherBri = (flashers[f].stateOn) ? 255-gamma8(fadeprog) : gamma8(fadeprog);
|
uint8_t flasherBri = (flashers[f].stateOn) ? 255-gamma8(fadeprog) : gamma8(fadeprog);
|
||||||
uint16_t lastR = PRNG16;
|
uint16_t lastR = PRNG16;
|
||||||
uint16_t diff = 0;
|
uint16_t diff = 0;
|
||||||
while (diff < 0x4000) { //make sure colors of two adjacent LEDs differ enough
|
while (diff < 0x4000) { //make sure colors of two adjacent LEDs differ enough
|
||||||
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; //next 'random' number
|
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; //next 'random' number
|
||||||
diff = (PRNG16 > lastR) ? PRNG16 - lastR : lastR - PRNG16;
|
diff = (PRNG16 > lastR) ? PRNG16 - lastR : lastR - PRNG16;
|
||||||
}
|
}
|
||||||
SEGMENT.setPixelColor(f, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(PRNG16 >> 8, false, false, 0), flasherBri));
|
SEGMENT.setPixelColor(f, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(PRNG16 >> 8, false, false, 0), flasherBri));
|
||||||
}
|
}
|
||||||
return FRAMETIME;
|
return FRAMETIME;
|
||||||
}
|
}
|
||||||
static const char _data_FX_MODE_FAIRYTWINKLE[] PROGMEM = "Fairy Twinkle@;;;mp12=0,1d"; //pixels
|
static const char _data_FX_MODE_FAIRYTWINKLE[] PROGMEM = "Fairy Twinkle@;;;mp12=0,1d"; //pixels
|
||||||
@ -2209,19 +2200,14 @@ static const char _data_FX_MODE_NOISE16_4[] PROGMEM = "Noise 4@!,!;!,!,!;!;1d";
|
|||||||
//based on https://gist.github.com/kriegsman/5408ecd397744ba0393e
|
//based on https://gist.github.com/kriegsman/5408ecd397744ba0393e
|
||||||
uint16_t mode_colortwinkle()
|
uint16_t mode_colortwinkle()
|
||||||
{
|
{
|
||||||
const uint16_t cols = strip.isMatrix ? SEGMENT.virtualWidth() : 1;
|
uint16_t dataSize = (SEGLEN+7) >> 3; //1 bit per LED
|
||||||
const uint16_t rows = strip.isMatrix ? SEGMENT.virtualHeight() : SEGMENT.virtualLength();
|
|
||||||
|
|
||||||
uint16_t dataSize = (cols*rows+7) >> 3; //1 bit per LED
|
|
||||||
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
||||||
|
|
||||||
CRGB fastled_col, prev;
|
CRGB fastled_col, prev;
|
||||||
fract8 fadeUpAmount = strip.getBrightness()>28 ? 8 + (SEGMENT.speed>>2) : 68-strip.getBrightness();
|
fract8 fadeUpAmount = strip.getBrightness()>28 ? 8 + (SEGMENT.speed>>2) : 68-strip.getBrightness();
|
||||||
fract8 fadeDownAmount = strip.getBrightness()>28 ? 8 + (SEGMENT.speed>>3) : 68-strip.getBrightness();
|
fract8 fadeDownAmount = strip.getBrightness()>28 ? 8 + (SEGMENT.speed>>3) : 68-strip.getBrightness();
|
||||||
|
for (uint16_t i = 0; i < SEGLEN; i++) {
|
||||||
for (int i = 0; i < rows*cols; i++) {
|
fastled_col = SEGMENT.getPixelColor(i);
|
||||||
uint16_t j = i % cols, k = i / cols;
|
|
||||||
fastled_col = CRGB(strip.isMatrix ? SEGMENT.getPixelColorXY(j, k) : SEGMENT.getPixelColor(i)); // TODO
|
|
||||||
prev = fastled_col;
|
prev = fastled_col;
|
||||||
uint16_t index = i >> 3;
|
uint16_t index = i >> 3;
|
||||||
uint8_t bitNum = i & 0x07;
|
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) {
|
if (fastled_col.red == 255 || fastled_col.green == 255 || fastled_col.blue == 255) {
|
||||||
bitWrite(SEGENV.data[index], bitNum, false);
|
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);
|
if (SEGMENT.getPixelColor(i) == RGBW32(prev.r, prev.g, prev.b, 0)) { //fix "stuck" pixels
|
||||||
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
|
|
||||||
fastled_col += fastled_col;
|
fastled_col += fastled_col;
|
||||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(j, k, fastled_col);
|
SEGMENT.setPixelColor(i, fastled_col);
|
||||||
else SEGMENT.setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fastled_col.nscale8(255 - fadeDownAmount);
|
fastled_col.nscale8(255 - fadeDownAmount);
|
||||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(j, k, fastled_col);
|
SEGMENT.setPixelColor(i, fastled_col);
|
||||||
else SEGMENT.setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j <= rows*cols / 50; j++) {
|
for (uint16_t j = 0; j <= SEGLEN / 50; j++) {
|
||||||
if (random8() <= SEGMENT.intensity) {
|
if (random8() <= SEGMENT.intensity) {
|
||||||
for (size_t times = 0; times < 5; times++) { //attempt to spawn a new pixel 5 times
|
for (uint8_t times = 0; times < 5; times++) { //attempt to spawn a new pixel 5 times
|
||||||
uint16_t i = random16(rows*cols);
|
int i = random16(SEGLEN);
|
||||||
uint16_t j = i % cols, k = i / cols;
|
if (SEGMENT.getPixelColor(i) == 0) {
|
||||||
uint32_t col = strip.isMatrix ? SEGMENT.getPixelColorXY(j, k) : SEGMENT.getPixelColor(i); // TODO
|
|
||||||
if (col == 0) {
|
|
||||||
fastled_col = ColorFromPalette(SEGPALETTE, random8(), 64, NOBLEND);
|
fastled_col = ColorFromPalette(SEGPALETTE, random8(), 64, NOBLEND);
|
||||||
uint16_t index = i >> 3;
|
uint16_t index = i >> 3;
|
||||||
uint8_t bitNum = i & 0x07;
|
uint8_t bitNum = i & 0x07;
|
||||||
bitWrite(SEGENV.data[index], bitNum, true);
|
bitWrite(SEGENV.data[index], bitNum, true);
|
||||||
if (strip.isMatrix) SEGMENT.setPixelColorXY(j, k, fastled_col);
|
SEGMENT.setPixelColor(i, fastled_col);
|
||||||
else SEGMENT.setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
|
||||||
break; //only spawn 1 new pixel per frame per 50 LEDs
|
break; //only spawn 1 new pixel per frame per 50 LEDs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2272,7 +2250,7 @@ uint16_t mode_colortwinkle()
|
|||||||
}
|
}
|
||||||
return FRAMETIME_FIXED;
|
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
|
//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
|
//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()
|
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;
|
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
|
SEGMENT.fill(SEGCOLOR(1)); //fill background
|
||||||
|
|
||||||
@ -2666,7 +2644,7 @@ uint16_t mode_halloween_eyes()
|
|||||||
if (stateTime == 0) stateTime = 2000;
|
if (stateTime == 0) stateTime = 2000;
|
||||||
|
|
||||||
if (state == 0) { //spawn eyes
|
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
|
SEGENV.aux1 = random8(); //color
|
||||||
if (strip.isMatrix) SEGMENT.offset = random16(SEGMENT.virtualHeight()-1); // a hack: reuse offset since it is not used in matrices
|
if (strip.isMatrix) SEGMENT.offset = random16(SEGMENT.virtualHeight()-1); // a hack: reuse offset since it is not used in matrices
|
||||||
state = 1;
|
state = 1;
|
||||||
@ -2696,9 +2674,9 @@ uint16_t mode_halloween_eyes()
|
|||||||
if (state > 2) state = 0;
|
if (state > 2) state = 0;
|
||||||
|
|
||||||
if (state < 2) {
|
if (state < 2) {
|
||||||
stateTime = 100 + (255 - SEGMENT.intensity)*10; //eye fade time
|
stateTime = 100 + SEGMENT.intensity*10; //eye fade time
|
||||||
} else {
|
} else {
|
||||||
uint16_t eyeOffTimeBase = (255 - SEGMENT.speed)*10;
|
uint16_t eyeOffTimeBase = (256 - SEGMENT.speed)*10;
|
||||||
stateTime = eyeOffTimeBase + random16(eyeOffTimeBase);
|
stateTime = eyeOffTimeBase + random16(eyeOffTimeBase);
|
||||||
}
|
}
|
||||||
SEGENV.step = strip.now;
|
SEGENV.step = strip.now;
|
||||||
@ -2818,59 +2796,71 @@ typedef struct Ball {
|
|||||||
*/
|
*/
|
||||||
uint16_t mode_bouncing_balls(void) {
|
uint16_t mode_bouncing_balls(void) {
|
||||||
//allocate segment data
|
//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;
|
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);
|
Ball* balls = reinterpret_cast<Ball*>(SEGENV.data);
|
||||||
|
|
||||||
// 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();
|
SEGMENT.fill(SEGCOLOR(2) ? BLACK : SEGCOLOR(1));
|
||||||
|
|
||||||
if (SEGENV.call == 0) {
|
// virtualStrip idea by @ewowi (Ewoud Wijma)
|
||||||
for (size_t i = 0; i < maxNumBalls; i++) balls[i].lastBounceTime = time;
|
// 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 {
|
||||||
bool hasCol2 = SEGCOLOR(2);
|
static void runStrip(size_t stripNr, Ball* balls) {
|
||||||
SEGMENT.fill(hasCol2 ? BLACK : SEGCOLOR(1));
|
// number of balls based on intensity setting to max of 7 (cycles colors)
|
||||||
|
// non-chosen color is a random color
|
||||||
for (size_t i = 0; i < numBalls; i++) {
|
uint16_t numBalls = (SEGMENT.intensity * (maxNumBalls - 1)) / 255 + 1; // minimum 1 ball
|
||||||
float timeSinceLastBounce = (time - balls[i].lastBounceTime)/((255-SEGMENT.speed)*8/256 +1);
|
const float gravity = -9.81; // standard value of gravity
|
||||||
float timeSec = timeSinceLastBounce/1000.0f;
|
const bool hasCol2 = SEGCOLOR(2);
|
||||||
balls[i].height = 0.5 * gravity * (timeSec * timeSec) + balls[i].impactVelocity * timeSec; // avoid use pow(x, 2) - its extremely slow !
|
const unsigned long time = millis();
|
||||||
|
|
||||||
if (balls[i].height < 0) { //start bounce
|
if (SEGENV.call == 0) {
|
||||||
balls[i].height = 0;
|
for (size_t i = 0; i < maxNumBalls; i++) balls[i].lastBounceTime = time;
|
||||||
//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 !
|
|
||||||
balls[i].impactVelocity = dampening * balls[i].impactVelocity;
|
for (size_t i = 0; i < numBalls; i++) {
|
||||||
balls[i].lastBounceTime = time;
|
float timeSinceLastBounce = (time - balls[i].lastBounceTime)/((255-SEGMENT.speed)/64 +1);
|
||||||
|
float timeSec = timeSinceLastBounce/1000.0f;
|
||||||
|
balls[i].height = (0.5f * gravity * timeSec + balls[i].impactVelocity) * timeSec; // avoid use pow(x, 2) - its extremely slow !
|
||||||
|
|
||||||
if (balls[i].impactVelocity < 0.015) {
|
if (balls[i].height <= 0.0f) {
|
||||||
balls[i].impactVelocity = impactVelocityStart;
|
balls[i].height = 0.0f;
|
||||||
|
//damping for better effect using multiple balls
|
||||||
|
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.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);
|
||||||
|
if (SEGMENT.palette) {
|
||||||
|
color = SEGMENT.color_wheel(i*(256/MAX(numBalls, 8)));
|
||||||
|
} else if (hasCol2) {
|
||||||
|
color = SEGCOLOR(i % NUM_COLORS);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
uint32_t color = SEGCOLOR(0);
|
|
||||||
if (SEGMENT.palette) {
|
|
||||||
color = SEGMENT.color_wheel(i*(256/MAX(numBalls, 8)));
|
|
||||||
} else if (hasCol2) {
|
|
||||||
color = SEGCOLOR(i % NUM_COLORS);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t pos = roundf(balls[i].height * (SEGLEN - 1));
|
for (int stripNr=0; stripNr<strips; stripNr++)
|
||||||
SEGMENT.setPixelColor(pos, color);
|
virtualStrip::runStrip(stripNr, &balls[stripNr * maxNumBalls]);
|
||||||
}
|
|
||||||
|
|
||||||
return FRAMETIME;
|
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();
|
mode_palette();
|
||||||
|
|
||||||
if (strip.isMatrix) {
|
if (SEGMENT.intensity > random8())
|
||||||
uint16_t height = SEGMENT.virtualHeight();
|
{
|
||||||
uint16_t width = SEGMENT.virtualWidth();
|
SEGMENT.setPixelColor(random16(SEGLEN), ULTRAWHITE);
|
||||||
for (int i = 0; i<height; i++) {
|
}
|
||||||
if (SEGMENT.intensity > random8()) SEGMENT.setPixelColorXY(random16(width-1), i, ULTRAWHITE);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
if (SEGMENT.intensity > random8()) SEGMENT.setPixelColor(random16(SEGLEN), ULTRAWHITE);
|
|
||||||
|
|
||||||
return FRAMETIME;
|
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
|
//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
|
* Tetris or Stacking (falling bricks) Effect
|
||||||
* by Blaz Kristan (AKA blazoncek) (https://github.com/blazoncek, https://blaz.at/home)
|
* by Blaz Kristan (AKA blazoncek) (https://github.com/blazoncek, https://blaz.at/home)
|
||||||
*/
|
*/
|
||||||
//12 bytes
|
//20 bytes
|
||||||
typedef struct Tetris {
|
typedef struct Tetris {
|
||||||
float pos;
|
float pos;
|
||||||
float speed;
|
float speed;
|
||||||
uint32_t col;
|
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;
|
} tetris;
|
||||||
|
|
||||||
uint16_t mode_tetrix(void) {
|
uint16_t mode_tetrix(void) {
|
||||||
|
uint16_t strips = SEGMENT.nrOfVStrips(); // allow running on virtual strips (columns in 2D segment)
|
||||||
uint16_t dataSize = sizeof(tetris);
|
uint16_t dataSize = sizeof(tetris);
|
||||||
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed
|
if (!SEGENV.allocateData(dataSize * strips)) return mode_static(); //allocation failed
|
||||||
Tetris* drop = reinterpret_cast<Tetris*>(SEGENV.data);
|
Tetris* drops = reinterpret_cast<Tetris*>(SEGENV.data);
|
||||||
|
|
||||||
// initialize dropping on first call or segment full
|
if (SEGENV.call == 0) SEGMENT.fill(SEGCOLOR(1)); // will fill entire segment (1D or 2D)
|
||||||
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.step == 0) { // init brick
|
|
||||||
drop->speed = 0.0238 * (SEGMENT.speed ? (SEGMENT.speed>>2)+1 : random8(6,64)); // 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
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SEGENV.step == 1) { // forming
|
|
||||||
if (random8()>>6) { // random drop
|
|
||||||
SEGENV.step = 2; // fall
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SEGENV.step == 2) { // falling
|
// virtualStrip idea by @ewowi (Ewoud Wijma)
|
||||||
if (drop->pos > SEGENV.aux1) { // fall until top of stack
|
// requires virtual strip # to be embedded into upper 16 bits of index in setPixelcolor()
|
||||||
drop->pos -= drop->speed; // may add gravity as: speed += gravity
|
// the following functions will not work on virtual strips: fill(), fade_out(), fadeToBlack(), blur()
|
||||||
if (uint16_t(drop->pos) < SEGENV.aux1) drop->pos = SEGENV.aux1;
|
struct virtualStrip {
|
||||||
for (int i=int(drop->pos); i<SEGLEN; i++) SEGMENT.setPixelColor(i,i<int(drop->pos)+SEGENV.aux0 ? drop->col : SEGCOLOR(1));
|
static void runStrip(size_t stripNr, Tetris *drop) {
|
||||||
} else { // we hit bottom
|
// initialize dropping on first call or segment full
|
||||||
SEGENV.step = 0; // proceed with next brick, go back to init
|
if (SEGENV.call == 0) {
|
||||||
SEGENV.aux1 += SEGENV.aux0; // increase the stack size
|
drop->aux1 = 0; // reset brick stack size
|
||||||
if (SEGENV.aux1 >= SEGLEN) SEGENV.step = millis() + 2500; // fade out stack
|
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 (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
|
||||||
|
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 (drop->step == 1) { // forming
|
||||||
|
if (random8()>>6) { // random drop
|
||||||
|
drop->step = 2; // fall
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (SEGENV.step > 2) {
|
if (drop->step == 2) { // falling
|
||||||
SEGENV.aux0 = 0; // reset brick size (no more growing)
|
if (drop->pos > drop->aux1) { // fall until top of stack
|
||||||
if (SEGENV.step > millis()) {
|
drop->pos -= drop->speed; // may add gravity as: speed += gravity
|
||||||
SEGMENT.fade_out(24); // fade out stack
|
if (uint16_t(drop->pos) < drop->aux1) drop->pos = drop->aux1;
|
||||||
} else {
|
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));
|
||||||
SEGENV.aux1 = 0; // reset brick stack size
|
} else { // we hit bottom
|
||||||
SEGENV.step = 0; // proceed with next brick
|
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 (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 {
|
||||||
|
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;
|
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,8 +3580,9 @@ static const char _data_FX_MODE_PLASMA[] PROGMEM = "Plasma@Phase,;1,2,3;!;1d";
|
|||||||
*/
|
*/
|
||||||
uint16_t mode_percent(void) {
|
uint16_t mode_percent(void) {
|
||||||
|
|
||||||
uint8_t percent = MAX(0, MIN(200, SEGMENT.intensity));
|
uint8_t percent = SEGMENT.intensity;
|
||||||
uint16_t active_leds = (percent < 100) ? SEGLEN * percent / 100.0
|
percent = constrain(percent, 0, 200);
|
||||||
|
uint16_t active_leds = (percent < 100) ? SEGLEN * percent / 100.0
|
||||||
: SEGLEN * (200 - percent) / 100.0;
|
: SEGLEN * (200 - percent) / 100.0;
|
||||||
|
|
||||||
uint8_t size = (1 + ((SEGMENT.speed * SEGLEN) >> 11));
|
uint8_t size = (1 + ((SEGMENT.speed * SEGLEN) >> 11));
|
||||||
@ -3583,22 +3590,22 @@ uint16_t mode_percent(void) {
|
|||||||
|
|
||||||
if (percent < 100) {
|
if (percent < 100) {
|
||||||
for (int i = 0; i < SEGLEN; i++) {
|
for (int i = 0; i < SEGLEN; i++) {
|
||||||
if (i < SEGENV.aux1) {
|
if (i < SEGENV.aux1) {
|
||||||
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
|
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SEGMENT.setPixelColor(i, SEGCOLOR(1));
|
SEGMENT.setPixelColor(i, SEGCOLOR(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < SEGLEN; i++) {
|
for (int i = 0; i < SEGLEN; i++) {
|
||||||
if (i < (SEGLEN - SEGENV.aux1)) {
|
if (i < (SEGLEN - SEGENV.aux1)) {
|
||||||
SEGMENT.setPixelColor(i, SEGCOLOR(1));
|
SEGMENT.setPixelColor(i, SEGCOLOR(1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
|
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(active_leds > SEGENV.aux1) { // smooth transition to the target value
|
if(active_leds > SEGENV.aux1) { // smooth transition to the target value
|
||||||
@ -3769,18 +3776,14 @@ uint16_t mode_solid_glitter()
|
|||||||
{
|
{
|
||||||
SEGMENT.fill(SEGCOLOR(0));
|
SEGMENT.fill(SEGCOLOR(0));
|
||||||
|
|
||||||
if (strip.isMatrix) {
|
if (SEGMENT.intensity > random8())
|
||||||
uint16_t height = SEGMENT.virtualHeight();
|
{
|
||||||
uint16_t width = SEGMENT.virtualWidth();
|
SEGMENT.setPixelColor(random16(SEGLEN), ULTRAWHITE);
|
||||||
for (int i = 0; i<height; i++) {
|
}
|
||||||
if (SEGMENT.intensity > random8()) SEGMENT.setPixelColorXY(random16(width-1), i, ULTRAWHITE);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
if (SEGMENT.intensity > random8()) SEGMENT.setPixelColor(random16(SEGLEN), ULTRAWHITE);
|
|
||||||
|
|
||||||
return FRAMETIME;
|
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";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3792,7 +3795,7 @@ uint16_t mode_sunrise() {
|
|||||||
//speed 60 - 120 : sunset time in minutes - 60;
|
//speed 60 - 120 : sunset time in minutes - 60;
|
||||||
//speed above: "breathing" rise and set
|
//speed above: "breathing" rise and set
|
||||||
if (SEGENV.call == 0 || SEGMENT.speed != SEGENV.aux0) {
|
if (SEGENV.call == 0 || SEGMENT.speed != SEGENV.aux0) {
|
||||||
SEGENV.step = millis(); //save starting time, millis() because now can change from sync
|
SEGENV.step = millis(); //save starting time, millis() because now can change from sync
|
||||||
SEGENV.aux0 = SEGMENT.speed;
|
SEGENV.aux0 = SEGMENT.speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3802,15 +3805,15 @@ uint16_t mode_sunrise() {
|
|||||||
uint32_t s10SinceStart = (millis() - SEGENV.step) /100; //tenths of seconds
|
uint32_t s10SinceStart = (millis() - SEGENV.step) /100; //tenths of seconds
|
||||||
|
|
||||||
if (SEGMENT.speed > 120) { //quick sunrise and sunset
|
if (SEGMENT.speed > 120) { //quick sunrise and sunset
|
||||||
uint16_t counter = (strip.now >> 1) * (((SEGMENT.speed -120) >> 1) +1);
|
uint16_t counter = (strip.now >> 1) * (((SEGMENT.speed -120) >> 1) +1);
|
||||||
stage = triwave16(counter);
|
stage = triwave16(counter);
|
||||||
} else if (SEGMENT.speed) { //sunrise
|
} else if (SEGMENT.speed) { //sunrise
|
||||||
uint8_t durMins = SEGMENT.speed;
|
uint8_t durMins = SEGMENT.speed;
|
||||||
if (durMins > 60) durMins -= 60;
|
if (durMins > 60) durMins -= 60;
|
||||||
uint32_t s10Target = durMins * 600;
|
uint32_t s10Target = durMins * 600;
|
||||||
if (s10SinceStart > s10Target) s10SinceStart = s10Target;
|
if (s10SinceStart > s10Target) s10SinceStart = s10Target;
|
||||||
stage = map(s10SinceStart, 0, s10Target, 0, 0xFFFF);
|
stage = map(s10SinceStart, 0, s10Target, 0, 0xFFFF);
|
||||||
if (SEGMENT.speed > 60) stage = 0xFFFF - stage; //sunset
|
if (SEGMENT.speed > 60) stage = 0xFFFF - stage; //sunset
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <= SEGLEN/2; i++)
|
for (int i = 0; i <= SEGLEN/2; i++)
|
||||||
@ -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.
|
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;
|
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.
|
||||||
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<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.
|
||||||
for (int i = 0; i<rows*cols; i++) {
|
|
||||||
uint16_t j = i % rows, k = i / rows;
|
|
||||||
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));
|
uint8_t pixBri = sin8(ranstart + 16 * strip.now/(256-SEGMENT.speed));
|
||||||
if (random8() > SEGMENT.intensity) pixBri = 0;
|
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);
|
SEGMENT.setPixelColor(i, 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FRAMETIME;
|
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.
|
// 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)
|
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 counter = strip.now * (6 + (SEGMENT.speed >> 4));
|
||||||
uint16_t numBirds = 2 + (SEGLEN >> 3); // 2 + 1/8 of a segment
|
uint16_t numBirds = 2 + (SEGLEN >> 3); // 2 + 1/8 of a segment
|
||||||
uint16_t span = (SEGMENT.intensity << 8) / numBirds;
|
uint16_t span = (SEGMENT.intensity << 8) / numBirds;
|
||||||
@ -4014,6 +4012,7 @@ uint16_t mode_chunchun(void)
|
|||||||
uint16_t megumin = sin16(counter) + 0x8000;
|
uint16_t megumin = sin16(counter) + 0x8000;
|
||||||
uint16_t bird = uint32_t(megumin * SEGLEN) >> 16;
|
uint16_t bird = uint32_t(megumin * SEGLEN) >> 16;
|
||||||
uint32_t c = SEGMENT.color_from_palette((i * 255)/ numBirds, false, false, 0); // no palette wrapping
|
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);
|
SEGMENT.setPixelColor(bird, c);
|
||||||
}
|
}
|
||||||
return FRAMETIME;
|
return FRAMETIME;
|
||||||
@ -4941,7 +4940,7 @@ uint16_t mode_2DHiphotic() { // By: ldirko https://edit
|
|||||||
|
|
||||||
const uint16_t cols = SEGMENT.virtualWidth();
|
const uint16_t cols = SEGMENT.virtualWidth();
|
||||||
const uint16_t rows = SEGMENT.virtualHeight();
|
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 x = 0; x < cols; x++) {
|
||||||
for (int y = 0; y < rows; y++) {
|
for (int y = 0; y < rows; y++) {
|
||||||
@ -4951,7 +4950,7 @@ uint16_t mode_2DHiphotic() { // By: ldirko https://edit
|
|||||||
|
|
||||||
return FRAMETIME;
|
return FRAMETIME;
|
||||||
} // mode_2DHiphotic()
|
} // 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";
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
|
19
wled00/FX.h
19
wled00/FX.h
@ -339,9 +339,9 @@
|
|||||||
|
|
||||||
typedef enum mapping1D2D {
|
typedef enum mapping1D2D {
|
||||||
M12_Pixels = 0,
|
M12_Pixels = 0,
|
||||||
M12_VerticalBar = 1,
|
M12_pBar = 1,
|
||||||
M12_Circle = 2,
|
M12_pArc = 2,
|
||||||
M12_Block = 3
|
M12_pCorner = 3
|
||||||
} mapping1D2D_t;
|
} mapping1D2D_t;
|
||||||
|
|
||||||
// segment, 72 bytes
|
// segment, 72 bytes
|
||||||
@ -551,7 +551,7 @@ typedef struct Segment {
|
|||||||
void setPixelColor(float i, uint32_t c, bool aa = true);
|
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, 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); }
|
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)
|
// 1D support functions (some implement 2D as well)
|
||||||
void blur(uint8_t);
|
void blur(uint8_t);
|
||||||
void fill(uint32_t c);
|
void fill(uint32_t c);
|
||||||
@ -570,6 +570,7 @@ typedef struct Segment {
|
|||||||
// 2D matrix
|
// 2D matrix
|
||||||
uint16_t virtualWidth(void) const;
|
uint16_t virtualWidth(void) const;
|
||||||
uint16_t virtualHeight(void) const;
|
uint16_t virtualHeight(void) const;
|
||||||
|
uint16_t nrOfVStrips(void) const;
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
uint16_t XY(uint16_t x, uint16_t y); // support function to get relative index within segment (for leds[])
|
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
|
void setPixelColorXY(int x, int y, uint32_t c); // set relative pixel within segment with color
|
||||||
@ -678,8 +679,8 @@ class WS2812FX { // 96 bytes
|
|||||||
_length(DEFAULT_LED_COUNT),
|
_length(DEFAULT_LED_COUNT),
|
||||||
_brightness(DEFAULT_BRIGHTNESS),
|
_brightness(DEFAULT_BRIGHTNESS),
|
||||||
_transitionDur(750),
|
_transitionDur(750),
|
||||||
_targetFps(WLED_FPS),
|
_targetFps(WLED_FPS),
|
||||||
_frametime(FRAMETIME_FIXED),
|
_frametime(FRAMETIME_FIXED),
|
||||||
_cumulativeFps(2),
|
_cumulativeFps(2),
|
||||||
_isServicing(false),
|
_isServicing(false),
|
||||||
_isOffRefreshRequired(false),
|
_isOffRefreshRequired(false),
|
||||||
@ -733,7 +734,7 @@ class WS2812FX { // 96 bytes
|
|||||||
fixInvalidSegments(),
|
fixInvalidSegments(),
|
||||||
setPixelColor(int n, uint32_t c),
|
setPixelColor(int n, uint32_t c),
|
||||||
show(void),
|
show(void),
|
||||||
setTargetFps(uint8_t fps),
|
setTargetFps(uint8_t fps),
|
||||||
deserializeMap(uint8_t n=0);
|
deserializeMap(uint8_t n=0);
|
||||||
|
|
||||||
void fill(uint32_t c) { for (int i = 0; i < _length; i++) setPixelColor(i, c); } // fill whole strip with color (inline)
|
void fill(uint32_t c) { for (int i = 0; i < _length; i++) setPixelColor(i, c); } // fill whole strip with color (inline)
|
||||||
@ -869,8 +870,8 @@ class WS2812FX { // 96 bytes
|
|||||||
uint8_t _brightness;
|
uint8_t _brightness;
|
||||||
uint16_t _transitionDur;
|
uint16_t _transitionDur;
|
||||||
|
|
||||||
uint8_t _targetFps;
|
uint8_t _targetFps;
|
||||||
uint16_t _frametime;
|
uint16_t _frametime;
|
||||||
uint16_t _cumulativeFps;
|
uint16_t _cumulativeFps;
|
||||||
|
|
||||||
// will require only 1 byte
|
// will require only 1 byte
|
||||||
|
@ -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 xR = roundf(fX+0.49f);
|
||||||
uint16_t yT = roundf(fY-0.49f);
|
uint16_t yT = roundf(fY-0.49f);
|
||||||
uint16_t yB = roundf(fY+0.49f);
|
uint16_t yB = roundf(fY+0.49f);
|
||||||
float dL = fX - xL;
|
float dL = (fX - xL)*(fX - xL);
|
||||||
float dR = xR - fX;
|
float dR = (xR - fX)*(xR - fX);
|
||||||
float dT = fY - yT;
|
float dT = (fY - yT)*(fY - yT);
|
||||||
float dB = yB - fY;
|
float dB = (yB - fY)*(yB - fY);
|
||||||
uint32_t cXLYT = getPixelColorXY(xL, yT);
|
uint32_t cXLYT = getPixelColorXY(xL, yT);
|
||||||
uint32_t cXRYT = getPixelColorXY(xR, yT);
|
uint32_t cXRYT = getPixelColorXY(xR, yT);
|
||||||
uint32_t cXLYB = getPixelColorXY(xL, yB);
|
uint32_t cXLYB = getPixelColorXY(xL, yB);
|
||||||
|
@ -196,8 +196,92 @@ void Segment::setUpLeds() {
|
|||||||
#else
|
#else
|
||||||
leds = &Segment::_globalLeds[start];
|
leds = &Segment::_globalLeds[start];
|
||||||
#endif
|
#endif
|
||||||
else if (!leds)
|
else if (!leds) {
|
||||||
leds = (CRGB*)malloc(sizeof(CRGB)*length());
|
#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) {
|
void Segment::startTransition(uint16_t dur) {
|
||||||
@ -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;
|
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) {
|
CRGBPalette16 &Segment::currentPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
|
||||||
loadPalette(targetPalette, pal);
|
loadPalette(targetPalette, pal);
|
||||||
if (transitional && _t && progress() < 0xFFFFU) {
|
if (transitional && _t && progress() < 0xFFFFU) {
|
||||||
@ -400,19 +406,33 @@ uint16_t Segment::virtualHeight() const {
|
|||||||
return vHeight;
|
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
|
// 1D strip
|
||||||
uint16_t Segment::virtualLength() const {
|
uint16_t Segment::virtualLength() const {
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
if (is2D()) {
|
if (is2D()) {
|
||||||
uint16_t vW = virtualWidth();
|
uint16_t vW = virtualWidth();
|
||||||
uint16_t vH = virtualHeight();
|
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) {
|
switch (map1D2D) {
|
||||||
case M12_VerticalBar:
|
case M12_pBar:
|
||||||
vLen = vW; // segment width since it is used in getPixelColor()
|
vLen = vH;
|
||||||
break;
|
break;
|
||||||
case M12_Block:
|
case M12_pCorner:
|
||||||
case M12_Circle:
|
case M12_pArc:
|
||||||
vLen = max(vW,vH); // get the longest dimension
|
vLen = max(vW,vH); // get the longest dimension
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -427,6 +447,11 @@ uint16_t Segment::virtualLength() const {
|
|||||||
|
|
||||||
void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
|
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
|
#ifndef WLED_DISABLE_2D
|
||||||
if (is2D()) { // if this does not work use strip.isMatrix
|
if (is2D()) { // if this does not work use strip.isMatrix
|
||||||
uint16_t vH = virtualHeight(); // segment height in logical pixels
|
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
|
// use all available pixels as a long strip
|
||||||
setPixelColorXY(i % vW, i / vW, col);
|
setPixelColorXY(i % vW, i / vW, col);
|
||||||
break;
|
break;
|
||||||
case M12_VerticalBar:
|
case M12_pBar:
|
||||||
// expand 1D effect vertically
|
// expand 1D effect vertically or have it play on virtual strips
|
||||||
for (int y = 0; y < vH; y++) setPixelColorXY(i, y, col);
|
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;
|
break;
|
||||||
case M12_Circle:
|
case M12_pArc:
|
||||||
// expand in circular fashion from center
|
// expand in circular fashion from center
|
||||||
if (i==0)
|
if (i==0)
|
||||||
setPixelColorXY(0, 0, col);
|
setPixelColorXY(0, 0, col);
|
||||||
else {
|
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) {
|
for (float rad = 0.0f; rad <= HALF_PI+step/2; rad += step) {
|
||||||
// may want to try float version as well (with or without antialiasing)
|
// may want to try float version as well (with or without antialiasing)
|
||||||
int x = roundf(sin_t(rad) * i);
|
int x = roundf(sin_t(rad) * i);
|
||||||
@ -454,22 +480,22 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case M12_Block:
|
case M12_pCorner:
|
||||||
for (int x = 0; x <= i; x++) setPixelColorXY(x, i, col);
|
for (int x = 0; x <= i; x++) setPixelColorXY(x, i, col);
|
||||||
for (int y = 0; y < i; y++) setPixelColorXY(i, y, col);
|
for (int y = 0; y < i; y++) setPixelColorXY(i, y, col);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (width()==1 && height()>1) {
|
} else if (strip.isMatrix && (width()==1 || height()==1)) { // TODO remove this hack
|
||||||
// we have a vertical 1D segment
|
// we have a vertical or horizontal 1D segment (WARNING: virtual...() may be transposed)
|
||||||
setPixelColorXY(0, i, col); // transpose
|
int x = 0, y = 0;
|
||||||
} else if (width()>1 && height()==1) {
|
if (virtualHeight()>1) y = i;
|
||||||
// we have a horizontal 1D segment
|
if (virtualWidth() >1) x = i;
|
||||||
setPixelColorXY(i, 0, col);
|
setPixelColorXY(x, y, col);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (i >= virtualLength() || i<0) return; // if pixel would fall out of segment just exit
|
|
||||||
if (leds) leds[i] = col;
|
if (leds) leds[i] = col;
|
||||||
|
|
||||||
uint16_t len = length();
|
uint16_t len = length();
|
||||||
@ -513,34 +539,40 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
|
|||||||
// anti-aliased normalized version of setPixelColor()
|
// anti-aliased normalized version of setPixelColor()
|
||||||
void Segment::setPixelColor(float i, uint32_t col, bool aa)
|
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
|
if (i<0.0f || i>1.0f) return; // not normalized
|
||||||
|
|
||||||
float fC = i * (virtualLength()-1);
|
float fC = i * (virtualLength()-1);
|
||||||
if (aa) {
|
if (aa) {
|
||||||
uint16_t iL = roundf(fC-0.49f);
|
uint16_t iL = roundf(fC-0.49f);
|
||||||
uint16_t iR = roundf(fC+0.49f);
|
uint16_t iR = roundf(fC+0.49f);
|
||||||
float dL = fC - iL;
|
float dL = (fC - iL)*(fC - iL);
|
||||||
float dR = iR - fC;
|
float dR = (iR - fC)*(iR - fC);
|
||||||
uint32_t cIL = getPixelColor(iL);
|
uint32_t cIL = getPixelColor(iL | (vStrip<<16));
|
||||||
uint32_t cIR = getPixelColor(iR);
|
uint32_t cIR = getPixelColor(iR | (vStrip<<16));
|
||||||
if (iR!=iL) {
|
if (iR!=iL) {
|
||||||
// blend L pixel
|
// blend L pixel
|
||||||
cIL = color_blend(col, cIL, uint8_t(dL*255.0f));
|
cIL = color_blend(col, cIL, uint8_t(dL*255.0f));
|
||||||
setPixelColor(iL, cIL);
|
setPixelColor(iL | (vStrip<<16), cIL);
|
||||||
// blend R pixel
|
// blend R pixel
|
||||||
cIR = color_blend(col, cIR, uint8_t(dR*255.0f));
|
cIR = color_blend(col, cIR, uint8_t(dR*255.0f));
|
||||||
setPixelColor(iR, cIR);
|
setPixelColor(iR | (vStrip<<16), cIR);
|
||||||
} else {
|
} else {
|
||||||
// exact match (x & y land on a pixel)
|
// exact match (x & y land on a pixel)
|
||||||
setPixelColor(iL, col);
|
setPixelColor(iL | (vStrip<<16), col);
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
#ifndef WLED_DISABLE_2D
|
||||||
if (is2D()) { // if this does not work use strip.isMatrix
|
if (is2D()) { // if this does not work use strip.isMatrix
|
||||||
uint16_t vH = virtualHeight(); // segment height in logical pixels
|
uint16_t vH = virtualHeight(); // segment height in logical pixels
|
||||||
@ -549,11 +581,12 @@ uint32_t Segment::getPixelColor(uint16_t i)
|
|||||||
case M12_Pixels:
|
case M12_Pixels:
|
||||||
return getPixelColorXY(i % vW, i / vW);
|
return getPixelColorXY(i % vW, i / vW);
|
||||||
break;
|
break;
|
||||||
case M12_VerticalBar:
|
case M12_pBar:
|
||||||
return getPixelColorXY(i, 0);
|
if (vStrip>0) return getPixelColorXY(vStrip - 1, vH - i -1);
|
||||||
|
else return getPixelColorXY(0, vH - i -1);
|
||||||
break;
|
break;
|
||||||
case M12_Circle:
|
case M12_pArc:
|
||||||
case M12_Block:
|
case M12_pCorner:
|
||||||
// use longest dimension
|
// use longest dimension
|
||||||
return vW>vH ? getPixelColorXY(i, 0) : getPixelColorXY(0, i);
|
return vW>vH ? getPixelColorXY(i, 0) : getPixelColorXY(0, i);
|
||||||
break;
|
break;
|
||||||
@ -1077,8 +1110,8 @@ uint16_t WS2812FX::getFps() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setTargetFps(uint8_t fps) {
|
void WS2812FX::setTargetFps(uint8_t fps) {
|
||||||
if (fps > 0 && fps <= 120) _targetFps = fps;
|
if (fps > 0 && fps <= 120) _targetFps = fps;
|
||||||
_frametime = 1000 / _targetFps;
|
_frametime = 1000 / _targetFps;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setMode(uint8_t segid, uint8_t m) {
|
void WS2812FX::setMode(uint8_t segid, uint8_t m) {
|
||||||
@ -1125,7 +1158,7 @@ void WS2812FX::setBrightness(uint8_t b, bool direct) {
|
|||||||
// would be dangerous if applied immediately (could exceed ABL), but will not output until the next show()
|
// would be dangerous if applied immediately (could exceed ABL), but will not output until the next show()
|
||||||
busses.setBrightness(b);
|
busses.setBrightness(b);
|
||||||
} else {
|
} else {
|
||||||
unsigned long t = millis();
|
unsigned long t = millis();
|
||||||
if (_segments[0].next_time > t + 22 && t - _lastShow > MIN_SHOW_DELAY) show(); //apply brightness change immediately if no refresh soon
|
if (_segments[0].next_time > t + 22 && t - _lastShow > MIN_SHOW_DELAY) show(); //apply brightness change immediately if no refresh soon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1178,7 +1211,7 @@ uint16_t WS2812FX::getLengthPhysical(void) {
|
|||||||
//returns if there is an RGBW bus (supports RGB and White, not only white)
|
//returns if there is an RGBW bus (supports RGB and White, not only white)
|
||||||
//not influenced by auto-white mode, also true if white slider does not affect output white channel
|
//not influenced by auto-white mode, also true if white slider does not affect output white channel
|
||||||
bool WS2812FX::hasRGBWBus(void) {
|
bool WS2812FX::hasRGBWBus(void) {
|
||||||
for (size_t b = 0; b < busses.getNumBusses(); b++) {
|
for (size_t b = 0; b < busses.getNumBusses(); b++) {
|
||||||
Bus *bus = busses.getBus(b);
|
Bus *bus = busses.getBus(b);
|
||||||
if (bus == nullptr || bus->getLength()==0) break;
|
if (bus == nullptr || bus->getLength()==0) break;
|
||||||
switch (bus->getType()) {
|
switch (bus->getType()) {
|
||||||
@ -1188,12 +1221,12 @@ bool WS2812FX::hasRGBWBus(void) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WS2812FX::hasCCTBus(void) {
|
bool WS2812FX::hasCCTBus(void) {
|
||||||
if (cctFromRgb && !correctWB) return false;
|
if (cctFromRgb && !correctWB) return false;
|
||||||
for (size_t b = 0; b < busses.getNumBusses(); b++) {
|
for (size_t b = 0; b < busses.getNumBusses(); b++) {
|
||||||
Bus *bus = busses.getBus(b);
|
Bus *bus = busses.getBus(b);
|
||||||
if (bus == nullptr || bus->getLength()==0) break;
|
if (bus == nullptr || bus->getLength()==0) break;
|
||||||
switch (bus->getType()) {
|
switch (bus->getType()) {
|
||||||
@ -1202,7 +1235,7 @@ bool WS2812FX::hasCCTBus(void) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::purgeSegments(bool force) {
|
void WS2812FX::purgeSegments(bool force) {
|
||||||
@ -1235,8 +1268,8 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping,
|
|||||||
boundsUnchanged &= (seg.startY == startY && seg.stopY == stopY);
|
boundsUnchanged &= (seg.startY == startY && seg.stopY == stopY);
|
||||||
}
|
}
|
||||||
if (boundsUnchanged
|
if (boundsUnchanged
|
||||||
&& (!grouping || (seg.grouping == grouping && seg.spacing == spacing))
|
&& (!grouping || (seg.grouping == grouping && seg.spacing == spacing))
|
||||||
&& (offset == UINT16_MAX || offset == seg.offset)) return;
|
&& (offset == UINT16_MAX || offset == seg.offset)) return;
|
||||||
|
|
||||||
//if (seg.stop) setRange(seg.start, seg.stop -1, BLACK); //turn old segment range off
|
//if (seg.stop) setRange(seg.start, seg.stop -1, BLACK); //turn old segment range off
|
||||||
if (seg.stop) seg.fill(BLACK); //turn old segment range off
|
if (seg.stop) seg.fill(BLACK); //turn old segment range off
|
||||||
@ -1271,7 +1304,7 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping,
|
|||||||
seg.grouping = grouping;
|
seg.grouping = grouping;
|
||||||
seg.spacing = spacing;
|
seg.spacing = spacing;
|
||||||
}
|
}
|
||||||
if (offset < UINT16_MAX) seg.offset = offset;
|
if (offset < UINT16_MAX) seg.offset = offset;
|
||||||
seg.markForReset();
|
seg.markForReset();
|
||||||
if (!boundsUnchanged) seg.refreshLightCapabilities();
|
if (!boundsUnchanged) seg.refreshLightCapabilities();
|
||||||
}
|
}
|
||||||
@ -1406,7 +1439,7 @@ void WS2812FX::setTransitionMode(bool t)
|
|||||||
void WS2812FX::printSize()
|
void WS2812FX::printSize()
|
||||||
{
|
{
|
||||||
size_t size = 0;
|
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("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("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 *)));
|
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
|
// otherwise use "double press" for segment selection
|
||||||
Segment& seg = strip.getSegment(macroDoublePress[b]);
|
Segment& seg = strip.getSegment(macroDoublePress[b]);
|
||||||
if (aRead == 0) {
|
if (aRead == 0) {
|
||||||
seg.on = false; // off
|
seg.setOption(SEG_OPTION_ON, false); // off (use transition)
|
||||||
} else {
|
} else {
|
||||||
seg.setOpacity(aRead);
|
seg.setOpacity(aRead);
|
||||||
seg.on = true;
|
seg.setOption(SEG_OPTION_ON, true); // on (use transition)
|
||||||
}
|
}
|
||||||
// this will notify clients of update (websockets,mqtt,etc)
|
// this will notify clients of update (websockets,mqtt,etc)
|
||||||
updateInterfaces(CALL_MODE_BUTTON);
|
updateInterfaces(CALL_MODE_BUTTON);
|
||||||
|
@ -283,11 +283,13 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
JsonArray hw_if_spi = hw[F("if")][F("spi-pin")];
|
JsonArray hw_if_spi = hw[F("if")][F("spi-pin")];
|
||||||
CJSON(spi_mosi, hw_if_spi[0]);
|
CJSON(spi_mosi, hw_if_spi[0]);
|
||||||
CJSON(spi_sclk, hw_if_spi[1]);
|
CJSON(spi_sclk, hw_if_spi[1]);
|
||||||
PinManagerPinType spi[3] = { { spi_mosi, true }, { spi_sclk, true } };
|
CJSON(spi_miso, hw_if_spi[2]);
|
||||||
if (spi_mosi >= 0 && spi_sclk >= 0 && pinManager.allocateMultiplePins(spi, 2, PinOwner::HW_SPI)) {
|
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
|
// do not initialise bus here
|
||||||
} else {
|
} else {
|
||||||
spi_mosi = -1;
|
spi_mosi = -1;
|
||||||
|
spi_miso = -1;
|
||||||
spi_sclk = -1;
|
spi_sclk = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,6 +748,7 @@ void serializeConfig() {
|
|||||||
JsonArray hw_if_spi = hw_if.createNestedArray("spi-pin");
|
JsonArray hw_if_spi = hw_if.createNestedArray("spi-pin");
|
||||||
hw_if_spi.add(spi_mosi);
|
hw_if_spi.add(spi_mosi);
|
||||||
hw_if_spi.add(spi_sclk);
|
hw_if_spi.add(spi_sclk);
|
||||||
|
hw_if_spi.add(spi_miso);
|
||||||
|
|
||||||
//JsonObject hw_status = hw.createNestedObject("status");
|
//JsonObject hw_status = hw.createNestedObject("status");
|
||||||
//hw_status["pin"] = -1;
|
//hw_status["pin"] = -1;
|
||||||
|
@ -384,6 +384,9 @@
|
|||||||
#if defined(ESP8266) && defined(HW_PIN_DATASPI)
|
#if defined(ESP8266) && defined(HW_PIN_DATASPI)
|
||||||
#undef HW_PIN_DATASPI
|
#undef HW_PIN_DATASPI
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(ESP8266) && defined(HW_PIN_MISOSPI)
|
||||||
|
#undef HW_PIN_MISOSPI
|
||||||
|
#endif
|
||||||
#if defined(ESP8266) && defined(HW_PIN_CSSPI)
|
#if defined(ESP8266) && defined(HW_PIN_CSSPI)
|
||||||
#undef HW_PIN_CSSPI
|
#undef HW_PIN_CSSPI
|
||||||
#endif
|
#endif
|
||||||
@ -394,6 +397,9 @@
|
|||||||
#ifndef HW_PIN_DATASPI
|
#ifndef HW_PIN_DATASPI
|
||||||
#define HW_PIN_DATASPI MOSI
|
#define HW_PIN_DATASPI MOSI
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef HW_PIN_MISOSPI
|
||||||
|
#define HW_PIN_MISOSPI MISO
|
||||||
|
#endif
|
||||||
#ifndef HW_PIN_CSSPI
|
#ifndef HW_PIN_CSSPI
|
||||||
#define HW_PIN_CSSPI SS
|
#define HW_PIN_CSSPI SS
|
||||||
#endif
|
#endif
|
||||||
|
@ -1219,6 +1219,12 @@ TD .checkmark, TD .radiomark {
|
|||||||
filter: grayscale(100%);
|
filter: grayscale(100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.lbl-l {
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
.lbl-s {
|
.lbl-s {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
/* margin: 10px 4px 0 0; */
|
/* margin: 10px 4px 0 0; */
|
||||||
|
@ -574,7 +574,7 @@ function populatePresets(fromls)
|
|||||||
<i class="icons e-icon flr" id="sege${i+100}" onclick="expand(${i+100})"></i>
|
<i class="icons e-icon flr" id="sege${i+100}" onclick="expand(${i+100})"></i>
|
||||||
<div class="presin lstIcontent" id="seg${i+100}"></div>
|
<div class="presin lstIcontent" id="seg${i+100}"></div>
|
||||||
</div>`;
|
</div>`;
|
||||||
pNum++;
|
pNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
gId('pcont').innerHTML = cn;
|
gId('pcont').innerHTML = cn;
|
||||||
@ -643,7 +643,7 @@ function populateInfo(i)
|
|||||||
var pwru = "Not calculated";
|
var pwru = "Not calculated";
|
||||||
if (pwr > 1000) {pwr /= 1000; pwr = pwr.toFixed((pwr > 10) ? 0 : 1); pwru = pwr + " A";}
|
if (pwr > 1000) {pwr /= 1000; pwr = pwr.toFixed((pwr > 10) ? 0 : 1); pwru = pwr + " A";}
|
||||||
else if (pwr > 0) {pwr = 50 * Math.round(pwr/50); pwru = pwr + " mA";}
|
else if (pwr > 0) {pwr = 50 * Math.round(pwr/50); pwru = pwr + " mA";}
|
||||||
var urows="";
|
var urows="";
|
||||||
if (i.u) {
|
if (i.u) {
|
||||||
for (const [k, val] of Object.entries(i.u)) {
|
for (const [k, val] of Object.entries(i.u)) {
|
||||||
if (val[1])
|
if (val[1])
|
||||||
@ -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>
|
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})">
|
<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="1" ${inst.mp12==1?' selected':''}>Bar</option>
|
||||||
<option value="2" ${inst.mp12==2?' selected':''}>Arc</option>
|
<option value="2" ${inst.mp12==2?' selected':''}>Arc</option>
|
||||||
<option value="3" ${inst.mp12==3?' selected':''}>Corner</option>
|
<option value="3" ${inst.mp12==3?' selected':''}>Corner</option>
|
||||||
@ -774,7 +774,7 @@ function populateSegments(s)
|
|||||||
${!isM?rvXck:''}
|
${!isM?rvXck:''}
|
||||||
${isM&&stoY-staY>1&&stoX-staX>1?map2D:''}
|
${isM&&stoY-staY>1&&stoX-staX>1?map2D:''}
|
||||||
${s.AudioReactive && s.AudioReactive.on ? "" : sndSim}
|
${s.AudioReactive && s.AudioReactive.on ? "" : sndSim}
|
||||||
<label class="check revchkl">
|
<label class="check revchkl" id="seg${i}lbtm">
|
||||||
${isM?'Transpose':'Mirror effect'}
|
${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":"")}>
|
<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>
|
<span class="checkmark"></span>
|
||||||
@ -826,7 +826,7 @@ function populateEffects()
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (let ef of effects) {
|
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 id = ef.id;
|
||||||
let nm = ef.name+" ";
|
let nm = ef.name+" ";
|
||||||
let fd = "";
|
let fd = "";
|
||||||
@ -845,7 +845,7 @@ function populateEffects()
|
|||||||
if (r.substring(0,2)=="fr") nm += "♫"; // frequency effects
|
if (r.substring(0,2)=="fr") nm += "♫"; // frequency effects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
html += generateListItemHtml('fx',id,nm,'setX','',fd);
|
html += generateListItemHtml('fx',id,nm,'setFX','',fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -863,10 +863,10 @@ function populatePalettes()
|
|||||||
html += generateListItemHtml(
|
html += generateListItemHtml(
|
||||||
'palette',
|
'palette',
|
||||||
pa[0],
|
pa[0],
|
||||||
pa[1],
|
pa[1],
|
||||||
'setPalette',
|
'setPalette',
|
||||||
`<div class="lstIprev" style="${genPalPrevCss(pa[0])}"></div>`
|
`<div class="lstIprev" style="${genPalPrevCss(pa[0])}"></div>`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
gId('pallist').innerHTML=html;
|
gId('pallist').innerHTML=html;
|
||||||
@ -932,7 +932,7 @@ function genPalPrevCss(id)
|
|||||||
|
|
||||||
function generateListItemHtml(listName, id, name, clickAction, extraHtml = '', effectPar = '')
|
function generateListItemHtml(listName, id, name, clickAction, extraHtml = '', effectPar = '')
|
||||||
{
|
{
|
||||||
return `<div class="lstI${id==0?' sticky':''}" data-id="${id}" ${effectPar===''?'':'data-opt="'+effectPar+'"'}onClick="${clickAction}(${id})">
|
return `<div class="lstI${id==0?' sticky':''}" data-id="${id}" ${effectPar===''?'':'data-opt="'+effectPar+'"'}onClick="${clickAction}(${id})">
|
||||||
<label class="radio schkl" onclick="event.preventDefault()">
|
<label class="radio schkl" onclick="event.preventDefault()">
|
||||||
<input type="radio" value="${id}" name="${listName}">
|
<input type="radio" value="${id}" name="${listName}">
|
||||||
<span class="radiomark"></span>
|
<span class="radiomark"></span>
|
||||||
@ -1035,16 +1035,27 @@ function updateLen(s)
|
|||||||
var stop = parseInt(gId(`seg${s}e`).value);
|
var stop = parseInt(gId(`seg${s}e`).value);
|
||||||
var len = stop - (cfg.comp.seglen?0:start);
|
var len = stop - (cfg.comp.seglen?0:start);
|
||||||
if (isM) {
|
if (isM) {
|
||||||
|
// matrix setup
|
||||||
let startY = parseInt(gId(`seg${s}sY`).value);
|
let startY = parseInt(gId(`seg${s}sY`).value);
|
||||||
let stopY = parseInt(gId(`seg${s}eY`).value);
|
let stopY = parseInt(gId(`seg${s}eY`).value);
|
||||||
len *= (stopY-(cfg.comp.seglen?0:startY));
|
len *= (stopY-(cfg.comp.seglen?0:startY));
|
||||||
|
let tPL = gId(`seg${s}lbtm`);
|
||||||
if (stop-start>1 && stopY-startY>1) {
|
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}"]`);
|
let sE = gId('fxlist').querySelector(`.lstI[data-id="${selectedFx}"]`);
|
||||||
if (sE) {
|
if (sE) {
|
||||||
let sN = sE.querySelector(".lstIname").innerText;
|
let sN = sE.querySelector(".lstIname").innerText;
|
||||||
let seg = gId(`seg${s}map2D`);
|
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)";
|
var out = "(delete)";
|
||||||
@ -1242,7 +1253,7 @@ function readState(s,command=false)
|
|||||||
|
|
||||||
tr = s.transition;
|
tr = s.transition;
|
||||||
gId('tt').value = tr/10;
|
gId('tt').value = tr/10;
|
||||||
|
|
||||||
populateSegments(s);
|
populateSegments(s);
|
||||||
var selc=0;
|
var selc=0;
|
||||||
var sellvl=0; // 0: selc is invalid, 1: selc is mainseg, 2: selc is first selected
|
var sellvl=0; // 0: selc is invalid, 1: selc is mainseg, 2: selc is first selected
|
||||||
@ -1274,7 +1285,7 @@ function readState(s,command=false)
|
|||||||
updateUI();
|
updateUI();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var cd = gId('csl').children;
|
var cd = gId('csl').children;
|
||||||
for (let e = cd.length-1; e >= 0; e--) {
|
for (let e = cd.length-1; e >= 0; e--) {
|
||||||
cd[e].dataset.r = i.col[e][0];
|
cd[e].dataset.r = i.col[e][0];
|
||||||
@ -1345,13 +1356,13 @@ function readState(s,command=false)
|
|||||||
function setEffectParameters(idx)
|
function setEffectParameters(idx)
|
||||||
{
|
{
|
||||||
if (!(Array.isArray(fxdata) && fxdata.length>idx)) return;
|
if (!(Array.isArray(fxdata) && fxdata.length>idx)) return;
|
||||||
var controlDefined = (fxdata[idx].substr(0,1) == "@");
|
var controlDefined = (fxdata[idx].substr(0,1) == "@");
|
||||||
var effectPar = fxdata[idx].substr(1);
|
var effectPar = fxdata[idx].substr(1);
|
||||||
var effectPars = (effectPar == '')?[]:effectPar.split(";");
|
var effectPars = (effectPar == '')?[]:effectPar.split(";");
|
||||||
var slOnOff = (effectPars.length==0 || effectPars[0]=='')?[]:effectPars[0].split(",");
|
var slOnOff = (effectPars.length==0 || effectPars[0]=='')?[]:effectPars[0].split(",");
|
||||||
var coOnOff = (effectPars.length<2 || effectPars[1]=='')?[]:effectPars[1].split(",");
|
var coOnOff = (effectPars.length<2 || effectPars[1]=='')?[]:effectPars[1].split(",");
|
||||||
var paOnOff = (effectPars.length<3 || effectPars[2]=='')?[]:effectPars[2].split(",");
|
var paOnOff = (effectPars.length<3 || effectPars[2]=='')?[]:effectPars[2].split(",");
|
||||||
|
|
||||||
// set html slider items on/off
|
// set html slider items on/off
|
||||||
//var nSliders = Math.min(7,Math.floor(gId("sliders").children.length)); // div for each slider + filter + options
|
//var nSliders = Math.min(7,Math.floor(gId("sliders").children.length)); // div for each slider + filter + options
|
||||||
let nSliders = 5;
|
let nSliders = 5;
|
||||||
@ -1394,7 +1405,7 @@ function setEffectParameters(idx)
|
|||||||
let top = parseInt(getComputedStyle(gId("sliders")).height);
|
let top = parseInt(getComputedStyle(gId("sliders")).height);
|
||||||
top += 5;
|
top += 5;
|
||||||
let sel = d.querySelector('#fxlist .selected');
|
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);
|
},750);
|
||||||
// set html color items on/off
|
// set html color items on/off
|
||||||
var cslLabel = '';
|
var cslLabel = '';
|
||||||
@ -1431,7 +1442,7 @@ function setEffectParameters(idx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
gId("cslLabel").innerHTML = cslLabel;
|
gId("cslLabel").innerHTML = cslLabel;
|
||||||
|
|
||||||
// set palette on/off
|
// set palette on/off
|
||||||
var palw = gId("palw"); // wrapper
|
var palw = gId("palw"); // wrapper
|
||||||
var pall = gId("pall"); // label
|
var pall = gId("pall"); // label
|
||||||
@ -1577,28 +1588,28 @@ function toggleSync()
|
|||||||
|
|
||||||
function toggleLiveview()
|
function toggleLiveview()
|
||||||
{
|
{
|
||||||
//WLEDSR adding liveview2D support
|
//WLEDSR adding liveview2D support
|
||||||
if (isInfo && isM) toggleInfo();
|
if (isInfo && isM) toggleInfo();
|
||||||
if (isNodes && isM) toggleNodes();
|
if (isNodes && isM) toggleNodes();
|
||||||
isLv = !isLv;
|
isLv = !isLv;
|
||||||
|
|
||||||
var lvID = "liveview";
|
var lvID = "liveview";
|
||||||
if (isM) {
|
if (isM) {
|
||||||
lvID = "liveview2D"
|
lvID = "liveview2D"
|
||||||
if (isLv) {
|
if (isLv) {
|
||||||
var cn = '<iframe id="liveview2D" src="about:blank"></iframe>';
|
var cn = '<iframe id="liveview2D" src="about:blank"></iframe>';
|
||||||
d.getElementById('kliveview2D').innerHTML = cn;
|
d.getElementById('kliveview2D').innerHTML = cn;
|
||||||
|
}
|
||||||
|
|
||||||
|
gId('mliveview2D').style.transform = (isLv) ? "translateY(0px)":"translateY(100%)";
|
||||||
}
|
}
|
||||||
|
|
||||||
gId('mliveview2D').style.transform = (isLv) ? "translateY(0px)":"translateY(100%)";
|
gId(lvID).style.display = (isLv) ? "block":"none";
|
||||||
}
|
var url = (loc?`http://${locip}`:'') + "/" + lvID;
|
||||||
|
gId(lvID).src = (isLv) ? url:"about:blank";
|
||||||
gId(lvID).style.display = (isLv) ? "block":"none";
|
gId('buttonSr').className = (isLv) ? "active":"";
|
||||||
var url = (loc?`http://${locip}`:'') + "/" + lvID;
|
if (!isLv && ws && ws.readyState === WebSocket.OPEN) ws.send('{"lv":false}');
|
||||||
gId(lvID).src = (isLv) ? url:"about:blank";
|
size();
|
||||||
gId('buttonSr').className = (isLv) ? "active":"";
|
|
||||||
if (!isLv && ws && ws.readyState === WebSocket.OPEN) ws.send('{"lv":false}');
|
|
||||||
size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleInfo()
|
function toggleInfo()
|
||||||
@ -1803,9 +1814,9 @@ ${makePlSel(plJson[i].end?plJson[i].end:0, true)}
|
|||||||
<span class="checkmark"></span>
|
<span class="checkmark"></span>
|
||||||
</label>`;
|
</label>`;
|
||||||
if (Array.isArray(lastinfo.maps) && lastinfo.maps.length>0) {
|
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>`;
|
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>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1817,17 +1828,12 @@ ${makePlSel(plJson[i].end?plJson[i].end:0, true)}
|
|||||||
<span class="lstIname">
|
<span class="lstIname">
|
||||||
${pl?"Show playlist editor":(i>0)?"Overwrite with state":"Use current state"}
|
${pl?"Show playlist editor":(i>0)?"Overwrite with state":"Use current state"}
|
||||||
</span>
|
</span>
|
||||||
<input type="checkbox" id="p${i}cstgl" onchange="tglCs(${i})" ${(i==0||pl)?"checked":""}>
|
<input type="checkbox" id="p${i}cstgl" onchange="tglCs(${i})" ${(i==0||pl)?"checked":""}>
|
||||||
<span class="checkmark"></span>
|
<span class="checkmark"></span>
|
||||||
</label>
|
</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>
|
||||||
|
<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">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">
|
<div class="c">
|
||||||
<button class="btn btn-p" onclick="saveP(${i},${pl})"><i class="icons btn-icon"></i>Save</button>
|
<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.remove('staybot');
|
||||||
p.classList.add('pres');
|
p.classList.add('pres');
|
||||||
p.innerHTML = `<div class="presin expanded">${makeP(0)}</div>`;
|
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({
|
p.scrollIntoView({
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
block: 'center'
|
block: 'center'
|
||||||
@ -1850,9 +1860,10 @@ function makePUtil()
|
|||||||
gId('psFind').classList.remove('staytop');
|
gId('psFind').classList.remove('staytop');
|
||||||
}
|
}
|
||||||
|
|
||||||
function makePlEntry(p,i) {
|
function makePlEntry(p,i)
|
||||||
return `<div class="plentry">
|
{
|
||||||
<div class="hrz"></div>
|
return `<div class="plentry">
|
||||||
|
<div class="hrz"></div>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="80%" colspan=2>
|
<td width="80%" colspan=2>
|
||||||
@ -1886,6 +1897,7 @@ function makePlUtil()
|
|||||||
p.classList.remove('staybot');
|
p.classList.remove('staybot');
|
||||||
p.innerHTML = `<div class="pres"><div class="segin expanded" id="seg100">${makeP(0,true)}</div></div>`;
|
p.innerHTML = `<div class="pres"><div class="segin expanded" id="seg100">${makeP(0,true)}</div></div>`;
|
||||||
refreshPlE(0);
|
refreshPlE(0);
|
||||||
|
gId('p0txt').focus();
|
||||||
p.scrollIntoView({
|
p.scrollIntoView({
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
block: 'center'
|
block: 'center'
|
||||||
@ -1913,7 +1925,11 @@ function tglCs(i)
|
|||||||
function tglSegn(s)
|
function tglSegn(s)
|
||||||
{
|
{
|
||||||
let t = gId(s<100?`seg${s}t`:`p${s-100}txt`);
|
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.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
@ -1979,6 +1995,7 @@ function setSeg(s)
|
|||||||
var stopY = parseInt(gId(`seg${s}eY`).value);
|
var stopY = parseInt(gId(`seg${s}eY`).value);
|
||||||
obj.seg.startY = startY;
|
obj.seg.startY = startY;
|
||||||
obj.seg.stopY = (cfg.comp.seglen?startY:0)+stopY;
|
obj.seg.stopY = (cfg.comp.seglen?startY:0)+stopY;
|
||||||
|
obj.seg.tp = gId(`seg${s}tp`).checked;
|
||||||
}
|
}
|
||||||
if (gId(`seg${s}grp`)) {
|
if (gId(`seg${s}grp`)) {
|
||||||
var grp = parseInt(gId(`seg${s}grp`).value);
|
var grp = parseInt(gId(`seg${s}grp`).value);
|
||||||
@ -2075,24 +2092,15 @@ function tglFreeze(s=null)
|
|||||||
requestJson(obj);
|
requestJson(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setX(ind = null)
|
function setFX(ind = null)
|
||||||
{
|
{
|
||||||
if (ind === null) {
|
if (ind === null) {
|
||||||
ind = parseInt(d.querySelector('#fxlist input[name="fx"]:checked').value);
|
ind = parseInt(d.querySelector('#fxlist input[name="fx"]:checked').value);
|
||||||
} else {
|
} else {
|
||||||
d.querySelector(`#fxlist input[name="fx"][value="${ind}"]`).checked = true;
|
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),"fxdef":1}}; // fxdef sets effect parameters to default values, TODO add client setting
|
||||||
*/
|
|
||||||
var obj = {"seg": {"fx": parseInt(ind)}};
|
|
||||||
requestJson(obj);
|
requestJson(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2103,13 +2111,7 @@ function setPalette(paletteId = null)
|
|||||||
} else {
|
} else {
|
||||||
d.querySelector(`#pallist input[name="palette"][value="${paletteId}"]`).checked = true;
|
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}};
|
var obj = {"seg": {"pal": paletteId}};
|
||||||
requestJson(obj);
|
requestJson(obj);
|
||||||
}
|
}
|
||||||
@ -2196,7 +2198,7 @@ function saveP(i,pl)
|
|||||||
gId(`p${i}warn`).innerHTML = "⚠ Syntax error in custom JSON API command";
|
gId(`p${i}warn`).innerHTML = "⚠ Syntax error in custom JSON API command";
|
||||||
return;
|
return;
|
||||||
} else if (raw.indexOf("Please") == 0) {
|
} else if (raw.indexOf("Please") == 0) {
|
||||||
gId(`p${i}warn`).innerHTML = "⚠ Please refresh the page before modifying this preset";
|
gId(`p${i}warn`).innerHTML = "⚠ Please refresh the page before modifying this preset";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@
|
|||||||
<i class="icons search-icon"></i>
|
<i class="icons search-icon"></i>
|
||||||
</div>
|
</div>
|
||||||
<div id="fxlist" class="list">
|
<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>
|
</div>
|
||||||
<div id="palDropdown" class="dd-content">
|
<div id="palDropdown" class="dd-content">
|
||||||
|
@ -1124,7 +1124,7 @@ function setSegBri(s)
|
|||||||
function setEffect(ind = 0)
|
function setEffect(ind = 0)
|
||||||
{
|
{
|
||||||
tglFxDropdown();
|
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);
|
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[11] = 4; //Firmware len ("WLED")
|
||||||
out[12] = 'W'; out[13] = 'L'; out[14] = 'E'; out[15] = 'D';
|
out[12] = 'W'; out[13] = 'L'; out[14] = 'E'; out[15] = 'D';
|
||||||
uint8_t lengthSum = 17;
|
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;
|
out[16] = vlen; lengthSum += vlen;
|
||||||
uint8_t hlen = 7;
|
uint8_t hlen = 7;
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
@ -102,12 +102,12 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
byte segbri = seg.opacity;
|
byte segbri = seg.opacity;
|
||||||
if (getVal(elem["bri"], &segbri)) {
|
if (getVal(elem["bri"], &segbri)) {
|
||||||
if (segbri > 0) seg.setOpacity(segbri);
|
if (segbri > 0) seg.setOpacity(segbri);
|
||||||
seg.on = segbri;
|
seg.setOption(SEG_OPTION_ON, segbri); // use transition
|
||||||
}
|
}
|
||||||
|
|
||||||
bool on = elem["on"] | seg.on;
|
bool on = elem["on"] | seg.on;
|
||||||
if (elem["on"].is<const char*>() && elem["on"].as<const char*>()[0] == 't') on = !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;
|
bool frz = elem["frz"] | seg.freeze;
|
||||||
if (elem["frz"].is<const char*>() && elem["frz"].as<const char*>()[0] == 't') frz = !seg.freeze;
|
if (elem["frz"].is<const char*>() && elem["frz"].as<const char*>()[0] == 't') frz = !seg.freeze;
|
||||||
seg.freeze = frz;
|
seg.freeze = frz;
|
||||||
@ -178,34 +178,29 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
seg.startTransition(strip.getTransition()); // set effect transitions
|
seg.startTransition(strip.getTransition()); // set effect transitions
|
||||||
//seg.markForReset();
|
//seg.markForReset();
|
||||||
seg.mode = fx;
|
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()
|
// load default values from effect string
|
||||||
&& elem["pal"].isNull()
|
if (elem[F("fxdef")])
|
||||||
&& elem[F("c1")].isNull()
|
{
|
||||||
&& elem[F("c2")].isNull()
|
int16_t sOpt;
|
||||||
&& elem[F("c3")].isNull() )
|
sOpt = extractModeDefaults(fx, SET_F("sx")); if (sOpt >= 0) seg.speed = sOpt;
|
||||||
{
|
sOpt = extractModeDefaults(fx, SET_F("ix")); if (sOpt >= 0) seg.intensity = sOpt;
|
||||||
int16_t sOpt;
|
sOpt = extractModeDefaults(fx, SET_F("c1")); if (sOpt >= 0) seg.custom1 = sOpt;
|
||||||
sOpt = extractModeDefaults(fx, SET_F("sx")); if (sOpt >= 0) seg.speed = sOpt;
|
sOpt = extractModeDefaults(fx, SET_F("c2")); if (sOpt >= 0) seg.custom2 = sOpt;
|
||||||
sOpt = extractModeDefaults(fx, SET_F("ix")); if (sOpt >= 0) seg.intensity = sOpt;
|
sOpt = extractModeDefaults(fx, SET_F("c3")); if (sOpt >= 0) seg.custom3 = sOpt;
|
||||||
sOpt = extractModeDefaults(fx, SET_F("c1")); if (sOpt >= 0) seg.custom1 = sOpt;
|
sOpt = extractModeDefaults(fx, SET_F("mp12")); if (sOpt >= 0) seg.map1D2D = sOpt & 0x07;
|
||||||
sOpt = extractModeDefaults(fx, SET_F("c2")); if (sOpt >= 0) seg.custom2 = sOpt;
|
sOpt = extractModeDefaults(fx, SET_F("ssim")); if (sOpt >= 0) seg.soundSim = sOpt & 0x03;
|
||||||
sOpt = extractModeDefaults(fx, SET_F("c3")); if (sOpt >= 0) seg.custom3 = sOpt;
|
sOpt = extractModeDefaults(fx, "rev"); if (sOpt >= 0) seg.reverse = (bool)sOpt;
|
||||||
sOpt = extractModeDefaults(fx, SET_F("mp12")); if (sOpt >= 0) seg.map1D2D = sOpt & 0x07;
|
sOpt = extractModeDefaults(fx, SET_F("mi")); if (sOpt >= 0) seg.mirror = (bool)sOpt; // NOTE: setting this option is a risky business
|
||||||
sOpt = extractModeDefaults(fx, SET_F("ssim")); if (sOpt >= 0) seg.soundSim = sOpt & 0x03;
|
sOpt = extractModeDefaults(fx, SET_F("rY")); if (sOpt >= 0) seg.reverse_y = (bool)sOpt;
|
||||||
sOpt = extractModeDefaults(fx, "rev"); if (sOpt >= 0) seg.reverse = (bool)sOpt;
|
sOpt = extractModeDefaults(fx, SET_F("mY")); if (sOpt >= 0) seg.mirror_y = (bool)sOpt; // NOTE: setting this option is a risky business
|
||||||
sOpt = extractModeDefaults(fx, SET_F("mi")); if (sOpt >= 0) seg.mirror = (bool)sOpt; // NOTE: setting this option is a risky business
|
sOpt = extractModeDefaults(fx, "pal");
|
||||||
sOpt = extractModeDefaults(fx, SET_F("rY")); if (sOpt >= 0) seg.reverse_y = (bool)sOpt;
|
if (sOpt >= 0 && sOpt < strip.getPaletteCount() + strip.customPalettes.size()) {
|
||||||
sOpt = extractModeDefaults(fx, SET_F("mY")); if (sOpt >= 0) seg.mirror_y = (bool)sOpt; // NOTE: setting this option is a risky business
|
if (sOpt != seg.palette) {
|
||||||
sOpt = extractModeDefaults(fx, "pal");
|
if (strip.paletteFade && !seg.transitional) seg.startTransition(strip.getTransition());
|
||||||
if (sOpt >= 0 && sOpt < strip.getPaletteCount() + strip.customPalettes.size()) {
|
seg.palette = sOpt;
|
||||||
if (sOpt != seg.palette) {
|
|
||||||
if (strip.paletteFade && !seg.transitional) seg.startTransition(strip.getTransition());
|
|
||||||
seg.palette = sOpt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -502,23 +502,27 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
i2c_scl = -1;
|
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_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()));
|
int8_t hw_sclk_pin = !request->arg(F("SCLK")).length() ? -1 : max(-1,min(33,(int)request->arg(F("SCLK")).toInt()));
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
// cannot change pins on 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_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;
|
if (hw_sclk_pin >= 0 && hw_sclk_pin != HW_PIN_CLOCKSPI) hw_sclk_pin = HW_PIN_CLOCKSPI;
|
||||||
#endif
|
#endif
|
||||||
PinManagerPinType spi[2] = { { hw_mosi_pin, true }, { hw_sclk_pin, true } };
|
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, 2, PinOwner::HW_SPI)) {
|
if (hw_mosi_pin >= 0 && hw_sclk_pin >= 0 && pinManager.allocateMultiplePins(spi, 3, PinOwner::HW_SPI)) {
|
||||||
spi_mosi = hw_mosi_pin;
|
spi_mosi = hw_mosi_pin;
|
||||||
|
spi_miso = hw_miso_pin;
|
||||||
spi_sclk = hw_sclk_pin;
|
spi_sclk = hw_sclk_pin;
|
||||||
// no bus initialisation
|
// no bus initialisation
|
||||||
} else {
|
} else {
|
||||||
//SPI.end();
|
//SPI.end();
|
||||||
DEBUG_PRINTLN(F("Could not allocate SPI pins."));
|
DEBUG_PRINTLN(F("Could not allocate SPI pins."));
|
||||||
uint8_t spi[2] = { spi_mosi, spi_sclk };
|
uint8_t spi[3] = { spi_mosi, spi_miso, spi_sclk };
|
||||||
pinManager.deallocateMultiplePins(spi, 2, PinOwner::HW_SPI); // just in case deallocation of old pins
|
pinManager.deallocateMultiplePins(spi, 3, PinOwner::HW_SPI); // just in case deallocation of old pins
|
||||||
spi_mosi = -1;
|
spi_mosi = -1;
|
||||||
|
spi_miso = -1;
|
||||||
spi_sclk = -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
|
pos = req.indexOf(F("SB=")); //Segment brightness/opacity
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
byte segbri = getNumVal(&req, pos);
|
byte segbri = getNumVal(&req, pos);
|
||||||
selseg.on = segbri;
|
selseg.setOption(SEG_OPTION_ON, segbri); // use transition
|
||||||
if (segbri) {
|
if (segbri) {
|
||||||
selseg.setOpacity(segbri);
|
selseg.setOpacity(segbri);
|
||||||
}
|
}
|
||||||
@ -722,9 +726,9 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
|||||||
pos = req.indexOf(F("SW=")); //segment power
|
pos = req.indexOf(F("SW=")); //segment power
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
switch (getNumVal(&req, pos)) {
|
switch (getNumVal(&req, pos)) {
|
||||||
case 0: selseg.on = false; break;
|
case 0: selseg.setOption(SEG_OPTION_ON, false); break; // use transition
|
||||||
case 1: selseg.on = true; break;
|
case 1: selseg.setOption(SEG_OPTION_ON, true); break; // use transition
|
||||||
default: selseg.on = !selseg.on; break;
|
default: selseg.setOption(SEG_OPTION_ON, !selseg.on); break; // use transition
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// 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
|
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||||
//#define WLED_USE_MY_CONFIG
|
//#define WLED_USE_MY_CONFIG
|
||||||
@ -51,8 +51,8 @@
|
|||||||
|
|
||||||
#ifndef WLED_WATCHDOG_TIMEOUT
|
#ifndef WLED_WATCHDOG_TIMEOUT
|
||||||
// 3 seconds should be enough to detect a lockup
|
// 3 seconds should be enough to detect a lockup
|
||||||
// define WLED_WATCHDOG_TIMEOUT=0 to disable watchdog
|
// define WLED_WATCHDOG_TIMEOUT=0 to disable watchdog, default
|
||||||
#define WLED_WATCHDOG_TIMEOUT 3
|
#define WLED_WATCHDOG_TIMEOUT 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//optionally disable brownout detector on ESP32.
|
//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_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 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_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)
|
WLED_GLOBAL int8_t spi_sclk _INIT(-1); // global SPI CLOCK/SCLK pin [HW_PIN_CLOCKSPI] (used for usermods)
|
||||||
|
|
||||||
// global ArduinoJson buffer
|
// global ArduinoJson buffer
|
||||||
|
@ -425,7 +425,7 @@ void deEEP() {
|
|||||||
for (byte j = 0; j < strip.getMaxSegments(); j++)
|
for (byte j = 0; j < strip.getMaxSegments(); j++)
|
||||||
{
|
{
|
||||||
strip.getSegment(j).opacity = 255;
|
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);
|
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("SDA"),i2c_sda);
|
||||||
sappend('v',SET_F("SCL"),i2c_scl);
|
sappend('v',SET_F("SCL"),i2c_scl);
|
||||||
sappend('v',SET_F("MOSI"),spi_mosi);
|
sappend('v',SET_F("MOSI"),spi_mosi);
|
||||||
|
sappend('v',SET_F("MISO"),spi_miso);
|
||||||
sappend('v',SET_F("SCLK"),spi_sclk);
|
sappend('v',SET_F("SCLK"),spi_sclk);
|
||||||
oappend(SET_F("addInfo('SDA','")); oappendi(HW_PIN_SDA); oappend(SET_F("');"));
|
oappend(SET_F("addInfo('SDA','")); oappendi(HW_PIN_SDA); oappend(SET_F("');"));
|
||||||
oappend(SET_F("addInfo('SCL','")); oappendi(HW_PIN_SCL); oappend(SET_F("');"));
|
oappend(SET_F("addInfo('SCL','")); oappendi(HW_PIN_SCL); oappend(SET_F("');"));
|
||||||
|
Loading…
Reference in New Issue
Block a user