Closed tripzero closed 2 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
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
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
does developer has plan to port this repo for ESP8266?
For the ESP its important to set the SPI Outputs as outputs separately like
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.
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.
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 :(.