adafruit / Adafruit_DotStar

GNU General Public License v3.0
97 stars 58 forks source link

hardcode tables, but give Python to regenerate them. #25

Closed BillyDonahue closed 6 years ago

BillyDonahue commented 6 years ago

Currently the _sinTable and _gammaTable are generated by sophisticated preprocessor logic, and rely on sin and pow being evaluated at compile time. The resulting code is hard to follow and there are potential portability problems.

In Issue #23, there's a complaint that M_PI isn't defined on some stdlibs.

It's also not unlikely that some compilers won't have constexpr support for pow and sin, or the nonstandard __COUNTER__, so it feels risky to depend on them for PROGMEM table initialization, which must be initialized with constant expressions, and I think will only build with optimizer flag -O2.

I've verified that these tables are identical to those generated by the existing preprocessor code. To keep the tables maintainable, I provide a comment with the Python snippet to regenerate them.

PaintYourDragon commented 6 years ago

Yeah. I was being too "1337" for my own good there. Gonna merge this in the NeoPixel lib as well. Thank you!