adafruit / Adafruit_DotStar

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

Library does not work with HW SPI on arduino/esp8266 #3

Closed tripzero closed 2 years ago

tripzero commented 9 years ago

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 :(.

ladyada commented 9 years ago

could be its too fast? use an oscilloscope or logic analyzer to determine the speed CLK is at, make it ~8MHz or less

tripzero commented 9 years ago

It could be. I did try 800KHz with different results[1]. All the lights came on briefly but very dim. Then they all turned off and only the first LED was on (still very dim). This LED cycled through red/green/blue.

Unfortunately, I don't have a oscilloscope or logic analyzer to test :(. Has anyone gotten dotstars with hardware SPI to work on either arduino/esp8266 or nodeMCU?

[1] I added:

#ifdef ESP8266
SPI.setFrequency(8000000L);
#else
SPI.setClockDivider((F_CPU + 4000000L) / 8000000L); // 8-ish MHz on Due
#endif

I tried both 8000000 (8MHz) and 800000 (800KHz) values and I think 1MHz -which is typically what I use with dotstars on other platforms such as the Minnowboard Max[2].

[2] https://github.com/tripzero/MaxVideoRenderer/blob/master/lights.py#L206

fab672000 commented 8 years ago

If you read the original lib code they don't use setFrequency() but the setTransaction() API, also setting frequency but also the endianness as well as the the SPI mode (mode 0). I also tried to change these by cloning the lib locally to an ino file and could not make it work either with frequencies as low as 500Khz

mkeyno commented 8 years ago

does developer has plan to port this repo for ESP8266?

jtauscher commented 5 years ago

For the ESP its important to set the SPI Outputs as outputs separately like

define data 13

define clock 14

void setup() { pinMode(13, OUTPUT); pinMode(14, OUTPUT);

With Atmega8 it was not necessary. I hope this helps anyone since it took me days to figure that out.

caternuson commented 2 years ago

This may have self fixed by all the various updates to ESP8266 BSP and maybe BusIO. Just tested using hardware SPI on a Feather ESP8266 with the following sketch and it worked as expected.

#include <Adafruit_DotStar.h>

#define NUMPIXELS 19

Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_BRG);

void setup() {
  strip.begin();
  strip.fill(0xADAF00);
  strip.show();
}

void loop() {
}

Closing since can't reproduce.