Ws2812 DMA library [RESOLVED]

Sorry, to kick this up. But I had some findings.

@mtnscott SPI won’t work, because I can’t set the timing precise (see: Set spi speed to 2Mhz precise)

I found an WS2812 DMA implementation for the Photon from @jvanier named autopixel. It’s a work in progress but it’s actually the first working code I’ve found that seems to output something with DMA. It works on pin A7 (there is also an earlier commit that I’ve successfully tested on pin D3). D3 works perfectly on the internet button. Of course this library needs some work for more pixels, but it’s a starter that shows at least working activity on a pin that turns my neopixels on.

I also tried the Speaker library that uses the DAC (https://github.com/monkbroc/particle-speaker), which outputs also in a good way. I can flash a LED with it in a pattern (changed the frequence to 1 Hz) although the speed of flashing seems still to be dictated by the buffer length (while I want each byte/halfword to have the same time span).

The combination of Timers, DMA channels, Streams, peripherals is still black magic to me. I’ve check the manual, but I think without a proper foundation in embedded programming I don’t come far.

For DMX I just need to set a pin high or low. So they have both the same length (4us). In all this WS2811 examples the pulse width seems to be modified by a byte array with “compare” values. They probably influence the HIGH and LOW time. But what do the values mean, how do I get to the values I need. Or is there a way to completely bypass the PWM (how) and just send a bytestream directly (just like on SPI, but then with more control on the timing)?