Skip to content

WS2812 driver to remove flickering

Yurik72 edited this page Feb 25, 2019 · 6 revisions

Precondition

During this project i have met wit a problem of flickering some leds on the ESP32, however it works perfectly on ESP8266.

Problem was discussed here and here

During on investigation and testing existing libraries i found that FastLED works perfectly. It's very good and complex library, thanks to the authors.

But, for my project I'm ok to use WS2812FX thanks to the authors as well. Therefore I have decided to get and idea and some codes ffrom the FastLED and adapt to WS2812FX. During that i decided to remove template reference to the PIN and number of leds. As result i have implemented WS2812Driver.h

The usage it's very simple and i need to put additional couple of code lines in my code Generally only few changes required as example simple sketch will looks

#include "WS2812Driver.h"   //include header`

LedInterruptDriver<NS(250), NS(625), NS(375)> ws2812driver;  // define driver here ! important for memory allocation
                                                         // timing defined for 2812 chip

WS2812FX* pstrip;    // ws2812fx object, i did this as pointer, but this is not importnat

void setup(){

pstrip=new  WS2812FX(numleds, pin, NEO_GRB + NEO_KHZ800);

ws2812driver.init(pstrip);

pstrip->setCustomShow([] () {ws2812driver.customShow();});

}

/// and traditionally loop

void loop(){

pstrip->service();

}

this changes are not requied any direct libraries changes and after that Adafruit_NeoPixel/WS2812FX will be switched to analog of FastLED engine ton produce output to RGB

P.S. Definetelly it's not final but at the moment I'm OK to works with ESP32 + WS2812 on the my home and changes are suficient for this project

Clone this wiki locally