Writing an LED Matrix display driver

I was hoping you guys could give me a few suggestions on how to write a display driver. As I have mentioned in several other posts, I do a lot of work on embedded platforms like AVR's. Lately, I have been working on an 8x8 LED Matrix video game system. I have working code that can set pixels on the screen, but I am not sure how to go about writing a higher-level driver. It should be capable of drawing sprites saved in memory, and performing operations on those sprites such as rotation(only at 90 degree angles, as rotations at such a low resolution would be greatly distorted).

I was thinking about an approach similar to SDL(keep in mind I am using pure C).

So, what do you guys think?
I have no clue how to write drivers, but I'll post anyway.

I don't see your problem. There isn't very much you can do with such resolution.
You should use a buffer to draw stuff. Then call a function to set appropriate pixels.
You could use matrices for simple transformations (moving, scaling, rotating). That probably isn't necessary if you're only going to do 90 rotations (though 45 might not look bad either).
You could use polygons and then texture them. That way images would react better to stretching.

If you rally wanted, you could do 3d support too. It's not hard. It's just ridiculous..
Last edited on
Thanks for your reply, that is kind of what I expected.

I do have another question:

Say I have an array of 8 bytes, each bit in the array would represent a pixel. How would I go about rotating it 90 degrees efficiently?
Are you sure you need such compression? Also, do LED's only have two states? And how much memory do you have?

Here's some code I came up with.
Rotations are clockwise. I feel it can be further simplified, but I don't know how..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>

void print(char* a){
    for(int y = 0; y < 8; y++){
        for(int x = 0; x < 8; x++)
            std::cout << (a[y] & (1<<x) ? 'X' : ' ') << ' ';
        std::cout << '\n';
    }
    std::cout << '\n';
}

int main(){
    char m[8], n[8] = {0};
    for(int i = 0; i < 8; i++) m[i] = rand();
    print(m);

    for(int y = 0; y < 8; y++)
    for(int x = 0; x < 8; x++)
        //choose one:
        //n[y] |= (m[7-x] & (1<<y)) >> y << x ;//90 deg
        //n[y] |= (m[7-y] & (1<<(7-x))) >> (7-x) << x;//180 deg
        n[y] |= (m[x] & (1<<(7-y))) >> (7-y) << x ;//270 deg

    print(n);
    std::cin.get();
    return 0;
}

Ok, thanks alot.

Are you sure you need such compression?

Yes. The LED Matrix I am using is bi-color(Red, Green, and Yellow when both Green and Red pixels are lit in the same position), so it takes a total of only 16 bytes of data to update the display. If I did make it one-byte per pixel, it would take at least 64 bytes.

The micro I am using has 2KB of ram. I think the extra memory is worth the hassle personally.

I'll test your code in a little while, thanks a lot.

Also, I will post all of my code after it is complete.
Last edited on
Topic archived. No new replies allowed.