Hi all,
I’ve yet again embarked on a rather big project and could use your help/guidance.
I have 96 touch sensors layer on a 8x12 grid. Around each sensor will be a 12 or 16-led strip(ws2812b most probably). What I want to do, is for each strip to fade in, stay on for 2 seconds, then fade out every time the corresponding sensor is touched.
Here’s how I’m trying to implement this:
An ESP32 will take care of all sensors via 7 MCP23017 expansion boards. I’ll take the interrupt route, but if I see the ESP32 gets overwhelmed, I’ll put a second one and split the load.
The ESP32 will then send all sensor data to Pixelblaze via Serial, piggy-backing on the sensor board stream. I’m already doing something similar on a different project(way less inputs though) and it works kind of successfully.
Here’s the question.
It’s too many inputs. I will use all bits of the stream, 2 inputs per bit, then separate them in PB, and have PB do the following:
Keep all LEDs black, turn on only the 12 of the corresponding input for the set time w/ fade in-out. This can be a few inputs together(but hardly simultaneously) and pretty much never more than 4-6.
I’m pretty bad at coding, and the only way I can think of doing it looks like this in pseudo code:
Initialize the sensor board array
Take each bit, do the math to separate the inputs. Assign a variable for each input. Copy paste 96 times.
Have a few animations, choose which to use depending on a switch position. Animations will be global - a rainbow, 1 static color per line of the grid(12 in total), or something equally simple.
Have an endless code in render function with if statements like so:
If sensor 1 changed state(LOW to HIGH), fade in LEDs 0-11, stay on for 2 seconds, fade out
If sensor 2 changed state(LOW to HIGH), fade in LEDs 12-23, stay on for 2 seconds, fade out
And so on.
I’m doing this exact thing in another project, and frame rate drops dramatically with every new if statement I bring in. Given the leds are equally divided(12 times 96), is there a way to do this in an array, or something outside render function? Is there also a way to not have to declare so many variables when picking up the bits from the sensor board stream, which I’m sure drops the frame rate even further?
Lastly, as I’m having close to 1200 leds connected, the expansion board is a given, right?
Thanks!