Sending all(0) with each refresh cycle is essentially marking all four quardants (4x64) as dirty which means that the next call to refresh will send all 256 leds values across the serial bus:
…the implementation of the all function - it is looping over every position in the buffer and setting the led value:
…the implementation of the refresh function:
The expensive part is the result of calling all(0) and refresh() inside of a tight loop because it is forcing the entire 256 leds grid state to be updated (redundantly) for every position in quick succession thus overwhelming the grid’s usb bus. If the goal is to essentially draw a single “pixel” moving over the grid I fairly confident you’ll have much more success:
- keeping track of the previously enabled led and turning it off specifically to avoid dirtying every grid quad
- using a metro or the new clock system to rate limit calls to
refresh() to something under 60Hz (which is about the fastest I’ve seen)
EDIT: The 4th study shows how many/most scripts work by redrawing grid state on demand or periodically (from a metro) when the leds state is known to need updating.