LOOP2.md
Determine the best strategy for fixed-point arithmetic in FastLED, driven by the concrete use case in src/fl/fx/2d/chasing_spirals.hpp and the current implementation in src/fl/fixed_point/q16.hpp.
FastLED currently has a hand-rolled fl::Q16 struct (~140 lines) providing:
from_float, mul, divsincos (wrapping FastLED's sin32/cos32)pnoise2d with Q8.24 internalsThe Q16 code is tightly optimized for the Chasing_Spirals animation (3.8x faster than float on x86, critical for ESP32). The question is whether to keep rolling our own, adopt a standard-track design, or pull in a third-party library.
chasing_spirals.hpp needs rewriting?fl/fixed_point/ (status quo)Research file: research_option_a_custom.md
Tasks:
q16.hpp for correctness edge cases (overflow in mul, div by zero, negative floor_frac).Q16 vs Q16n16 vs Fixed16_16 vs FixedPoint<16,16> template.fl/stl/fixed_point.hResearch file: research_option_b_p0037_cnl.md
Tasks:
scaled_integer can express mixed-precision (Q16.16 input → Q8.24 intermediate → Q16.16 output).fl::fixed_point<Rep, Exponent> is feasible.fl/stl/ convention: does a failed proposal belong in fl/stl/? Or is fl/fixed_point/ more honest?Research file: research_option_c_fpm.md
Tasks:
fpm::fixed<int32_t, int64_t, 16> replace fl::Q16? Does it support custom fractional bits?Chasing_Spirals_Q31 inner loop using fpm types and compare performance.Q16::mul() — which is clearer for the codebase?third_party/fpm/, what wrapping is needed?Research file: research_option_d_libfixmath.md
Tasks:
libfixmath by flatmush).fix16_t). Compare API to our Q16.fix16_sin, fix16_cos. Compare precision and speed to our sin32-based approach.fl::FixedPoint<IntBits, FracBits>)Research file: research_option_e_template.md
Tasks:
fl::FixedPoint<int IntBits, int FracBits> that auto-selects int16_t, int32_t, or int64_t as backing type.Q16 (no abstraction penalty).fl/fixed_point/ as a project-specific utility.research_option_*.md file.FINAL_RECOMMENDATION.md with:
fl::Q16