Merge branch 'main' into alt-buffer
This commit is contained in:
commit
822298ab66
@ -10,7 +10,7 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# CI binaries
|
||||
;; default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth # ESP32 variant builds are temporarily excluded from CI due to toolchain issues on the GitHub Actions Linux environment
|
||||
; default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth # ESP32 variant builds are temporarily excluded from CI due to toolchain issues on the GitHub Actions Linux environment
|
||||
default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth, lolin_s2_mini, esp32c3dev, esp32s3dev_8MB
|
||||
|
||||
# Release binaries
|
||||
@ -40,6 +40,8 @@ default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth, lolin_
|
||||
; default_envs = esp32dev_qio80
|
||||
; default_envs = esp32_eth_ota1mapp
|
||||
; default_envs = esp32s2_saola
|
||||
; default_envs = esp32c3dev
|
||||
; default_envs = lolin_s2_mini
|
||||
|
||||
src_dir = ./wled00
|
||||
data_dir = ./wled00/data
|
||||
@ -460,8 +462,8 @@ board = esp32-c3-devkitm-1
|
||||
board_build.partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
|
||||
build_flags = ${common.build_flags} ${esp32c3.build_flags} #-D WLED_RELEASE_NAME=ESP32-C3
|
||||
-D WLED_WATCHDOG_TIMEOUT=0
|
||||
; -DARDUINO_USB_CDC_ON_BOOT=1 ;; for virtual CDC USB
|
||||
-DARDUINO_USB_CDC_ON_BOOT=0 ;; for serial-to-USB chip
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1 ;; for virtual CDC USB
|
||||
;-DARDUINO_USB_CDC_ON_BOOT=0 ;; for serial-to-USB chip
|
||||
upload_speed = 460800
|
||||
build_unflags = ${common.build_unflags}
|
||||
lib_deps = ${esp32c3.lib_deps}
|
||||
@ -573,10 +575,10 @@ platform = ${esp32s2.platform}
|
||||
platform_packages = ${esp32s2.platform_packages}
|
||||
board = lolin_s2_mini
|
||||
board_build.partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
|
||||
build_unflags = ${common.build_unflags} -DARDUINO_USB_CDC_ON_BOOT=1
|
||||
build_unflags = ${common.build_unflags} #-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
build_flags = ${common.build_flags} ${esp32s2.build_flags} #-D WLED_RELEASE_NAME=LolinS2
|
||||
-DBOARD_HAS_PSRAM
|
||||
-DARDUINO_USB_CDC_ON_BOOT=0
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1 # try disabling and enabling unflag above in case of board-specific issues, will disable Serial
|
||||
-DARDUINO_USB_MSC_ON_BOOT=0
|
||||
-DARDUINO_USB_DFU_ON_BOOT=0
|
||||
-DLOLIN_WIFI_FIX ; seems to work much better with this
|
||||
|
@ -390,12 +390,6 @@ const char PAGE_dmxmap[] PROGMEM = R"=====()=====";
|
||||
method: "gzip",
|
||||
filter: "html-minify",
|
||||
},
|
||||
{
|
||||
file: "liveviewws.htm",
|
||||
name: "PAGE_liveviewws",
|
||||
method: "gzip",
|
||||
filter: "html-minify",
|
||||
},
|
||||
{
|
||||
file: "liveviewws2D.htm",
|
||||
name: "PAGE_liveviewws2D",
|
||||
|
@ -45,6 +45,10 @@
|
||||
#define ENCODER_SW_PIN 19
|
||||
#endif
|
||||
|
||||
#ifndef ENCODER_MAX_DELAY_MS // max delay between polling encoder pins
|
||||
#define ENCODER_MAX_DELAY_MS 8 // 8 milliseconds => max 120 change impulses in 1 second, for full turn of a 30/30 encoder (4 changes per segment, 30 segments for one turn)
|
||||
#endif
|
||||
|
||||
#ifndef USERMOD_USE_PCF8574
|
||||
#undef USE_PCF8574
|
||||
#define USE_PCF8574 false
|
||||
@ -539,8 +543,9 @@ void RotaryEncoderUIUsermod::setup()
|
||||
*/
|
||||
void RotaryEncoderUIUsermod::loop()
|
||||
{
|
||||
if (!enabled || strip.isUpdating()) return;
|
||||
if (!enabled) return;
|
||||
unsigned long currentTime = millis(); // get the current elapsed time
|
||||
if (strip.isUpdating() && ((currentTime - loopTime) < ENCODER_MAX_DELAY_MS)) return; // be nice, but not too nice
|
||||
|
||||
// Initialize effectCurrentIndex and effectPaletteIndex to
|
||||
// current state. We do it here as (at least) effectCurrent
|
||||
|
@ -278,7 +278,7 @@ uint16_t mode_random_color(void) {
|
||||
SEGMENT.fill(color_blend(SEGMENT.color_wheel(SEGENV.aux1), SEGMENT.color_wheel(SEGENV.aux0), fade));
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_RANDOM_COLOR[] PROGMEM = "Random Colors@!,Fade time;;!";
|
||||
static const char _data_FX_MODE_RANDOM_COLOR[] PROGMEM = "Random Colors@!,Fade time;;!;01";
|
||||
|
||||
|
||||
/*
|
||||
@ -432,7 +432,7 @@ uint16_t mode_rainbow(void) {
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_RAINBOW[] PROGMEM = "Colorloop@!,Saturation;;!";
|
||||
static const char _data_FX_MODE_RAINBOW[] PROGMEM = "Colorloop@!,Saturation;;!;01";
|
||||
|
||||
|
||||
/*
|
||||
@ -5273,7 +5273,7 @@ uint16_t mode_2DPlasmaball(void) { // By: Stepko https://edito
|
||||
|
||||
SEGMENT.fadeToBlackBy(SEGMENT.custom1>>2);
|
||||
|
||||
float t = millis() / (33 - SEGMENT.speed/8);
|
||||
uint_fast32_t t = (millis() * 8) / (256 - SEGMENT.speed); // optimized to avoid float
|
||||
for (int i = 0; i < cols; i++) {
|
||||
uint16_t thisVal = inoise8(i * 30, t, t);
|
||||
uint16_t thisMax = map(thisVal, 0, 255, 0, cols-1);
|
||||
@ -5878,7 +5878,7 @@ uint16_t mode_2Dscrollingtext(void) {
|
||||
}
|
||||
const bool zero = SEGMENT.check3;
|
||||
const int yoffset = map(SEGMENT.intensity, 0, 255, -rows/2, rows/2) + (rows-letterHeight)/2;
|
||||
char text[33] = {'\0'};
|
||||
char text[WLED_MAX_SEGNAME_LEN+1] = {'\0'};
|
||||
if (SEGMENT.name) for (size_t i=0,j=0; i<strlen(SEGMENT.name); i++) if (SEGMENT.name[i]>31 && SEGMENT.name[i]<128) text[j++] = SEGMENT.name[i];
|
||||
|
||||
if (!strlen(text)
|
||||
|
@ -505,8 +505,8 @@ typedef struct Segment {
|
||||
inline bool hasRGB(void) const { return _isRGB; }
|
||||
inline bool hasWhite(void) const { return _hasW; }
|
||||
inline bool isCCT(void) const { return _isCCT; }
|
||||
inline uint16_t width(void) const { return stop - start; } // segment width in physical pixels (length if 1D)
|
||||
inline uint16_t height(void) const { return stopY - startY; } // segment height (if 2D) in physical pixels
|
||||
inline uint16_t width(void) const { return (stop > start) ? (stop - start) : 0; } // segment width in physical pixels (length if 1D)
|
||||
inline uint16_t height(void) const { return (stopY > startY) ? (stopY - startY) : 0; } // segment height (if 2D) in physical pixels // softhack007: make sure its always > 0
|
||||
inline uint16_t length(void) const { return width() * height(); } // segment length (count) in physical pixels
|
||||
inline uint16_t groupLength(void) const { return grouping + spacing; }
|
||||
inline uint8_t getLightCapabilities(void) const { return _capabilities; }
|
||||
|
@ -191,6 +191,8 @@ uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
|
||||
uint16_t /*IRAM_ATTR*/ Segment::XY(uint16_t x, uint16_t y) {
|
||||
uint16_t width = virtualWidth(); // segment width in logical pixels
|
||||
uint16_t height = virtualHeight(); // segment height in logical pixels
|
||||
if (width == 0) return 0; // softhack007 avoid div/0
|
||||
if (height == 0) return (x%width); // softhack007 avoid div/0
|
||||
return (x%width) + (y%height) * width;
|
||||
}
|
||||
|
||||
@ -303,6 +305,7 @@ void Segment::blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t
|
||||
|
||||
// Adds the specified color with the existing pixel color perserving color balance.
|
||||
void Segment::addPixelColorXY(int x, int y, uint32_t color, bool fast) {
|
||||
if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0) return; // if pixel would fall out of virtual segment just exit
|
||||
uint32_t col = getPixelColorXY(x,y);
|
||||
uint8_t r = R(col);
|
||||
uint8_t g = G(col);
|
||||
@ -327,24 +330,26 @@ void Segment::fadePixelColorXY(uint16_t x, uint16_t y, uint8_t fade) {
|
||||
|
||||
// blurRow: perform a blur on a row of a rectangular matrix
|
||||
void Segment::blurRow(uint16_t row, fract8 blur_amount) {
|
||||
const uint16_t cols = virtualWidth();
|
||||
const uint16_t rows = virtualHeight();
|
||||
const uint_fast16_t cols = virtualWidth();
|
||||
const uint_fast16_t rows = virtualHeight();
|
||||
|
||||
if (row >= rows) return;
|
||||
// blur one row
|
||||
uint8_t keep = 255 - blur_amount;
|
||||
uint8_t seep = blur_amount >> 1;
|
||||
CRGB carryover = CRGB::Black;
|
||||
for (uint16_t x = 0; x < cols; x++) {
|
||||
for (uint_fast16_t x = 0; x < cols; x++) {
|
||||
CRGB cur = getPixelColorXY(x, row);
|
||||
uint32_t before = uint32_t(cur); // remember color before blur
|
||||
CRGB part = cur;
|
||||
part.nscale8(seep);
|
||||
cur.nscale8(keep);
|
||||
cur += carryover;
|
||||
if (x) {
|
||||
if (x>0) {
|
||||
CRGB prev = CRGB(getPixelColorXY(x-1, row)) + part;
|
||||
setPixelColorXY(x-1, row, prev);
|
||||
}
|
||||
if (before != uint32_t(cur)) // optimization: only set pixel if color has changed
|
||||
setPixelColorXY(x, row, cur);
|
||||
carryover = part;
|
||||
}
|
||||
@ -352,25 +357,27 @@ void Segment::blurRow(uint16_t row, fract8 blur_amount) {
|
||||
|
||||
// blurCol: perform a blur on a column of a rectangular matrix
|
||||
void Segment::blurCol(uint16_t col, fract8 blur_amount) {
|
||||
const uint16_t cols = virtualWidth();
|
||||
const uint16_t rows = virtualHeight();
|
||||
const uint_fast16_t cols = virtualWidth();
|
||||
const uint_fast16_t rows = virtualHeight();
|
||||
|
||||
if (col >= cols) return;
|
||||
// blur one column
|
||||
uint8_t keep = 255 - blur_amount;
|
||||
uint8_t seep = blur_amount >> 1;
|
||||
CRGB carryover = CRGB::Black;
|
||||
for (uint16_t i = 0; i < rows; i++) {
|
||||
CRGB cur = getPixelColorXY(col, i);
|
||||
for (uint_fast16_t y = 0; y < rows; y++) {
|
||||
CRGB cur = getPixelColorXY(col, y);
|
||||
CRGB part = cur;
|
||||
uint32_t before = uint32_t(cur); // remember color before blur
|
||||
part.nscale8(seep);
|
||||
cur.nscale8(keep);
|
||||
cur += carryover;
|
||||
if (i) {
|
||||
CRGB prev = CRGB(getPixelColorXY(col, i-1)) + part;
|
||||
setPixelColorXY(col, i-1, prev);
|
||||
if (y>0) {
|
||||
CRGB prev = CRGB(getPixelColorXY(col, y-1)) + part;
|
||||
setPixelColorXY(col, y-1, prev);
|
||||
}
|
||||
setPixelColorXY(col, i, cur);
|
||||
if (before != uint32_t(cur)) // optimization: only set pixel if color has changed
|
||||
setPixelColorXY(col, y, cur);
|
||||
carryover = part;
|
||||
}
|
||||
}
|
||||
@ -389,8 +396,8 @@ void Segment::box_blur(uint16_t i, bool vertical, fract8 blur_amount) {
|
||||
for (uint16_t j = 0; j < dim1; j++) {
|
||||
uint16_t x = vertical ? i : j;
|
||||
uint16_t y = vertical ? j : i;
|
||||
uint16_t xp = vertical ? x : x-1;
|
||||
uint16_t yp = vertical ? y-1 : y;
|
||||
int16_t xp = vertical ? x : x-1; // "signed" to prevent underflow
|
||||
int16_t yp = vertical ? y-1 : y; // "signed" to prevent underflow
|
||||
uint16_t xn = vertical ? x : x+1;
|
||||
uint16_t yn = vertical ? y+1 : y;
|
||||
CRGB curr = getPixelColorXY(x,y);
|
||||
|
@ -96,11 +96,11 @@ Segment::Segment(const Segment &orig) {
|
||||
Segment::Segment(Segment &&orig) noexcept {
|
||||
//DEBUG_PRINTLN(F("-- Move segment constructor --"));
|
||||
memcpy((void*)this, (void*)&orig, sizeof(Segment));
|
||||
orig.leds = nullptr;
|
||||
orig.name = nullptr;
|
||||
orig.data = nullptr;
|
||||
orig._dataLen = 0;
|
||||
orig._t = nullptr;
|
||||
orig.leds = nullptr;
|
||||
}
|
||||
|
||||
// copy assignment
|
||||
@ -542,6 +542,7 @@ uint16_t Segment::virtualLength() const {
|
||||
}
|
||||
#endif
|
||||
uint16_t groupLen = groupLength();
|
||||
if (groupLen < 1) groupLen = 1; // prevent division by zero - better safe than sorry ...
|
||||
uint16_t vLength = (length() + groupLen - 1) / groupLen;
|
||||
if (mirror) vLength = (vLength + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
||||
return vLength;
|
||||
@ -724,7 +725,7 @@ uint32_t Segment::getPixelColor(int i)
|
||||
i += start;
|
||||
/* offset/phase */
|
||||
i += offset;
|
||||
if (i >= stop) i -= length();
|
||||
if ((i >= stop) && (stop>0)) i -= length(); // avoids negative pixel index (stop = 0 is a possible value)
|
||||
return strip.getPixelColor(i);
|
||||
}
|
||||
|
||||
@ -881,6 +882,7 @@ void Segment::fade_out(uint8_t rate) {
|
||||
|
||||
// fades all pixels to black using nscale8()
|
||||
void Segment::fadeToBlackBy(uint8_t fadeBy) {
|
||||
if (fadeBy == 0) return; // optimization - no scaling to apply
|
||||
const uint16_t cols = is2D() ? virtualWidth() : virtualLength();
|
||||
const uint16_t rows = virtualHeight(); // will be 1 for 1D
|
||||
|
||||
@ -895,23 +897,26 @@ void Segment::fadeToBlackBy(uint8_t fadeBy) {
|
||||
*/
|
||||
void Segment::blur(uint8_t blur_amount)
|
||||
{
|
||||
if (blur_amount == 0) return; // optimization: 0 means "don't blur"
|
||||
#ifndef WLED_DISABLE_2D
|
||||
if (is2D()) {
|
||||
// compatibility with 2D
|
||||
const uint16_t cols = virtualWidth();
|
||||
const uint16_t rows = virtualHeight();
|
||||
for (uint16_t i = 0; i < rows; i++) blurRow(i, blur_amount); // blur all rows
|
||||
for (uint16_t k = 0; k < cols; k++) blurCol(k, blur_amount); // blur all columns
|
||||
const uint_fast16_t cols = virtualWidth();
|
||||
const uint_fast16_t rows = virtualHeight();
|
||||
for (uint_fast16_t i = 0; i < rows; i++) blurRow(i, blur_amount); // blur all rows
|
||||
for (uint_fast16_t k = 0; k < cols; k++) blurCol(k, blur_amount); // blur all columns
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
uint8_t keep = 255 - blur_amount;
|
||||
uint8_t seep = blur_amount >> 1;
|
||||
CRGB carryover = CRGB::Black;
|
||||
for(uint16_t i = 0; i < virtualLength(); i++)
|
||||
uint_fast16_t vlength = virtualLength();
|
||||
for(uint_fast16_t i = 0; i < vlength; i++)
|
||||
{
|
||||
CRGB cur = CRGB(getPixelColor(i));
|
||||
CRGB part = cur;
|
||||
uint32_t before = uint32_t(cur); // remember color before blur
|
||||
part.nscale8(seep);
|
||||
cur.nscale8(keep);
|
||||
cur += carryover;
|
||||
@ -920,9 +925,10 @@ void Segment::blur(uint8_t blur_amount)
|
||||
uint8_t r = R(c);
|
||||
uint8_t g = G(c);
|
||||
uint8_t b = B(c);
|
||||
setPixelColor(i-1, qadd8(r, part.red), qadd8(g, part.green), qadd8(b, part.blue));
|
||||
setPixelColor((uint16_t)(i-1), qadd8(r, part.red), qadd8(g, part.green), qadd8(b, part.blue));
|
||||
}
|
||||
setPixelColor(i,cur.red, cur.green, cur.blue);
|
||||
if (before != uint32_t(cur)) // optimization: only set pixel if color has changed
|
||||
setPixelColor((uint16_t)i,cur.red, cur.green, cur.blue);
|
||||
carryover = part;
|
||||
}
|
||||
}
|
||||
@ -1182,7 +1188,7 @@ uint8_t WS2812FX::estimateCurrentAndLimitBri() {
|
||||
for (uint_fast16_t i = 0; i < len; i++) { //sum up the usage of each LED
|
||||
uint32_t c = bus->getPixelColor(i);
|
||||
byte r = R(c), g = G(c), b = B(c), w = W(c);
|
||||
if (useGlobalLedBuffer) {
|
||||
if (useGlobalLedBuffer) { // TODO this should only apply for digital bus typpes
|
||||
r = scale8(r, _brightness);
|
||||
g = scale8(g, _brightness);
|
||||
b = scale8(b, _brightness);
|
||||
@ -1203,7 +1209,7 @@ uint8_t WS2812FX::estimateCurrentAndLimitBri() {
|
||||
}
|
||||
|
||||
uint8_t newBri = _brightness;
|
||||
if (powerSum > powerBudget) {//scale brightness down to stay in current limit
|
||||
if (powerSum > powerBudget) { //scale brightness down to stay in current limit
|
||||
float scale = (float)powerBudget / (float)powerSum;
|
||||
uint16_t scaleI = scale * 255;
|
||||
uint8_t scaleB = (scaleI > 255) ? 255 : scaleI;
|
||||
|
@ -174,7 +174,7 @@ bool BusDigital::canShow() {
|
||||
return PolyBus::canShow(_busPtr, _iType);
|
||||
}
|
||||
|
||||
void BusDigital::setBrightness(uint8_t b) {
|
||||
void BusDigital::setBrightness(uint8_t b, bool immediate) {
|
||||
//Fix for turning off onboard LED breaking bus
|
||||
#ifdef LED_BUILTIN
|
||||
if (_bri == 0 && b > 0) {
|
||||
@ -587,9 +587,9 @@ void IRAM_ATTR BusManager::setPixelColor(uint16_t pix, uint32_t c) {
|
||||
}
|
||||
}
|
||||
|
||||
void BusManager::setBrightness(uint8_t b) {
|
||||
void BusManager::setBrightness(uint8_t b, bool immediate) {
|
||||
for (uint8_t i = 0; i < numBusses; i++) {
|
||||
busses[i]->setBrightness(b);
|
||||
busses[i]->setBrightness(b, immediate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,21 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef WLED_MAX_SEGNAME_LEN
|
||||
#ifdef ESP8266
|
||||
#define WLED_MAX_SEGNAME_LEN 32
|
||||
#else
|
||||
#define WLED_MAX_SEGNAME_LEN 64
|
||||
#endif
|
||||
#else
|
||||
#if WLED_MAX_SEGNAME_LEN<32
|
||||
#undef WLED_MAX_SEGNAME_LEN
|
||||
#define WLED_MAX_SEGNAME_LEN 32
|
||||
#else
|
||||
#warning WLED UI does not support modified maximum segment name length!
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Usermod IDs
|
||||
#define USERMOD_ID_RESERVED 0 //Unused. Might indicate no usermod present
|
||||
#define USERMOD_ID_UNSPECIFIED 1 //Default value for a general user mod that does not specify a custom ID
|
||||
@ -388,7 +403,7 @@
|
||||
#ifdef ESP8266
|
||||
#define SETTINGS_STACK_BUF_SIZE 2048
|
||||
#else
|
||||
#define SETTINGS_STACK_BUF_SIZE 3096
|
||||
#define SETTINGS_STACK_BUF_SIZE 3608 // warning: quite a large value for stack
|
||||
#endif
|
||||
|
||||
#ifdef WLED_USE_ETHERNET
|
||||
|
@ -42,6 +42,6 @@
|
||||
<img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAbUExURQAAAAB81gCU/zKq/////9bW1oCAgGhoaAAAAGPLX8AAAAAJdFJOU///////////AFNPeBIAAAAJcEhZcwAADsAAAA7AAWrWiQkAAACdSURBVDhPxc9bDoUgEANQebP/FUuHMjBGY/B+3EYR7RH0qC/ZBc6HwCljgHO+xZIVSI2sYgHaG7EBWh8jWoxTrCBFdDJ+BD4lbIHxAcz8APAVLTsrZE4eQD5qzt3cAFTYokC4YCN9Gybgu4yAQtBFLQXHuHABA7JMeOEC/E0W5uy9gv4vo5QHK2i7yq2C8UABM4HmL+CSTXCTF1DrCX6+Gp9zB5dsAAAAAElFTkSuQmCC">
|
||||
<h1>404 Not Found</h1>
|
||||
<b>Akemi does not know where you are headed...</b><br><br>
|
||||
<button onclick="window.location.href='../sliders'">Back to controls</button>
|
||||
<button onclick="window.location.href='../?sliders'">Back to controls</button>
|
||||
</body>
|
||||
</html>
|
@ -379,8 +379,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="mliveview2D" class="modal">
|
||||
<div id="kliveview2D" style="width:100%; height:100%">Loading...</div><br>
|
||||
<div id="mlv2D" class="modal">
|
||||
<div id="klv2D" style="width:100%; height:100%">Loading...</div>
|
||||
</div>
|
||||
|
||||
<div id="rover" class="modal">
|
||||
|
@ -22,7 +22,7 @@ var pN = "", pI = 0, pNum = 0;
|
||||
var pmt = 1, pmtLS = 0, pmtLast = 0;
|
||||
var lastinfo = {};
|
||||
var isM = false, mw = 0, mh=0;
|
||||
var ws, cpick, ranges;
|
||||
var ws, cpick, ranges, wsRpt=0;
|
||||
var cfg = {
|
||||
theme:{base:"dark", bg:{url:""}, alpha:{bg:0.6,tab:0.8}, color:{bg:""}},
|
||||
comp :{colors:{picker: true, rgb: false, quick: true, hex: false},
|
||||
@ -217,7 +217,7 @@ function onLoad()
|
||||
// detect reverse proxy and/or HTTPS
|
||||
let pathn = l.pathname;
|
||||
let paths = pathn.slice(1,pathn.endsWith('/')?-1:undefined).split("/");
|
||||
if (paths[0]==="sliders") paths.shift();
|
||||
//if (paths[0]==="sliders") paths.shift();
|
||||
//while (paths[0]==="") paths.shift();
|
||||
locproto = l.protocol;
|
||||
locip = l.hostname + (l.port ? ":" + l.port : "");
|
||||
@ -773,7 +773,7 @@ function populateSegments(s)
|
||||
`<i class="icons e-icon flr" id="sege${i}" onclick="expand(${i})"></i>`+
|
||||
(cfg.comp.segpwr ? segp : '') +
|
||||
`<div class="segin" id="seg${i}in">`+
|
||||
`<input type="text" class="ptxt" id="seg${i}t" autocomplete="off" maxlength=32 value="${inst.n?inst.n:""}" placeholder="Enter name..."/>`+
|
||||
`<input type="text" class="ptxt" id="seg${i}t" autocomplete="off" maxlength=${li.arch=="esp8266"?32:64} value="${inst.n?inst.n:""}" placeholder="Enter name..."/>`+
|
||||
`<table class="infot segt">`+
|
||||
`<tr>`+
|
||||
`<td>${isMSeg?'Start X':'Start LED'}</td>`+
|
||||
@ -1331,11 +1331,12 @@ function makeWS() {
|
||||
};
|
||||
ws.onclose = (e)=>{
|
||||
gId('connind').style.backgroundColor = "var(--c-r)";
|
||||
setTimeout(makeWS,1500); // retry WS connection
|
||||
if (wsRpt++ < 5) setTimeout(makeWS,1500); // retry WS connection
|
||||
ws = null;
|
||||
}
|
||||
ws.onopen = (e)=>{
|
||||
//ws.send("{'v':true}"); // unnecessary (https://github.com/Aircoookie/WLED/blob/master/wled00/ws.cpp#L18)
|
||||
wsRpt = 0;
|
||||
reqsLegal = true;
|
||||
}
|
||||
}
|
||||
@ -1637,6 +1638,7 @@ function requestJson(command=null)
|
||||
//load presets and open websocket sequentially
|
||||
if (!pJson || isEmpty(pJson)) setTimeout(()=>{
|
||||
loadPresets(()=>{
|
||||
wsRpt = 0;
|
||||
if (!(ws && ws.readyState === WebSocket.OPEN)) makeWS();
|
||||
});
|
||||
},25);
|
||||
@ -1684,27 +1686,22 @@ function toggleSync()
|
||||
|
||||
function toggleLiveview()
|
||||
{
|
||||
//WLEDSR adding liveview2D support
|
||||
if (isInfo && isM) toggleInfo();
|
||||
if (isNodes && isM) toggleNodes();
|
||||
isLv = !isLv;
|
||||
let wsOn = ws && ws.readyState === WebSocket.OPEN;
|
||||
|
||||
var lvID = "liveview";
|
||||
if (isM) {
|
||||
lvID = "liveview2D"
|
||||
if (isLv) {
|
||||
var cn = '<iframe id="liveview2D" src="about:blank"></iframe>';
|
||||
d.getElementById('kliveview2D').innerHTML = cn;
|
||||
}
|
||||
|
||||
gId('mliveview2D').style.transform = (isLv) ? "translateY(0px)":"translateY(100%)";
|
||||
if (isM && wsOn) {
|
||||
lvID += "2D";
|
||||
if (isLv) gId('klv2D').innerHTML = `<iframe id="${lvID}" src="about:blank"></iframe>`;
|
||||
gId('mlv2D').style.transform = (isLv) ? "translateY(0px)":"translateY(100%)";
|
||||
}
|
||||
|
||||
gId(lvID).style.display = (isLv) ? "block":"none";
|
||||
var url = getURL("/" + lvID);
|
||||
gId(lvID).src = (isLv) ? url:"about:blank";
|
||||
gId('buttonSr').className = (isLv) ? "active":"";
|
||||
if (!isLv && ws && ws.readyState === WebSocket.OPEN) ws.send('{"lv":false}');
|
||||
gId(lvID).src = (isLv) ? getURL("/" + lvID + ((wsOn) ? "?ws":"")):"about:blank";
|
||||
gId('buttonSr').classList.toggle("active");
|
||||
if (!isLv && wsOn) ws.send('{"lv":false}');
|
||||
size();
|
||||
}
|
||||
|
||||
|
@ -17,14 +17,10 @@
|
||||
position: absolute;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="canv" />
|
||||
<script>
|
||||
update();
|
||||
|
||||
var ws;
|
||||
var tmout = null;
|
||||
function update()
|
||||
function update() // via HTTP (/json/live)
|
||||
{
|
||||
if (document.hidden) {
|
||||
clearTimeout(tmout);
|
||||
@ -57,8 +53,57 @@
|
||||
clearTimeout(tmout);
|
||||
tmout = setTimeout(update, 2500);
|
||||
})
|
||||
}
|
||||
function S() { // Startup function (onload)
|
||||
let wsOn = (window.location.href.indexOf("?ws") > 0);
|
||||
if (!wsOn) {update(); return;}
|
||||
|
||||
// Initialize WebSocket connection
|
||||
try {
|
||||
ws = top.window.ws;
|
||||
} catch (e) {}
|
||||
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||
//console.info("Peek uses top WS");
|
||||
ws.send("{'lv':true}");
|
||||
} else {
|
||||
//console.info("Peek WS opening");
|
||||
let l = window.location;
|
||||
let pathn = l.pathname;
|
||||
let paths = pathn.slice(1,pathn.endsWith('/')?-1:undefined).split("/");
|
||||
let url = l.origin.replace("http","ws");
|
||||
if (paths.length > 1) {
|
||||
url += "/" + paths[0];
|
||||
}
|
||||
ws = new WebSocket(url+"/ws");
|
||||
ws.onopen = function () {
|
||||
//console.info("Peek WS open");
|
||||
ws.send("{'lv':true}");
|
||||
}
|
||||
}
|
||||
ws.binaryType = "arraybuffer";
|
||||
ws.addEventListener('message', (e) => {
|
||||
try {
|
||||
if (toString.call(e.data) === '[object ArrayBuffer]') {
|
||||
let leds = new Uint8Array(event.data);
|
||||
if (leds[0] != 76) return; //'L'
|
||||
let str = "linear-gradient(90deg,";
|
||||
let len = leds.length;
|
||||
let start = leds[1]==2 ? 4 : 2; // 1 = 1D, 2 = 1D/2D (leds[2]=w, leds[3]=h)
|
||||
for (i = start; i < len; i+=3) {
|
||||
str += `rgb(${leds[i]},${leds[i+1]},${leds[i+2]})`;
|
||||
if (i < len -3) str += ","
|
||||
}
|
||||
str += ")";
|
||||
document.getElementById("canv").style.background = str;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Peek WS error:",err);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="S()">
|
||||
<div id="canv"></div>
|
||||
</body>
|
||||
</html>
|
@ -1,68 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<meta name="theme-color" content="#222222">
|
||||
<title>WLED Live Preview</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
#canv {
|
||||
background: black;
|
||||
filter: brightness(175%);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="canv"></div>
|
||||
<script>
|
||||
var ws;
|
||||
try {
|
||||
ws = top.window.ws;
|
||||
} catch (e) {}
|
||||
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||
//console.info("Peek uses top WS");
|
||||
ws.send("{'lv':true}");
|
||||
} else {
|
||||
//console.info("Peek WS opening");
|
||||
let l = window.location;
|
||||
let pathn = l.pathname;
|
||||
let paths = pathn.slice(1,pathn.endsWith('/')?-1:undefined).split("/");
|
||||
let url = l.origin.replace("http","ws");
|
||||
if (paths.length > 1) {
|
||||
url += "/" + paths[0];
|
||||
}
|
||||
ws = new WebSocket(url+"/ws");
|
||||
ws.onopen = function () {
|
||||
//console.info("Peek WS open");
|
||||
ws.send("{'lv':true}");
|
||||
}
|
||||
}
|
||||
ws.binaryType = "arraybuffer";
|
||||
ws.addEventListener('message', (e) => {
|
||||
try {
|
||||
if (toString.call(e.data) === '[object ArrayBuffer]') {
|
||||
let leds = new Uint8Array(event.data);
|
||||
if (leds[0] != 76) return; //'L'
|
||||
let str = "linear-gradient(90deg,";
|
||||
let len = leds.length;
|
||||
let start = leds[1]==2 ? 4 : 2; // 1 = 1D, 2 = 1D/2D (leds[2]=w, leds[3]=h)
|
||||
for (i = start; i < len; i+=3) {
|
||||
str += `rgb(${leds[i]},${leds[i+1]},${leds[i+2]})`;
|
||||
if (i < len -3) str += ","
|
||||
}
|
||||
str += ")";
|
||||
document.getElementById("canv").style.background = str;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Peek WS error:",err);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -57,7 +57,7 @@
|
||||
Connect the module to your local WiFi here!<br>
|
||||
<button onclick="window.location.href='./settings/wifi'">WiFi settings</button><br>
|
||||
<i>Just trying this out in AP mode?</i><br>
|
||||
<button onclick="window.location.href='./sliders'">To the controls!</button><br>
|
||||
<button onclick="window.location.href='./?sliders'">To the controls!</button><br>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -104,10 +104,20 @@ void sendHuePoll();
|
||||
void onHueData(void* arg, AsyncClient* client, void *data, size_t len);
|
||||
|
||||
//improv.cpp
|
||||
enum ImprovRPCType {
|
||||
Command_Wifi = 0x01,
|
||||
Request_State = 0x02,
|
||||
Request_Info = 0x03,
|
||||
Request_Scan = 0x04
|
||||
};
|
||||
|
||||
void handleImprovPacket();
|
||||
void sendImprovRPCResult(ImprovRPCType type, uint8_t n_strings = 0, const char **strings = nullptr);
|
||||
void sendImprovStateResponse(uint8_t state, bool error = false);
|
||||
void sendImprovInfoResponse();
|
||||
void sendImprovRPCResponse(byte commandId);
|
||||
void startImprovWifiScan();
|
||||
void handleImprovWifiScan();
|
||||
void sendImprovIPRPCResult(ImprovRPCType type);
|
||||
|
||||
//ir.cpp
|
||||
void applyRepeatActions();
|
||||
|
1911
wled00/html_other.h
1911
wled00/html_other.h
File diff suppressed because it is too large
Load Diff
3977
wled00/html_ui.h
3977
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,11 @@
|
||||
#define DIMPROV_PRINTF(x...)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
#undef WLED_DISABLE_IMPROV_WIFISCAN
|
||||
#define WLED_DISABLE_IMPROV_WIFISCAN
|
||||
#endif
|
||||
|
||||
#define IMPROV_VERSION 1
|
||||
|
||||
void parseWiFiCommand(char *rpcData);
|
||||
@ -28,20 +33,14 @@ enum ImprovPacketByte {
|
||||
RPC_CommandType = 9
|
||||
};
|
||||
|
||||
enum ImprovRPCType {
|
||||
Command_Wifi = 0x01,
|
||||
Request_State = 0x02,
|
||||
Request_Info = 0x03
|
||||
};
|
||||
|
||||
//File dbgf;
|
||||
#ifndef WLED_DISABLE_IMPROV_WIFISCAN
|
||||
static bool improvWifiScanRunning = false;
|
||||
#endif
|
||||
|
||||
//blocking function to parse an Improv Serial packet
|
||||
void handleImprovPacket() {
|
||||
uint8_t header[6] = {'I','M','P','R','O','V'};
|
||||
|
||||
//dbgf = WLED_FS.open("/improv.log","a");
|
||||
|
||||
bool timeout = false;
|
||||
uint8_t waitTime = 25;
|
||||
uint16_t packetByte = 0;
|
||||
@ -62,12 +61,11 @@ void handleImprovPacket() {
|
||||
byte next = Serial.read();
|
||||
|
||||
DIMPROV_PRINT("Received improv byte: "); DIMPROV_PRINTF("%x\r\n",next);
|
||||
//f.write(next);
|
||||
|
||||
switch (packetByte) {
|
||||
case ImprovPacketByte::Version: {
|
||||
if (next != IMPROV_VERSION) {
|
||||
DIMPROV_PRINTLN(F("Invalid version"));
|
||||
//dbgf.close();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@ -75,7 +73,6 @@ void handleImprovPacket() {
|
||||
case ImprovPacketByte::PacketType: {
|
||||
if (next != ImprovPacketType::RPC_Command) {
|
||||
DIMPROV_PRINTF("Non RPC-command improv packet type %i\n",next);
|
||||
//dbgf.close();
|
||||
return;
|
||||
}
|
||||
if (!improvActive) improvActive = 1;
|
||||
@ -89,7 +86,6 @@ void handleImprovPacket() {
|
||||
if (checksum != next) {
|
||||
DIMPROV_PRINTF("Got RPC checksum %i, expected %i",next,checksum);
|
||||
sendImprovStateResponse(0x01, true);
|
||||
//dbgf.close();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -100,22 +96,23 @@ void handleImprovPacket() {
|
||||
if (WLED_WIFI_CONFIGURED) improvState = 0x03; //provisioning
|
||||
if (Network.isConnected()) improvState = 0x04; //provisioned
|
||||
sendImprovStateResponse(improvState, false);
|
||||
if (improvState == 0x04) sendImprovRPCResponse(ImprovRPCType::Request_State);
|
||||
if (improvState == 0x04) sendImprovIPRPCResult(ImprovRPCType::Request_State);
|
||||
break;
|
||||
}
|
||||
case ImprovRPCType::Request_Info: sendImprovInfoResponse(); break;
|
||||
#ifndef WLED_DISABLE_IMPROV_WIFISCAN
|
||||
case ImprovRPCType::Request_Scan: startImprovWifiScan(); break;
|
||||
#endif
|
||||
default: {
|
||||
DIMPROV_PRINTF("Unknown RPC command %i\n",next);
|
||||
sendImprovStateResponse(0x02, true);
|
||||
}
|
||||
}
|
||||
//dbgf.close();
|
||||
return;
|
||||
}
|
||||
if (packetByte < 6) { //check header
|
||||
if (next != header[packetByte]) {
|
||||
DIMPROV_PRINTLN(F("Invalid improv header"));
|
||||
//dbgf.close();
|
||||
return;
|
||||
}
|
||||
} else if (packetByte > 9) { //RPC data
|
||||
@ -128,7 +125,6 @@ void handleImprovPacket() {
|
||||
checksum += next;
|
||||
packetByte++;
|
||||
}
|
||||
//dbgf.close();
|
||||
}
|
||||
|
||||
void sendImprovStateResponse(uint8_t state, bool error) {
|
||||
@ -147,79 +143,116 @@ void sendImprovStateResponse(uint8_t state, bool error) {
|
||||
Serial.write('\n');
|
||||
}
|
||||
|
||||
void sendImprovRPCResponse(byte commandId) {
|
||||
// used by sendImprovIPRPCResult(), sendImprovInfoResponse(), and handleImprovWifiScan()
|
||||
void sendImprovRPCResult(ImprovRPCType type, uint8_t n_strings, const char **strings) {
|
||||
if (improvError > 0 && improvError < 3) sendImprovStateResponse(0x00, true);
|
||||
uint8_t packetLen = 12;
|
||||
char out[64] = {'I','M','P','R','O','V'};
|
||||
char out[256] = {'I','M','P','R','O','V'};
|
||||
out[6] = IMPROV_VERSION;
|
||||
out[7] = ImprovPacketType::RPC_Response;
|
||||
out[8] = 2; //Length (set below)
|
||||
out[9] = commandId;
|
||||
out[10] = 0; //Data len (set below)
|
||||
out[11] = '\0'; //URL len (set below)
|
||||
//out[8] = 2; //Length (set below)
|
||||
out[9] = type;
|
||||
//out[10] = 0; //Data len (set below)
|
||||
uint16_t pos = 11;
|
||||
|
||||
if (Network.isConnected())
|
||||
{
|
||||
IPAddress localIP = Network.localIP();
|
||||
uint8_t len = sprintf(out+12, "http://%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
|
||||
if (len > 24) return; //sprintf fail?
|
||||
out[11] = len;
|
||||
out[10] = 1 + len;
|
||||
out[8] = 3 + len; //RPC command type + data len + url len + url
|
||||
packetLen = 13 + len;
|
||||
for (uint8_t s = 0; s < n_strings; s++) {
|
||||
size_t len = strlen(strings[s]);
|
||||
if (pos + len > 254) continue; // simple buffer overflow guard
|
||||
out[pos++] = len;
|
||||
strcpy(out + pos, strings[s]);
|
||||
pos += len;
|
||||
}
|
||||
|
||||
packetLen = pos +1;
|
||||
out[8] = pos -9; // Length of packet (excluding first 9 header bytes and final checksum byte)
|
||||
out[10] = pos -11; // Data len
|
||||
|
||||
uint8_t checksum = 0;
|
||||
for (uint8_t i = 0; i < packetLen -1; i++) checksum += out[i];
|
||||
out[packetLen -1] = checksum;
|
||||
Serial.write((uint8_t*)out, packetLen);
|
||||
Serial.write('\n');
|
||||
DIMPROV_PRINT("RPC result checksum");
|
||||
DIMPROV_PRINTLN(checksum);
|
||||
}
|
||||
|
||||
void sendImprovIPRPCResult(ImprovRPCType type) {
|
||||
if (Network.isConnected())
|
||||
{
|
||||
char urlStr[64];
|
||||
IPAddress localIP = Network.localIP();
|
||||
uint8_t len = sprintf(urlStr, "http://%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
|
||||
if (len > 24) return; //sprintf fail?
|
||||
const char *str[1] = {urlStr};
|
||||
sendImprovRPCResult(type, 1, str);
|
||||
} else {
|
||||
sendImprovRPCResult(type, 0);
|
||||
}
|
||||
|
||||
improvActive = 1; //no longer provisioning
|
||||
}
|
||||
|
||||
void sendImprovInfoResponse() {
|
||||
if (improvError > 0 && improvError < 3) sendImprovStateResponse(0x00, true);
|
||||
uint8_t packetLen = 12;
|
||||
char out[128] = {'I','M','P','R','O','V'};
|
||||
out[6] = IMPROV_VERSION;
|
||||
out[7] = ImprovPacketType::RPC_Response;
|
||||
//out[8] = 2; //Length (set below)
|
||||
out[9] = ImprovRPCType::Request_Info;
|
||||
//out[10] = 0; //Data len (set below)
|
||||
out[11] = 4; //Firmware len ("WLED")
|
||||
out[12] = 'W'; out[13] = 'L'; out[14] = 'E'; out[15] = 'D';
|
||||
uint8_t lengthSum = 17;
|
||||
uint8_t vlen = sprintf_P(out+lengthSum,PSTR("0.14.0-b3/%i"),VERSION);
|
||||
out[16] = vlen; lengthSum += vlen;
|
||||
uint8_t hlen = 7;
|
||||
const char* bString =
|
||||
#ifdef ESP8266
|
||||
strcpy(out+lengthSum+1,"esp8266");
|
||||
#else
|
||||
hlen = 5;
|
||||
strcpy(out+lengthSum+1,"esp32");
|
||||
"esp8266"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
"esp32-c3"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
"esp32-s2"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
"esp32-s3";
|
||||
#else // ESP32
|
||||
"esp32";
|
||||
#endif
|
||||
out[lengthSum] = hlen;
|
||||
lengthSum += hlen + 1;
|
||||
;
|
||||
|
||||
//Use serverDescription if it has been changed from the default "WLED", else mDNS name
|
||||
bool useMdnsName = (strcmp(serverDescription, "WLED") == 0 && strlen(cmDNS) > 0);
|
||||
strcpy(out+lengthSum+1,useMdnsName ? cmDNS : serverDescription);
|
||||
uint8_t nlen = strlen(useMdnsName ? cmDNS : serverDescription);
|
||||
out[lengthSum] = nlen;
|
||||
lengthSum += nlen + 1;
|
||||
char vString[20];
|
||||
sprintf_P(vString, PSTR("0.14.0-b3/%i"), VERSION);
|
||||
const char *str[4] = {"WLED", vString, bString, useMdnsName ? cmDNS : serverDescription};
|
||||
|
||||
packetLen = lengthSum +1;
|
||||
out[8] = lengthSum -9;
|
||||
out[10] = lengthSum -11;
|
||||
|
||||
uint8_t checksum = 0;
|
||||
for (uint8_t i = 0; i < packetLen -1; i++) checksum += out[i];
|
||||
out[packetLen -1] = checksum;
|
||||
Serial.write((uint8_t*)out, packetLen);
|
||||
Serial.write('\n');
|
||||
DIMPROV_PRINT("Info checksum");
|
||||
DIMPROV_PRINTLN(checksum);
|
||||
sendImprovRPCResult(ImprovRPCType::Request_Info, 4, str);
|
||||
}
|
||||
|
||||
#ifndef WLED_DISABLE_IMPROV_WIFISCAN
|
||||
void startImprovWifiScan() {
|
||||
if (improvWifiScanRunning) return;
|
||||
WiFi.scanNetworks(true);
|
||||
improvWifiScanRunning = true;
|
||||
}
|
||||
|
||||
void handleImprovWifiScan() {
|
||||
if (!improvWifiScanRunning) return;
|
||||
int16_t status = WiFi.scanComplete();
|
||||
if (status == WIFI_SCAN_RUNNING) return;
|
||||
// here scan completed or failed (-2)
|
||||
improvWifiScanRunning = false;
|
||||
|
||||
for (int i = 0; i < status; i++) {
|
||||
char rssiStr[8];
|
||||
sprintf(rssiStr, "%d", WiFi.RSSI(i));
|
||||
#ifdef ESP8266
|
||||
bool isOpen = WiFi.encryptionType(i) == ENC_TYPE_NONE;
|
||||
#else
|
||||
bool isOpen = WiFi.encryptionType(i) == WIFI_AUTH_OPEN;
|
||||
#endif
|
||||
|
||||
char ssidStr[33];
|
||||
strcpy(ssidStr, WiFi.SSID(i).c_str());
|
||||
const char *str[3] = {ssidStr, rssiStr, isOpen ? "NO":"YES"};
|
||||
sendImprovRPCResult(ImprovRPCType::Request_Scan, 3, str);
|
||||
}
|
||||
sendImprovRPCResult(ImprovRPCType::Request_Scan, 0);
|
||||
|
||||
WiFi.scanDelete();
|
||||
}
|
||||
#else
|
||||
void startImprovWifiScan() {}
|
||||
void handleImprovWifiScan() {}
|
||||
#endif
|
||||
|
||||
void parseWiFiCommand(char* rpcData) {
|
||||
uint8_t len = rpcData[0];
|
||||
if (!len || len > 126) return;
|
||||
|
@ -34,7 +34,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
|
||||
uint16_t start = elem["start"] | seg.start;
|
||||
if (stop < 0) {
|
||||
uint16_t len = elem["len"];
|
||||
int len = elem["len"];
|
||||
stop = (len > 0) ? start + len : seg.stop;
|
||||
}
|
||||
// 2D segments
|
||||
@ -70,9 +70,10 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
const char * name = elem["n"].as<const char*>();
|
||||
size_t len = 0;
|
||||
if (name != nullptr) len = strlen(name);
|
||||
if (len > 0 && len < 33) {
|
||||
if (len > 0) {
|
||||
if (len > WLED_MAX_SEGNAME_LEN) len = WLED_MAX_SEGNAME_LEN;
|
||||
seg.name = new char[len+1];
|
||||
if (seg.name) strlcpy(seg.name, name, 33);
|
||||
if (seg.name) strlcpy(seg.name, name, WLED_MAX_SEGNAME_LEN+1);
|
||||
} else {
|
||||
// but is empty (already deleted above)
|
||||
elem.remove("n");
|
||||
@ -425,7 +426,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
|
||||
// a) already applied preset content (requires "seg" or "win" but will ignore the rest)
|
||||
if (!root["pd"].isNull() && stateChanged) {
|
||||
currentPreset = root[F("pd")] | currentPreset;
|
||||
if (root["win"].isNull()) presetCycCurr = currentPreset;
|
||||
if (root["win"].isNull()) presetCycCurr = currentPreset; // otherwise it was set in handleSet() [set.cpp]
|
||||
presetToRestore = currentPreset; // stateUpdated() will clear the preset, so we need to restore it after
|
||||
//unloadPlaylist(); // applying a preset unloads the playlist, may be needed here too?
|
||||
} else if (!root["ps"].isNull()) {
|
||||
@ -472,7 +473,7 @@ void serializeSegment(JsonObject& root, Segment& seg, byte id, bool forPreset, b
|
||||
root[F("stopY")] = seg.stopY;
|
||||
}
|
||||
}
|
||||
if (!forPreset) root["len"] = seg.stop - seg.start;
|
||||
if (!forPreset) root["len"] = (seg.stop >= seg.start) ? (seg.stop - seg.start) : 0;
|
||||
root["grp"] = seg.grouping;
|
||||
root[F("spc")] = seg.spacing;
|
||||
root[F("of")] = seg.offset;
|
||||
|
@ -180,7 +180,7 @@ void handlePresets()
|
||||
fdo.remove("ps"); // remove load request for presets to prevent recursive crash (if not called by button and contains preset cycling string "1~5~")
|
||||
deserializeState(fdo, CALL_MODE_NO_NOTIFY, tmpPreset); // may change presetToApply by calling applyPreset()
|
||||
}
|
||||
if (!errorFlag && tmpPreset < 255 && changePreset) presetCycCurr = currentPreset = tmpPreset;
|
||||
if (!errorFlag && tmpPreset < 255 && changePreset) currentPreset = tmpPreset;
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
//Aircoookie recommended not to delete buffer
|
||||
|
@ -503,8 +503,8 @@ um_data_t* simulateSound(uint8_t simulationId)
|
||||
}
|
||||
|
||||
samplePeak = random8() > 250;
|
||||
FFT_MajorPeak = volumeSmth;
|
||||
maxVol = 10; // this gets feedback fro UI
|
||||
FFT_MajorPeak = 21 + (volumeSmth*volumeSmth) / 8.0f; // walk thru full range of 21hz...8200hz
|
||||
maxVol = 31; // this gets feedback fro UI
|
||||
binNum = 8; // this gets feedback fro UI
|
||||
volumeRaw = volumeSmth;
|
||||
my_magnitude = 10000.0 / 8.0f; //no idea if 10000 is a good value for FFT_Magnitude ???
|
||||
|
@ -52,6 +52,7 @@ void WLED::loop()
|
||||
handleConnection();
|
||||
handleRemote();
|
||||
handleSerial();
|
||||
handleImprovWifiScan();
|
||||
handleNotifications();
|
||||
handleTransitions();
|
||||
#ifdef WLED_ENABLE_DMX
|
||||
@ -656,7 +657,6 @@ void WLED::initConnection()
|
||||
ws.onEvent(wsEvent);
|
||||
#endif
|
||||
|
||||
|
||||
WiFi.disconnect(true); // close old connections
|
||||
#ifdef ESP8266
|
||||
WiFi.setPhyMode(WIFI_PHY_MODE_11N);
|
||||
@ -855,7 +855,7 @@ void WLED::handleConnection()
|
||||
if (improvActive) {
|
||||
if (improvError == 3) sendImprovStateResponse(0x00, true);
|
||||
sendImprovStateResponse(0x04);
|
||||
if (improvActive > 1) sendImprovRPCResponse(0x01);
|
||||
if (improvActive > 1) sendImprovIPRPCResult(ImprovRPCType::Command_Wifi);
|
||||
}
|
||||
initInterfaces();
|
||||
userConnected();
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2307060
|
||||
#define VERSION 2307090
|
||||
|
||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||
//#define WLED_USE_MY_CONFIG
|
||||
@ -36,7 +36,7 @@
|
||||
#undef WLED_ENABLE_ADALIGHT // disable has priority over enable
|
||||
#endif
|
||||
//#define WLED_ENABLE_DMX // uses 3.5kb (use LEDPIN other than 2)
|
||||
//#define WLED_ENABLE_JSONLIVE // peek LED output via /json/live (WS binary peek is always enabled)
|
||||
#define WLED_ENABLE_JSONLIVE // peek LED output via /json/live (WS binary peek is always enabled)
|
||||
#ifndef WLED_DISABLE_LOXONE
|
||||
#define WLED_ENABLE_LOXONE // uses 1.2kb
|
||||
#endif
|
||||
|
@ -116,14 +116,6 @@ void initServer()
|
||||
DefaultHeaders::Instance().addHeader(F("Access-Control-Allow-Headers"), "*");
|
||||
|
||||
#ifdef WLED_ENABLE_WEBSOCKETS
|
||||
server.on("/liveview", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
if (handleIfNoneMatchCacheHeader(request)) return;
|
||||
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", PAGE_liveviewws, PAGE_liveviewws_length);
|
||||
response->addHeader(FPSTR(s_content_enc),"gzip");
|
||||
setStaticContentCacheHeaders(response);
|
||||
request->send(response);
|
||||
//request->send_P(200, "text/html", PAGE_liveviewws);
|
||||
});
|
||||
#ifndef WLED_DISABLE_2D
|
||||
server.on("/liveview2D", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
if (handleIfNoneMatchCacheHeader(request)) return;
|
||||
@ -131,19 +123,16 @@ void initServer()
|
||||
response->addHeader(FPSTR(s_content_enc),"gzip");
|
||||
setStaticContentCacheHeaders(response);
|
||||
request->send(response);
|
||||
//request->send_P(200, "text/html", PAGE_liveviewws);
|
||||
});
|
||||
#endif
|
||||
#else
|
||||
#endif
|
||||
server.on("/liveview", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
if (handleIfNoneMatchCacheHeader(request)) return;
|
||||
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", PAGE_liveview, PAGE_liveview_length);
|
||||
response->addHeader(FPSTR(s_content_enc),"gzip");
|
||||
setStaticContentCacheHeaders(response);
|
||||
request->send(response);
|
||||
//request->send_P(200, "text/html", PAGE_liveview);
|
||||
});
|
||||
#endif
|
||||
|
||||
//settings page
|
||||
server.on("/settings", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
@ -167,10 +156,6 @@ void initServer()
|
||||
}
|
||||
});
|
||||
|
||||
server.on("/sliders", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
serveIndex(request);
|
||||
});
|
||||
|
||||
server.on("/welcome", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
serveSettings(request);
|
||||
});
|
||||
@ -247,19 +232,15 @@ void initServer()
|
||||
request->send(200, "text/plain", (String)ESP.getFreeHeap());
|
||||
});
|
||||
|
||||
#ifdef WLED_ENABLE_USERMOD_PAGE
|
||||
server.on("/u", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
if (handleIfNoneMatchCacheHeader(request)) return;
|
||||
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", PAGE_usermod, PAGE_usermod_length);
|
||||
response->addHeader(FPSTR(s_content_enc),"gzip");
|
||||
setStaticContentCacheHeaders(response);
|
||||
request->send(response);
|
||||
//request->send_P(200, "text/html", PAGE_usermod);
|
||||
});
|
||||
|
||||
//Deprecated, use of /json/state and presets recommended instead
|
||||
server.on("/url", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
URL_response(request);
|
||||
});
|
||||
#endif
|
||||
|
||||
server.on("/teapot", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
serveMessage(request, 418, F("418. I'm a teapot."), F("(Tangible Embedded Advanced Project Of Twinkling)"), 254);
|
||||
@ -356,9 +337,14 @@ void initServer()
|
||||
serveMessage(request, 501, "Not implemented", F("DMX support is not enabled in this build."), 254);
|
||||
});
|
||||
#endif
|
||||
|
||||
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
if (captivePortal(request)) return;
|
||||
serveIndexOrWelcome(request);
|
||||
if (!showWelcomePage || request->hasArg(F("sliders"))){
|
||||
serveIndex(request);
|
||||
} else {
|
||||
serveSettings(request);
|
||||
}
|
||||
});
|
||||
|
||||
#ifdef WLED_ENABLE_PIXART
|
||||
@ -420,20 +406,9 @@ void initServer()
|
||||
response->addHeader(FPSTR(s_content_enc),"gzip");
|
||||
setStaticContentCacheHeaders(response);
|
||||
request->send(response);
|
||||
//request->send_P(404, "text/html", PAGE_404);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void serveIndexOrWelcome(AsyncWebServerRequest *request)
|
||||
{
|
||||
if (!showWelcomePage){
|
||||
serveIndex(request);
|
||||
} else {
|
||||
serveSettings(request);
|
||||
}
|
||||
}
|
||||
|
||||
bool handleIfNoneMatchCacheHeader(AsyncWebServerRequest* request)
|
||||
{
|
||||
AsyncWebHeader* header = request->getHeader("If-None-Match");
|
||||
|
@ -72,55 +72,6 @@ void XML_response(AsyncWebServerRequest *request, char* dest)
|
||||
if (request != nullptr) request->send(200, "text/xml", obuf);
|
||||
}
|
||||
|
||||
//Deprecated, use of /json/state and presets recommended instead
|
||||
void URL_response(AsyncWebServerRequest *request)
|
||||
{
|
||||
char sbuf[256];
|
||||
char s2buf[100];
|
||||
obuf = s2buf;
|
||||
olen = 0;
|
||||
|
||||
char s[16];
|
||||
oappend(SET_F("http://"));
|
||||
IPAddress localIP = Network.localIP();
|
||||
sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
|
||||
oappend(s);
|
||||
|
||||
oappend(SET_F("/win&A="));
|
||||
oappendi(bri);
|
||||
oappend(SET_F("&CL=h"));
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
sprintf(s,"%02X", col[i]);
|
||||
oappend(s);
|
||||
}
|
||||
oappend(SET_F("&C2=h"));
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
sprintf(s,"%02X", colSec[i]);
|
||||
oappend(s);
|
||||
}
|
||||
oappend(SET_F("&FX="));
|
||||
oappendi(effectCurrent);
|
||||
oappend(SET_F("&SX="));
|
||||
oappendi(effectSpeed);
|
||||
oappend(SET_F("&IX="));
|
||||
oappendi(effectIntensity);
|
||||
oappend(SET_F("&FP="));
|
||||
oappendi(effectPalette);
|
||||
|
||||
obuf = sbuf;
|
||||
olen = 0;
|
||||
|
||||
oappend(SET_F("<html><body><a href=\""));
|
||||
oappend(s2buf);
|
||||
oappend(SET_F("\" target=\"_blank\">"));
|
||||
oappend(s2buf);
|
||||
oappend(SET_F("</a></body></html>"));
|
||||
|
||||
if (request != nullptr) request->send(200, "text/html", obuf);
|
||||
}
|
||||
|
||||
void extractPin(JsonObject &obj, const char *key) {
|
||||
if (obj[key].is<JsonArray>()) {
|
||||
JsonArray pins = obj[key].as<JsonArray>();
|
||||
|
Loading…
Reference in New Issue
Block a user