Is there a sane way to display bitmaps/animated gifs on an LED matrix? Obviously,

Is there a sane way to display bitmaps/animated gifs on an LED matrix? Obviously, they’ll be formatted to the right dimensions.

I suppose I could convert them to arrays - but that gets a little crazy for 3 colors. If I could toss a bitmap onto an SD card and display that, it would be cool.

that would be awesome! The only way i have found todo so is by running the image through a script in mathlab which gives be rgb for each pixel. Then dropping that into a fastled script with a delay.

I would probably just create a PHP script to output the data from a given image. I was looking around at using an SD card, and it’s pretty simple, as SD cards are SPI devices! Buy a SD card with adapter, wire up the adapter, and away I go.

It’ll just make things easier if I can draw patterns in a paint program, rather than try and implement algorithms.
Not to mention I won’t have to create fonts.

So, showing bitmaps is what I’m doing with my POV display. As @Larry1 suggested, I use a c++ program to read every pixel and dump them in a single stream binary file that contains RGB values for each pixel. From there I read in each column I need to display.

Expanding on that, you can read as many columns as you need for your matrix and push them out to each column before finally calling LEDS.show() on all of them.

Now depending on how your matrix is build, whether you have strips in columns or in rows, you might be able to use a regular BMP file without needing to do any kind of conversion, just read them as is.

Animation on the other hand is a different beast. Fast reading and updating … :slight_smile:

I wish you on that one Noel it’s 10000x easier for me to draw patterns.

well, my matrix is wired up in a serpentine manner, but I have written a column flip routine. so pushing data out, then flipping the odd columns is pretty simple.

Most animations I can think of will be scrolling, so not TOO bad.

I’ve been looking at algorithms, and have implemented Bresenham’s line algorithm, and will be adding circles and other shapes right away. maybe a plasma animation would be sweet, too.

Okay, so I’ve converted an image into an array of arrays. Image: http://twyst.us/arrows.png
output: http://twyst.us/img2array.php

Obviously, a little data massaging is in order, but it’s there. Any suggestions on how to store in PROGMEM? I figure that’s the best place to start. Loading a full image will be ram intensive - 672 - so I figure loading a row at a time will be best - that’s only 21 bytes.

I’ve been fiddling with this for my 32 x 18 panel connected to a Yun. Two problems I’ve run into so far:

  1. With my leds[] array taking 1728 bytes of my 2560 bytes of RAM, importing the Bridge library (which allows me to talk to the Linux side of the Yun and access the SD card) gets me into a ridiculously low ram crashy state.

  2. If I pretend the panel is smaller, there’s something screwy going on with (my understanding of?) the Bridge library, such that using readBytesUntil() to read directly into the leds[] array from a PPM/PBM file on the SD card (http://en.wikipedia.org/wiki/Netpbm_format) doesn’t work right.

@Noel_Bundy Why bother with the brackets at all? As long as you are reading in multiples of three, you don’t need the brackets. Save the space and the code to strip them out.

My processed images are one long stream of r,g,b,r,g,b,r,g,b (correction), rgbrgbrgb,etc., etc. (I store in binary format, so I don’t need any delimiters. The same applies to a standard BMP file, no delimiters used, juse one long stream for each row.) When I read a column, it’s a full NUM_LEDS * 3, which is read directly in the “leds” array. I don’t need to process the incoming data, just read and call LEDS.show(). I also store everything on an SD card, leaving the AVR to just the actual program.

I’m not sure how well it will cope with having to buffer everything before sending it out to the string. I wonder if you can read a full row in, push it out to the string, advance the string forward (so the data is now on the second row), read the next row and push it out again. Basically all your doing is reading data for the first row only and pushing the string forward each time. Not sure if my explanation makes sense …

The brackets were more for my sanity. Easy enough to change that. I’m going to try making a home made SD card reader out of an adapter, and see how that works. heck, if that works, I have a LCD shield that I could use for selecting images. Long wired cord, I guess.

If you’re going for a hack, this is the best one I’ve seen for a regular sized SD card: http://www.ppl-pilot.com/logger/

I use micro cards in my projects … harder to hack, but not impossible.

So I got image display working. Go me!

Now I just have to:
a) convert a 3x5 font, like Pixelzim
b) create font drawing code for vertical text that allows arbitrary cursor positioning (for scrolling)
c) finish out drawing routines, like rectangles/round rectangles
d) SD card reading instead of PROGMEM.
e) LCD shield support for picking animations

a & c are easy, b is tough, d and e are optional.

Add (d) to (a) & ©.

Well, yes. But small steps. (b) is the one I’m really stumped by - it shouldn’t be TOO hard. Also, I should implement image wrapping/positioning so I can move backgrounds separate from stuff layered on top.

Woot. Productive day at the hackerspace. made an SD card adapter hack, and got it to work with the LCD keypad shield, and it should also work with the LEDs. And also got the image stuff done, so I don’t even need to do a font system - I’ll just make images of the text I want to display!

Aaaaaand, crash & burn - massive memory issues on an Uno - the SD lib eats most of the ram I have available, causing the whole thing to crash and burn. I guess I need to upgrade to a mega or something. :frowning:

SD or SdFat? I use SdFat because it’s much faster, but I thought it also compiled smaller, but I forgot.

I’ll look at SdFat, but the issue isn’t sketch size, it’s how much sram it’s using - apparently it uses a 512byte buffer for reading, which shoots my ram usage into orbit.

Oh yeah, there’s a limit on that buffer (regardless of which library you use.) On my POV unit, I read 144 bytes at a time, so every 4th read, it has to go back to the card to fill the buffer again. It took me a while to figure out why every 4th read was taking longer than the rest. Till I slowed things way down and noticed it was only reading every 4th cycle. Adding the numbers up then made sense …

Right. So either I move to a Mega (which I don’t have), or no SD card. I do want to keep the LCD + keypad, since I plan on integrating all the electronics into a vambrace, and switching stuff will be neat.