TinyPico with the "DotStar" (APA102)

Posted on
  • Picked up a couple of the TinyPICO V2 (USB-C variant) boards and, of course, the first thing I did was flashed the ESP32 version of Espruino onto it. I did try the micropython, but I found the wifi to be a bit flaky, whereas I had no problem in Espruino.

    It does show one error on boot though:

    E (542) psram: ESP32PICOD4  do not support psram yet
    E (542) spiram: SPI RAM enabled but initialization failed. Bailing out.
    WARNING: check error not implemented yet:0
    

    ... but that hasn't bothered me so far. And I'm aware that the bluetooth support isn't there yet, but again, that's not something I plan to use it for yet.

    What did bother me was the onboard "LED" (the DotStar, or APA102). Couldn't get that working at all, and since I've never done anything with SPI, I presumed it was me.

    Anyway, I fixed it, then I lost the settings to fix it - so I thought I'd document it here in case anyone else has the same problem.

    Turns out, the thing I was missing from the documentation is that the following is required to activate the LED:

    digitalWrite(D9, 0); // set this to 1 to cut power to the LED completely
    digitalWrite(D13, 0); // Not sure what this is for, but doesn't like it high
    SPI1.setup({mosi:D2, sck:D12});
    

    The D13 confused me. The micropython codebase has a comment that I relied on for far too long - if you look at that code for anything, ignore the suggested pins - they are completely false, and I suspect correspond to a pre-production version of the tinypico.

    Also note that in the micropython version, MISO is set to a non-dotstar-specific SPI pin. I believe this is for chaining, so that you can talk to 2 or more of these efficiently, but not something I needed to do.

    Once that's set up, you can just write to it - for example:

    SPI1.write([
      0,0,0,0, // header, probably not necessary, useful for chaining
      0xE0 | 5, // brightness, replace 5 with anything from 1 - 31
      10, 127, 255, // blue, green, red
      0,0,0,0 // footer - some of this is needed I think
    ])
    

    (Of course, you SHOULD use a Uint8Array... and be a bit more consistent with whether you're using hex or decimals... but for testing it out, this works beautifully)

    Hope that helps someone (and if not, it will probably help me when I forget where I saved my current code again!)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

TinyPico with the "DotStar" (APA102)

Posted by Avatar for undecided @undecided

Actions