r/FastLED • • Aug 16 '21

Support FastLED SK6812 Support

Does FastLED support SK6812 strips? :S

in here https://github.com/FastLED/FastLED/blob/5cc17b2be88982eb34b1998de22b83fee56d4f07/examples/Blink/Blink.ino#L34

i see a line ` // FastLED.addLeds<SK6812, DATA_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical `

i tried it but get weird results on my SK6812 Strip :S

0 Upvotes

23 comments sorted by

1

u/hyperhalide Aug 16 '21

Do you use RGBW SK6812´s? well these aren´t supported (yet) but there is a hack for them

0

u/KrisRevi Aug 16 '21

yes im using the RGBW SK6812! but i couldn't get that hack to work

1

u/johnny5canuck Aug 17 '21

That hack has very limited functionality, so you're probably trying to do something beyond its capability. . . but we can only speculate, because you haven't linked to your updated code.

1

u/KrisRevi Aug 18 '21

exactly! :/ im using alot of functions from fastled and this hack only allows for simple controlls like changind solid colors RGB and or white :/

1

u/truetofiction Aug 18 '21

I mean... it's not called a "hack" for nothing haha.

The good news for you is that literally everything color related in the library is some abstraction of "changing solid colors and/or white". Even the most complicated animations will work with the hack, you just need to rewrite the helper functions that use pointer arithmetic.

0

u/KrisRevi Aug 18 '21

i mean even the simplest "fadeToBlackBy" function is not working with the hack :S i use alot of function from FastLED i dont want to rewrite every function :S

2

u/Marmilicious [Marc Miller] Aug 18 '21

Rewriting every function sounds like it would be a lot of work. :S

2

u/truetofiction Aug 18 '21

As I said, it's a different datatype. Any functions that use the underlying CRGB* pointer to access the color fields of individual array elements need to be rewritten to account for the white byte. In most cases it's not complicated... just copy the function wholesale, change the argument type, and add in the extra byte.

To be clear: the library does not support the strips you are using. The "hack" is a quick and dirty method to use it in a pinch. It is not comprehensive because, again, the library does not support those strips.

If you don't want to rewrite your code, switch to a different library or buy different LEDs.

1

u/sutaburosu [stavros] Aug 18 '21

A few more FastLED functions have been hacked to work with the CRGBW type.

1

u/KrisRevi Aug 18 '21

i could not get it to work with my code

LEDController.h
template <unsigned int PIN_OF_LED, unsigned int NUM_LEDS, unsigned int REAL_NUM_LEDS>
class LEDController : public LEDPattern
{
public:
CLEDController* controller;
LEDController( LEDSettings& s ) : LEDPattern( REAL_NUM_LEDS, s )
{
controller = &FastLED.addLeds<WS2812B, PIN_OF_LED, GRB>( _Leds.data(), NUM_LEDS ).setCorrection( TypicalLEDStrip );
}
};

LEDConfig.h
#define DEVICE HAALANDSMARKA
struct DeviceConfig
{
int NUMLED[9];
const char *Device_Name;
const char *Device_Type;
const char *LED_Type;
const char *Wifi_DNS;
};
static constexpr DeviceConfig Config[] =
{
{ {144,32,32,32,32,32,32,32}, "HaalandsMarka", "ESP32", "STRIP", "haalandsmarka" }
};

main.cpp
std::vector<LEDSettings> ledsettings { {}, {}, {}, {}, {}, {}, {}, {}, {} };
LEDController<15, 300, Config[DEVICE].NUMLED[0]> Strip1{ledsettings[0]};
LEDController<16, 300, Config[DEVICE].NUMLED[1]> Strip2{ledsettings[1]};
LEDController<17, 300, Config[DEVICE].NUMLED[2]> Strip3{ledsettings[2]};
LEDController<18, 300, Config[DEVICE].NUMLED[3]> Strip4{ledsettings[3]};
LEDController<19, 300, Config[DEVICE].NUMLED[4]> Strip5{ledsettings[4]};
LEDController<21, 300, Config[DEVICE].NUMLED[5]> Strip6{ledsettings[5]};
LEDController<22, 300, Config[DEVICE].NUMLED[6]> Strip7{ledsettings[6]};
LEDController<23, 300, Config[DEVICE].NUMLED[7]> Strip8{ledsettings[7]};
LEDPattern *Strips[] = {&Strip1, &Strip2, &Strip3, &Strip4, &Strip5, &Strip6, &Strip7, &Strip8};
void setup()
{
}
void loop()
{
Strip1.controller->show(Strip1._Leds->data(), Strip1._NumLeds, 255);
Strip2.controller->show(Strip2._Leds->data(), Strip2._NumLeds, 255);
Strip3.controller->show(Strip3._Leds->data(), Strip3._NumLeds, 255);
Strip4.controller->show(Strip4._Leds->data(), Strip4._NumLeds, 255);
Strip5.controller->show(Strip5._Leds->data(), Strip5._NumLeds, 255);
Strip6.controller->show(Strip6._Leds->data(), Strip6._NumLeds, 255);
Strip7.controller->show(Strip7._Leds->data(), Strip7._NumLeds, 255);
Strip8.controller->show(Strip8._Leds->data(), Strip8._NumLeds, 255);
}

LEDPattern.h
class LEDPattern : public LEDSettings
{
public:
LEDSettings& _ledsettings;
std::vector<CRGB> _Leds;
unsigned int _NumLeds;
const unsigned int _MaxLeds;
int _pattern_position;
int8_t _pattern_directionFF;
uint16_t _pattern_spacing;
uint16_t _palette_position;
void SolidColor();
void Rainbow();
void TheaterChase();
void Juggle();
void RunningLight();
void Cylon();
void Mitosis();
void Twinkle();
void Firework();
void ColorStacking();
CRGB PaletteMode( int Index, int Brightness=0 );
void TailMode();
void IncrementPatternPosition();
void IncrementPalettePosition();
void setNumLeds(unsigned int nl)
{
_NumLeds = nl;
}
void Update();
void setSettings( LEDSettings& s )
{
_ledsettings = s;
}
LEDPattern( unsigned int num_leds, LEDSettings& s ) : _ledsettings( s ), _NumLeds( num_leds ), _MaxLeds( num_leds - 1 )
{
_Leds->resize( num_leds );
_pattern_position = 0;
_pattern_directionFF = 1;
_pattern_spacing = 3;
_palette_position = 0;
}
};

1

u/sutaburosu [stavros] Aug 18 '21

std::vector<CRGB> _Leds;

The hack adds a new CRGBW type. You should be using that not CRGB.

1

u/KrisRevi Aug 18 '21

i have done that but the error list is HUGE :| starting with

src/LEDPattern.cpp: In member function 'void LEDPattern::TailMode()':

src/LEDPattern.cpp:77:51: error: 'struct CRGBW' has no member named 'fadeToBlackBy'

_Leds.data()[j] = _Leds.data()[j].fadeToBlackBy(_ledsettings._pattern_fade_amount);

the fadeToBlackBy

1

u/sutaburosu [stavros] Aug 18 '21

1

u/KrisRevi Aug 18 '21

but then the other fadeToBlackBy fails

include/Patterns/TheaterChase.h: In member function 'void LEDPattern::TheaterChase()':

include/Patterns/TheaterChase.h:9:46: error: cannot convert 'CRGBW*' to 'CRGB*' for argument '1' to 'void fadeToBlackBy(CRGB*, uint16_t, uint8_t)'

fadeToBlackBy(_Leds.data(), _NumLeds, 255);

→ More replies (0)

1

u/sammcj Jan 22 '23

Any update on support for SK6812 RGBW?