Also, I ran the code you posted, with the 500 item data set from a few messages up. On my PB2, with a 16x16 WS2812 matrix (256 pixels), it runs at a fairly constant 87 fps. This is about what I’d expect. Is yours still running slowly?
Edit: Oh – just realized, you probably need to change the LED type in your PB’s settings to “Buffered (x2 rate) WS2812/Neopixel”. This greatly helps performance as the number of pixels goes up!
@jeff This one is straight-forward. Very simple. Very nice. In this case the array is just a container for data. Thanks.
Quote=“jeff, post:13, topic:1055”]
Populating an array’s values manually
Let’s just work with the first 5 of your pixels for this one.
export var data = array(5) // Set up a 5-bin container
[/quote]
On the other hand,
gave me a “fract” unrecognized error. (Displays a nice rainbow, tho) so I modified the code - But it does not work…
var brightnesses = array(pixelCount)
var saturation = array(pixelCount)
export var brightnesses // Watcher
export var saturation // Watcher
for (i = 0; i < pixelCount; i++) {
if (sqrt((i) -floor (i)) == 0) { // "if (frac(sqrt(i)) == 0) { > unrecognized,
// so re-wrote. But it does not work.
brightnesses[i] = 0.2
saturation[i] = 1
}
else {
brightnesses[i] = 0
saturation[i] = 0
}
}
export function render(index) {
h = 0 // Red for easy diagnostics - index/pixelCount = Rainbow
s = saturation[index]
v = brightnesses[index]
hsv(h, s, v)
}
Getting there with arrays. They are a many splendored thing!
This sped things up to about 90 FPS.
But then, why and when to use buffering and why not use it always. Perhaps just as you say, “improves performance as the number of pixels goes up.”
Side Note: I had messed with data speed but that just blanked everything! Didn’t think to change the pixel type.
Yes, you can feed in as much data as you like through the websockets API. Take a look at this thread for an example that sends about 1k of data per frame at a rate of 20fps :
Cool! Tiny is good. I’ve got two pretty long strings of basically parallel data to work with so I’m running up against what I understand is a 20,000 character limit in PB-code space. Not sure if this is carried over to the v3. Thus looking at running it in through a websocket.