Add parallel DMA start for driving all strips at once.

Split DMA start into prepare/trigger so all eight strips can be armed
and then kicked off together, optionally from a flash address. Also drop
a stray self.dma.start_transfer call in the WS2812B constructor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-11-08 22:20:48 +13:00
1 parent bf0429c505
commit 47f4a6663b
3 files changed
+48 -5

No files matched your search

+10 -1
View File
@@ -28,13 +28,22 @@ class WS2812B:
self.brightness = brightness
self.invert = invert
self.pio_dma = dma.PIO_DMA_Transfer(state_machine+4, state_machine, 8, num_leds*3)
self.dma.start_transfer(self.ar)
def show(self, array=None, offset=0):
if array is None:
array = self.ar
self.pio_dma.start_transfer(array, offset)
def prepare_show(self, buffer_or_address, offset=0):
"""Set DMA read address only (buffer or int flash address). Use with trigger() for parallel start."""
if buffer_or_address is None:
buffer_or_address = self.ar
self.pio_dma.prepare_transfer(buffer_or_address, offset)
def trigger(self):
"""Start DMA for this strip (use after prepare_show on all strips for parallel drive)."""
self.pio_dma.trigger()
def set(self, i, color):
self.ar[i*3] = int(color[1]*self.brightness)