Shop OBEX P1 Docs P2 Docs Learn Events
Cogless Pixel Drivers for P2 — Parallax Forums

Cogless Pixel Drivers for P2

JonnyMacJonnyMac Posts: 8,805
edited 2023-10-25 16:57 in PASM2/Spin2 (P2)

There are many applications that use just a few smart pixels, and in those cases we can save a cog when using the P2. Attached are drivers for 1-wire (WS2812b, et al.) and 2-wire (APA102c) pixels. Both use inline PASM, and the 2-wire driver uses Smart Pin SPI to generate the output.

These drivers work like Schmarschmino drivers: you change the pixels (with object methods or directly in the app), then call the show() method to refresh the pixel string. Some 1-wire pixels swap the red and green bytes in a color, so there is a swap flag as part of the show() method in that driver.

These are minimalist drivers -- not fancy, but they work well and don't need a cog. I'm using them in a couple of work projects.

Updated: 25 OCT 2023


  • JonnyMacJonnyMac Posts: 8,805
    edited 2023-10-25 16:50

    I didn't like that I was passing the swap flag in the show() method of the single-wire driver. After a great dinner with my friend, Rick Galinson (Mandalorian, Book of Boba Fett, Ahsoka, lots of movies and commercials) last night, and some much needed rest, I found a way to fix that. Of course, it seems obvious now.

    If you downloaded these drivers before I put the "Updated" notice in post #1, please replace them with what's posted now. The swap flag is passed in the startx() method and, so the show() method doesn't need that parameter. I did some formatting clean-ups, and did my best to make both drivers very consistent with each other. Code written for one driver is easier to migrate to the other now (just start() or startx() method change).

  • RaymanRayman Posts: 13,512

    This is very useful for me, thanks.

Sign In or Register to comment.