C++ to python for LED Matrix

L

Liam Knott

Hey folks,

So the last week or so I've been searching this site for information on howto control and program a LED Matrix (or a number of them) for a project. Afew Topics have caught my eye, with me originally having in mind using a Maxim MAX7221 to control the matrix, but none more than Klaas's: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=41713.
This was almost perfect for me, until I saw the code was in C++ and from the title all I know is Python. So after checking the code out and trying to figure how this language works I just couldn't break it down and Unfortunately I don't have a lot of time to learn C++ ( would be great if I could butI don't have that luxury right now).
So if anyone is willing to check Klaas's topic and code and convert it intopython that would be awesome, even if someone would explain how the code is working that would be great, oh and don't be scared to comment on ways ofgoing about this project.

Note: Hoping I could achieve something like this but with the Pi:

Cheers!

Lknott :-D
 
M

Michael Torrie

Yes you could use Python for this sort of thing. The link you posted is
just using a kernel spi driver that Python can write to just as well as
C++ can (via it's /dev/spidev0.0 file). There is a python library that
can talk to SPI in Python on the pi:

http://www.100randomtasks.com/simple-spi-on-raspberry-pi

You still need to know some low-level stuff though. Like hexadecimal,
binary bit-wise operations, etc.

Definitely talk to people on the Raspberry Pi forum. They are doing
this stuff frequently.

Also don't be afraid of C. Learn it. You'll be glad. The code you
linked to looks more complicated than it really is. The ioctl stuff
looks complicated. But everything else is easy. If it weren't for the
ioctl stuff, which I know can be translated to Python directly but I'm
not quite sure how at the moment, the rest of that code could be
transliterated into Python in very short order. The trick is to make
the code more pythonic, and use classes when appropriate to encapsulate
things. I'd make a class that talks to SPI, for example. It would open
the file, set the ioctls, and then provide a basic interface for writing
to the bus. Then from that I'd build another class that implements the
matrix abstraction, using SPI class for the low-level stuff.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top