Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions firmware/esp32-d0.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ build_flags = ${env.build_flags}
; ${ESP32_LEDSDRIVER.build_flags} ;use the LedsDriver class only for setBrightness and setColorCorrection and LUT
${HP_ALL_DRIVERS.build_flags}
; -D ML_LIVE_MAPPING
; -D FASTLED_RMT_BUILTIN_DRIVER=true
; -D FASTLED_ESP32_HAS_RMT5 ; avoid flickering (on IDF 5 with WiFi)
; -D FASTLED_RMT5=1
lib_deps = ${env.lib_deps}
${moonlight.lib_deps}
; ${livescripts.lib_deps}
Expand Down
4 changes: 3 additions & 1 deletion lib/framework/CoreDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include "esp_partition.h"
#include "esp_flash.h"

#define MIN(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
#ifndef MIN // 🌙
#define MIN(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
#endif

CoreDump::CoreDump(PsychicHttpServer *server,
SecurityManager *securityManager) : _server(server),
Expand Down
6 changes: 3 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ build_flags =

-D FT_MOONBASE=1

-D HTTPD_STACK_SIZE=5120 ; default 4096 but not enough for more complex read and update
-D HTTPD_STACK_SIZE=6144 ; default 4096 but not enough for more complex read and update , 5120 not enough when switching from FastLED to parallel LED driver
-D SVELTEKIT_STACK_SIZE=6144 ; psramFound() ? 8 * 1024 : 6 * 1024🌙 4096 to 8192 / 6144

; 🌙 Move ESP32SvelteKit (HTTP/WebSocket) to Core 1 (APP_CPU) to avoid WiFi preemption on Core 0
Expand Down Expand Up @@ -149,7 +149,7 @@ build_flags =
-D FT_MOONLIGHT=1
-D FT_MONITOR=1
-D EFFECTS_STACK_SIZE=3072 ; psramFound() ? 4 * 1024 : 3 * 1024
-D DRIVERS_STACK_SIZE=4096 ; psramFound() ? 4 * 1024 : 3 * 1024
-D DRIVERS_STACK_SIZE=4196 ; psramFound() ? 4 * 1024 : 3 * 1024

; FastLED pre-compiled settings:
; ML_CHIPSET: Used by FastLED driver.init
Expand All @@ -159,7 +159,7 @@ build_flags =
-D ML_COLOR_ORDER=GRB ; define your color order here if needed (why WS2812 has GRB instead of RGB?) Only for FastLED, PD software configurable
; -D ML_RGBW=1 ; define whether to enable RGBW (1 = yes, 0 = no) ... could be derived from ML_CHIPSET???
lib_deps =
https://github.com/FastLED/FastLED.git#3.10.3 ; sept 2025
https://github.com/FastLED/FastLED#8b4fd586ba38a6c3b67ce94f78d68e77aa505fa5
https://github.com/ewowi/WLED-sync#25f280b5e8e47e49a95282d0b78a5ce5301af4fe ; sourceIP + fftUdp.clear() if arduino >=3 (20251104)

; 💫 currently only enabled on s3 as esp32dev runs over 100%
Expand Down
2 changes: 1 addition & 1 deletion src/MoonBase/Nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void LiveScriptNode::setup() {
addExternal("uint32_t millis()", (void*)millis);
addExternal("uint32_t now()", (void*)millis); // todo: synchronized time (sys->now)
addExternal("uint16_t random16(uint16_t)", (void*)(uint16_t (*)(uint16_t))random16);
addExternal("void delay(uint32_t)", (void*)delay);
addExternal("void delay(uint32_t)", (void*)((void (*)(uint32_t))delay));
addExternal("void pinMode(uint8_t,uint8_t)", (void*)pinMode);
addExternal("void digitalWrite(uint8_t,uint8_t)", (void*)digitalWrite);

Expand Down
6 changes: 3 additions & 3 deletions src/MoonLight/Layers/VirtualLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

// convenience functions to call fastled functions out of the Leds namespace (there naming conflict)
void fastled_fadeToBlackBy(CRGB* leds, uint16_t num_leds, uint8_t fadeBy) { fadeToBlackBy(leds, num_leds, fadeBy); } // supports max UINT16_MAX leds !
void fastled_fill_solid(struct CRGB* targetArray, int numToFill, const CRGB& color) { fill_solid(targetArray, numToFill, color); }
void fastled_fill_rainbow(struct CRGB* targetArray, int numToFill, uint8_t initialhue, uint8_t deltahue) { fill_rainbow(targetArray, numToFill, initialhue, deltahue); }
void fastled_fill_solid(CRGB* targetArray, int numToFill, const CRGB& color) { fill_solid(targetArray, numToFill, color); }
void fastled_fill_rainbow(CRGB* targetArray, int numToFill, uint8_t initialhue, uint8_t deltahue) { fill_rainbow(targetArray, (uint16_t)numToFill, initialhue, deltahue); }

VirtualLayer::VirtualLayer() { EXT_LOGV(ML_TAG, "constructor"); }

Expand Down Expand Up @@ -290,7 +290,7 @@ void VirtualLayer::addLight(Coord3D position) {
createMappingTableAndAddOneToOne();
}

nrOfLights = MAX(nrOfLights, indexV + 1);
nrOfLights = max(nrOfLights, nrOfLights_t(indexV + 1));

if (!oneToOneMapping) {
if (indexV < mappingTableSize) {
Expand Down
25 changes: 15 additions & 10 deletions src/MoonLight/Layers/VirtualLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ class VirtualLayer {
void setRGB(const nrOfLights_t indexV, CRGB color) {
if (indexV < mappingTableSize && mappingTable[indexV].mapType == m_zeroLights) {
#ifdef BOARD_HAS_PSRAM
memcpy(mappingTable[indexV].rgb, &color, 3);
memcpy(mappingTable[indexV].rgb, (void*)&color, 3);
#else
mappingTable[indexV].rgb = ((min(color[0] + 3, 255) >> 3) << 9) + ((min(color[1] + 3, 255) >> 3) << 4) + (min(color[2] + 7, 255) >> 4);
#endif
} else
forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy(&layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW], &color, sizeof(color)); });
forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy(&layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW], (void*)&color, sizeof(color)); });
}
void setRGB(Coord3D pos, CRGB color) { setRGB(XYZ(pos), color); }

Expand Down Expand Up @@ -198,17 +198,17 @@ class VirtualLayer {
void setGobo(Coord3D pos, const uint8_t value) { setGobo(XYZ(pos), value); }

void setRGB1(const nrOfLights_t indexV, CRGB color) {
if (layerP->lights.header.offsetRGBW1 != UINT8_MAX) forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy(&layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW1], &color, sizeof(color)); });
if (layerP->lights.header.offsetRGBW1 != UINT8_MAX) forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy(&layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW1], (void*)&color, sizeof(color)); });
}
void setRGB1(Coord3D pos, CRGB color) { setRGB1(XYZ(pos), color); }

void setRGB2(const nrOfLights_t indexV, CRGB color) {
if (layerP->lights.header.offsetRGBW2 != UINT8_MAX) forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy(&layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW2], &color, sizeof(color)); });
if (layerP->lights.header.offsetRGBW2 != UINT8_MAX) forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy(&layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW2], (void*)&color, sizeof(color)); });
}
void setRGB2(Coord3D pos, CRGB color) { setRGB2(XYZ(pos), color); }

void setRGB3(const nrOfLights_t indexV, CRGB color) {
if (layerP->lights.header.offsetRGBW3 != UINT8_MAX) forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy(&layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW3], &color, sizeof(color)); });
if (layerP->lights.header.offsetRGBW3 != UINT8_MAX) forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy(&layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW3], (void*)&color, sizeof(color)); });
}
void setRGB3(Coord3D pos, CRGB color) { setRGB3(XYZ(pos), color); }

Expand Down Expand Up @@ -238,13 +238,18 @@ class VirtualLayer {
#endif
} else {
CRGB color = CRGB::Black;
forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy(&color, &layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW], sizeof(color)); }, true);
forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy((void*)&color, &layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW], sizeof(color)); }, true);
return color;
}
}
CRGB getRGB(Coord3D pos) { return getRGB(XYZ(pos)); }

void addRGB(const Coord3D& position, const CRGB& color) { setRGB(position, getRGB(position) + color); }
void addRGB(const Coord3D& position, const CRGB& color) {
// setRGB(position, getRGB(position) + color); + not working anymore in newest FastLED ???
CRGB result = getRGB(position);
result += color;
setRGB(position, result);
}

void blendColor(const nrOfLights_t indexV, const CRGB& color, uint8_t blendAmount) { setRGB(indexV, blend(color, getRGB(indexV), blendAmount)); }
void blendColor(Coord3D position, const CRGB& color, const uint8_t blendAmount) { blendColor(XYZ(position), color, blendAmount); }
Expand All @@ -255,23 +260,23 @@ class VirtualLayer {
CRGB getRGB1(const nrOfLights_t indexV) {
if (layerP->lights.header.offsetRGBW1 == UINT8_MAX) return CRGB::Black;
CRGB color = CRGB::Black;
forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy(&color, &layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW1], sizeof(color)); }, true);
forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy((void*)&color, &layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW1], sizeof(color)); }, true);
return color;
}
CRGB getRGB1(Coord3D pos) { return getRGB1(XYZ(pos)); }

CRGB getRGB2(const nrOfLights_t indexV) {
if (layerP->lights.header.offsetRGBW2 == UINT8_MAX) return CRGB::Black;
CRGB color = CRGB::Black;
forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy(&color, &layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW2], sizeof(color)); }, true);
forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy((void*)&color, &layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW2], sizeof(color)); }, true);
return color;
}
CRGB getRGB2(Coord3D pos) { return getRGB2(XYZ(pos)); }

CRGB getRGB3(const nrOfLights_t indexV) {
if (layerP->lights.header.offsetRGBW3 == UINT8_MAX) return CRGB::Black;
CRGB color = CRGB::Black;
forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy(&color, &layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW3], sizeof(color)); }, true);
forEachLightIndex(indexV, [&](nrOfLights_t indexP) { memcpy((void*)&color, &layerP->lights.channelsE[indexP * layerP->lights.header.channelsPerLight + layerP->lights.header.offsetRGBW3], sizeof(color)); }, true);
return color;
}
CRGB getRGB3(Coord3D pos) { return getRGB3(XYZ(pos)); }
Expand Down
2 changes: 1 addition & 1 deletion src/MoonLight/Modules/ModuleLightsControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ class ModuleLightsControl : public Module {
xSemaphoreGive(swapMutex);
} else if (isPositions == 0 && layerP.lights.header.nrOfLights) { // send to UI
static unsigned long monitorMillis = 0;
if (millis() - monitorMillis >= MAX(20, layerP.lights.header.nrOfLights / 300)) { // 12K lights -> 40ms
if (millis() - monitorMillis >= max(20UL, layerP.lights.header.nrOfLights / 300)) { // 12K lights -> 40ms
monitorMillis = millis();

if (_socket->getActiveClients() && _state.data["monitorOn"]) {
Expand Down
Loading