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


Groups > comp.lang.python > #65250

Re: C++ to python for LED Matrix

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <torriem+gmail@torriefamily.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'talks': 0.03; 'binary': 0.07; 'implements': 0.09; 'skip:/ 10': 0.09; 'python': 0.11; 'posted': 0.15; '(via': 0.16; 'bus.': 0.16; 'file).': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'stuff,': 0.16; 'stuff.': 0.16; 'subject:python': 0.16; 'appropriate': 0.16; 'library': 0.18; 'file,': 0.19; 'things.': 0.19; 'translated': 0.19; 'header:User-Agent:1': 0.23; 'driver': 0.24; 'example.': 0.24; 'looks': 0.24; 'sort': 0.25; 'order.': 0.26; 'header:In-Reply-To:1': 0.27; 'rest': 0.29; 'operations,': 0.30; "i'm": 0.30; 'code': 0.31; 'though.': 0.31; 'class': 0.32; 'stuff': 0.32; 'interface': 0.32; 'another': 0.32; 'quite': 0.32; 'open': 0.33; "i'd": 0.34; 'could': 0.34; 'basic': 0.35; 'classes': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'c++': 0.36; 'doing': 0.36; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'short': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'is.': 0.60; "you'll": 0.62; 'provide': 0.64; 'more': 0.64; 'afraid': 0.65; 'linked': 0.65; 'yes': 0.68; 'subject:LED': 0.91
X-Virus-Scanned amavisd-new at torriefamily.org
Date Sat, 01 Feb 2014 20:29:13 -0700
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12
MIME-Version 1.0
To python-list@python.org
Subject Re: C++ to python for LED Matrix
References <52c58d64-be7e-4241-aef1-2215acde6ec6@googlegroups.com>
In-Reply-To <52c58d64-be7e-4241-aef1-2215acde6ec6@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6297.1391311792.18130.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391311792 news.xs4all.nl 2906 [2001:888:2000:d::a6]:49765
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65250

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

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

csiph-web