Posterous theme by Cory Watilo

Terminal Life

Terminal-life

After completing my first iteration of Conway's Game of Life I was unhappy with the performance. After a bit of testing I discovered that the real bottleneck wasn't in my algorithm, but in the overhead associated with the pygame module that was taking care of the graphics.

I just completed a branch of the code that does away with the pygame module. Instead, it runs in a bash shell. The program uses tput to read in lines and columns available in the terminal, and also to move the cursor back to the top left before each new generation is draw. Of course the limitation here is that it only works on LInux. I was able to maintain the look by using a Unicode character which draws a box. That's a screenshot of the code running.

What I've learned about using the Beautiful Soup Python module

I like to use Beautiful Soup in combination with urllib2 to parse HTML from Python scripts. The problem is that I spend like 30 minutes relearning how to use it every time I do a new project. So, for my own use (and maybe yours) here's my quick tips for syntax.

I always start off the same way, two lines of code to snag and objectify the HTML:

html = urllib2.urlopen("http://hackaday.com/comments/feed").read()
soup = BeautifulSoup(html)

From there it's a matter of working with the 'soup' data object. This one gets an RSS feed of comments. They have are partitioned into <item> tags which you can traverse like this:

soup('item')[0]

Which is an array with an index (this is item 0). But you can also iterate through the list using:

for item in soup('item'):

From there just walk through the tree hierarchy. Here's how you can get the publish date (string surrounded by <pubdate> tags) for the item. Notice that you need to index the pubdate in order to access its string data:

soup('item')[0]('pubdate')[0].string

The part that always confuses me is the need for the index. It identifies which tag you're accessing in case there are multiples in this part of the tree. You can get the number of tags found by wrapping your tag term in the length funtion:

len(soup('item'))

Should always return 15 because that's the number of comments Wordpress is set to publish in the RSS feed.

There are other ways to do this using soup.findAll, but I find this one usually works the best.

Sneak a peek at the LED Lighbulb schematics

I'm working feverishly on a follow-up to my original LED light bulb post. But if you want a sneak peek at the schematics here they are. One outlines the control circuitry, the other the power supply. I'm hoping that I'll have this writeup down in time to publish tomorrow over at Hackaday.com

(download)

Stream music from Linux to iPad - no app needed

I'm a Linux guy but I've also got this iPad. I don't run iTunes so there's no music on it. I have a collection on my home server that feeds the computers and XBMC boxes in the house. But what about the iPad? I had looked all over, and managed to patch together a working system using gnump3d but it was a pretty gruesome hack.

Well, I've got some functionality working now. I installed mod_musicindex for my Apache server. It's just an added layer on top of the indexing feature that Apache has. I like it, and it works somewhat acceptably. I can even password protect the directory, but I can't seem to get anything to stream outside of the LAN. I also have one album that I can't play but I have no idea why.

Is this crippled functionality really necessary? Why can't the iPod app have built-in web address browsing? Nice hardware, but I detest crippled software. Grr!

Light bulb microcontroller salvaged with HVSP

The ATtiny13 microcontroller from that LED light bulb is now waiting for new firmware. I used High Voltage Serial Programming to erase the chip, which clears the lock bits. I then reset the high fuse back to 0xFF. It was 0xFA before which disables the reset pin (and enables brownout detection) making In System Programming impossible.

I finished mapping out the PCB and it does use the example circuit from the buck converter's datasheet. Looks like it was outputting 12V and using a 7V zener diode to step down to the 5V source the tiny13 needed. I'm going to depopulate the PSU and patch in a 12V feed for further testing. I'm thinking my first project will be a red/green flasher for a Christmas porch light.

LED lightbulb schematic

Led-logic-sch

I had a bit of time to test out the PCB from that LED light bulb. I've just been using continuity tester and ohm-meter for this. Here's the LED logic. High-side transistors but I haven't quite figured out how the resistors are wired. I've also established the A/C side of the switching regulator but I'm having trouble figuring out the output. Similar to the example in the datasheet but not quite the same.

Learning Git

I decided to learn Git. Our file hosting over at Hackaday.com has been hosed for a while and I wanted a good place to host code. I knew that Adafruit and others use Github. I had looked into that and bitbucket a while ago but I've never really been pleased with subversion when it came to merging and resolving conflicts. So I found a guide over at Stack Overflow that is pretty handy. I read through the commands and got myself setup, committing my code to a repository and all that jazz. But it wasn't until I got to the bottom of that guide that I found out about Understanding Git conceptually. Wow! Fantastic. Not only is it very well written, but when you understand what Git is actually doing you can begin to see how truly brilliant it is.