Repository navigation
ESP8266 SPI - #936
ESP8266 SPI#936
Conversation
|
To use it: #define FASTLED_ALL_PINS_HARDWARE_SPI
#define ESP8266_SPI
#include <FastLED.h>I had some glitches with a 160MHz CPU speed, lowering it to 80MHz fixed that. |
|
@samguyer: Could you take a look at this PR? Looks interesting |
|
I do not think that I respect the way the library should be structured but it does works |
|
Just to check, is this the same method as using I've tried for many months to try and stop the watchdog resets on my code using FastLED - yet NeoPixelBus can stay operational for days at a time with no resets. However because of the better maths support in FastLED, I'd like to try and move back - without the watchdog resets... |
|
@CRCinAU I don't know about NeoPixelBus, but it's the same SPI implementation as for others ESP in FastLED |
|
Thanks for the reply. I can't see it specified anywhere - so does this use GPIO3 on the ESP8266? aka the RX pin? EDIT: I think I'm getting a bit confused here - as the DMA method seems to use GPIO3. @coryking did a fork here to add DMA mode: https://github.com/coryking/FastLED This is probably better as far as fixing the hardware resets that always occur on the ESP8266 chips... I wonder if he'd be interested in bringing it up to date and trying to merge things? It sure would make life easier for people... |
|
Just wondering if there is any further details on this - specifically which pin needs to be used, and if it is expected that this would work around the constant hardware watchdog resets with the ESP8266? |
|
@CRCinAU I do use the defaults SPI pins, there is a schematics on my project |
|
Ok, good to know... I'm currently testing the DMA support via the RX pin on a D1 Mini - and it seems to do very well... My current uptime is 0 days 06:11:20.255 - which is more than I can normally stay up using the stock bit-banging with FastLED... This is the DMA repo: https://github.com/coryking/FastLED I wonder what the status is for FastLED in accepting patches / PRs these days - as there doesn't seem to be a lot of movement of late... |
|
Native SPI can work very fast as well, I choosed a frequency that work well to drive my 576 APA102 strip but the frequency should be a constent so may be defined by user, I should fix it but I guess there is a couple issue to assert before merging. The PR is more a beta/proof of concept so I'm waiting for instruction to do it with the proper FastLED way I do not have any crash issue even with my messy Home Asistant MQTT setup, the only issue I have is the wifi wich is not stable |
|
Ah - Wifi having problems is easy fixed... Use My main problem has been having watchdog resets when using FastLED in bit banging mode... |
|
Mine can run for hours, the only watchdog reset I have is with my UDP control, I think a buffer overflow or a interuption issue but FastLED with SPI per se is not causing any reset, my wifi issue I guess it's the presence of multiple access points, I didn't try to use the BSSID but thank for the tip |
|
Can this be used for clockless LEDs, such as the WS2812B? |
|
@cyberjacob I don't have them to test it but it should work |
|
Yeah - I only use WS2812 LEDs - hence the DMA option is better for me - and I can confirm that it works perfectly via the RX pin... |
|
Out of curiosity, why #if defined(ESP8266_SPI) instead of #if defined(ESP8266) && defined(FASTLED_ALL_PINS_HARDWARE_SPI) ? |
|
@BlainHamon I hadn't thought about code consitency, norm ect .... I was just doing fast prototyping, so I know there is somes fixes/rewrte to do, before merging but I do not really know the project and how to integrate this code properly, but in the meanwhile the code is already available to use by others |
|
Hey there, |
|
@domiko96 This patch is not merged, if you want to use it you'll need to aply this patch on your library and use thoses headers as mentioned above by h3ndrik #define FASTLED_ALL_PINS_HARDWARE_SPI
#define ESP8266_SPI
#include <FastLED.h>If you use the FastLED master it will use a bitbanging method that is overly laggy and thus not able to drive as much leds as the SPI method |
|
Thanks @BenoitAnastay Works great! I have 240 SK6822 LEDs attached to a HiLetGo ESP8266 using pins 13/14 running at 6mhz without issue. Example config with PlatformIO if anyone else needs:
#define FASTLED_ESP8266_RAW_PIN_ORDER
//#define FASTLED_ESP8266_NODEMCU_PIN_ORDER
//#define FASTLED_ESP8266_D1_PIN_ORDER
// Enable FastLED SPI for ESP8266 using https://github.com/BenoitAnastay/FastLED
#define FASTLED_ALL_PINS_HARDWARE_SPI
#define ESP8266_SPI
#include <FastLED.h>
FASTLED_USING_NAMESPACE
#define DATA_PIN 13
#define CLK_PIN 14
#define LED_TYPE SK6822
#define COLOR_ORDER RGB
void setup() {
FastLED
.addLeds<LED_TYPE, DATA_PIN, CLK_PIN, COLOR_ORDER, DATA_RATE_MHZ(6)>(
leds, NUM_LEDS)
.setCorrection(TypicalLEDStrip);
} |
|
are there any plans of this being merged any time soon? |
|
I'm not maintening this PR but anyone is free to update and cleanup this. @samguyer was assigned to this PR by @kriegsman but he do net left any comment ... 🤷 |
|
Why hasn't this PR been applied yet? "FastLED" is not fast without it ... |
I don't know, they did merged the one for ESP32 but not this one. Nowaday there is conflicts but the logics works great. Im still waiting after a project admin to review the code |
|
Hi all! Apologies for the delay. I will prioritize this PR and try to get it in as soon as possible. |
|
I'll not be able to maintain the PR because I don't have any ESP board today. But since the logic was working I guess that there is only the need to fix the conflicts and check if it's respect the good practices |
|
@BenoitAnastay I want to merge this work today. Any chance you can look at the conflicts and get the PR to the point I can merge it? I'm happy to look over the changes after that and do testing on actual ESP hardware. |
|
@samguyer I'll try to fix the conflicts (and respect the files location) by the 5th. Basicaly there is just the same changes as the one for the ESP32 (which was bases on my PR, itself based on another SPI intégration of FastLED). |
|
The 5th of what? June? Could you please fix this ASAP, this would be awesome to have merged into FastLED. |
|
@psrcek I'll try to get this merged in soon. I think the goal was January 5, but hey, we've all got day jobs! |
|
Sorry I was a lot busy, I'll do that ASAP, I do not have ESP board but I'll just try to fix conflits since the logic was working well |
|
@BenoitAnastay That would be great. If you can resolve the conflicts, I can do the testing and any debugging. |
|
I tried to update the PR, I did the same changes as the ones that was merged for the ESP32, hope it'll work The original one is here : d88b124 |
|
I'm able to build Blink.ino with |
|
@BenoitAnastay Fantastic! Thank you for all your work on this contribution! |
|
Is it still working on hardware ? I was only able tu build it, not test it on real hardware |
|
I'll do some testing. I just wanted to get the code in there. |
| // select the SPI output (TODO: research whether this really means hi or lo. Alt TODO: move select responsibility out of the SPI classes | ||
| // entirely, make it up to the caller to remember to lock/select the line?) | ||
| void select() { | ||
| SPI.beginTransaction(SPISettings(3200000, MSBFIRST, SPI_MODE0)); |
There was a problem hiding this comment.
Maybe we need to replace hardcoded speed by SPI_SPEED, 32Mhz was fine for my project driving 576 APA102
| #define DATA_RATE_MHZ(X) (((48000000L / 1000000L) / X)) | ||
| #define DATA_RATE_KHZ(X) (((48000000L / 1000L) / X)) | ||
| #elif defined(FASTLED_TEENSY4) || (defined(ESP32) && defined(FASTLED_ALL_PINS_HARDWARE_SPI)) | ||
| #elif defined(FASTLED_TEENSY4) || (defined(ESP32) && defined(FASTLED_ALL_PINS_HARDWARE_SPI)) || (defined(ESP8266) && defined(FASTLED_ALL_PINS_HARDWARE_SPI)) |
There was a problem hiding this comment.
I did not change that in my original PR, the consistency should be checked
|
FTR (because i was a bit confused after ending up here): |
|
@dbu looking at my precedent comment I guess you have to define ESP8266 |
|
i think that constant is defined by the arduino env when you select an ESP8266 board. i did not define it but the pragma warning went away when defining only the FASTLED_ALL_PINS_HARDWARE_SPI. |
|
My initial commit was working for sure, I had to update it and make it consistent with other PRs made after but I wasn't able to test it myself since I do not have the hardware. You can have a look into this merge to check changes https://github.com/FastLED/FastLED/compare/18fccac9a20df0824c52b12831ffc0dbd12ee929..4d73cddfe4bd2b370ee882b6f68769bf7f8309f4 Since the logic hasn't changed it might be a loading issue. this should be displayed in the build logs Another thing that might cause issue it if you are using GPIO ports because of a label differences between your board and mine I put a diagram here |
|
yes, i do get the pragma message that hardware spi is added, and the LEDs blink nicely as they should :-D thanks for the contribution btw, i am really enjoying the FastLED library. |

Implementation of SPI for ESP8266