diff --git a/firmware/esp32-d0.ini b/firmware/esp32-d0.ini index 2132c29b..8c8a217d 100644 --- a/firmware/esp32-d0.ini +++ b/firmware/esp32-d0.ini @@ -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} diff --git a/firmware/esp32-s3.ini b/firmware/esp32-s3.ini index d4863102..5a6a8164 100644 --- a/firmware/esp32-s3.ini +++ b/firmware/esp32-s3.ini @@ -10,14 +10,11 @@ build_flags = ; -D ARDUINO_USB_MSC_ON_BOOT=0 ;Mass Storage Class, disable ; -D ARDUINO_USB_DFU_ON_BOOT=0 ;download firmware update, disable ; -D ML_LIVE_MAPPING - ; Do not use the following FastLED settings! As we use the better version of this in Parallel LED Driverer - ; -D FASTLED_USES_ESP32S3_I2S ; S3 boards use the I2S driver (RMT is not supporting more then 4 outputs) - ; -DCOLOR_ORDER_RGB=1 ; not working yet, see also https://github.com/FastLED/FastLED/issues/1966, should use ML_COLOR_ORDER / FastLED.addLeds(RGB_ORDER), workaround change #define COLOR_ORDER_RBG in driver.h lib_deps = ${env.lib_deps} ${moonlight.lib_deps} ${livescripts.lib_deps} - ${HP_ALL_DRIVERS.lib_deps} ; FASTLED_USES_ESP32S3_I2S instead! + ${HP_ALL_DRIVERS.lib_deps} diff --git a/lib/framework/CoreDump.cpp b/lib/framework/CoreDump.cpp index 5667b692..ad621e29 100644 --- a/lib/framework/CoreDump.cpp +++ b/lib/framework/CoreDump.cpp @@ -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), diff --git a/platformio.ini b/platformio.ini index c2cfb676..8e6f6b50 100644 --- a/platformio.ini +++ b/platformio.ini @@ -56,13 +56,13 @@ build_flags = -D BUILD_TARGET=\"$PIOENV\" -D APP_NAME=\"MoonLight\" ; πŸŒ™ Must only contain characters from [a-zA-Z0-9-_] as this is converted into a filename -D APP_VERSION=\"0.8.1\" ; semver compatible version string - -D APP_DATE=\"20260204\" ; πŸŒ™ + -D APP_DATE=\"20260207\" ; πŸŒ™ -D PLATFORM_VERSION=\"pioarduino-55.03.35\" ; πŸŒ™ make sure it matches with above plaftform -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 @@ -149,17 +149,11 @@ 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 - - ; FastLED pre-compiled settings: - ; ML_CHIPSET: Used by FastLED driver.init - -D ML_CHIPSET=WS2812B ; RGB, for fairy lights or https://www.waveshare.com/wiki/ESP32-S3-Matrix - ; -D ML_CHIPSET=APA106 ; for Cube202020 / some fairy curtain strings do not work with WS2812B - ; -D ML_CHIPSET=SK6812 ; 🚧 - -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??? + -D DRIVERS_STACK_SIZE=4196 ; psramFound() ? 4 * 1024 : 3 * 1024 + + ; -D FASTLED_TESTING ; causes duplicate definition of initSpiHardware(); - workaround: removed implementation in spi_hw_manager_esp32.cpp.hpp lib_deps = - https://github.com/FastLED/FastLED.git#3.10.3 ; sept 2025 + https://github.com/FastLED/FastLED#f413fee79300bb0e173e9e737aea57b32b0c371c ; master 20260207 https://github.com/ewowi/WLED-sync#25f280b5e8e47e49a95282d0b78a5ce5301af4fe ; sourceIP + fftUdp.clear() if arduino >=3 (20251104) ; πŸ’« currently only enabled on s3 as esp32dev runs over 100% diff --git a/src/MoonBase/Nodes.cpp b/src/MoonBase/Nodes.cpp index 7aeb6b0a..b540909a 100644 --- a/src/MoonBase/Nodes.cpp +++ b/src/MoonBase/Nodes.cpp @@ -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); diff --git a/src/MoonLight/Layers/VirtualLayer.cpp b/src/MoonLight/Layers/VirtualLayer.cpp index 88bd7047..a122c7f6 100644 --- a/src/MoonLight/Layers/VirtualLayer.cpp +++ b/src/MoonLight/Layers/VirtualLayer.cpp @@ -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"); } @@ -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) { diff --git a/src/MoonLight/Layers/VirtualLayer.h b/src/MoonLight/Layers/VirtualLayer.h index 024d0a21..d85f3af1 100644 --- a/src/MoonLight/Layers/VirtualLayer.h +++ b/src/MoonLight/Layers/VirtualLayer.h @@ -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); } @@ -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); } @@ -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); } @@ -255,7 +260,7 @@ 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)); } @@ -263,7 +268,7 @@ class VirtualLayer { 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)); } @@ -271,7 +276,7 @@ class VirtualLayer { 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)); } diff --git a/src/MoonLight/Modules/ModuleLightsControl.h b/src/MoonLight/Modules/ModuleLightsControl.h index 38de4f60..773bad66 100644 --- a/src/MoonLight/Modules/ModuleLightsControl.h +++ b/src/MoonLight/Modules/ModuleLightsControl.h @@ -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"]) { diff --git a/src/MoonLight/Nodes/Drivers/D_FastLED.h b/src/MoonLight/Nodes/Drivers/D_FastLED.h index 3a296336..32209c8e 100644 --- a/src/MoonLight/Nodes/Drivers/D_FastLED.h +++ b/src/MoonLight/Nodes/Drivers/D_FastLED.h @@ -13,19 +13,13 @@ #if FT_MOONLIGHT - // Expand to , COLOR_ORDER if defined - #if defined(ML_COLOR_ORDER) - #define COLOR_ORDER_ARG , ML_COLOR_ORDER - #else - #define COLOR_ORDER_ARG - #endif - - // Expand to .setRgbw(RgbwDefault()) if ML_RGBW is 1 - #if ML_RGBW - #define RGBW_CALL .setRgbw(RgbwDefault()) - #else - #define RGBW_CALL - #endif +// #include "fl/channels/channel.h" +// #include "fl/channels/config.h" +// #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 +// #include "platforms/esp/32/drivers/spi/channel_engine_spi.h" +// #else +// #include "platforms/esp/32/drivers/parlio/channel_engine_parlio.h" +// #endif class FastLEDDriver : public Node { public: @@ -33,27 +27,11 @@ class FastLEDDriver : public Node { static uint8_t dim() { return _NoD; } static const char* tags() { return "☸️"; } - char chipSet[20] = TOSTRING(ML_CHIPSET); char version[20] = TOSTRING(FASTLED_VERSION); // "." TOSTRING(FASTLED_VERSION_MINOR) "." TOSTRING(FASTLED_VERSION_PATCH); - char colorOrder[20] = TOSTRING(ML_COLOR_ORDER); - #if FASTLED_USES_ESP32S3_I2S - bool usesI2S = true; - #else - bool usesI2S = false; - #endif - #if FASTLED_RMT5 - bool usesRMT5 = true; - #else - bool usesRMT5 = false; - #endif Char<32> status = "ok"; void setup() override { addControl(version, "version", "text", 0, 20, true); - addControl(chipSet, "chipSet", "text", 0, 20, true); - addControl(colorOrder, "colorOrder", "text", 0, 20, true); - addControl(usesI2S, "usesI2S", "checkbox", 0, 20, true); - addControl(usesRMT5, "usesRMT5", "checkbox", 0, 20, true); addControl(status, "status", "text", 0, 32, true); } @@ -75,7 +53,6 @@ class FastLEDDriver : public Node { CRGB correction = CRGB(layerP.lights.header.red, layerP.lights.header.green, layerP.lights.header.blue); CLEDController* pCur = CLEDController::head(); while (pCur) { - // ++x; if (pCur->getCorrection() != correction) { EXT_LOGD(ML_TAG, "setColorCorrection r:%d, g:%d, b:%d (#:%d)", layerP.lights.header.red, layerP.lights.header.green, layerP.lights.header.blue, pCur->size()); pCur->setCorrection(correction); @@ -122,441 +99,57 @@ class FastLEDDriver : public Node { updateControl("status", statusString.c_str()); moduleNodes->requestUIUpdate = true; + // https://github.com/FastLED/FastLED/blob/master/src/fl/channels/README.md + fl::ChipsetTimingConfig timing = fl::makeTimingConfig(); + CRGB* leds = (CRGB*)layerP.lights.channelsD; uint16_t startLed = 0; + #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 + FastLED.setExclusiveDriver("I2S"); + #else + FastLED.setExclusiveDriver("PARLIO"); + #endif + for (uint8_t pinIndex = 0; pinIndex < nrOfPins; pinIndex++) { - EXT_LOGD(ML_TAG, "ledPin s:%d #:%d p:%d", pinIndex, layerP.ledsPerPin[pinIndex]); + EXT_LOGD(ML_TAG, "ledPin p:%d #:%d", pins[pinIndex], layerP.ledsPerPin[pinIndex]); - uint16_t nrOfLights = layerP.ledsPerPin[pinIndex]; + fl::ChannelOptions options; + #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 + options.mAffinity = "I2S"; + #else + options.mAffinity = "PARLIO"; + #endif - CRGB* leds = (CRGB*)layerP.lights.channelsD; + fl::ChannelConfig config(pins[pinIndex], timing, fl::span(&leds[startLed], layerP.ledsPerPin[pinIndex]), GRB, options); + fl::ChannelPtr channel = fl::Channel::create(config); - switch (pins[pinIndex]) { - #if CONFIG_IDF_TARGET_ESP32 - case 0: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 1: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 2: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 3: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 4: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 5: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - // case 6: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 7: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 8: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 9: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 10: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - case 11: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 12: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 13: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 14: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 15: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - #if !defined(BOARD_HAS_PSRAM) && !defined(ARDUINO_ESP32_PICO) - // 16+17 = reserved for PSRAM, or reserved for FLASH on pico-D4 - case 16: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 17: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - #endif - case 18: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 19: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - // case 20: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - case 21: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 22: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 23: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - // case 24: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - case 25: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 26: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 27: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - // case 28: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 29: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 30: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 31: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - case 32: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 33: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - // 34-39 input-only - // case 34: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 35: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 36: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 37: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 38: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 39: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - #endif // CONFIG_IDF_TARGET_ESP32 + FastLED.add(channel); - #if CONFIG_IDF_TARGET_ESP32S2 - case 0: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 1: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 2: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 3: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 4: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 5: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 6: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 7: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 8: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 9: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 10: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 11: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 12: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 13: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 14: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 15: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 16: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 17: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 18: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - #if !ARDUINO_USB_CDC_ON_BOOT - // 19 + 20 = USB HWCDC. reserved for USB port when ARDUINO_USB_CDC_ON_BOOT=1 - case 19: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 20: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - #endif - case 21: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - // 22 to 32: not connected, or reserved for SPI FLASH - // case 22: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 23: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 24: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 25: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - #if !defined(BOARD_HAS_PSRAM) - // 26-32 = reserved for PSRAM - case 26: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - // case 27: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 28: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 29: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 30: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 31: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 32: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - #endif - case 33: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 34: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 35: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 36: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 37: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 38: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 39: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 40: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 41: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 42: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 43: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 44: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 45: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - // 46 input-only - // case 46: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - #endif // CONFIG_IDF_TARGET_ESP32S2 + // FastLED.addLeds(leds, layerP.ledsPerPin[pinIndex]); this works!!! (but this is static) - #if CONFIG_IDF_TARGET_ESP32C3 - case 0: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 1: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 2: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 3: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 4: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 5: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 6: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 7: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 8: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 9: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 10: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - // 11-17 reserved for SPI FLASH - // case 11: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 12: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 13: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 14: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 15: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 16: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 17: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - #if !ARDUINO_USB_CDC_ON_BOOT - // 18 + 19 = USB HWCDC. reserved for USB port when ARDUINO_USB_CDC_ON_BOOT=1 - case 18: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 19: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - #endif - // 20+21 = Serial RX+TX --> don't use for LEDS when serial-to-USB is needed - case 20: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 21: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - #endif // CONFIG_IDF_TARGET_ESP32S2 + startLed += layerP.ledsPerPin[pinIndex]; - #ifdef CONFIG_IDF_TARGET_ESP32S3 - case 0: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 1: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 2: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 3: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 4: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 5: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 6: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 7: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 8: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 9: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 10: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 11: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 12: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 13: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 14: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 15: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 16: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 17: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 18: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - #if !ARDUINO_USB_CDC_ON_BOOT - // 19 + 20 = USB-JTAG. Not recommended for other uses. - case 19: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 20: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - #endif - case 21: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - // // 22 to 32: not connected, or SPI FLASH - // case 22: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 23: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 24: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 25: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 26: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 27: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 28: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 29: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 30: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 31: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - // case 32: FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; break; - #if !defined(BOARD_HAS_PSRAM) - // 33 to 37: reserved if using _octal_ SPI Flash or _octal_ PSRAM - case 33: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 34: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 35: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 36: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 37: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - #endif - case 38: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 39: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 40: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 41: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 42: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - // 43+44 = Serial RX+TX --> don't use for LEDS when serial-to-USB is needed - case 43: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 44: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 45: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 46: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 47: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - case 48: - FastLED.addLeds(leds, startLed, nrOfLights).setCorrection(TypicalLEDStrip) RGBW_CALL; - break; - #endif // CONFIG_IDF_TARGET_ESP32S3 + CLEDController* pCur = CLEDController::head(); + EXT_LOGD(ML_TAG, "controller p:%p", pCur); + while (pCur) { + EXT_LOGD(ML_TAG, "controller %d", pCur->size()); + pCur = pCur->next(); + } - default: - EXT_LOGW(ML_TAG, "FastLEDPin assignment: pin not supported %d", pins[pinIndex]); - } // switch pins[pinIndex] + } // for pinIndex < nrOfPins - startLed += layerP.ledsPerPin[pinIndex]; + // Check which drivers are available + for (size_t i = 0; i < FastLED.getDriverCount(); i++) { + auto drivers = FastLED.getDriverInfos(); + auto& info = drivers[i]; + EXT_LOGD(ML_TAG, "Driver: %s, Priority: %d, Enabled: %s", info.name.c_str(), info.priority, info.enabled ? "yes" : "no"); + } - } // for pinIndex < nrOfPins + CLEDController* pCur = CLEDController::head(); + EXT_LOGD(ML_TAG, "controller p:%p", pCur); + while (pCur) { + EXT_LOGD(ML_TAG, "controller %d", pCur->size()); + pCur = pCur->next(); + } } FastLED.setMaxPowerInMilliWatts(1000 * layerP.maxPower); // 5v, 2000mA, to protect usb while developing diff --git a/src/MoonLight/Nodes/Drivers/D_Infrared.h b/src/MoonLight/Nodes/Drivers/D_Infrared.h index a856930b..c9b78dcd 100644 --- a/src/MoonLight/Nodes/Drivers/D_Infrared.h +++ b/src/MoonLight/Nodes/Drivers/D_Infrared.h @@ -367,7 +367,7 @@ class IRDriver : public Node { } else if (combined_code == codePaletteInc) { // palette increase newState["palette"] = MIN(state.data["palette"].as() + 1, 8 + 3 + 61); // 8 FastLED + 3 custom + 61 WLED palettes. to do: replace nr with max palette count } else if (combined_code == codePaletteDec) { // palette decrease - newState["palette"] = MAX(state.data["palette"].as() - 1, 0); + newState["palette"] = max(state.data["palette"].as() - 1, 0); } else if (combined_code == codePresetDec) { // next button - go to previous preset newState["preset"] = state.data["preset"]; newState["preset"]["action"] = "click"; diff --git a/src/MoonLight/Nodes/Effects/E_MoonLight.h b/src/MoonLight/Nodes/Effects/E_MoonLight.h index 277ab7c6..3285fb83 100644 --- a/src/MoonLight/Nodes/Effects/E_MoonLight.h +++ b/src/MoonLight/Nodes/Effects/E_MoonLight.h @@ -725,7 +725,7 @@ class FreqSawsEffect : public Node { } else { // Calculate decay amount based on time to reach zero if (decreaser > 0 && bandSpeed[band] > 0) { - uint32_t decayAmount = MAX((bandSpeed[band] * deltaMs) / (decreaser * 10UL), 1); // *10 to scale decreaser range 0-255 to 0-2550ms + uint32_t decayAmount = max((bandSpeed[band] * deltaMs) / (decreaser * 10UL), 1UL); // *10 to scale decreaser range 0-255 to 0-2550ms if (decayAmount >= bandSpeed[band]) { bandSpeed[band] = 0; } else { @@ -905,9 +905,9 @@ class RubiksCubeEffect : public Node { } void drawCube(VirtualLayer* layer) { - int sizeX = MAX(layer->size.x - 1, 1); - int sizeY = MAX(layer->size.y - 1, 1); - int sizeZ = MAX(layer->size.z - 1, 1); + int sizeX = max(layer->size.x - 1, 1); + int sizeY = max(layer->size.y - 1, 1); + int sizeZ = max(layer->size.z - 1, 1); // 3 Sided Cube Cheat add 1 to led size if "panels" missing. May affect different fixture types if (layer->layerDimension == _3D) { @@ -1610,7 +1610,7 @@ class PixelMapEffect : public Node { Coord3D pos = {0, 0, 0}; - void setup() override { addControl(pos, "pos", "coord3D", 0, MAX(MAX(layer->size.x, layer->size.x), layer->size.x) - 1); } + void setup() override { addControl(pos, "pos", "coord3D", 0, max(max(layer->size.x, layer->size.y), layer->size.z) - 1); } void loop() override { layer->fill_solid(CRGB::Black); @@ -1721,7 +1721,7 @@ class AudioRingsEffect : public RingEffect { } void loop() override { - uint8_t nrOfRings = MAX(layer->size.y, 2); // height of the layer, minimal 2 + uint8_t nrOfRings = max(layer->size.y, 2); // height of the layer, minimal 2 for (int i = 0; i < nrOfRings; i++) { uint8_t band = ::map(i, 0, nrOfRings - 1, 0, NUM_GEQ_CHANNELS - 1); diff --git a/src/MoonLight/Nodes/Effects/E_WLED.h b/src/MoonLight/Nodes/Effects/E_WLED.h index 7279ee2e..7163baca 100644 --- a/src/MoonLight/Nodes/Effects/E_WLED.h +++ b/src/MoonLight/Nodes/Effects/E_WLED.h @@ -72,7 +72,7 @@ class BouncingBallsEffect : public Node { // uint32_t color = SEGCOLOR(0); // if (layerP.palette) { - // color = layer->color_wheel(i*(256/MAX(numBalls, 8))); + // color = layer->color_wheel(i*(256/max(numBalls, 8))); // } // else if (hasCol2) { // color = SEGCOLOR(i % NUM_COLORS); @@ -136,7 +136,7 @@ class BlurzEffect : public Node { if (freqMap) { // FreqMap mode : blob location by major frequency int freqLocn; - unsigned maxLen = (geqScanner) ? MAX(1, layer->size.x * layer->size.y * layer->size.z - 16) : layer->size.x * layer->size.y * layer->size.z; // usable segment length - leave 16 pixels when embedding "GEQ scan" + unsigned maxLen = (geqScanner) ? max(1, layer->size.x * layer->size.y * layer->size.z - 16) : layer->size.x * layer->size.y * layer->size.z; // usable segment length - leave 16 pixels when embedding "GEQ scan" freqLocn = roundf((log10f((float)sharedData.majorPeak) - 1.78f) * float(maxLen) / (MAX_FREQ_LOG10 - 1.78f)); // log10 frequency range is from 1.78 to 3.71. Let's scale to layer->size.x * layer->size.y * layer->size.z. // WLEDMM proper rounding if (freqLocn < 1) freqLocn = 0; // avoid underflow segLoc = (geqScanner) ? freqLocn + freqBand : freqLocn; @@ -145,7 +145,7 @@ class BlurzEffect : public Node { int bandStart = roundf(bandWidth * freqBand); segLoc = bandStart + random16(max(1, int(bandWidth))); } - segLoc = MAX(nrOfLights_t(0), MIN(nrOfLights_t(layer->size.x * layer->size.y * layer->size.z - 1), segLoc)); // fix overflows + segLoc = max(nrOfLights_t(0), MIN(nrOfLights_t(layer->size.x * layer->size.y * layer->size.z - 1), segLoc)); // fix overflows if (layer->size.x * layer->size.y * layer->size.z < 2) segLoc = 0; // WLEDMM just to be sure unsigned pixColor = (2 * sharedData.bands[freqBand] * 240) / max(1, layer->size.x * layer->size.y * layer->size.z - 1); // WLEDMM avoid uint8 overflow, and preserve pixel parameters for redraw @@ -1819,10 +1819,10 @@ class DripEffect : public Node { drops[x][j].col = sourcedrop; // brightness drops[x][j].colIndex = forming; // drop state CRGB c = ColorFromPalette(layerP.palette, random8()); // random color by MoonModules, hacked into velX of type float - memcpy(&drops[x][j].velX, &c, sizeof(CRGB)); + memcpy(&drops[x][j].velX, (void*)&c, sizeof(CRGB)); } CRGB dropColor; - memcpy(&dropColor, &drops[x][j].velX, sizeof(CRGB)); // hacked back + memcpy((void*)&dropColor, &drops[x][j].velX, sizeof(CRGB)); // hacked back layer->setRGB(Coord3D(x, 0), blend(CRGB::Black, dropColor, sourcedrop)); // water source if (drops[x][j].colIndex == forming) { diff --git a/src/MoonLight/Nodes/Layouts/L_MoonLight.h b/src/MoonLight/Nodes/Layouts/L_MoonLight.h index 52c25cf9..0f9bef5f 100644 --- a/src/MoonLight/Nodes/Layouts/L_MoonLight.h +++ b/src/MoonLight/Nodes/Layouts/L_MoonLight.h @@ -539,10 +539,8 @@ class Rings16Layout : public Node { static const char* tags() { return "πŸš₯"; } uint8_t scale = 1; - - void setup() override { - addControl(scale, "scale", "slider", 1, 10); - } + + void setup() override { addControl(scale, "scale", "slider", 1, 10); } bool hasOnLayout() const override { return true; } @@ -658,7 +656,7 @@ class CarLightsLayout : public Node { uint8_t leftMargin = 9; // inner light left - ringLayout.ringCenter = {leftMargin + 11, 10, 0}; + ringLayout.ringCenter = {leftMargin + 11, 8, 0}; ringLayout.nrOfLEDs = 1; ringLayout.onLayout(); ringLayout.nrOfLEDs = 8; @@ -682,13 +680,13 @@ class CarLightsLayout : public Node { ringLayout.onLayout(); ringLayout.nrOfLEDs = 24; ringLayout.onLayout(); - ringLayout.nrOfLEDs = 34; + ringLayout.nrOfLEDs = 32; ringLayout.onLayout(); nextPin(); // inner light right - ringLayout.ringCenter = {leftMargin + 25, 10, 0}; + ringLayout.ringCenter = {leftMargin + 25, 8, 0}; ringLayout.nrOfLEDs = 1; ringLayout.onLayout(); ringLayout.nrOfLEDs = 8; @@ -712,7 +710,7 @@ class CarLightsLayout : public Node { ringLayout.onLayout(); ringLayout.nrOfLEDs = 24; ringLayout.onLayout(); - ringLayout.nrOfLEDs = 34; + ringLayout.nrOfLEDs = 32; ringLayout.onLayout(); nextPin(); diff --git a/src/MoonLight/Nodes/Modifiers/M_MoonLight.h b/src/MoonLight/Nodes/Modifiers/M_MoonLight.h index 8a5a060f..90ac44c4 100644 --- a/src/MoonLight/Nodes/Modifiers/M_MoonLight.h +++ b/src/MoonLight/Nodes/Modifiers/M_MoonLight.h @@ -294,7 +294,7 @@ class RotateModifier : public Node { void modifySize() override { if (expand) { - uint8_t size = MAX(layer->size.x, MAX(layer->size.y, layer->size.z)); + uint8_t size = max(layer->size.x, max(layer->size.y, layer->size.z)); size = sqrt(size * size * 2) + 1; Coord3D offset = Coord3D((size - layer->size.x) / 2, (size - layer->size.y) / 2, 0); @@ -310,7 +310,7 @@ class RotateModifier : public Node { void modifyPosition(Coord3D& position) override { if (expand) { - int size = MAX(modifierSize.x, MAX(modifierSize.y, modifierSize.z)); + int size = max(modifierSize.x, max(modifierSize.y, modifierSize.z)); size = sqrt(size * size * 2) + 1; Coord3D offset = Coord3D((size - modifierSize.x) / 2, (size - modifierSize.y) / 2, 0); position += offset;