Code Monkey home page Code Monkey logo

adafruit_dotstar's Introduction

Adafruit DotStar Build Status

Arduino library for controlling two-wire-based LED pixels and strips such as Adafruit DotStar LEDs and other APA102-compatible devices.

adafruit_dotstar's People

Contributors

billydonahue avatar caternuson avatar creativerobotics avatar dan-lightsource avatar digitalcircuit avatar driverblock avatar embeddedman avatar evaherrada avatar hoffmannjan avatar ladyada avatar paintyourdragon avatar petervollmer avatar russmcinnis avatar siddacious avatar tdicola avatar tyeth avatar whichkatiedid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_dotstar's Issues

DotStar v1.2.2 breaks strandtest hardware SPI on ItsyBitsy M4

  • Arduino board: ItsyBitsy M4 Express

  • Arduino IDE version (found in Arduino -> About Arduino menu): 2.0.4

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):

  1. Connect a strand of DotStar LEDs to the hardware SPI pins on the ItsyBitsy M4 (SCK and MOSI)
  2. Download the 1.2.1 or 1.2.2 version of the DotStar library
  3. Open and modify the bundled strandtest.ino example to use hardware SPI, not bit-banging
diff --git a/strandtest.ino b/strandtest-hardware.ino
index bdf885c..d798ef9 100644
--- a/strandtest.ino
+++ b/strandtest-hardware.ino
@@ -15,7 +15,7 @@
 // Here's how to control the LEDs from any two pins:
 #define DATAPIN    4
 #define CLOCKPIN   5
-Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
+//Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
 // The last parameter is optional -- this is the color data order of the
 // DotStar strip, which has changed over time in different production runs.
 // Your code just uses R,G,B colors, the library then reassigns as needed.
@@ -23,7 +23,7 @@ Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
 
 // Hardware SPI is a little faster, but must be wired to specific pins
 // (Arduino Uno = pin 11 for data, 13 for clock, other boards are different).
-//Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_BRG);
+Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_BRG);
 
 void setup() {
  1. Observe the results

With DotStar version 1.2.1, the DotStar LEDs show the strand testing pattern.

With DotStar version 1.2.2, the microcontroller appears to lock up, requiring a double-tap Reset into bootloader to flash new code.

Of note, the ItsyBitsy M4 appears to not have a default SPI device defined. Should strandtest.ino be updated?

PIxel buffer over read in MONO mode

Just quickly looking at the code, looks like show() reads past the end of the pixel buffer when in MONO mode. show() assumes the buffer is 3*n bytes long, but update Length() allocates a buffer of n + ((n + 3) / 4) bytes when in MONO mode.

Looking now in the header file, it says not to use MONO mode, but just wanted to make you aware that this needs to be fixed before MONO mode can work.

Document which boards are supported

I, for example, want to use this on the beaglebone. Is it supported there?

It would be great if at a minimum the readme said which platforms are supported.

APA102 Brightness function could use the 5-bit brightness value instead of scaling the component values.

In the Adafruit_DotStar library that brightness is implemented via scaling down the led values, similar to the WS2812. But DotStar contains a 5-bit brightness value that if used, will preserve the color resolution. The downside is that there would only be 32 brightness levels rather than the 256.

FastLED enables something similar via the global brightness #define.

Since I just submitted a PR already for this code base, I might implement this for Adafruit myself.

The question I want to ask is whether it's important to preserve the current brightness setting. My recommendation is to replace the brightness logic with the 5-bit brightness yet present the same brightness range to the user through the API.

For example, store the brightness as a full range uint8_t but then scale down to the 5-bit brightness value and write that out with the leds during show(). This way anyone using the brightness feature would get an improvement in visual quality without having to change how they use the API.

Hardware SPI clock divider should be set faster for ItsyBitsy M4

In brief

Details

In experimentation with the ItsyBitsy M4 Express, updating 300 DotStar LEDs from the Arduino takes around 3326 µs, measured like so:

// Set up LED strips first
// [...]
unsigned long start = micros();   // Track start time
strip.show();                     // Refresh strip
Serial.println(micros() - start); // Print time taken

However, by setting the SPI clock divider to 1 instead of the default calculated 15, updating the same 300 LEDs takes around 2518 µs, averaging 0.8 ms faster updates.

Changes made for testing:

--- a/Adafruit_DotStar.cpp
+++ b/Adafruit_DotStar.cpp
@@ -115,7 +115,11 @@ void Adafruit_DotStar::hw_spi_init(void) { // Initialize hardware SPI
     SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
     SPI.endTransaction();
   #else
-    SPI.setClockDivider((F_CPU + 4000000L) / 8000000L); // 8-ish MHz on Due
+    #if defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS)
+      SPI.setClockDivider(1); // As fast as possible
+    #else
+      SPI.setClockDivider((F_CPU + 4000000L) / 8000000L); // 8-ish MHz on Due
+    #endif
   #endif
  #endif
   SPI.setBitOrder(MSBFIRST);

Resolution

Though I can manually override by calling SPI.setClockDivider(1); after calling lights.begin(), it'd make sense to offer all users of the library the faster update rate.

Are there gotchas or pitfalls that I am overlooking with this approach, and/or can this be done in a more generic way?


In case it's used for automatic bug tagging, I've filled out the original template here:

  • Arduino board: ItsyBitsy M4
  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.9
  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):

Example

strandtest_perf.ino

// Simple strand test for Adafruit Dot Star RGB LED strip.
// Mostly copied from https://github.com/adafruit/Adafruit_DotStar/blob/master/examples/strandtest/strandtest.ino
// Includes commands to measure timing of updating LED strand

#include <Adafruit_DotStar.h>
#include <SPI.h>

// For testing: 300 DotStar pixels
#define NUMPIXELS 300 // Number of LEDs in strip

// For testing: hardware SPI
Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_BGR);

void setup() {
  Serial.begin(115200);     // Initialize to fastest common baud rate

  strip.begin();            // Initialize pins for output
  //SPI.setClockDivider(1); // Override default SPI clock divider
  strip.show();             // Turn all LEDs off ASAP
}

// Runs 10 LEDs at a time along strip, cycling through red, green and blue.

int      head  = 0, tail = -10; // Index of first 'on' and 'off' pixels
uint32_t color = 0xFF0000;      // 'On' color (starts red)

void loop() {
  strip.setPixelColor(head, color); // 'On' pixel at head
  strip.setPixelColor(tail, 0);     // 'Off' pixel at tail

  unsigned long start = micros();   // Track start time
  strip.show();                     // Refresh strip
  Serial.println(micros() - start); // Print time taken

  delay(20);                        // Pause 20 milliseconds (~50 FPS)

  if(++head >= NUMPIXELS) {         // Increment head index.  Off end of strip?
    head = 0;                       //  Yes, reset head index to start
    if((color >>= 8) == 0)          //  Next color (R->G->B) ... past blue now?
      color = 0xFF0000;             //   Yes, reset to red
  }
  if(++tail >= NUMPIXELS) tail = 0; // Increment, reset tail index
}

DotStar SPI incompatibility with nrf52840 (Nano 33 BLE and BLE Sense)

There are SPI compatibility problems with the Adafruit_DotStar library for some of the newer Ardrino boards. Was hoping to take advantage of the much higher clock speed (64Mhz) of the newer board for doing high speed refresh of DotStar strips over SPI for POV applications.

  • Arduino board: Nano 33 BLE

  • Arduino IDE version: 1.8.13

  • List the steps to reproduce the problem below:
    strandtest.txt

  1. Install Adafruit_DotStar library.
  2. Modified NUMPIXELS from 30 to 60
  3. commented out // Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
  4. uncommented Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_BRG);
  5. Tried to compile/upload to a new Nano 33 BLE board. Recieved several errors shown below:

`Arduino: 1.8.13 (Windows 10), Board: "Arduino Nano 33 BLE"
C:\Users\karl\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp: In member function 'void Adafruit_DotStar::hw_spi_init()':

C:\Users\karl\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:189:7: error: 'class arduino::MbedSPI' has no member named 'setClockDivider'

SPI.setClockDivider((F_CPU + 4000000L) / 8000000L); // 8-ish MHz on Due
^~~~~~~~~~~~~~~

C:\Users\karl\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:189:24: error: 'F_CPU' was not declared in this scope

SPI.setClockDivider((F_CPU + 4000000L) / 8000000L); // 8-ish MHz on Due
^~~~~

C:\Users\karl\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:189:24: note: suggested alternative: 'FPU'

SPI.setClockDivider((F_CPU + 4000000L) / 8000000L); // 8-ish MHz on Due
^~~~~
FPU

C:\Users\karl\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:192:7: error: 'class arduino::MbedSPI' has no member named 'setBitOrder'

SPI.setBitOrder(MSBFIRST);
^~~~~~~~~~~

C:\Users\karl\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:193:7: error: 'class arduino::MbedSPI' has no member named 'setDataMode'

SPI.setDataMode(SPI_MODE0);
^~~~~~~~~~~

exit status 1
Error compiling for board Arduino Nano 33 BLE.
`

Dotstar random Flickering in SPI Mode

Hi I'm actually using your Library on an ESP8266 project, controlling 30 devices with 6 Dotstars each via OSC Protocol. I choose SPI mode to save as much time as possible and everything went nice at first.

The problem started when I did my first real scale test with every 30 devices connected at this point the Dotstars start flickering randomly. I didn't really figured out, addding a noInterrupts() before sending the dotstar command didn't help and I had to go back to the bitbanging mode to make it work (on the exact same SPI pins actually so I don't have to spoil my boards).

But so far it seems that SPI mode have a kind of limit...

Example ItsyBitsyM4Onboard Update Suggestion

  • Arduino board: Gemma M0
  • Arduino IDE version (found in Arduino -> About Arduino menu): N/A
  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

When following the example code for the ItsyBitsyM4 Onboard, it was not clear which Data/Cock Pin numbers to use for the Gemma M0 without prior knowledge of the board's schematics or pinouts.

As a suggestion, could the example code be simplified to use "internal" DotStar #defines such as INTERNAL_DS_DATA and INTERNAL_DS_CLK? After doing a quick skim of the framework-arduinosam package library, it appears that most of the boards with an on-board DotStar define this in their variant.h file.

Example

// ...
Adafruit_DotStar _dotStar(NUMPIXELS, INTERNAL_DS_DATA, INTERNAL_DS_CLK, strip);
// ...

Versus the current example, which the user must look up their board's data/clock pin numbers.

// ...
//Use these pin definitions for the ItsyBitsy M4
#define DATAPIN    8
#define CLOCKPIN   6

Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
// ...

Please correct me if this is an unsupported #define to use for on-board DotStars. Thank you and keep up the great work!

Cannot compile strandtest example on 5V trinket

  • Arduino board: Adafruit Trinket 5V

  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.19

  • List the steps to reproduce the problem below (if possible attach a sketch or

  1. Install the DotStar Library
  2. Load the strandtest example
  3. Comment out #include <SPI.h> and uncomment #include <avr/power.h>
  4. Compile
In file included from /home/mike/Arduino/strandtest/strandtest.ino:8:0:
/home/mike/Arduino/libraries/Adafruit_DotStar/Adafruit_DotStar.h:191:3: error: 'Adafruit_SPIDevice' does not name a type; did you mean 'Adafruit_SPIDevice_h'?
   Adafruit_SPIDevice *spi_dev = NULL; ///< Pointer to SPI bus interface
   ^~~~~~~~~~~~~~~~~~
   Adafruit_SPIDevice_h

Missing definition for M_PI on Arduino 101

  • Arduino board: 101

  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.4

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):
    Install the DotStar library version 1.0.3
    Adafruit_DotStar.cpp fails to compile with the error:
    \Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:356:53: error: 'M_PI' was not declared in this scope

#define S1 (sin((COUNTER - SBASE) / 128.0 * M_PI) + 1.0) * 127.5 + 0.5,

Adding a definition for M_PI before this fixes the problem and the library works fine after that.

Set SPI clock to 8Mhz on chipKIT (PIC32) by default

Currently it gets set to about 750Khz. Use beginTransaction/endTransaction calls to set speed for all PIC32s to 8Mhz, so that it matches the default speed on other supported cores (ESP8266, AVR, Teensy, etc.)

Hardware SPI - Chip Select

What is the recommended way of using Dot Stars when there's something else that's also using SPI, for example an SD card ?

I'm thinking that if you're using a level shifter (E.g: 74AHCT125), you could use the output enable level shifter pin on the clock line to act as a chip select for the Dot Stars, and simple set it before every call to the Dot Star "show" method. Thoughts ?

Atmega4809 support

Hello,

I have been trying to use this library for the newly Arduino Nano Every, which has an ATMEGA4809 chip.
The new megaAVR-0 series have different registers than the "classic" AVRs found on the Arduino Uno for instance.

Here are the errors when I try to compile:

C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp: In member function 'void Adafruit_DotStar::show()':
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:329:5: error: 'SPDR' was not declared in this scope
SPDR = 0x00; // 4th is pipelined
^~~~
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:329:5: note: suggested alternative: 'SPI'
SPDR = 0x00; // 4th is pipelined
^~~~
SPI
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:331:16: error: 'SPSR' was not declared in this scope
while (!(SPSR & _BV(SPIF)))
^~~~
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:331:16: note: suggested alternative: 'SPI'
while (!(SPSR & _BV(SPIF)))
^~~~
SPI
In file included from c:\users\spiki\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,
from c:\users\spiki\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,
from C:\Users\Spiki\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/String.h:31,
from C:\Users\Spiki\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/IPAddress.h:24,
from C:\Users\Spiki\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\Spiki\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/Arduino.h:23,
from C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.h:25,
from C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:42:
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:331:27: error: 'SPIF' was not declared in this scope
while (!(SPSR & _BV(SPIF)))
^
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:331:27: note: suggested alternative: 'SPI'
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:336:18: error: 'SPSR' was not declared in this scope
while (!(SPSR & _BV(SPIF)))
^~~~
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:336:18: note: suggested alternative: 'SPI'
while (!(SPSR & _BV(SPIF)))
^~~~
SPI
In file included from c:\users\spiki\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,
from c:\users\spiki\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,
from C:\Users\Spiki\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/String.h:31,
from C:\Users\Spiki\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/IPAddress.h:24,
from C:\Users\Spiki\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\Spiki\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/Arduino.h:23,
from C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.h:25,
from C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:42:
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:336:29: error: 'SPIF' was not declared in this scope
while (!(SPSR & _BV(SPIF)))
^
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:336:29: note: suggested alternative: 'SPI'
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:341:14: error: 'SPSR' was not declared in this scope
while (!(SPSR & _BV(SPIF)))
^~~~
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:341:14: note: suggested alternative: 'SPI'
while (!(SPSR & _BV(SPIF)))
^~~~
SPI
In file included from c:\users\spiki\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,
from c:\users\spiki\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,
from C:\Users\Spiki\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/String.h:31,
from C:\Users\Spiki\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/IPAddress.h:24,
from C:\Users\Spiki\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\Spiki\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/Arduino.h:23,
from C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.h:25,
from C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:42:
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:341:25: error: 'SPIF' was not declared in this scope
while (!(SPSR & _BV(SPIF)))
^
C:\Users\Spiki\Documents\Arduino\libraries\Adafruit_DotStar\Adafruit_DotStar.cpp:341:25: note: suggested alternative: 'SPI'

I`m guessing this library does not support the new megaAVR-0 series?
Anyone else encountered this?

Off-by-one error? Last LED is not properly updated on strip.show();

I just recently got a strip of DotStar LEDs, and noticed while programming a strip to flash between two colors that if I set the length to the number of LEDs and periodically called strip.show() with alternating colors, the last LED always seemed to be out of sync. Two workarounds that seemed to work was making the strip an extra LED longer or calling strip.show() twice (as commented below). I've attached a brief example that demonstrates this by toggling the last 5 LEDs in a strip (adjust NUMPIXELS to the strip you use).

#include <Adafruit_DotStar.h>
#include <SPI.h>

#define NUMPIXELS  72 // 73

#define DATAPIN    11
#define CLOCKPIN   13
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN);

void setup() {
  strip.begin();
}

boolean flash = false;

void loop() {
  for(int i = NUMPIXELS-5; i<NUMPIXELS; i++)
    strip.setPixelColor(i, flash ? 0xFF0000 : 0x0000FF);
  strip.show();
  // strip.show();
  delay(500);
  flash = !flash;
}

Issue with 144 LED strip

If I try the library with lighting up all 144 LEDS, the last 2 are not light up correctly and seem delayed by a step. I confirmed this using an Arduino Uno and ESP8266. I switched to the FastLED library and the issue went away.

uint16_t NUM_LEDS = 144;

uint32_t color = 0xFF0000;

for(byte i=0; i<3; i++){
      for(byte x=0;x<NUM_LEDS;x++)
      {
        strip.setPixelColor(x, color);    
     }
  
strip.show(); 

delay(1500);                        

if((color >>= 8) == 0)          //  Next color (R->G->B) ... past blue now?
    color = 0xFF0000;             //   Yes, reset to red
}

Potential bug

We looking at the code and saw updatePins(void) and updatePins(uint8_t data, uint8_t clock). It looks like they are both assuming you are switching from SW to HW and HW to SW respectively, I imagine they should both check like in the destructor versus assuming that since the user could be switching from SW pins to other SW pins, etc.

fill() function take too long to change

The fill() function doesn't switch fast enough. It seems to have a big delay somewhere, which I couldn't spot.
My expectation will have a color-switching very fast ~1ms or even slower, but apparently, it would take 100ms or more and can be detected the color change by eyes.

See the code below:

import adafruit_dotstar
import digitalio
import board
import math
import time
import random

num_pixels = 40
brightness = 0.005

pixels = adafruit_dotstar.DotStar(board.SCK, board.MOSI, num_pixels, brightness=brightness, auto_write=False)

BLACK = (0, 0, 0)
WHITE = (255, 255, 255)

while True:

pixels.fill(WHITE)
pixels.show()
time.sleep(0.001)

pixels.fill(BLACK)
pixels.show()
time.sleep(0.001)

Library does not work with HW SPI on arduino/esp8266

The library and accompanying seems to work by bitbanging, but not with HW SPI.

To test with bitbanging, I used pins 13 and 14 for MOSI and CLK. There was some weirdness with the first LED, but it generally worked with some flickering.

To use hardware SPI, you simply use the constructor that doesn't take pin assignments arguments. However, with this change, nothing happened. No lights :(.

Versions 1.2.0+ breaks onboard DotStar on Trinket M0

  • Arduino board: Adafruit Trinket M0

  • Arduino IDE version (found in Arduino -> About Arduino menu): 2.0.1 (Also saw the issue on the legacy IDE)

Please note this seems to be slightly intermittent; see notes at end.

  1. Install 1.1.5 version of Adafruit DotStar
  2. The sketch below (which simply flashes the onboard DotStar in blue) will compile, upload, and work fine.
  3. Install 1.2.0 or 1.2.1 version of DotStar
  4. The same sketch will compile and upload, but after the device reboots it crashes and you get the "USB device not recognized". Resetting or disconnecting/reconnecting the Trinket makes no difference; you have to do a double-reset to get to the bootloader in order to get the device responding again.
  5. Reinstall 1.1.5 and the sketch works again.
#include <Adafruit_DotStar.h>

Adafruit_DotStar strip(1, 7, 8, DOTSTAR_BRG);

void setup() {
  strip.begin();
  strip.setBrightness(25);
  strip.show();
}

void loop() {
  strip.setPixelColor(0, 0, 0, 255);
  strip.show();
  delay(500);
  strip.setPixelColor(0, 0, 0, 0);
  strip.show();
  delay(500);
}

I have 4 Trinket M0s, and the problem can be reproduced reliably on 3 of them. Of those three, two have the 2.0.0 UF2 bootloader, and I upgraded one of them to the latest 3.14.0 to see if that made a difference (it didn't).

On the fourth board, which also has the 2.0.0 UF2 bootloader, the problem is intermittent; immediately after upload it usually works, but resetting the board with the reset button or a power cycle brings it to the same "USB device not recognized".

All four boards work reliably with the 1.1.5 version of the library.

I also have a couple of ItsyBitsy M4s with onboard DotStars; I tried both of them (with the appropriate pin numbers) and didn't see the problem there.

Decision to ignore brightness is wrong, you just killed high dynamic color range

Here is the comment in the cpp file:

Although the LED driver has an additional per-pixel 5-bit brightness
setting, it is NOT used or supported here because it's a brain-dead
misfeature that's counter to the whole point of Dot Stars, which is to
have a much faster PWM rate than NeoPixels. It gates the high-speed
PWM output through a second, much slower PWM (about 400 Hz), rendering
it useless for POV. This brings NOTHING to the table that can't be
already handled better in one's sketch code. If you really can't live
without this abomination, you can fork the library and add it for your
own use, but any pull requests for this will NOT be merged, nuh uh!

I think this is misguided. We led artists/programmers are trying to implement high-range brightness control and we don't need the high-speed PWM. In fact, I would reason that the number of people that need the high-speed PWM for POV projects is in the single digits. Most artist/programmers that I know are programming light strips that are more or less stationary.

All of us with stationary strips have the same problem - we can't get dim pixels. Having a brightness control would solve this problem.

Hypothetically, think what would happen if the brightness pixel was used - we stationary strip users would get high dynamic range for the LEDs, and the POV people would get their POV feature if they set the brightness to 255.

Add support for passing in non-default SPI

This was intentionally left out of #47 just to keep that PR as simple as possible, since it was a major conversion. With that PR now in place, can look at adding the ability to pass in a non-default SPI instance.

There is a semi-related PR #20. But that PR is based on the older non-BusIO version of the library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.