Skip to content

Commit 1988199

Browse files
CopilotDedeHai
andcommitted
Fix parallel I2S DMA buffer estimation (8x multiplier)
Fixed critical bug in I2S memory estimation where parallel I2S wasn't accounting for 8x larger DMA buffer: **Problem:** - Parallel I2S uses 8 channels simultaneously (I2S0-I2S7) - Each channel requires its own DMA buffer - Total DMA buffer is 8x larger than single I2S mode - Both UI and firmware were underestimating memory by 8x **Changes:** 1. **FX_fcn.cpp (firmware estimation):** - Added 8x multiplier when `hasParallelOutput()` is true - Applied after calculating base i2sCommonSize - Only affects parallel I2S mode, single I2S unchanged 2. **settings_leds.htm (UI estimation):** - Added check for parallel I2S checkbox (`d.Sf.PI.checked`) - Multiplies DMA buffer size by 8 when parallel mode enabled - Provides accurate memory estimate to users before saving **Example Impact:** - Single I2S with 300 LEDs: ~2.7KB DMA buffer - Parallel I2S with 300 LEDs: ~21.6KB DMA buffer (8x) - Without fix: UI showed 2.7KB, firmware allocated 21.6KB → confusion - With fix: Both correctly show and allocate 21.6KB **Technical Details:** - Parallel I2S (X8 methods) drive 8 output pins simultaneously - Each pin needs independent DMA buffer for timing - NeoPixelBus library allocates 8 separate buffers internally - Memory estimation must match actual allocation **Testing:** - ✅ Web UI built successfully - ✅ All 16 npm tests passed - ✅ No compilation errors - ✅ Accurate memory estimation for both modes Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com>
1 parent 8da802a commit 1988199

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

wled00/FX_fcn.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,8 @@ void WS2812FX::finalizeInit() {
12341234
constexpr unsigned stepFactor = 3; // 3 step cadence (3 bits per pixel bit)
12351235
#endif
12361236
unsigned i2sCommonSize = stepFactor * bus.count * (3*Bus::hasRGB(bus.type)+Bus::hasWhite(bus.type)+Bus::hasCCT(bus.type)) * (Bus::is16bit(bus.type)+1);
1237+
// Parallel I2S uses 8 channels, requiring 8x the DMA buffer size
1238+
if (BusManager::hasParallelOutput()) i2sCommonSize *= 8;
12371239
if (i2sCommonSize > maxI2S) maxI2S = i2sCommonSize;
12381240
}
12391241
#endif

wled00/data/settings_leds.htm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@
240240
mul = 2; // RMT uses double buffer
241241
} else if (enabledI2S && toNum(n) < 8) { // I2S/LCD uses extra DMA buffer
242242
dbl = len * ch * 3; // DMA buffer for I2S/LCD (TODO: only the bus with largest LED count should be used)
243+
// Parallel I2S uses 8 channels, requiring 8x the DMA buffer size
244+
if (d.Sf.PI && d.Sf.PI.checked) dbl *= 8;
243245
}
244246
}
245247
return len * ch * mul + dbl + pbfr;

0 commit comments

Comments
 (0)