diff --git a/.gitignore b/.gitignore
index cdfd81d0..5a928325 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,7 +13,10 @@ esp01-update.sh
platformio_override.ini
replace_fs.py
wled-update.sh
+qodana.yaml
+compile_commands.json
+/build/
/build_output/
/node_modules/
diff --git a/platformio.ini b/platformio.ini
index 248d27fe..49f9da49 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -81,7 +81,8 @@ default_envs =
esp32S3_16MB_PSRAM_M_HUB75 ;; for S3 with 16MB flash, and MOONHUB HUB75 adapter board
esp32S3_WROOM-2_M ;; for S3 WROOM-2
;; esp32s2_tinyUF2_PSRAM_S ;; experimental - only for adafruit -S2 boards with tinyUF2 bootloader !!!
- esp32s2_PSRAM_M ;; experimental
+ esp32s2_PSRAM_S ;; OTA-compatible with upstream
+ esp32s2_PSRAM_M ;; for lolin S2 mini
esp32c3dev_4MB_M ;; experimental
esp32c3dev_2MB_M ;; experimental - 2MB Flash, no OTA
esp32c3mini_dio_4MB_M ;; for boards that need "dio" flash mode (instead of qio)
@@ -2299,7 +2300,7 @@ platform = ${esp32s2.platform} ;; using 5.2.0, due to
platform_packages = ${esp32s2.platform_packages}
board = lolin_s2_mini
-board_build.partitions = tools/WLED_ESP32_4MB_256KB_FS.csv ;; 1.8MB firmware, 256KB filesystem (esptool erase_flash needed when changing from "standard WLED" partitions)
+board_build.partitions = ${esp32.extended_partitions} ;; 1.65MB firmware, 700KB filesystem (esptool erase_flash needed when changing from "standard WLED" partitions)
board_build.flash_mode = dio
upload_speed = 256000 ;; 921600
build_unflags = ${common.build_unflags}
@@ -2308,7 +2309,6 @@ build_unflags = ${common.build_unflags}
-D USERMOD_DALLASTEMPERATURE ;; disabled because it hangs during usermod setup on -S3 (autodetect broken?)
-D WLED_ENABLE_DMX ;; disabled because it does not work with ESP-IDF 4.4.x (buggy driver in SparkFunDMX)
-D WLED_ENABLE_DMX_INPUT ;; needs more testing
- -DWLEDMM_FASTPATH ;; needs more testing on -S2
-D WLED_ENABLE_HUB75MATRIX
build_flags = ${common.build_flags} ${esp32s2.build_flags}
;; ${Debug_Flags.build_flags}
@@ -2340,9 +2340,32 @@ lib_deps = ${esp32s2.lib_deps} ${common_mm.lib_deps_S} ${common_mm.lib_deps_V4_M
lib_ignore =
IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation
OneWire ; not needed as we don't include USERMOD_DALLASTEMPERATURE
+ ${common_mm.HUB75_lib_ignore}
+ ${common_mm.DMXin_lib_ignore}
monitor_filters = esp32_exception_decoder
-; RAM: [== ] 21.8% (used 71304 bytes from 327680 bytes)
-; Flash: [======== ] 84.0% (used 1596970 bytes from 1900544 bytes)
+; RAM: [== ] 20.5% (used 67256 bytes from 327680 bytes)
+; Flash: [========= ] 93.3% (used 1590266 bytes from 1703936 bytes)
+
+[env:esp32s2_PSRAM_S]
+extends = env:esp32s2_PSRAM_M
+board_build.partitions = ${esp32.default_partitions} ;; 1.55MB firmware, 1MB filesystem
+build_unflags = ${env:esp32s2_PSRAM_M.build_unflags}
+ -DWLED_DISABLE_ADALIGHT
+ -D WLED_RELEASE_NAME=esp32s2_4MB_M
+ -DUSE_ALT_DISPLAY
+ -DUSERMOD_FOUR_LINE_DISPLAY
+ -DUSERMOD_ROTARY_ENCODER_UI
+ -DUSERMOD_ANIMARTRIX
+ ;; -DUSERMOD_ARTIFX ;; uncomment to reduce flash size
+build_flags = ${env:esp32s2_PSRAM_M.build_flags}
+ -D WLED_RELEASE_NAME=esp32s2_4MB_S
+lib_deps = ${env:esp32s2_PSRAM_M.lib_deps}
+lib_ignore = ${env:esp32s2_PSRAM_M.lib_ignore}
+ U8g2
+ ${common_mm.animartrix_lib_ignore}
+; RAM: [== ] 20.4% (used 66792 bytes from 327680 bytes)
+; Flash: [========= ] 94.8% (used 1490390 bytes from 1572864 bytes)
+
# ------------------------------------------------------------------------------
# esp32-C3 environments
diff --git a/wled00/FX.cpp b/wled00/FX.cpp
index c34c2af7..2e74f743 100644
--- a/wled00/FX.cpp
+++ b/wled00/FX.cpp
@@ -2589,7 +2589,7 @@ uint16_t ripple_base()
} else {//randomly create new wave
if (random16(IBN + 10000) <= (SEGMENT.intensity >> (SEGMENT.is2D()*3))) {
ripples[i].state = 1;
- ripples[i].pos = SEGMENT.is2D() ? ((random8(SEGENV.virtualWidth())<<8) | (random8(SEGENV.virtualHeight()))) : random16(SEGLEN);
+ ripples[i].pos = SEGMENT.is2D() ? ((random16(SEGENV.virtualWidth())<<8) | (random16(SEGENV.virtualHeight()))) : random16(SEGLEN);
ripples[i].color = random8(); //color
}
}
@@ -5884,7 +5884,7 @@ uint16_t mode_2Dmatrix(void) { // Matrix2D. By Jeremy Williams.
// spawn new falling code
if (random8() <= SEGMENT.intensity || emptyScreen) {
- uint8_t spawnX = random8(cols);
+ uint16_t spawnX = random16(cols);
SEGMENT.setPixelColorXY(spawnX, 0, spawnColor);
// update hint for next run
SEGENV.aux0 = spawnX;
@@ -6357,8 +6357,8 @@ uint16_t mode_2Dcrazybees(void) {
void aimed(uint_fast16_t w, uint_fast16_t h) {
if (!true) //WLEDMM SuperSync
random16_set_seed(strip.now);
- aimX = random8(0, w);
- aimY = random8(0, h);
+ aimX = random8(0, min(UINT8_MAX, int(w)));
+ aimY = random8(0, min(UINT8_MAX, int(h)));
hue = random8();
deltaX = abs(aimX - posX);
deltaY = abs(aimY - posY);
@@ -6377,8 +6377,8 @@ uint16_t mode_2Dcrazybees(void) {
SEGMENT.setUpLeds();
SEGMENT.fill(BLACK);
for (size_t i = 0; i < n; i++) {
- bee[i].posX = random8(0, cols);
- bee[i].posY = random8(0, rows);
+ bee[i].posX = random8(0, min(UINT8_MAX, int(cols)));
+ bee[i].posY = random8(0, min(UINT8_MAX, int(rows)));
bee[i].aimed(cols, rows);
}
}
@@ -8502,7 +8502,7 @@ uint16_t mode_2Doctopus() {
const uint16_t cols = SEGMENT.virtualWidth();
const uint16_t rows = SEGMENT.virtualHeight();
- const uint8_t mapp = 180 / MAX(cols,rows);
+ const uint16_t mapp = max(1, 180 / MAX(cols,rows)); // WLEDMM make sure this value is not 0
typedef struct {
uint8_t angle;
@@ -8539,8 +8539,8 @@ uint16_t mode_2Doctopus() {
SEGENV.aux1 = rows;
*offsX = SEGMENT.custom1;
*offsY = SEGMENT.custom2;
- const uint8_t C_X = cols / 2 + (SEGMENT.custom1 - 128)*cols/255;
- const uint8_t C_Y = rows / 2 + (SEGMENT.custom2 - 128)*rows/255;
+ const uint16_t C_X = cols / 2 + (SEGMENT.custom1 - 128)*cols/255;
+ const uint16_t C_Y = rows / 2 + (SEGMENT.custom2 - 128)*rows/255;
for (int x = xStart; x < xEnd; x++) {
for (int y = yStart; y < yEnd; y++) {
rMap[XY(x, y)].angle = int(40.7436f * atan2f((y - C_Y), (x - C_X))); // avoid 128*atan2()/PI
diff --git a/wled00/FX.h b/wled00/FX.h
index 413b87cd..c0693462 100644
--- a/wled00/FX.h
+++ b/wled00/FX.h
@@ -390,8 +390,8 @@ typedef struct Segment {
bool check2 : 1; // checkmark 2
bool check3 : 1; // checkmark 3
};
- uint8_t startY; // start Y coodrinate 2D (top); there should be no more than 255 rows
- uint8_t stopY; // stop Y coordinate 2D (bottom); there should be no more than 255 rows
+ uint16_t startY; // start Y coodrinate 2D (top); there should be no more than 255 rows, but we cannot be sure.
+ uint16_t stopY; // stop Y coordinate 2D (bottom); there should be no more than 255 rows, but we cannot be sure.
char *name = nullptr; // WLEDMM initialize to nullptr
// runtime data
@@ -1017,10 +1017,10 @@ class WS2812FX { // 96 bytes
} panelO; //panelOrientation
typedef struct panel_t {
- uint8_t xOffset; // x offset relative to the top left of matrix in LEDs. WLEDMM 8 bits/256 is enough
- uint8_t yOffset; // y offset relative to the top left of matrix in LEDs. WLEDMM 8 bits/256 is enough
- uint8_t width; // width of the panel
- uint8_t height; // height of the panel
+ uint16_t xOffset; // x offset relative to the top left of matrix in LEDs.
+ uint16_t yOffset; // y offset relative to the top left of matrix in LEDs.
+ uint16_t width; // width of the panel
+ uint16_t height; // height of the panel
union {
uint8_t options;
struct {
diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp
index 57612247..f6d2bc0b 100644
--- a/wled00/FX_2Dfcn.cpp
+++ b/wled00/FX_2Dfcn.cpp
@@ -129,11 +129,11 @@ void WS2812FX::setUpMatrix() {
}
if (needLedMap && customMappingTable != nullptr) { // softhack007
- uint16_t x, y, pix=0; //pixel
+ uint_fast16_t x, y, pix=0; //pixel
for (size_t pan = 0; pan < panel.size(); pan++) {
Panel &p = panel[pan];
- uint16_t h = p.vertical ? p.height : p.width;
- uint16_t v = p.vertical ? p.width : p.height;
+ uint_fast16_t h = p.vertical ? p.height : p.width;
+ uint_fast16_t v = p.vertical ? p.width : p.height;
for (size_t j = 0; j < v; j++){
for(size_t i = 0; i < h; i++) {
y = (p.vertical?p.rightStart:p.bottomStart) ? v-j-1 : j;
diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp
index d2602218..f98f5dcb 100644
--- a/wled00/FX_fcn.cpp
+++ b/wled00/FX_fcn.cpp
@@ -873,8 +873,11 @@ uint16_t Segment::calc_virtualLength() const {
vLen = max(vW,vH); // get the longest dimension
break;
case M12_pArc:
- vLen = sqrt16(vW * vW + vH * vH);
- if (vW != vH) vLen++; // round up
+ { unsigned vLen2 = vW * vW + vH * vH; // length ^2
+ if (vLen2 < UINT16_MAX) vLen = sqrt16(vLen2); // use faster function for 16bit values
+ else vLen = sqrtf(vLen2); // fall-back to float if bigger
+ if (vW != vH) vLen++; // round up
+ }
break;
case M12_jMap: //WLEDMM jMap
if (jMap)
@@ -888,7 +891,7 @@ uint16_t Segment::calc_virtualLength() const {
if (nrOfVStrips()>1)
vLen = max(vW,vH) * 4;//0.5; // get the longest dimension
else
- vLen = max(vW,vH) * 0.5; // get the longest dimension
+ vLen = max(vW,vH) * 0.5f; // get the longest dimension
break;
case M12_sPinwheel:
vLen = getPinwheelLength(vW, vH);
@@ -906,23 +909,23 @@ uint16_t Segment::calc_virtualLength() const {
//WLEDMM used for M12_sBlock
static void xyFromBlock(uint16_t &x,uint16_t &y, uint16_t i, uint16_t vW, uint16_t vH, uint16_t vStrip) {
float i2;
- if (i<=SEGLEN*0.25) { //top, left to right
- i2 = i/(SEGLEN*0.25);
+ if (i<=SEGLEN*0.25f) { //top, left to right
+ i2 = i/(SEGLEN*0.25f);
x = vW / 2 - vStrip - 1 + i2 * vStrip * 2;
y = vH / 2 - vStrip - 1;
}
- else if (i <= SEGLEN * 0.5) { //right, top to bottom
- i2 = (i-SEGLEN*0.25)/(SEGLEN*0.25);
+ else if (i <= SEGLEN * 0.5f) { //right, top to bottom
+ i2 = (i-SEGLEN*0.25f)/(SEGLEN*0.25f);
x = vW / 2 + vStrip;
y = vH / 2 - vStrip - 1 + i2 * vStrip * 2;
}
- else if (i <= SEGLEN * 0.75) { //bottom, right to left
- i2 = (i-SEGLEN*0.5)/(SEGLEN*0.25);
+ else if (i <= SEGLEN * 0.75f) { //bottom, right to left
+ i2 = (i-SEGLEN*0.5f)/(SEGLEN*0.25f);
x = vW / 2 + vStrip - i2 * vStrip * 2;
y = vH / 2 + vStrip;
}
else if (i <= SEGLEN) { //left, bottom to top
- i2 = (i-SEGLEN*0.75)/(SEGLEN*0.25);
+ i2 = (i-SEGLEN*0.75f)/(SEGLEN*0.25f);
x = vW / 2 - vStrip - 1;
y = vH / 2 + vStrip - i2 * vStrip * 2;
}
diff --git a/wled00/data/settings_2D.htm b/wled00/data/settings_2D.htm
index c602b98c..c57bf3d9 100644
--- a/wled00/data/settings_2D.htm
+++ b/wled00/data/settings_2D.htm
@@ -111,9 +111,9 @@ Orientation:
Serpentine:
-Dimensions (WxH): x
-Offset X:
-Y:
(offset from top-left corner in # LEDs)
+Dimensions (WxH): x
+Offset X:
+Y:
(offset from top-left corner in # LEDs)
`;
p.insertAdjacentHTML("beforeend", b);
}
@@ -401,7 +401,7 @@ Y:Matrix Generator