Merge branch 'async-psave' into dev

This commit is contained in:
Blaž Kristan 2022-10-13 14:25:01 +02:00
commit 3841780fe6
14 changed files with 1161 additions and 1117 deletions

View File

@ -293,8 +293,8 @@ class MultiRelay : public Usermod {
json[F("stat_t")] = "~";
json[F("cmd_t")] = F("~/command");
json[F("pl_off")] = F("off");
json[F("pl_on")] = F("on");
json[F("pl_off")] = "off";
json[F("pl_on")] = "on";
json[F("uniq_id")] = uid;
strcpy(buf, mqttDeviceTopic); //max length: 33 + 7 = 40

View File

@ -4106,14 +4106,14 @@ uint16_t mode_dancing_shadows(void)
if (spotlights[i].width <= 1) {
if (start >= 0 && start < SEGLEN) {
SEGMENT.blendPixelColor(start, color, 128); // TODO
SEGMENT.blendPixelColor(start, color, 128);
}
} else {
switch (spotlights[i].type) {
case SPOT_TYPE_SOLID:
for (size_t j = 0; j < spotlights[i].width; j++) {
if ((start + j) >= 0 && (start + j) < SEGLEN) {
SEGMENT.blendPixelColor(start + j, color, 128); // TODO
SEGMENT.blendPixelColor(start + j, color, 128);
}
}
break;
@ -4121,7 +4121,7 @@ uint16_t mode_dancing_shadows(void)
case SPOT_TYPE_GRADIENT:
for (size_t j = 0; j < spotlights[i].width; j++) {
if ((start + j) >= 0 && (start + j) < SEGLEN) {
SEGMENT.blendPixelColor(start + j, color, cubicwave8(map(j, 0, spotlights[i].width - 1, 0, 255))); // TODO
SEGMENT.blendPixelColor(start + j, color, cubicwave8(map(j, 0, spotlights[i].width - 1, 0, 255)));
}
}
break;
@ -4129,7 +4129,7 @@ uint16_t mode_dancing_shadows(void)
case SPOT_TYPE_2X_GRADIENT:
for (size_t j = 0; j < spotlights[i].width; j++) {
if ((start + j) >= 0 && (start + j) < SEGLEN) {
SEGMENT.blendPixelColor(start + j, color, cubicwave8(2 * map(j, 0, spotlights[i].width - 1, 0, 255))); // TODO
SEGMENT.blendPixelColor(start + j, color, cubicwave8(2 * map(j, 0, spotlights[i].width - 1, 0, 255)));
}
}
break;
@ -4137,7 +4137,7 @@ uint16_t mode_dancing_shadows(void)
case SPOT_TYPE_2X_DOT:
for (size_t j = 0; j < spotlights[i].width; j += 2) {
if ((start + j) >= 0 && (start + j) < SEGLEN) {
SEGMENT.blendPixelColor(start + j, color, 128); // TODO
SEGMENT.blendPixelColor(start + j, color, 128);
}
}
break;
@ -4145,7 +4145,7 @@ uint16_t mode_dancing_shadows(void)
case SPOT_TYPE_3X_DOT:
for (size_t j = 0; j < spotlights[i].width; j += 3) {
if ((start + j) >= 0 && (start + j) < SEGLEN) {
SEGMENT.blendPixelColor(start + j, color, 128); // TODO
SEGMENT.blendPixelColor(start + j, color, 128);
}
}
break;
@ -4153,7 +4153,7 @@ uint16_t mode_dancing_shadows(void)
case SPOT_TYPE_4X_DOT:
for (size_t j = 0; j < spotlights[i].width; j += 4) {
if ((start + j) >= 0 && (start + j) < SEGLEN) {
SEGMENT.blendPixelColor(start + j, color, 128); // TODO
SEGMENT.blendPixelColor(start + j, color, 128);
}
}
break;
@ -4163,7 +4163,7 @@ uint16_t mode_dancing_shadows(void)
return FRAMETIME;
}
static const char _data_FX_MODE_DANCING_SHADOWS[] PROGMEM = "Dancing Shadows@!,# of shadows;!,,;!;1d";
static const char _data_FX_MODE_DANCING_SHADOWS[] PROGMEM = "Dancing Shadows@!,# of shadows;!,!,!;!;1d";
/*
@ -4524,7 +4524,7 @@ uint16_t mode_perlinmove(void) {
return FRAMETIME;
} // mode_perlinmove()
static const char _data_FX_MODE_PERLINMOVE[] PROGMEM = "Perlin Move@!,# of pixels,fade rate;,!;!;1d";
static const char _data_FX_MODE_PERLINMOVE[] PROGMEM = "Perlin Move@!,# of pixels,fade rate;!,!;!;1d";
/////////////////////////

View File

@ -4,9 +4,12 @@
#include "NeoPixelBrightnessBus.h"
// temporary - these defines should actually be set in platformio.ini
// C3: I2S0 and I2S1 methods not supported
// S2: I2S1 methods not supported
// S3: I2S0 and I2S1 methods not supported yet
// C3: I2S0 and I2S1 methods not supported (has one I2S bus)
// S2: I2S1 methods not supported (has one I2S bus)
// S3: I2S0 and I2S1 methods not supported yet (has two I2S buses)
// https://github.com/Makuna/NeoPixelBus/blob/b32f719e95ef3c35c46da5c99538017ef925c026/src/internal/Esp32_i2s.h#L4
// https://github.com/Makuna/NeoPixelBus/blob/b32f719e95ef3c35c46da5c99538017ef925c026/src/internal/NeoEsp32RmtMethod.h#L857
#if !defined(WLED_NO_I2S0_PIXELBUS) && (defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3))
#define WLED_NO_I2S0_PIXELBUS
#endif
@ -46,54 +49,57 @@
#define I_8266_DM_TM1_4 15
#define I_8266_BB_TM1_4 16
//TM1829 (RGB)
#define I_8266_U0_TM2_3 39
#define I_8266_U1_TM2_3 40
#define I_8266_DM_TM2_3 41
#define I_8266_BB_TM2_3 42
#define I_8266_U0_TM2_3 17
#define I_8266_U1_TM2_3 18
#define I_8266_DM_TM2_3 19
#define I_8266_BB_TM2_3 20
/*** ESP32 Neopixel methods ***/
//RGB
#define I_32_RN_NEO_3 17
#define I_32_I0_NEO_3 18
#define I_32_I1_NEO_3 19
#define I_32_RN_NEO_3 21
#define I_32_I0_NEO_3 22
#define I_32_I1_NEO_3 23
#define I_32_BB_NEO_3 24 // bitbangging on ESP32 not recommended
//RGBW
#define I_32_RN_NEO_4 20
#define I_32_I0_NEO_4 21
#define I_32_I1_NEO_4 22
#define I_32_RN_NEO_4 25
#define I_32_I0_NEO_4 26
#define I_32_I1_NEO_4 27
#define I_32_BB_NEO_4 28 // bitbangging on ESP32 not recommended
//400Kbps
#define I_32_RN_400_3 23
#define I_32_I0_400_3 24
#define I_32_I1_400_3 25
#define I_32_RN_400_3 29
#define I_32_I0_400_3 30
#define I_32_I1_400_3 31
#define I_32_BB_400_3 32 // bitbangging on ESP32 not recommended
//TM1814 (RGBW)
#define I_32_RN_TM1_4 26
#define I_32_I0_TM1_4 27
#define I_32_I1_TM1_4 28
#define I_32_RN_TM1_4 33
#define I_32_I0_TM1_4 34
#define I_32_I1_TM1_4 35
//Bit Bang theoratically possible, but very undesirable and not needed (no pin restrictions on RMT and I2S)
//TM1829 (RGB)
#define I_32_RN_TM2_3 43
#define I_32_I0_TM2_3 44
#define I_32_I1_TM2_3 45
#define I_32_RN_TM2_3 36
#define I_32_I0_TM2_3 37
#define I_32_I1_TM2_3 38
//Bit Bang theoratically possible, but very undesirable and not needed (no pin restrictions on RMT and I2S)
//APA102
#define I_HS_DOT_3 29 //hardware SPI
#define I_SS_DOT_3 30 //soft SPI
#define I_HS_DOT_3 39 //hardware SPI
#define I_SS_DOT_3 40 //soft SPI
//LPD8806
#define I_HS_LPD_3 31
#define I_SS_LPD_3 32
#define I_HS_LPD_3 41
#define I_SS_LPD_3 42
//WS2801
#define I_HS_WS1_3 33
#define I_SS_WS1_3 34
#define I_HS_WS1_3 43
#define I_SS_WS1_3 44
//P9813
#define I_HS_P98_3 35
#define I_SS_P98_3 36
#define I_HS_P98_3 45
#define I_SS_P98_3 46
//LPD6803
#define I_HS_LPO_3 37
#define I_SS_LPO_3 38
#define I_HS_LPO_3 47
#define I_SS_LPO_3 48
/*** ESP8266 Neopixel methods ***/
@ -135,6 +141,7 @@
#ifndef WLED_NO_I2S1_PIXELBUS
#define B_32_I1_NEO_3 NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp32I2s1800KbpsMethod>
#endif
//#define B_32_BB_NEO_3 NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp32BitBang800KbpsMethod>
//RGBW
#define B_32_RN_NEO_4 NeoPixelBrightnessBus<NeoGrbwFeature, NeoEsp32RmtNWs2812xMethod>
#ifndef WLED_NO_I2S0_PIXELBUS
@ -143,6 +150,7 @@
#ifndef WLED_NO_I2S1_PIXELBUS
#define B_32_I1_NEO_4 NeoPixelBrightnessBus<NeoGrbwFeature, NeoEsp32I2s1800KbpsMethod>
#endif
//#define B_32_BB_NEO_4 NeoPixelBrightnessBus<NeoGrbwFeature, NeoEsp32BitBang800KbpsMethod>
//400Kbps
#define B_32_RN_400_3 NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp32RmtN400KbpsMethod>
#ifndef WLED_NO_I2S0_PIXELBUS
@ -151,6 +159,7 @@
#ifndef WLED_NO_I2S1_PIXELBUS
#define B_32_I1_400_3 NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp32I2s1400KbpsMethod>
#endif
//#define B_32_BB_400_3 NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp32BitBang400KbpsMethod>
//TM1814 (RGBW)
#define B_32_RN_TM1_4 NeoPixelBrightnessBus<NeoWrgbTm1814Feature, NeoEsp32RmtNTm1814Method>
#ifndef WLED_NO_I2S0_PIXELBUS
@ -255,6 +264,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_3: (static_cast<B_32_I1_NEO_3*>(busPtr))->Begin(); break;
#endif
// case I_32_BB_NEO_3: (static_cast<B_32_BB_NEO_3*>(busPtr))->Begin(); break;
case I_32_RN_NEO_4: (static_cast<B_32_RN_NEO_4*>(busPtr))->Begin(); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_NEO_4: (static_cast<B_32_I0_NEO_4*>(busPtr))->Begin(); break;
@ -262,6 +272,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_4: (static_cast<B_32_I1_NEO_4*>(busPtr))->Begin(); break;
#endif
// case I_32_BB_NEO_4: (static_cast<B_32_BB_NEO_4*>(busPtr))->Begin(); break;
case I_32_RN_400_3: (static_cast<B_32_RN_400_3*>(busPtr))->Begin(); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_400_3: (static_cast<B_32_I0_400_3*>(busPtr))->Begin(); break;
@ -269,6 +280,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_400_3: (static_cast<B_32_I1_400_3*>(busPtr))->Begin(); break;
#endif
// case I_32_BB_400_3: (static_cast<B_32_BB_400_3*>(busPtr))->Begin(); break;
case I_32_RN_TM1_4: beginTM1814<B_32_RN_TM1_4*>(busPtr); break;
case I_32_RN_TM2_3: (static_cast<B_32_RN_TM2_3*>(busPtr))->Begin(); break;
#ifndef WLED_NO_I2S0_PIXELBUS
@ -327,6 +339,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_3: busPtr = new B_32_I1_NEO_3(len, pins[0]); break;
#endif
// case I_32_BB_NEO_3: busPtr = new B_32_BB_NEO_3(len, pins[0], (NeoBusChannel)channel); break;
case I_32_RN_NEO_4: busPtr = new B_32_RN_NEO_4(len, pins[0], (NeoBusChannel)channel); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_NEO_4: busPtr = new B_32_I0_NEO_4(len, pins[0]); break;
@ -334,6 +347,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_4: busPtr = new B_32_I1_NEO_4(len, pins[0]); break;
#endif
// case I_32_BB_NEO_4: busPtr = new B_32_BB_NEO_4(len, pins[0], (NeoBusChannel)channel); break;
case I_32_RN_400_3: busPtr = new B_32_RN_400_3(len, pins[0], (NeoBusChannel)channel); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_400_3: busPtr = new B_32_I0_400_3(len, pins[0]); break;
@ -341,6 +355,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_400_3: busPtr = new B_32_I1_400_3(len, pins[0]); break;
#endif
// case I_32_BB_400_3: busPtr = new B_32_BB_400_3(len, pins[0], (NeoBusChannel)channel); break;
case I_32_RN_TM1_4: busPtr = new B_32_RN_TM1_4(len, pins[0], (NeoBusChannel)channel); break;
case I_32_RN_TM2_3: busPtr = new B_32_RN_TM2_3(len, pins[0], (NeoBusChannel)channel); break;
#ifndef WLED_NO_I2S0_PIXELBUS
@ -400,6 +415,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_3: (static_cast<B_32_I1_NEO_3*>(busPtr))->Show(); break;
#endif
// case I_32_BB_NEO_3: (static_cast<B_32_BB_NEO_3*>(busPtr))->Show(); break;
case I_32_RN_NEO_4: (static_cast<B_32_RN_NEO_4*>(busPtr))->Show(); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_NEO_4: (static_cast<B_32_I0_NEO_4*>(busPtr))->Show(); break;
@ -407,6 +423,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_4: (static_cast<B_32_I1_NEO_4*>(busPtr))->Show(); break;
#endif
// case I_32_BB_NEO_4: (static_cast<B_32_BB_NEO_4*>(busPtr))->Show(); break;
case I_32_RN_400_3: (static_cast<B_32_RN_400_3*>(busPtr))->Show(); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_400_3: (static_cast<B_32_I0_400_3*>(busPtr))->Show(); break;
@ -414,6 +431,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_400_3: (static_cast<B_32_I1_400_3*>(busPtr))->Show(); break;
#endif
// case I_32_BB_400_3: (static_cast<B_32_BB_400_3*>(busPtr))->Show(); break;
case I_32_RN_TM1_4: (static_cast<B_32_RN_TM1_4*>(busPtr))->Show(); break;
case I_32_RN_TM2_3: (static_cast<B_32_RN_TM2_3*>(busPtr))->Show(); break;
#ifndef WLED_NO_I2S0_PIXELBUS
@ -470,6 +488,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_3: return (static_cast<B_32_I1_NEO_3*>(busPtr))->CanShow(); break;
#endif
// case I_32_BB_NEO_3: return (static_cast<B_32_BB_NEO_3*>(busPtr))->CanShow(); break;
case I_32_RN_NEO_4: return (static_cast<B_32_RN_NEO_4*>(busPtr))->CanShow(); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_NEO_4: return (static_cast<B_32_I0_NEO_4*>(busPtr))->CanShow(); break;
@ -477,6 +496,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_4: return (static_cast<B_32_I1_NEO_4*>(busPtr))->CanShow(); break;
#endif
// case I_32_BB_NEO_4: return (static_cast<B_32_BB_NEO_4*>(busPtr))->CanShow(); break;
case I_32_RN_400_3: return (static_cast<B_32_RN_400_3*>(busPtr))->CanShow(); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_400_3: return (static_cast<B_32_I0_400_3*>(busPtr))->CanShow(); break;
@ -484,6 +504,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_400_3: return (static_cast<B_32_I1_400_3*>(busPtr))->CanShow(); break;
#endif
// case I_32_BB_400_3: return (static_cast<B_32_BB_400_3*>(busPtr))->CanShow(); break;
case I_32_RN_TM1_4: return (static_cast<B_32_RN_TM1_4*>(busPtr))->CanShow(); break;
case I_32_RN_TM2_3: return (static_cast<B_32_RN_TM2_3*>(busPtr))->CanShow(); break;
#ifndef WLED_NO_I2S0_PIXELBUS
@ -564,6 +585,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_3: (static_cast<B_32_I1_NEO_3*>(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break;
#endif
// case I_32_BB_NEO_3: (static_cast<B_32_BB_NEO_3*>(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break;
case I_32_RN_NEO_4: (static_cast<B_32_RN_NEO_4*>(busPtr))->SetPixelColor(pix, col); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_NEO_4: (static_cast<B_32_I0_NEO_4*>(busPtr))->SetPixelColor(pix, col); break;
@ -571,6 +593,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_4: (static_cast<B_32_I1_NEO_4*>(busPtr))->SetPixelColor(pix, col); break;
#endif
// case I_32_BB_NEO_4: (static_cast<B_32_BB_NEO_4*>(busPtr))->SetPixelColor(pix, col); break;
case I_32_RN_400_3: (static_cast<B_32_RN_400_3*>(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_400_3: (static_cast<B_32_I0_400_3*>(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break;
@ -578,6 +601,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_400_3: (static_cast<B_32_I1_400_3*>(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break;
#endif
// case I_32_BB_400_3: (static_cast<B_32_BB_400_3*>(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break;
case I_32_RN_TM1_4: (static_cast<B_32_RN_TM1_4*>(busPtr))->SetPixelColor(pix, col); break;
case I_32_RN_TM2_3: (static_cast<B_32_RN_TM2_3*>(busPtr))->SetPixelColor(pix, RgbColor(col.R,col.G,col.B)); break;
#ifndef WLED_NO_I2S0_PIXELBUS
@ -634,6 +658,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_3: (static_cast<B_32_I1_NEO_3*>(busPtr))->SetBrightness(b); break;
#endif
// case I_32_BB_NEO_3: (static_cast<B_32_BB_NEO_3*>(busPtr))->SetBrightness(b); break;
case I_32_RN_NEO_4: (static_cast<B_32_RN_NEO_4*>(busPtr))->SetBrightness(b); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_NEO_4: (static_cast<B_32_I0_NEO_4*>(busPtr))->SetBrightness(b); break;
@ -641,6 +666,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_4: (static_cast<B_32_I1_NEO_4*>(busPtr))->SetBrightness(b); break;
#endif
// case I_32_BB_NEO_4: (static_cast<B_32_BB_NEO_4*>(busPtr))->SetBrightness(b); break;
case I_32_RN_400_3: (static_cast<B_32_RN_400_3*>(busPtr))->SetBrightness(b); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_400_3: (static_cast<B_32_I0_400_3*>(busPtr))->SetBrightness(b); break;
@ -648,6 +674,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_400_3: (static_cast<B_32_I1_400_3*>(busPtr))->SetBrightness(b); break;
#endif
// case I_32_BB_400_3: (static_cast<B_32_BB_400_3*>(busPtr))->SetBrightness(b); break;
case I_32_RN_TM1_4: (static_cast<B_32_RN_TM1_4*>(busPtr))->SetBrightness(b); break;
case I_32_RN_TM2_3: (static_cast<B_32_RN_TM2_3*>(busPtr))->SetBrightness(b); break;
#ifndef WLED_NO_I2S0_PIXELBUS
@ -705,6 +732,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_3: col = (static_cast<B_32_I1_NEO_3*>(busPtr))->GetPixelColor(pix); break;
#endif
// case I_32_BB_NEO_3: col = (static_cast<B_32_BB_NEO_3*>(busPtr))->GetPixelColor(pix); break;
case I_32_RN_NEO_4: col = (static_cast<B_32_RN_NEO_4*>(busPtr))->GetPixelColor(pix); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_NEO_4: col = (static_cast<B_32_I0_NEO_4*>(busPtr))->GetPixelColor(pix); break;
@ -712,6 +740,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_4: col = (static_cast<B_32_I1_NEO_4*>(busPtr))->GetPixelColor(pix); break;
#endif
// case I_32_BB_NEO_4: col = (static_cast<B_32_BB_NEO_4*>(busPtr))->GetPixelColor(pix); break;
case I_32_RN_400_3: col = (static_cast<B_32_RN_400_3*>(busPtr))->GetPixelColor(pix); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_400_3: col = (static_cast<B_32_I0_400_3*>(busPtr))->GetPixelColor(pix); break;
@ -719,6 +748,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_400_3: col = (static_cast<B_32_I1_400_3*>(busPtr))->GetPixelColor(pix); break;
#endif
// case I_32_BB_400_3: col = (static_cast<B_32_BB_400_3*>(busPtr))->GetPixelColor(pix); break;
case I_32_RN_TM1_4: col = (static_cast<B_32_RN_TM1_4*>(busPtr))->GetPixelColor(pix); break;
case I_32_RN_TM2_3: col = (static_cast<B_32_RN_TM2_3*>(busPtr))->GetPixelColor(pix); break;
#ifndef WLED_NO_I2S0_PIXELBUS
@ -795,6 +825,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_3: delete (static_cast<B_32_I1_NEO_3*>(busPtr)); break;
#endif
// case I_32_BB_NEO_3: delete (static_cast<B_32_BB_NEO_3*>(busPtr)); break;
case I_32_RN_NEO_4: delete (static_cast<B_32_RN_NEO_4*>(busPtr)); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_NEO_4: delete (static_cast<B_32_I0_NEO_4*>(busPtr)); break;
@ -802,6 +833,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_NEO_4: delete (static_cast<B_32_I1_NEO_4*>(busPtr)); break;
#endif
// case I_32_BB_NEO_4: delete (static_cast<B_32_BB_NEO_4*>(busPtr)); break;
case I_32_RN_400_3: delete (static_cast<B_32_RN_400_3*>(busPtr)); break;
#ifndef WLED_NO_I2S0_PIXELBUS
case I_32_I0_400_3: delete (static_cast<B_32_I0_400_3*>(busPtr)); break;
@ -809,6 +841,7 @@ class PolyBus {
#ifndef WLED_NO_I2S1_PIXELBUS
case I_32_I1_400_3: delete (static_cast<B_32_I1_400_3*>(busPtr)); break;
#endif
// case I_32_BB_400_3: delete (static_cast<B_32_BB_400_3*>(busPtr)); break;
case I_32_RN_TM1_4: delete (static_cast<B_32_RN_TM1_4*>(busPtr)); break;
case I_32_RN_TM2_3: delete (static_cast<B_32_RN_TM2_3*>(busPtr)); break;
#ifndef WLED_NO_I2S0_PIXELBUS
@ -875,18 +908,18 @@ class PolyBus {
}
#else //ESP32
uint8_t offset = 0; //0 = RMT (num 0-7) 8 = I2S0 9 = I2S1
#ifdef CONFIG_IDF_TARGET_ESP32S2
#if defined(CONFIG_IDF_TARGET_ESP32S2)
// ESP32-S2 only has 4 RMT channels
if (num > 4) return I_NONE;
if (num > 3) offset = num -3;
if (num > 3) offset = 1; // only one I2S
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
// On ESP32-C3 only the first 2 RMT channels are usable for transmitting
if (num > 1) return I_NONE;
//if (num > 2) offset = num -2; // I2S not supported yet
//if (num > 1) offset = 1; // I2S not supported yet (only 1 I2S)
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
// On ESP32-S3 only the first 4 RMT channels are usable for transmitting
if (num > 3) return I_NONE;
//if (num > 4) offset = num -4; // I2S not supported yet
//if (num > 3) offset = num -4; // I2S not supported yet
#else
// standard ESP32 has 8 RMT and 2 I2S channels
if (num > 9) return I_NONE;

View File

@ -25,10 +25,18 @@
#ifdef ESP8266
#define WLED_MAX_BUSSES 3
#else
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3)
#define WLED_MAX_BUSSES 5
#if defined(CONFIG_IDF_TARGET_ESP32C3) // 2 RMT, only has 1 I2S but NPB does not support it ATM
#define WLED_MAX_BUSSES 2
#elif defined(CONFIG_IDF_TARGET_ESP32S2) // 4 RMT, only has 1 I2S bus, supported in NPB
#if defined(USERMOD_AUDIOREACTIVE) // requested by @softhack007 https://github.com/blazoncek/WLED/issues/33
#define WLED_MAX_BUSSES 4
#else
#if defined(CONFIG_IDF_TARGET_ESP32S3)
#define WLED_MAX_BUSSES 5
#endif
#elif defined(CONFIG_IDF_TARGET_ESP32S3) // 4 RMT, has 2 I2S but NPB does not support them ATM
#define WLED_MAX_BUSSES 4
#else
#if defined(USERMOD_AUDIOREACTIVE) // requested by @softhack007 https://github.com/blazoncek/WLED/issues/33
#define WLED_MAX_BUSSES 8
#else
#define WLED_MAX_BUSSES 10
@ -286,7 +294,7 @@
#ifdef ESP8266
#define MAX_LED_MEMORY 4000
#else
#ifdef ARDUINO_ARCH_ESP32S2
#if defined(ARDUINO_ARCH_ESP32S2) || defined(ARDUINO_ARCH_ESP32C3)
#define MAX_LED_MEMORY 32000
#else
#define MAX_LED_MEMORY 64000

View File

@ -399,7 +399,7 @@ function presetError(empty)
if (bckstr.length > 10) hasBackup = true;
} catch (e) {}
var cn = `<div class="pres c" ${empty?'style="padding:8px;margin-top: 16px;"':'onclick="loadPresets()" style="cursor:pointer;padding:8px;margin-top: 16px;"'}>`;
var cn = `<div class="pres c" ${empty?'style="padding:8px;margin-top: 16px;"':'onclick="pmtLast=0;loadPresets();" style="cursor:pointer;padding:8px;margin-top: 16px;"'}>`;
if (empty)
cn += `You have no presets yet!`;
else
@ -2240,7 +2240,7 @@ function saveP(i,pl)
}
populatePresets();
resetPUtil();
setTimeout(()=>{pmtLast=0; loadPresets();}, 500); // force reloading of presets
setTimeout(()=>{pmtLast=0; loadPresets();}, 750); // force reloading of presets
}
function testPl(i,bt) {
@ -2269,6 +2269,7 @@ function delP(i) {
requestJson(obj);
delete pJson[i];
populatePresets();
gId('putil').classList.add("staybot");
} else {
bt.style.color = "var(--c-r)";
bt.innerHTML = "<i class='icons btn-icon'>&#xe037;</i>Delete!";

View File

@ -135,7 +135,7 @@ void handleIR();
void deserializeSegment(JsonObject elem, byte it, byte presetId = 0);
bool deserializeState(JsonObject root, byte callMode = CALL_MODE_DIRECT_CHANGE, byte presetId = 0);
void serializeSegment(JsonObject& root, Segment& seg, byte id, bool forPreset = false, bool segmentBounds = true);
void serializeState(JsonObject root, bool forPreset = false, bool includeBri = true, bool segmentBounds = true);
void serializeState(JsonObject root, bool forPreset = false, bool includeBri = true, bool segmentBounds = true, bool selectedSegmentsOnly = false);
void serializeInfo(JsonObject root);
void serializeModeNames(JsonArray arr, const char *qstring);
void serializeModeData(JsonObject root);
@ -192,6 +192,7 @@ void shufflePlaylist();
void unloadPlaylist();
int16_t loadPlaylist(JsonObject playlistObject, byte presetId = 0);
void handlePlaylist();
void serializePlaylist(JsonObject obj);
//presets.cpp
void handlePresets();

File diff suppressed because it is too large Load Diff

View File

@ -309,7 +309,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
receiveNotifications = udpn["recv"] | receiveNotifications;
if ((bool)udpn[F("nn")]) callMode = CALL_MODE_NO_NOTIFY; //send no notification just for this request
unsigned long timein = root[F("time")] | UINT32_MAX; //backup time source if NTP not synced
unsigned long timein = root["time"] | UINT32_MAX; //backup time source if NTP not synced
if (timein != UINT32_MAX) {
setTimeFromAPI(timein);
if (presetsModifiedTime == 0) presetsModifiedTime = timein;
@ -396,10 +396,11 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
// b) preset ID only or preset that does not change state (use embedded cycling limits if they exist in getVal())
presetCycCurr = ps;
presetId = ps;
root.remove(F("v")); // may be added in UI call
root.remove(F("time")); // may be added in UI call
root.remove("v"); // may be added in UI call
root.remove("time"); // may be added in UI call
root.remove("ps");
if (root.size() == 0) {
unloadPlaylist(); // we need to unload playlist
applyPreset(ps, callMode); // async load (only preset ID was specified)
return stateResponse;
}
@ -481,7 +482,7 @@ void serializeSegment(JsonObject& root, Segment& seg, byte id, bool forPreset, b
root["mp12"] = seg.map1D2D;
}
void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segmentBounds)
void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segmentBounds, bool selectedSegmentsOnly)
{
if (includeBri) {
root["on"] = (bri > 0);
@ -517,11 +518,10 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme
root[F("mainseg")] = strip.getMainSegmentId();
bool selectedSegmentsOnly = root[F("sc")] | false;
JsonArray seg = root.createNestedArray("seg");
for (size_t s = 0; s < strip.getMaxSegments(); s++) {
if (s >= strip.getSegmentsNum()) {
if (forPreset && segmentBounds) { //disable segments not part of preset
if (forPreset && segmentBounds && !selectedSegmentsOnly) { //disable segments not part of preset
JsonObject seg0 = seg.createNestedObject();
seg0["stop"] = 0;
continue;
@ -529,7 +529,7 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme
break;
}
Segment &sg = strip.getSegment(s);
if (!forPreset && selectedSegmentsOnly && !sg.isSelected()) continue;
if (forPreset && selectedSegmentsOnly && !sg.isSelected()) continue;
if (sg.isActive()) {
JsonObject seg0 = seg.createNestedObject();
serializeSegment(seg0, sg, s, forPreset, segmentBounds);

View File

@ -149,3 +149,19 @@ void handlePlaylist() {
applyPreset(playlistEntries[playlistIndex].preset);
}
}
void serializePlaylist(JsonObject sObj) {
JsonObject playlist = sObj.createNestedObject(F("playlist"));
JsonArray ps = playlist.createNestedArray("ps");
JsonArray dur = playlist.createNestedArray("dur");
JsonArray transition = playlist.createNestedArray(F("transition"));
playlist[F("repeat")] = playlistRepeat;
playlist["end"] = playlistEndPreset;
playlist["r"] = playlistOptions & PL_OPTION_SHUFFLE;
for (int i=0; i<playlistLen; i++) {
ps.add(playlistEntries[i].preset);
dur.add(playlistEntries[i].dur);
transition.add(playlistEntries[i].tr);
}
}

View File

@ -10,6 +10,70 @@ static char *tmpRAMbuffer = nullptr;
static volatile byte presetToApply = 0;
static volatile byte callModeToApply = 0;
static volatile byte presetToSave = 0;
static char quickLoad[3];
static char saveName[33];
static bool includeBri = true, segBounds = true, selectedOnly = false, playlistSave = false;;
static const char *getName(bool persist = true) {
return persist ? "/presets.json" : "/tmp.json";
}
static void doSaveState() {
bool persist = (presetToSave < 251);
const char *filename = getName(persist);
if (!requestJSONBufferLock(10)) return; // will set fileDoc
JsonObject sObj = doc.to<JsonObject>();
DEBUG_PRINTLN(F("Serialize current state"));
if (playlistSave) {
serializePlaylist(sObj);
if (includeBri) sObj["on"] = true;
} else {
serializeState(sObj, true, includeBri, segBounds, selectedOnly);
}
sObj["n"] = saveName;
if (quickLoad[0]) sObj[F("ql")] = quickLoad;
/*
#ifdef WLED_DEBUG
DEBUG_PRINTLN(F("Serialized preset"));
serializeJson(doc,Serial);
DEBUG_PRINTLN();
#endif
*/
#if defined(ARDUINO_ARCH_ESP32)
if (!persist) {
if (tmpRAMbuffer!=nullptr) free(tmpRAMbuffer);
size_t len = measureJson(*fileDoc) + 1;
DEBUG_PRINTLN(len);
// if possible use SPI RAM on ESP32
#ifdef WLED_USE_PSRAM
if (psramFound())
tmpRAMbuffer = (char*) ps_malloc(len);
else
#endif
tmpRAMbuffer = (char*) malloc(len);
if (tmpRAMbuffer!=nullptr) {
serializeJson(*fileDoc, tmpRAMbuffer, len);
} else {
writeObjectToFileUsingId(filename, presetToSave, fileDoc);
}
} else
#endif
writeObjectToFileUsingId(filename, presetToSave, fileDoc);
if (persist) presetsModifiedTime = toki.second(); //unix time
releaseJSONBufferLock();
updateFSInfo();
// clean up
presetToSave = 0;
saveName[0] = '\0';
quickLoad[0] = '\0';
playlistSave = false;
}
bool applyPreset(byte index, byte callMode)
{
@ -17,16 +81,16 @@ bool applyPreset(byte index, byte callMode)
DEBUG_PRINTLN(index);
presetToApply = index;
callModeToApply = callMode;
/*
// the following is needed in case of HTTP JSON API call to return correct state to the caller
// fromJson is true in case when deserializeState() was called with presetId==0
if (fromJson) handlePresets(true); // force immediate processing
*/
return true;
}
void handlePresets()
{
if (presetToSave) {
doSaveState();
return;
}
bool changePreset = false;
uint8_t tmpPreset = presetToApply; // store temporary since deserializeState() may call applyPreset()
uint8_t tmpMode = callModeToApply;
@ -34,60 +98,8 @@ void handlePresets()
if (tmpPreset == 0 || (fileDoc /*&& !force*/)) return; // JSON buffer already allocated and not force apply or no preset waiting
JsonObject fdo;
const char *filename = tmpPreset < 255 ? "/presets.json" : "/tmp.json";
const char *filename = getName(tmpPreset < 255);
/*
* The following code is no longer needed as handlePreset() is never run from
* network callback.
* **************************************************************************
*
//crude way to determine if this was called by a network request
uint8_t core = 1;
#ifdef ARDUINO_ARCH_ESP32
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S2)
// this does not make sense on single core
core = xPortGetCoreID();
#endif
#endif
//only allow use of fileDoc from the core responsible for network requests (AKA HTTP JSON API)
//do not use active network request doc from preset called by main loop (playlist, schedule, ...)
if (fileDoc && core && force && tmpPreset < 255) {
DEBUG_PRINT(F("Force applying preset: "));
DEBUG_PRINTLN(presetToApply);
presetToApply = 0; //clear request for preset
callModeToApply = 0;
// this will overwrite doc with preset content but applyPreset() is the last in such case and content of doc is no longer needed
errorFlag = readObjectFromFileUsingId(filename, tmpPreset, fileDoc) ? ERR_NONE : ERR_FS_PLOAD;
JsonObject fdo = fileDoc->as<JsonObject>();
//HTTP API commands
const char* httpwin = fdo["win"];
if (httpwin) {
String apireq = "win"; // reduce flash string usage
apireq += F("&IN&"); // internal call
apireq += httpwin;
handleSet(nullptr, apireq, false); // may call applyPreset() via PL=
setValuesFromFirstSelectedSeg(); // fills legacy values
changePreset = true;
} else {
if (!fdo["seg"].isNull()) unloadPlaylist(); // if preset contains "seg" we must unload playlist
if (!fdo["seg"].isNull() || !fdo["on"].isNull() || !fdo["bri"].isNull() || !fdo["ps"].isNull() || !fdo[F("playlist")].isNull()) changePreset = true;
fdo.remove("ps"); //remove load request for presets to prevent recursive crash
deserializeState(fdo, tmpMode, tmpPreset); // may call applyPreset() which will overwrite presetToApply
}
if (!errorFlag && changePreset) presetCycCurr = currentPreset = tmpPreset;
colorUpdated(tmpMode);
return;
}
if (force) return; // something went wrong with force option (most likely WS request), quit and wait for async load
*/
// allocate buffer
if (!requestJSONBufferLock(9)) return; // will also assign fileDoc
@ -138,72 +150,53 @@ void handlePresets()
}
//called from handleSet(PS=) [network callback (fileDoc==nullptr), IR (irrational), deserializeState, UDP] and deserializeState() [network callback (filedoc!=nullptr)]
void savePreset(byte index, const char* pname, JsonObject saveobj)
void savePreset(byte index, const char* pname, JsonObject sObj)
{
if (index == 0 || (index > 250 && index < 255)) return;
char tmp[12];
JsonObject sObj = saveobj;
bool bufferAllocated = false;
bool persist = (index != 255);
const char *filename = persist ? "/presets.json" : "/tmp.json";
if (!fileDoc) {
// called from handleSet() HTTP API
if (!requestJSONBufferLock(10)) return;
sObj = fileDoc->to<JsonObject>();
bufferAllocated = true;
if (pname) strlcpy(saveName, pname, 33);
else {
if (sObj["n"].is<const char*>()) strlcpy(saveName, sObj["n"].as<const char*>(), 33);
else sprintf_P(saveName, PSTR("Preset %d"), index);
}
if (sObj["n"].isNull() && pname == nullptr) {
sprintf_P(tmp, PSTR("Preset %d"), index);
sObj["n"] = tmp;
} else if (pname) sObj["n"] = pname;
DEBUG_PRINT(F("Saving preset (")); DEBUG_PRINT(index); DEBUG_PRINT(F(") ")); DEBUG_PRINTLN(saveName);
presetToSave = index;
playlistSave = false;
if (sObj[F("ql")].is<const char*>()) strlcpy(quickLoad, sObj[F("ql")].as<const char*>(), 3); // only 2 chars for QL
sObj.remove("v");
sObj.remove("time");
sObj.remove(F("error"));
sObj.remove(F("psave"));
sObj.remove(F("v"));
if (!sObj["o"]) {
DEBUGFS_PRINTLN(F("Serialize current state"));
if (sObj["ib"].isNull() && sObj["sb"].isNull()) serializeState(sObj, true);
else serializeState(sObj, true, sObj["ib"], sObj["sb"]);
if (persist) currentPreset = index;
}
sObj.remove("o");
if (sObj["o"].isNull()) { // "o" marks a playlist or manually entered API
includeBri = sObj["ib"].as<bool>() || index==255; // temporary preset needs brightness
segBounds = sObj["sb"].as<bool>() || index==255; // temporary preset needs bounds
selectedOnly = sObj[F("sc")].as<bool>();
sObj.remove("ib");
sObj.remove("sb");
sObj.remove(F("sc"));
sObj.remove(F("error"));
sObj.remove(F("time"));
#if defined(ARDUINO_ARCH_ESP32)
if (index==255) {
if (tmpRAMbuffer!=nullptr) free(tmpRAMbuffer);
size_t len = measureJson(*fileDoc) + 1;
DEBUG_PRINTLN(len);
// if possible use SPI RAM on ESP32
#ifdef WLED_USE_PSRAM
if (psramFound())
tmpRAMbuffer = (char*) ps_malloc(len);
else
#endif
tmpRAMbuffer = (char*) malloc(len);
if (tmpRAMbuffer!=nullptr) {
serializeJson(*fileDoc, tmpRAMbuffer, len);
} else {
writeObjectToFileUsingId(filename, index, fileDoc);
}
} else
#endif
writeObjectToFileUsingId(filename, index, fileDoc);
if (persist) presetsModifiedTime = toki.second(); //unix time
if (bufferAllocated) releaseJSONBufferLock();
// this is a playlist or API
sObj.remove("o");
if (sObj[F("playlist")].isNull()) {
presetToSave = 0; // we will save API immediately
if (index < 251 && fileDoc) {
if (sObj["n"].isNull()) sObj["n"] = saveName;
writeObjectToFileUsingId(getName(index), index, fileDoc);
presetsModifiedTime = toki.second(); //unix time
updateFSInfo();
}
} else {
// store playlist
includeBri = true; // !sObj["on"].isNull();
playlistSave = true;
}
}
}
void deletePreset(byte index) {
StaticJsonDocument<24> empty;
writeObjectToFileUsingId("/presets.json", index, &empty);
writeObjectToFileUsingId(getName(), index, &empty);
presetsModifiedTime = toki.second(); //unix time
updateFSInfo();
}

View File

@ -158,9 +158,9 @@ bool oappend(const char* txt)
void prepareHostname(char* hostname)
{
sprintf_P(hostname, "wled-%*s", 6, escapedMac.c_str() + 6);
const char *pC = serverDescription;
uint8_t pos = 5;
uint8_t pos = 5; // keep "wled-"
while (*pC && pos < 24) { // while !null and not over length
if (isalnum(*pC)) { // if the current char is alpha-numeric append it to the hostname
hostname[pos] = *pC;
@ -172,14 +172,10 @@ void prepareHostname(char* hostname)
// else do nothing - no leading hyphens and do not include hyphens for all other characters.
pC++;
}
// if the hostname is left blank, use the mac address/default mdns name
if (pos < 6) {
sprintf(hostname + 5, "%*s", 6, escapedMac.c_str() + 6);
} else { //last character must not be hyphen
while (pos > 0 && hostname[pos -1] == '-') {
hostname[pos -1] = 0;
pos--;
}
//last character must not be hyphen
if (pos > 5) {
while (pos > 4 && hostname[pos -1] == '-') pos--;
hostname[pos] = '\0'; // terminate string (leave at least "wled")
}
}

View File

@ -634,7 +634,7 @@ void WLED::initConnection()
DEBUG_PRINTLN("...");
// convert the "serverDescription" into a valid DNS hostname (alphanumeric)
char hostname[25] = "wled-";
char hostname[25];
prepareHostname(hostname);
#ifdef ESP8266

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2210041
#define VERSION 2210101
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG

View File

@ -367,12 +367,7 @@ void getSettingsJS(byte subPage, char* dest)
// set limits
oappend(SET_F("bLimits("));
#if defined(ESP32) && defined(USERMOD_AUDIOREACTIVE) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32C3)
// requested by @softhack007 https://github.com/blazoncek/WLED/issues/33
oappend(itoa(WLED_MAX_BUSSES-2,nS,10)); oappend(","); // prevent use of I2S buses if audio installed. ESP32-S3 currently does not support these busses.
#else
oappend(itoa(WLED_MAX_BUSSES,nS,10)); oappend(",");
#endif
oappend(itoa(MAX_LEDS_PER_BUS,nS,10)); oappend(",");
oappend(itoa(MAX_LED_MEMORY,nS,10)); oappend(",");
oappend(itoa(MAX_LEDS,nS,10));