Introduction: Display Messages From Twitter on the Small Screen

This prototype uses an embedded system and colour LCD screen to display messages from twitter.com. It was a fun way to learn Ruby programming, as well programming against this little LCD.

Twitter is a place to post brief updates on what's going on in your world. At a conference I recently attended, a LCD TV was used to "broadcast" updates from the organizers and attendees. This got me thinking...what about twitter for a (much) smaller screen?

And what's the point of all this? I'm not 100% sure. Who reads them? Why would people post their mundane daily doings, and why display them....there's no logical answer but for some reason it's addictive!


Step 1: The Hardware

The screen is the 'uLCD-128' from 4D Systems. I bought mine online from a company called Dontronics. This version has an extra 1MB of flash memory onboard, but it's not used in this prototype. The LCD has a serial interface and a well documented API, which makes interfacing quite easy.

The brains is a "system on module" called the TS-7400 from Technologic Systems. For less than $100 this little marvel runs Debian Linux and has a multitude of connectivity options: USB, ethernet, DAC, GPIO.

This project made use of one of the onboard serial UARTs. Both the TS-7400 and the uLCD have serial ports at logic (3.3v) levels. This makes wiring the two together a breeze as no interfacing circuitry is required.

Step 2: The Software

I've recently been learning the Ruby programming language, but needed something "real" to try it out on. Usually embedded systems are limited in languages to assembly or C. The TS-7400 is just that little bit bigger, runs Debian Linux and so has no problem with a language like Ruby. For that matter it could be done in C, Java, Perl or pretty much whatever language you chose - as long as you can run it on Linux.

Getting the software setup...
1. Compile Ruby from the source on the board itself. Another benefit of the TS-7400 is that cross-compiling isn't usually needed, the CPU has enough horsepower to compile in place (if you have the patience)
2. Compile the Ruby serial port library. This provides the necessary hooks to communicate with the uLCD.
3. Install the ImageMagick suite and RMagick library to handle image manipulation. One of the trickier aspects of this project was converting each user's profile image. The uLCD has unusual expectations for pixel and colour data which means some extra logic to convert the jpeg's from twitter.
4. Write the ruby program...

The program uses the Twitter API to retrieve the public timeline in XML format. The XML document contains the latest posts to twitter at that point in time, and links to retrieve each user's profile pic. The code simply loops through each of the "twits", massages the image files and writes it out to the LCD over the serial port.

Update: Twitter API clients are springing up like mushrooms. I just noticed a Ruby Twitter client on RubyForge. Something like this would make the program even simpler!