WS2812 Christmas Fun

For general Flowcode discussion that does not belong in the other sections.
Post Reply
mnfisher
Valued Contributor
Posts: 984
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 105 times
Been thanked: 516 times

WS2812 Christmas Fun

Post by mnfisher »

So - I wanted a rainbow scroller for a window display.

I did a 5 metre (300) WS2812 led scroller - which looked very pretty :D (using a Nano)

But - could I get a Attiny to do the same? So here is a Rainbow scroller using an ATTINY85 (running at 16MHz)- the trick I use is to generate the colours on the fly rather than using a buffer (which for the 5m display is 900bytes)

Here presented as a 60 led scroller (note that I buffer the colours for the rainbow as 'wheel' took a little too long (although at 19us it was less than the 50us reset time for the LED strip)

This doesn't use the WS2812 component and has my own 'bit-bang' output to pin B0.

It's also a 'request' for the callback feature in V9 - as the colours are generated as required it would make outputting different patterns very easy - just by changing the 'generator' function called...
at85_rainbow.fcfx
(17.53 KiB) Downloaded 164 times
Martin

mnfisher
Valued Contributor
Posts: 984
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 105 times
Been thanked: 516 times

Re: WS2812 Christmas Fun

Post by mnfisher »

In fact callback functions turn out to be easy to work with anyway.

(Perhaps this should be in tricks and tips?)

In supplementary code I defined my function pointer as ;

Code: Select all

MX_UINT32 (*Generator)(int);
- as in this case I want a function takes an 'offset' (int) and returns a 32 bit number (actually a 24 bit colour)

Then to set the generator function in a C block :

Code: Select all

Generator = FCM_Pattern2;
Where Pattern2 is the Flowcode macro to call...

And to call (also in a C block)

Code: Select all

FCL_DATA = Generator(FCL_N);
My 'test' program has two patterns (a red green stripey and a rainbow scroll) - but now it is easy to add extra patterns.

Note that if we really wanted to get 'fancy' we could store function pointers in an array and then work through the array rather than using the individual assignments I have here...
at85_rainbow.fcfx
(19.21 KiB) Downloaded 168 times
Martin
Perhaps I'll try a 'KITT' scroller next...

mnfisher
Valued Contributor
Posts: 984
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 105 times
Been thanked: 516 times

Re: WS2812 Christmas Fun

Post by mnfisher »

As an aside - I did the timings for the WS2812 instructions using a smartscope to check the times.
They are currently reduced to 149euros on the Elektor website. I recommend it - a very useful bit of kit. An oscilloscope that works with PC (any flavour), smartphone or tablet
(and, sadly, I'm not on commission)

Martin

Post Reply