Sending large amounts of information to the Core

Hi,

I’m a relative beginner using the Spark Core connected to a 10x10 LED matrix, and I want to build web pages that send each pixel RGB information to the core, so that I can then stuff like upload an image on the website and have the server send over the image to the core which then displays it on the 10x10 matrix. I don’t have a specific roadblock yet as I’m only starting - my question is whether there is a better way to do this than the one I’m describing below:

Seeing as the maximum arg size for the Spark Function is 64, I will have to repeat that call numerous times to send all the information. The strings will look something like:
“1&1:255,0,0;2:0,255,255;3:0, 255, 255…” Where 1 refers to the image ID and & is the delimiter then the rest is organized as “pixel number : red, green, blue ;”.

At the Spark Core end I’ll parse the strings into a 2D int array, with strchr(), strtok() and atoi(), which I’ll use then on the Neo Pixel library functions. I’m not sure what are the implications on memory if my 10x10 matrix grows… is this the best way to handle sending relatively large amounts of information to the Spark Core?

Thanks!

Idea: mixture of push/pull!

  • your webapp stores the pixels-to-set assigned to a random token
  • send this token to the spark via a cloud function call
  • let the spark connect to your webapp including the sent token
  • the webapp looks up the token related data and streams it to the core

Advantages:

  • no more limited to any size! (ok, nearly.. right now you'll be fine with < 8kb)
  • you can send binary data (including 0-bytes) -> much less data to be transferred
  • you will limit the whole data transaction to two requests (spark push -> webapp pull)

Hope that helped! :sunflower:

4 Likes