From a441ee81b678daf25528db7408f2dc8bc59106fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Sep 2025 04:52:35 +0000 Subject: [PATCH] Implement bus creation fallback when memory limit exceeded Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com> --- wled00/FX_fcn.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 2f8d5515f..3be3e533d 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -13,6 +13,10 @@ #include "FXparticleSystem.h" // TODO: better define the required function (mem service) in FX.h? #include "palettes.h" +#ifndef DEFAULT_LED_COLOR_ORDER + #define DEFAULT_LED_COLOR_ORDER COL_ORDER_GRB //default to GRB +#endif + /* Custom per-LED mapping has moved! @@ -1182,6 +1186,14 @@ void WS2812FX::finalizeInit() { busConfigs.clear(); busConfigs.shrink_to_fit(); + // ensure at least one bus exists as fallback to prevent UI issues and provide basic LED output + if (BusManager::getNumBusses() == 0) { + DEBUG_PRINTLN(F("No buses created due to memory limits! Creating fallback bus with default LED count.")); + uint8_t defPin[1] = {DEFAULT_LED_PIN}; + BusConfig defCfg = BusConfig(DEFAULT_LED_TYPE, defPin, 0, DEFAULT_LED_COUNT, DEFAULT_LED_COLOR_ORDER, false, 0, RGBW_MODE_MANUAL_ONLY, 0); + BusManager::add(defCfg); + } + _length = 0; for (size_t i=0; i