Adafruit 32x32 matrix - drawing images

Hi there!

I’m brand brand new to Arduino, but I had seen several tutorials for drawing pixel-based images by building a LED matrix.

Well, I purchased the 32x32 matrix, and I have found some basic drawing commands in the Adafruit library, however I am trying to draw an image of my own.

The matrix is hooked up to an Arduino Uno with the RGB Matrix Shield from Adafruit.

I’ve found that I can’t just code every single pixel one by one since that takes up too much memory.

I’ve seen other people do it, but I can’t figure out how to assign values to each of the pixels.
I have a 32x32 set of images, and I can even convert those images to RGB values, but I can’t figure out how to draw those values to the screen.

Any advice?

If the image is static, use PROGMEM.
Each image will occupy 3072 bytes, so you should be able to store a few.

Amazing - I figured out a way to store the individual values to PROGMEM now, but how do I go about drawing those items onto the screen? My apologies if that is too big of a question.

By reading them out of PROGMEM (instead of RAM) and writing them to your display driver.

I have my code below (so far) below.
I stored the values to PROGMEM - could you please help with the sending to the matrix portion?

These are my very first few weeks of coding at all.

I appreciate it so much!

#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library

#define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega)
#define OE 9
#define LAT 10
#define A A0
#define B A1
#define C A2
#define D A3

RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);

void setup() {
// put your setup code here, to run once:

static const int8_t MM1 PROGMEM = {0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x00, 0xff, 0x0a, 0x0d, 0x0e, 0xff, 0x1f, 0x27, 0x2a, 0xff, 0x20, 0x28, 0x27, 0xff, 0x07, 0x08, 0x08, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x09, 0x08, 0x07, 0xff, 0x0a, 0x05, 0x13, 0xff, 0x27, 0x4a, 0x83, 0xff, 0x69, 0xc5, 0xf3, 0xff, 0x88, 0xf5, 0xfc, 0xff, 0x40, 0x6c, 0x73, 0xff, 0x09, 0x07, 0x0f, 0xff, 0x04, 0x03, 0x04, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x08, 0x06, 0x06, 0xff, 0x1d, 0x1e, 0x43, 0xff, 0x0c, 0x43, 0xde, 0xff, 0x03, 0x3c, 0xc8, 0xff, 0x34, 0x60, 0xab, 0xff, 0x6a, 0xc5, 0xf7, 0xff, 0x88, 0xf6, 0xff, 0xff, 0x4a, 0x81, 0xbf, 0xff, 0x11, 0x12, 0x37, 0xff, 0x03, 0x01, 0x03, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x03, 0x01, 0x00, 0xff, 0x1d, 0x1b, 0x2e, 0xff, 0x12, 0x3e, 0xd1, 0xff, 0x00, 0x61, 0xf2, 0xff, 0x02, 0x7d, 0xd6, 0xff, 0x08, 0x41, 0xaf, 0xff, 0x2d, 0x51, 0xb3, 0xff, 0x69, 0xcb, 0xfb, 0xff, 0x88, 0xff, 0xff, 0xff, 0x3f, 0x81, 0xcb, 0xff, 0x0e, 0x12, 0x33, 0xff, 0x03, 0x02, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00};

}

void loop() {
// put your main code here, to run repeatedly:

}

Start here

You probably don’t want to limit the scope of the image to just setup ()

Yes, I realized my mistake and moved that above the setup.

It's the setup where I'm stuck. I looked at that PROGMEM link to figure out how to set the pixel information as a stored variable.

Now, I am needing to figure out how to write that information to the screen.

Probably a pixel at a time.

This could be a good time to investigate the AVR 24 bit datatype

I tried to write it a pixel a a time, but the code needed to write one line of lit pixels was over 60% of the memory.

Thanks for your help. I'll continue banging my head against this wall.