This is required for MicroPython error text compression which is
going to be enabled by default for RP2 builds.
We have a lot of error messages, so the potential flash gain here
is worth the effort of making this work.
When no buffer was supplied it would fall upon the class to call "new" and allocate within C/C++'s (very small) heap.
Ensure a MicroPython managed buffer (allocated from gc_heap) is always supplied to the APA102/WS2812 classes.
Documentation for set_brightness function was under WS2812 but text referred to APA102, and set_brightness is not supported on WS2812. I've moved the paragraph to the end of the APA102, verbatim.
MicroPython has changed MP_REGISTER_MODULE to use only *two* args and now runs the preprocessing stage on files before running makemoduledefs.py.
This change avoids the build exploding, since the new regex matches the last two args as a single argument and generates a malformed module defs include.
The pattern here exploits the fact that 1.18 and below do not preprocess files, so *both* MP_REGISTER_MODULE lines are included in the source, but *only* the three arg version is matched by regex.
In >1.18 the files will be processed and the three arg version removed before makemoduledefs.py processes it.
A bytearray allocated in Python would point to uninitialised bytes, missing the SOF byte and brightness for APA102 pixels.
Add a blunt loop over the MicroPython buffer, calling "brightness" for each RGB element to ensure the SOF byte and brightness are initialized.