MessageTorch - torch fire animation with WS2812 leds + message display

@Hootie81, given that the SPI MOSI line is used for driving the neopixels without SS it basically makes it dedicated. Even with the SharpMem display tricks I used for reading directly from the FRAM to the display, a chipselect was still needed for the display.

The compiler output will not show the memory used by the neopixel array since it is dynamically allocated at runtime. Nonetheless, 720 neopixels translates to a buffer size of 2,160 bytes which should be available if you are judicious with your code. The trick to knowing if the allocation will work is to compile the code and run it on a Spark. If on bootup the Spark immediately goes into an red flashing SOS condition then you know you don’t have enough RAM. :smile:

I just added the code for the website to github (sample_website subdirectory). All you need to do is putting that to a web server with PHP, and inserting your spark core's ID and access token at the indicated lines (Line 73-75, "Configuration..."). Hope it'll work for your sister's wedding! Nice idea :smile:

1 Like

Amazing project. I plan to build a little bigger torch where you can send messages in different color depending the category you choose.

How about to use a color lookup table? Four bits for color index and four bits for brightness. Maybe this could be programmed as a two dimensional static array within programm code space?

Interesting idea. How would you use the lookup table?

You can already set the text color/brightness using the “red_text”, “blue_text”, “green_text” parameters. So with two API calls (one “params”, one “message” you can easily create messages in different colors already.

Using two curl calls like:

  curl https://api.spark.io/v1/devices/zzzzzz/params -d access_token=ttttt -d "args=red_text=255,blue_text=0,green_text=0"
  curl https://api.spark.io/v1/devices/zzzzzz/message -d access_token=ttttt -d "Hello"

would give you a bright red “Hello”

1 Like

Just made my mega torch! 12m of LED’s (720 pixels) in a 15cm diameter vase! The RAM savings in the new versions of firmware must be really good, so far its working great with no SOS’s yet! Hmmm maybe i should order some more :slight_smile:

9 Likes

Wow, that’s amazing.! I wouldn’t have though this little project would ever grow so BIG :slight_smile:

3 Likes

I have messed up… i wanted to leave a gap at the back to make the display taller, then i staggered the LED’s to give the italic look, there are 30 rows of leds so i chose to stagger in groups of 5… but now the top 2 rows of text are 1 LED ahead.

Ive tried changing the base layer of test, but the characters are 7 rows tall…

ive tried changing the number of LEDs per row to try and make the text more italic but that just messes things up even more

Now i can probably go and edit each character individually but is there an easy way to move 2 lines a pixel to the right?

1 Like

OK so i have increased the font from 5x7 to 6x7 then decreased the spacing to 1px, now i can redraw the characters with the top 2 rows shifted by 1px… time consuming but its working perfectly!

Hi Luz,

This is the code I think should work.

//************************************************
struct colorpalette {
    byte red;
    byte green;
    byte blue;
};

const byte colorindexRED     = 0x00;
const byte colorindexGREEN   = 0x10;
const byte colorindexBLUE    = 0x20;
/*
const byte colorindexYELLOW  = 0x30;
const byte colorindexMAGENTA = 0x40;
const byte colorindexCYAN    = 0x50;
*/

const int LEDstripLEDs = 720;
byte LEDstrip[LEDstripLEDs];

static colorpalette ColorTable[] = {
    {0, 0, 0},  //red - off 
    {15, 0, 0},
    {31, 0, 0}, 
    {47, 0, 0},
    {63, 0, 0}, 
    {79, 0, 0},
    {95, 0, 0}, 
    {111, 0, 0},
    {127, 0, 0}, 
    {143, 0, 0},
    {159, 0, 0}, 
    {175, 0, 0},
    {191, 0, 0}, 
    {207, 0, 0},
    {223, 0, 0}, 
    {239, 0, 0},
    {255, 0, 0}, // red - brightest
    
    {0, 0, 0},  //green - off 
    {0, 15, 0},
    {0, 31, 0}, 
    {0, 47, 0},
    {0, 63,  0}, 
    {0, 79, 0},
    {0, 95, 0}, 
    {0, 111, 0},
    {0, 127, 0}, 
    {0, 143, 0},
    {0, 159, 0}, 
    {0, 175, 0},
    {0, 191, 0}, 
    {0, 207, 0},
    {0, 223, 0}, 
    {0, 239, 0},
    {0, 255, 0}, // green - brightest    
    
    {0, 0, 0},  //blue - off 
    {0, 0, 15},
    {0, 0, 31}, 
    {0, 0, 47},
    {0, 0, 63}, 
    {0, 0, 79},
    {0, 0, 95}, 
    {0, 0, 111},
    {0, 0, 127}, 
    {0, 0, 143},
    {0, 0, 159}, 
    {0, 0, 175},
    {0, 0, 191}, 
    {0, 0, 207},
    {0, 0, 223}, 
    {0, 0, 239},
    {0, 0, 255} // blue - brightest    
};

//************************************************


void setup() {
    // do something
}

void loop() {
    LEDstrip[0] = colorindexRED | 15; // color and brightness
    /* send data to LED strip */
    // writeRED (ColorTable.red[LEDstrip[0]]);
    // writeGREEN (ColorTable.green[LEDstrip[0]]);
    // writeBLUE (ColorTable.blue[LEDstrip[0]]);
    
}
1 Like

edit: solved it myself!

Tips for beginners setting up Apache and PHP… to run the website to send msg’s

I used this video https://www.youtube.com/watch?v=3TH6BnjuNG0

and you will need to ensure that in php.ini that this line is changed from off to on as below

short_open_tag = On

and also make sure that the php and php/ext folders are both in your path variables

Any recommendation about mechanical dimensions? Soon I will get 3 x 5m Stripes with 60 leds/meter.
My plan is to wind the stripes with more distance than at the area where the text is displayed.

I have cut mine into 400mm long strips. . Not recommended
but the exponentially increasing gap works really well and the sparks look very realistic accelerating as they go up

I started with a gap between leds of 14mm in the vertical direction which increases up to 16.5mm for the area the text is displayed (same as horizontal spacing) and the gap gets bigger and bigger after that up to 50mm between leds at the top all up I have a 15cm dia torch that’s 55cm tall

I had a spreadsheet I used to work it out… I’ll share it when I have my computer set up again…

P. S. Watch the voltage drop on a string that long

Hootie81: Thanks for your advice

I will power the strip every 3 meters from the main power unit.
What about a flat type, like a 2D torch?

Mine was made as a “2d torch” on thin card, each strip was 400mm long, then rolled up into the vase, but i didnt put the data line links in till i rolled it up, i’m not sure how lots of long data lines would effect things? mine are 2" long between the strips and work fine. maybe a zig zag pattern with the data line would be best but would probably require some pretty big changes in the code…

I have hacked in a color selector to @luz’s sample PHP website. i tried to keep it super simple, just click the color box and use the little javascript thingy to choose a color, it will first send the text color param’s then send the message.

I also made it change the color of the text in the textbox… it works on firefox but cant figure it out on my phone, if anyone is a guru with that sort of thing feel free to have a look for us!

Depending on how much time i have over the next few days i will try and make a settings page… because I hate typing into cmd prompts… those curl things are long!

Thank you.

Best wishes.

@Hootie81 it’s time for Spark-cli :slight_smile:

I use the spark-cli pretty much every day… but i like pretty icon buttons and text boxes that say exactly what its for!

And i dont think my wife would know how to even open the cmd prompt, let alone find the Dev ID and Access token and remember the key called mode and that mode=3 is for lamp… just to turn the lamp on, and that hasn’t even set the color or brightness!

1 Like

I’m running the message torch code, and while:
curl https://api.spark.io/v1/devices/xxxxxxx/params -d access_token=tttt -d “args=mode=2,brightness=255”
…works.

The message command:
curl https://api.spark.io/v1/devices/xxxxxxx/message -d access_token=tttt -d “args=Hello Spark”
… does not work. No scrolling text is seen. Any ideas as to why? Settings I have to change somewhere?

Terminal returns the text below, but no text scrolls:
“id”: “xxx”,
“name”: “xxx”,
“last_app”: null,
“connected”: true,
“return_value”: 1

try

curl https://api.spark.io/v1/devices/xxxxxxx/message -d access_token=tttt -d "Hello Spark"