For sure. I agree that it's definitely a better and more robust approach! Was mainly just providing the other links as an FYI for other work in this area.OutoftheBOTS_ wrote: ↑Tue Apr 28, 2020 6:12 amFrom the googling that I have done this seems to be the most common method for creating neopixle timings. basically work out how many NOPs are needed to get correct timings. Although it gets the job done it isn't very flexible to be able change the timings or running on different CPU freq MCUs. You can see mine uses a timer to create PWM on a pin but an interrupt changes the duty and freq at the end of each cycle to update the next cycle to be what ever the timing are needed for next cycle. The advantage is that it is very easy to adapt from different MCU's and different timing LEDs. See this in my video from 9:50 to 10:50 https://www.youtube.com/watch?v=4NSNO7NJv5c&t=2s
One difficulty with timers though is that now the API becomes a bit more complicated because it doesn't just work on any pin. So coming up with a Python API might have some challenges, but definitely not impossible. This is the same reason why defining a machine.PWM API for stm32 is tricky.
FWIW, I tested both the cycle counter version and instruction counter versions across a wide range of frequencies (although the F0 version needs some work).