adafruit / Adafruit_DotStar

GNU General Public License v3.0
97 stars 58 forks source link

Added support for passing in a pointer to a SERCOM module #20

Closed yngndrw closed 2 years ago

yngndrw commented 7 years ago

Allows the SERCOM module to be passed in, rather than always assuming SPI. Tested with an Adafruit Feather M0 Adalogger. See: Adafruit: Using ATSAMD21 SERCOM for more SPI, I2C and Serial ports

Example usage:

#include <Adafruit_DotStar.h>
#include "wiring_private.h"

SPIClass SPI1(&sercom1, 12, 13, 11, SPI_PAD_0_SCK_1, SERCOM_RX_PAD_3);

Adafruit_DotStar dotStarStrip = Adafruit_DotStar(NUMBER_OF_PIXELS, &SPI1, DOTSTAR_BGR);

void setup()
{
    dotStarStrip.begin();
    dotStarStrip.setBrightness(32);
    dotStarStrip.show();

    pinPeripheral(11, PIO_SERCOM);
    pinPeripheral(12, PIO_SERCOM);
    pinPeripheral(13, PIO_SERCOM);
}

void loop()
{
    dotStarStrip.setPixelColor(0, 255, 0, 0);
    dotStarStrip.show();
}
magicmonkey commented 2 years ago

Hi, just wanted to say thanks for this. I patched it in to a setup on my Feather M0 WiFi so I could use a DotStar strip and the onboard wifi module at the same time, using hardware SPI for them both. Incredibly useful! It would be nice if the main library had the support built in.

caternuson commented 2 years ago

Thanks for this PR. Closing this since it's based on older code. Opened a new issue here: https://github.com/adafruit/Adafruit_DotStar/issues/48