C++ to python for LED Matrix

2014-02-01 Thread Liam Knott
Hey folks,

So the last week or so I've been searching this site for information on how to 
control and program a LED Matrix (or a number of them) for a project. A few 
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 but I don't have 
that luxury right now).
So if anyone is willing to check Klaas's topic and code and convert it into 
python 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 of going 
about this project.

Note: Hoping I could achieve something like this but with the Pi: 
http://www.youtube.com/watch?v=FzHT-L-7jIA

Cheers!

Lknott :-D
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: C++ to python for LED Matrix

2014-02-01 Thread 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.

-- 
https://mail.python.org/mailman/listinfo/python-list