Getting AdaFruit DOTStar LED matrix working over SPI

Status
Not open for further replies.

roach374

Member
I'm trying to get this LED matrix working over SPI on Teensy 4 (using pins 11 and 13 for DIN and CLK), but it seems like nothing at all is happening.

One weird thing: If I don't #include <Wire.h> explicitly, the program doesn't compile (the dependency isn't loaded transitively, but it is loaded explicitly. Weird).

Here's the minimum repro code. When I run it, literally nothing happens:

Code:
#include <Wire.h>
#include <Adafruit_DotStar.h>

#define NUMPIXELS 64  

Adafruit_DotStar strip(NUMPIXELS, PIN_SPI_MOSI, PIN_SPI_SCK);

void setup() {
    strip.begin();
    strip.clear();
    strip.setBrightness(128);
    strip.setPixelColor(1, 32, 0, 0); // turn on just one pixel, at low-brightness (since I'm powering over USB)
    strip.show();
}

void loop() {
    // do nothing.
}

Has anyone managed to get these DotStar strips working on Teensy4 with hardware SPI?
 
Well, not really a strip but yes, I've got the APA102 [what DotStars are] to work on the T4 using this code:
Code:
#include <FastLED.h>
#define NUM_LEDS    1
#define DATA_PIN   11
#define CLOCK_PIN  13

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, BGR>(leds, NUM_LEDS);  // BGR ordering is typical
  FastLED.setBrightness(255);
}

void loop() {
  for (int i = 0; i < 255; i++) {
    fill_rainbow( leds, NUM_LEDS, i, 255);
    FastLED.show();
    FastLED.delay(20);
  }
}

So I did not use the Adafruit DotStar library. And I only used 1pc DotStar for this test.

Paul
 
Sorry I am not sure what constructor you are using here:
Code:
Adafruit_DotStar::Adafruit_DotStar(uint16_t n, uint8_t o)
    : numLEDs(n), dataPin(USE_HW_SPI), brightness(0), pixels(NULL),
      rOffset(o & 3), gOffset((o >> 2) & 3), bOffset((o >> 4) & 3) {
  updateLength(n);
}

/*!
  @brief   DotStar constructor for 'soft' (bitbang) SPI. Any two pins
           can be used.
  @param   n      Number of DotStars in strand.
  @param   data   Arduino pin number for data out.
  @param   clock  Arduino pin number for clock out.
  @param   o      Pixel type -- one of the DOTSTAR_* constants defined in
                  Adafruit_DotStar.h, for example DOTSTAR_BRG for DotStars
                  expecting color bytes expressed in blue, red, green order
                  per pixel. Default if unspecified is DOTSTAR_BRG.
  @return  Adafruit_DotStar object. Call the begin() function before use.
*/
Adafruit_DotStar::Adafruit_DotStar(uint16_t n, uint8_t data, uint8_t clock,
                                   uint8_t o)
    : dataPin(data), clockPin(clock), brightness(0), pixels(NULL),
      rOffset(o & 3), gOffset((o >> 2) & 3), bOffset((o >> 4) & 3) {
  updateLength(n);
}
It looks like they have 2 constructors, one that is has 2 parameters and the other 4 and you passed in 3?

What happens if instead have it: Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_BRG);
 
I'm using the 4-arg constructor (but the fourth arg has a default of DOTSTAR_BRG)

What happens if instead have it: Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_BRG);

Good question! I'll check this out when I'm back at home.
 
Status
Not open for further replies.
Back
Top