Yule Be Impressed

Or not - as the case may be. This is my attempt to revive an old, bust Christmas decoration.

The original Christmas candle decoration was a white casing, simply filled with static, old-school filament lighting - and as happens one of them went by the by. We don't keep spares as most of our decorations today are LED. I was left with an empty shell -  what to do?

As it happens I had a roll of serial LED strip lying around looking for a job - so last night I set about giving it one.

In the early days of putting together my software for the ESP8266 (see Home Control 2016 project - binaries available), once I'd managed to get serial LEDs to run properly, I put together several RGB controls one of which includes animation, but never actually used it until now.

The programming below is easy once you know how.

{rgbstop}

{rgbstart:12,94}
{rgbadd:8,22,255,0,0,5}
{rgbadd:36,24,255,0,0,5}
{rgbadd:66,20,255,0,0,5}
{rgbadd:0,8,0,255,0,5}
{rgbadd:86,8,0,255,0,5}

{rgbadd:60,6,255,255,0,5}
{rgbadd:30,6,255,255,255,200}
{rgbadd:60,6,255,255,80,5}
{rgbadd:30,6,255,255,150,200}
{rgbadd:60,6,255,255,150,5}
{rgbadd:30,6,255,255,80,200}
{rgbadd:60,6,255,255,255,5}
{rgbadd:30,6,255,255,0,200}


{rgbadd:60,6,255,255,0,5}
{rgbadd:30,6,255,255,255,200}
{rgbadd:60,6,255,200,40,5}
{rgbadd:30,6,255,255,150,200}
{rgbadd:60,6,255,255,80,5}
{rgbadd:30,6,255,255,120,200}
{rgbadd:60,6,255,255,200,5}
{rgbadd:30,6,255,255,30,200}


{rgbadd:60,6,255,255,0,5}
{rgbadd:30,6,200,255,200,200}
{rgbadd:60,6,255,200,80,5}
{rgbadd:30,6,255,255,130,200}
{rgbadd:60,6,200,200,150,5}
{rgbadd:30,6,255,180,80,200}
{rgbadd:60,6,255,255,200,5}
{rgbadd:30,6,255,255,0,200}

The first line stops any animation and clears out any queue. The second line starts up the yet-to-be-defined animation and defines which GPIO pin to use on the ESP and how many LEDs are involved (to set up the buffer which is number_of_leds * 3 - not that you need to know that).

rgbstart:gpio_number, number_of_leds

The remaining lines start operating in the background as soon as they are called... here's the format:

rgbadd led_number, led_count, r, g, b, delay_in_ms

Hence any decoration such as the one in the video - which is nothing more than a strip of around 94 LEDs, starting where the wire comes in at the bottom and following the profile, pointing inwards (inside the hollow container) until coming back to the bottom. So, the first 8 and last 8 LEDs are set to green, the rest being red APART from half a dozen at positions 30 and 60 which get some animation between yellow and white.

You could do a LOT more and the software  has enough storage for 300 LEDs and a lot more instructions than this, 600 in total (version 1.70 onwards). I've used around 180 here. I could make it considerably longer but that seemed like a reasonable size at the time.

In the above example, you would simply fire out these commands from the serial port – in my case I wanted to do this at the push of a button on the mobile phone.

Using Node-Red, I simply made a sequencer to send the instructions out one group at a time – you need a slight delay as the board takes time to process each command – only a tiny delay in milliseconds – but some.

tmp4839

Below are the two VERY crude functions to let me start up the display from the phone – or from a Node-Red Dashboard button.

if (msg.payload=="reset") context.global.stepper=0;

var steps=[
"{rgbstop}",
"{rgbstart:12,94}",
"{rgbadd:8,22,255,0,0,5}",
"{rgbadd:36,24,255,0,0,5}",
"{rgbadd:66,20,255,0,0,5}",
"{rgbadd:0,8,0,255,0,5}",
"{rgbadd:86,8,0,255,0,5}",
"{rgbadd:60,6,255,255,0,5}",
"{rgbadd:30,6,255,255,255,200}",
"{rgbadd:60,6,255,255,80,5}",
"{rgbadd:30,6,255,255,150,200}",
"{rgbadd:60,6,255,255,150,5}",
"{rgbadd:30,6,255,255,80,200}",
"{rgbadd:60,6,255,255,255,5}",
"{rgbadd:30,6,255,255,0,200}",

"{rgbadd:60,6,255,255,0,5}",
"{rgbadd:30,6,255,255,255,200}",
"{rgbadd:60,6,255,200,40,5}",
"{rgbadd:30,6,255,255,150,200}",
"{rgbadd:60,6,255,255,80,5}",
"{rgbadd:30,6,255,255,120,200}",
"{rgbadd:60,6,255,255,200,5}",
"{rgbadd:30,6,255,255,30,200}",

"{rgbadd:60,6,255,255,0,5}",
"{rgbadd:30,6,255,255,00,200}",
"{rgbadd:60,6,255,200,80,5}",
"{rgbadd:30,6,255,255,130,200}",
"{rgbadd:60,6,200,200,150,5}",
"{rgbadd:30,6,255,180,80,200}",
"{rgbadd:60,6,255,255,200,5}",
"{rgbadd:30,6,255,255,0,200}"];

msg.topic="testi2c/toesp";
msg.payload=steps[context.global.stepper++];
return msg;

and...

if (msg.payload!==undefined) return msg;

Basically a payload of "reset" starts a crude global counter and iterates through the array, sending out messages at 100ms intervals until it falls off the end of the array  (well, I was in a hurry).  Works a treat. I have a test button there in Node-Red itself and a button on the phone, both of which do the same thing.

Facebooktwittergoogle_pluspinterestlinkedin

One thought on “Yule Be Impressed

  1. Good job getting revamping that old decoration.

    BTW, what does it mean? Is it IO or 10 or something I'm too dense to figure out?

Leave a Reply

Your email address will not be published. Required fields are marked *