Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65209 > unrolled thread

C++ to python for LED Matrix

Started byLiam Knott <limko9012@googlemail.com>
First post2014-02-01 02:13 -0800
Last post2014-02-01 20:29 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  C++ to python for LED Matrix Liam Knott <limko9012@googlemail.com> - 2014-02-01 02:13 -0800
    Re: C++ to python for LED Matrix Michael Torrie <torriem@gmail.com> - 2014-02-01 20:29 -0700

#65209 — C++ to python for LED Matrix

FromLiam Knott <limko9012@googlemail.com>
Date2014-02-01 02:13 -0800
SubjectC++ to python for LED Matrix
Message-ID<52c58d64-be7e-4241-aef1-2215acde6ec6@googlegroups.com>
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

[toc] | [next] | [standalone]


#65250

FromMichael Torrie <torriem@gmail.com>
Date2014-02-01 20:29 -0700
Message-ID<mailman.6297.1391311792.18130.python-list@python.org>
In reply to#65209
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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web