Skip to content

Commit d84f2a6

Browse files
authored
Merge branch 'Aircoookie:main' into main
2 parents cca0d05 + 42b2477 commit d84f2a6

32 files changed

+3295
-4003
lines changed

platformio.ini

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# ------------------------------------------------------------------------------
1111

1212
# CI binaries
13-
;; 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
13+
; 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
1414
default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth, lolin_s2_mini, esp32c3dev, esp32s3dev_8MB
1515

1616
# Release binaries
@@ -40,6 +40,8 @@ default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth, lolin_
4040
; default_envs = esp32dev_qio80
4141
; default_envs = esp32_eth_ota1mapp
4242
; default_envs = esp32s2_saola
43+
; default_envs = esp32c3dev
44+
; default_envs = lolin_s2_mini
4345

4446
src_dir = ./wled00
4547
data_dir = ./wled00/data
@@ -460,8 +462,8 @@ board = esp32-c3-devkitm-1
460462
board_build.partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
461463
build_flags = ${common.build_flags} ${esp32c3.build_flags} #-D WLED_RELEASE_NAME=ESP32-C3
462464
-D WLED_WATCHDOG_TIMEOUT=0
463-
; -DARDUINO_USB_CDC_ON_BOOT=1 ;; for virtual CDC USB
464-
-DARDUINO_USB_CDC_ON_BOOT=0 ;; for serial-to-USB chip
465+
-DARDUINO_USB_CDC_ON_BOOT=1 ;; for virtual CDC USB
466+
;-DARDUINO_USB_CDC_ON_BOOT=0 ;; for serial-to-USB chip
465467
upload_speed = 460800
466468
build_unflags = ${common.build_unflags}
467469
lib_deps = ${esp32c3.lib_deps}
@@ -573,10 +575,10 @@ platform = ${esp32s2.platform}
573575
platform_packages = ${esp32s2.platform_packages}
574576
board = lolin_s2_mini
575577
board_build.partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
576-
build_unflags = ${common.build_unflags} -DARDUINO_USB_CDC_ON_BOOT=1
578+
build_unflags = ${common.build_unflags} #-DARDUINO_USB_CDC_ON_BOOT=1
577579
build_flags = ${common.build_flags} ${esp32s2.build_flags} #-D WLED_RELEASE_NAME=LolinS2
578580
-DBOARD_HAS_PSRAM
579-
-DARDUINO_USB_CDC_ON_BOOT=0
581+
-DARDUINO_USB_CDC_ON_BOOT=1 # try disabling and enabling unflag above in case of board-specific issues, will disable Serial
580582
-DARDUINO_USB_MSC_ON_BOOT=0
581583
-DARDUINO_USB_DFU_ON_BOOT=0
582584
-DLOLIN_WIFI_FIX ; seems to work much better with this

tools/cdata.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,6 @@ const char PAGE_dmxmap[] PROGMEM = R"=====()=====";
390390
method: "gzip",
391391
filter: "html-minify",
392392
},
393-
{
394-
file: "liveviewws.htm",
395-
name: "PAGE_liveviewws",
396-
method: "gzip",
397-
filter: "html-minify",
398-
},
399393
{
400394
file: "liveviewws2D.htm",
401395
name: "PAGE_liveviewws2D",

usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
#define ENCODER_SW_PIN 19
4646
#endif
4747

48+
#ifndef ENCODER_MAX_DELAY_MS // max delay between polling encoder pins
49+
#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)
50+
#endif
51+
4852
#ifndef USERMOD_USE_PCF8574
4953
#undef USE_PCF8574
5054
#define USE_PCF8574 false
@@ -539,8 +543,9 @@ void RotaryEncoderUIUsermod::setup()
539543
*/
540544
void RotaryEncoderUIUsermod::loop()
541545
{
542-
if (!enabled || strip.isUpdating()) return;
546+
if (!enabled) return;
543547
unsigned long currentTime = millis(); // get the current elapsed time
548+
if (strip.isUpdating() && ((currentTime - loopTime) < ENCODER_MAX_DELAY_MS)) return; // be nice, but not too nice
544549

545550
// Initialize effectCurrentIndex and effectPaletteIndex to
546551
// current state. We do it here as (at least) effectCurrent

wled00.sln

Lines changed: 0 additions & 25 deletions
This file was deleted.

wled00/FX.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ uint16_t mode_random_color(void) {
278278
SEGMENT.fill(color_blend(SEGMENT.color_wheel(SEGENV.aux1), SEGMENT.color_wheel(SEGENV.aux0), fade));
279279
return FRAMETIME;
280280
}
281-
static const char _data_FX_MODE_RANDOM_COLOR[] PROGMEM = "Random Colors@!,Fade time;;!";
281+
static const char _data_FX_MODE_RANDOM_COLOR[] PROGMEM = "Random Colors@!,Fade time;;!;01";
282282

283283

284284
/*
@@ -433,7 +433,7 @@ uint16_t mode_rainbow(void) {
433433

434434
return FRAMETIME;
435435
}
436-
static const char _data_FX_MODE_RAINBOW[] PROGMEM = "Colorloop@!,Saturation;;!";
436+
static const char _data_FX_MODE_RAINBOW[] PROGMEM = "Colorloop@!,Saturation;;!;01";
437437

438438

439439
/*
@@ -5274,7 +5274,7 @@ uint16_t mode_2DPlasmaball(void) { // By: Stepko https://edito
52745274

52755275
SEGMENT.fadeToBlackBy(SEGMENT.custom1>>2);
52765276

5277-
float t = millis() / (33 - SEGMENT.speed/8);
5277+
uint_fast32_t t = (millis() * 8) / (256 - SEGMENT.speed); // optimized to avoid float
52785278
for (int i = 0; i < cols; i++) {
52795279
uint16_t thisVal = inoise8(i * 30, t, t);
52805280
uint16_t thisMax = map(thisVal, 0, 255, 0, cols-1);
@@ -5879,7 +5879,7 @@ uint16_t mode_2Dscrollingtext(void) {
58795879
}
58805880
const bool zero = SEGMENT.check3;
58815881
const int yoffset = map(SEGMENT.intensity, 0, 255, -rows/2, rows/2) + (rows-letterHeight)/2;
5882-
char text[33] = {'\0'};
5882+
char text[WLED_MAX_SEGNAME_LEN+1] = {'\0'};
58835883
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];
58845884

58855885
if (!strlen(text)

wled00/FX.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ typedef struct Segment {
487487
//if (leds) Serial.printf(" [%u]", length()*sizeof(CRGB));
488488
//Serial.println();
489489
//#endif
490-
if (!Segment::_globalLeds && leds) free(leds);
490+
if (!Segment::_globalLeds && leds) { free(leds); leds = nullptr;} // reset to nullptr, to avoid race conditions
491491
if (name) delete[] name;
492492
if (_t) delete _t;
493493
deallocateData();
@@ -507,9 +507,9 @@ typedef struct Segment {
507507
inline bool hasRGB(void) const { return _isRGB; }
508508
inline bool hasWhite(void) const { return _hasW; }
509509
inline bool isCCT(void) const { return _isCCT; }
510-
inline uint16_t width(void) const { return stop - start; } // segment width in physical pixels (length if 1D)
511-
inline uint16_t height(void) const { return stopY - startY; } // segment height (if 2D) in physical pixels
512-
inline uint16_t length(void) const { return width() * height(); } // segment length (count) in physical pixels
510+
inline uint16_t width(void) const { return (stop > start) ? (stop - start) : 0; } // segment width in physical pixels (length if 1D)
511+
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
512+
inline uint16_t length(void) const { return width() * height(); } // segment length (count) in physical pixels
513513
inline uint16_t groupLength(void) const { return grouping + spacing; }
514514
inline uint8_t getLightCapabilities(void) const { return _capabilities; }
515515

@@ -710,7 +710,7 @@ class WS2812FX { // 96 bytes
710710
panel.clear();
711711
#endif
712712
customPalettes.clear();
713-
if (useLedsArray && Segment::_globalLeds) free(Segment::_globalLeds);
713+
if (useLedsArray && Segment::_globalLeds) {free(Segment::_globalLeds); Segment::_globalLeds = nullptr;} // reset to nullptr, to avoid race conditions
714714
}
715715

716716
static WS2812FX* getInstance(void) { return instance; }

wled00/FX_2Dfcn.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
191191
uint16_t /*IRAM_ATTR*/ Segment::XY(uint16_t x, uint16_t y) {
192192
uint16_t width = virtualWidth(); // segment width in logical pixels
193193
uint16_t height = virtualHeight(); // segment height in logical pixels
194+
if (width == 0) return 0; // softhack007 avoid div/0
195+
if (height == 0) return (x%width); // softhack007 avoid div/0
194196
return (x%width) + (y%height) * width;
195197
}
196198

@@ -304,6 +306,7 @@ void Segment::blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t
304306

305307
// Adds the specified color with the existing pixel color perserving color balance.
306308
void Segment::addPixelColorXY(int x, int y, uint32_t color, bool fast) {
309+
if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0) return; // if pixel would fall out of virtual segment just exit
307310
uint32_t col = getPixelColorXY(x,y);
308311
uint8_t r = R(col);
309312
uint8_t g = G(col);
@@ -328,50 +331,54 @@ void Segment::fadePixelColorXY(uint16_t x, uint16_t y, uint8_t fade) {
328331

329332
// blurRow: perform a blur on a row of a rectangular matrix
330333
void Segment::blurRow(uint16_t row, fract8 blur_amount) {
331-
const uint16_t cols = virtualWidth();
332-
const uint16_t rows = virtualHeight();
334+
const uint_fast16_t cols = virtualWidth();
335+
const uint_fast16_t rows = virtualHeight();
333336

334337
if (row >= rows) return;
335338
// blur one row
336339
uint8_t keep = 255 - blur_amount;
337340
uint8_t seep = blur_amount >> 1;
338341
CRGB carryover = CRGB::Black;
339-
for (uint16_t x = 0; x < cols; x++) {
342+
for (uint_fast16_t x = 0; x < cols; x++) {
340343
CRGB cur = getPixelColorXY(x, row);
344+
uint32_t before = uint32_t(cur); // remember color before blur
341345
CRGB part = cur;
342346
part.nscale8(seep);
343347
cur.nscale8(keep);
344348
cur += carryover;
345-
if (x) {
349+
if (x>0) {
346350
CRGB prev = CRGB(getPixelColorXY(x-1, row)) + part;
347351
setPixelColorXY(x-1, row, prev);
348352
}
349-
setPixelColorXY(x, row, cur);
353+
if (before != uint32_t(cur)) // optimization: only set pixel if color has changed
354+
setPixelColorXY(x, row, cur);
350355
carryover = part;
351356
}
352357
}
353358

354359
// blurCol: perform a blur on a column of a rectangular matrix
355360
void Segment::blurCol(uint16_t col, fract8 blur_amount) {
356-
const uint16_t cols = virtualWidth();
357-
const uint16_t rows = virtualHeight();
361+
const uint_fast16_t cols = virtualWidth();
362+
const uint_fast16_t rows = virtualHeight();
358363

359364
if (col >= cols) return;
360365
// blur one column
361366
uint8_t keep = 255 - blur_amount;
362367
uint8_t seep = blur_amount >> 1;
363368
CRGB carryover = CRGB::Black;
364-
for (uint16_t i = 0; i < rows; i++) {
365-
CRGB cur = getPixelColorXY(col, i);
369+
for (uint_fast16_t y = 0; y < rows; y++) {
370+
CRGB cur = getPixelColorXY(col, y);
366371
CRGB part = cur;
372+
uint32_t before = uint32_t(cur); // remember color before blur
367373
part.nscale8(seep);
368374
cur.nscale8(keep);
369375
cur += carryover;
370-
if (i) {
371-
CRGB prev = CRGB(getPixelColorXY(col, i-1)) + part;
372-
setPixelColorXY(col, i-1, prev);
376+
if (y>0) {
377+
CRGB prev = CRGB(getPixelColorXY(col, y-1)) + part;
378+
setPixelColorXY(col, y-1, prev);
373379
}
374-
setPixelColorXY(col, i, cur);
380+
if (before != uint32_t(cur)) // optimization: only set pixel if color has changed
381+
setPixelColorXY(col, y, cur);
375382
carryover = part;
376383
}
377384
}
@@ -390,8 +397,8 @@ void Segment::box_blur(uint16_t i, bool vertical, fract8 blur_amount) {
390397
for (uint16_t j = 0; j < dim1; j++) {
391398
uint16_t x = vertical ? i : j;
392399
uint16_t y = vertical ? j : i;
393-
uint16_t xp = vertical ? x : x-1;
394-
uint16_t yp = vertical ? y-1 : y;
400+
int16_t xp = vertical ? x : x-1; // "signed" to prevent underflow
401+
int16_t yp = vertical ? y-1 : y; // "signed" to prevent underflow
395402
uint16_t xn = vertical ? x : x+1;
396403
uint16_t yn = vertical ? y+1 : y;
397404
CRGB curr = getPixelColorXY(x,y);

0 commit comments

Comments
 (0)