Global pre-beforeRender() and pre-render() hooks?

As an alternative/complement to some notion of “#includes”, I would find a global pre-beforeRender() and pre-render() hook useful.

To recap my use-case, I have hardware buttons to trigger sequencerNext() and sequencerPrev() functions. Without any kind of pre-beforeRender() hook I’ve had to duplicate the button reading and debounce logic into every single pattern. This is obviously not the way you want to do it. It’s tedious and error-prone, and if I want to make a change to that code I’ve got to duplicate the change back into every single pattern in the playlist.

If I could simply implement a preBeforeRender() (and/or postBeforeRender()) function that would run pre- and -post the beforeRender() of every pattern, I’d have a single place to put that kind of code. I don’t have a direct use-case for preRender() (and I guess preRender2D() and preRender3D()) but I would guess they could be useful to someone, for example for pre-processing sensor input.


I thought of uses for this option too. I had a project I was working on that had similar requirements. It was LED Whip antennas on a side-by-side with rock lights and other elements. When the turn signals were used, the whip on the appropriate side would stop the pattern and flash orange. Similar effect for braking. Without globals, these trigger codes needed to be each pattern. Making a global option would save development time and space on the device. Unfortunately, my friend sold his side-by-side before I got to finish the idea.

I’d also add a +1 for this – for Burning Man this year, I adopted a palette switcher functionality across many different patterns across many different PixelBlaze, and version control on it when a bug was found was… time consuming. See Detailed Beginner Tutorial for Making Wearables with PixelBlaze for more details on that.

1 Like