[HH] Seeking help on Programming I2C bus in python on Raspberry Pi

Tom Metro tmetro+hhacking at gmail.com
Thu Nov 15 14:36:52 EST 2012


Ming kuo wrote:
> Hi Guys, I was recently introduced to this group, so here is my first post.

Welcome to the group.


> I figured out the wiring to get the bar to light up using the same codes
> as above.

Sounds like you've got the hard part done. If you've gotten that much to
work, then you've proven the hardware works, and the basic software
works. Now you just need to tweak the behavior.


> I am stuck...on the python code to control the I2C.
> This is my immediate challenge to figure out how to program the
> I2C for the LED bar...

Can you clarify?

You said above that you succeeded in getting the bar to light up using
the same setup as the article you referenced. That implies you have a
working I2C driver and some Python code using it.


> ...I need to program a python code to POV display the messages which
> i can imaging that it get pretty challenging given how to form a
> character with LED while timing the rotation.

So POV is persistence of vision? You're looking to build something like:
http://www.youtube.com/watch?v=fJBYOU-Y-ZU

How do you plan to move the display?

To build on what Jon Evans said in his reply, it sounds like what you
have left to do is less hardware hacking and more basic Python coding.
Looking at the sample code:
http://www.skpang.co.uk/blog/wp-content/uploads/2012/06/ledchaser.py

they provide a set_led() function, so you'll need to remove the two
chunks of code used to strobe the LEDs ("# Move led left " and "# Move
led right") and replace them with your character generating code.

Not trivial but given that POV displays seem to be popular, likely you
can find some existing code for the character generator. If not, you'll
need to dig up a library or lookup table that maps characters to dot
patterns. Basically a dot matrix font. Then build a function that when
given a character, translates that into the equivalent array of dots.

I'd be inclined to use an architecture where rows of dots are pushed
onto a stack, and then some background process is responsible for
pulling a row from the stack and lighting up the LEDs on a steady clock
rate. (I'm not sure if that's easy to accomplish in Python.)

I'm guessing that with most of these POV displays, there isn't any real
synchronization between the display motion and the strobing. The builder
simply tunes the strobe rate until it works most of the time for
whatever RPM their display ends up running at.


> So any help through email or in person would be greatly appreciated.

Post some follow up questions as you get stuck and we'll see what we can do.

 -Tom



More information about the Hardwarehacking mailing list