C++ to python for LED Matrix

Michael Torrie torriem at gmail.com
Sun Feb 2 04:29:13 CET 2014

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:


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.

More information about the Python-list mailing list