sapphireos / chromatron

36 stars 4 forks source link

Support more than 300 pixels #34

Open bogdanr opened 4 years ago

bogdanr commented 4 years ago

It would be nice if we could support up to 2000 pixels. Where does this limitation come from?

readmodifywrite commented 4 years ago

Short answer: it's a limitation between the memory for the fader engine and the cycles available to the scripting engine.

Longer answer: Chromatron doesn't render pixels the same way FastLED/Adafruit do. The native graphics are 16 bit HSV (so that's 6 bytes per pixel right there) with two fader engines per-pixel (one for hue/saturation, another for brightness), then we do an RGB/RGBW conversion. It's more memory intensive, but it ensures high color/brightness resolution and makes it trivial to do timed fades in the scripting engine.

More forward looking answer: I am planning to port this to the ESP32 over the summer. 2000+ pixels is probably doable on that.

bogdanr commented 4 years ago

The native graphics are 16 bit HSV (so that's 6 bytes per pixel right there) with two fader engines per-pixel (one for hue/saturation, another for brightness), then we do an RGB/RGBW conversion. It's more memory intensive, but it ensures high color/brightness resolution and makes it trivial to do timed fades in the scripting engine.

Would it be noticeable in practice if we only had 8 bit HSV?

readmodifywrite commented 4 years ago

It's noticeable - but it depends on what kinds of look you're going for. There were already a lot of 8 bit solutions out there, I wanted to start with a higher-res solution.

Personally - I think 8 bit hue is entirely insufficient - you can see visible stepping on larger arrays doing a rainbow pattern, and if you run a constrained palette (say, just sweep blues across 15 feet of strip) it's even more noticeable since now you have more pixels than you do distinct color points.

The other thing 16 bits does is it makes it easier to do longer programmed fades. The fader engine runs at 50 Hz and the minimum is obviously 1 step per tick, so that's 50 ticks per second. With 8 bits, you are limited to a 5 second fade time.

It also helps with mapping to curves. Brightness runs on a curve before mapping to the actual RGB values. 16 bits give us a lot more resolution in that curve - the effective post-curve resolution is less than 16 bits but still more than 8.

Basically - the idea is that the ultimate limiting factor is never in the HSV space, it's in the 8 bit RGB space that the LEDs themselves are limited to.

readmodifywrite commented 4 years ago

This is all good feedback though. I have part of my ESP8266 port running, but it's slow going at the moment. Realistically t'll probably only be 128 or so - the original Chromatron hardware has a second microcontroller to help get to 300. So the path to 1000+ will be the ESP32. It's still a couple months out though.