Skip to content

Commit 6b8287e

Browse files
Merge pull request #53 from adafruit/pb-hwspi
Add support for non-default SPI devices
2 parents e87a9cb + 5e802a6 commit 6b8287e

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

Adafruit_DotStar.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,20 @@
4444
/*!
4545
@brief DotStar constructor for hardware SPI. Must be connected to
4646
MOSI, SCK pins.
47-
@param n Number of DotStars in strand.
48-
@param o Pixel type -- one of the DOTSTAR_* constants defined in
49-
Adafruit_DotStar.h, for example DOTSTAR_BRG for DotStars
50-
expecting color bytes expressed in blue, red, green order
51-
per pixel. Default if unspecified is DOTSTAR_BRG.
47+
@param n Number of DotStars in strand.
48+
@param o Pixel type -- one of the DOTSTAR_* constants defined in
49+
Adafruit_DotStar.h, for example DOTSTAR_BRG for DotStars
50+
expecting color bytes expressed in blue, red, green order
51+
per pixel. Default if unspecified is DOTSTAR_BRG.
52+
@param spi Pointer to hardware SPIClass object (default is primary
53+
SPI device 'SPI' if defined, else MUST pass in device).
5254
@return Adafruit_DotStar object. Call the begin() function before use.
5355
*/
54-
Adafruit_DotStar::Adafruit_DotStar(uint16_t n, uint8_t o)
56+
Adafruit_DotStar::Adafruit_DotStar(uint16_t n, uint8_t o, SPIClass *spi)
5557
: numLEDs(n), brightness(0), pixels(NULL), rOffset(o & 3),
5658
gOffset((o >> 2) & 3), bOffset((o >> 4) & 3) {
57-
spi_dev = new Adafruit_SPIDevice(-1, 8000000);
59+
spi_dev = new Adafruit_SPIDevice(-1, 8000000, SPI_BITORDER_MSBFIRST,
60+
SPI_MODE0, spi);
5861
updateLength(n);
5962
}
6063

Adafruit_DotStar.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ static const uint8_t PROGMEM _DotStarGammaTable[256] = {
101101
class Adafruit_DotStar {
102102

103103
public:
104-
Adafruit_DotStar(uint16_t n, uint8_t o = DOTSTAR_BRG);
104+
#if defined SPI // Is a default hardware SPI device defined for this board?
105+
Adafruit_DotStar(uint16_t n, uint8_t o = DOTSTAR_BRG, SPIClass *spi = &SPI);
106+
#else
107+
Adafruit_DotStar(uint16_t n, uint8_t o = DOTSTAR_BRG, SPIClass *spi = NULL);
108+
#endif
105109
Adafruit_DotStar(uint16_t n, uint8_t d, uint8_t c, uint8_t o = DOTSTAR_BRG);
106110
~Adafruit_DotStar(void);
107111

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit DotStar
2-
version=1.2.1
2+
version=1.2.2
33
author=Adafruit
44
maintainer=Adafruit <info@adafruit.com>
55
sentence=Adafruit DotStar LED Library

0 commit comments

Comments
 (0)