A blog for recording some of my miscellaneous projects on programming, home automation, wearable computing etc.

Friday, 15 March 2013

Snowboard HUD Part 4 - Basic display

This posts describes the construction of a basic display with some placeholders.

The idea is to produce something like this that displays the speed, altitude and temperature.

I'm using a Raspberry Pi and I want to avoid booting into the GUI so I need a way of creating a graphical display from the terminal display. I discovered that this is possible using Python and PyGame.

I think this was already installed but in case it isn't, the easiest thing to do is use aptitide to install python setup tools and then you can install any packages you want.

sudo apt-get install python-setuptoolssudo apt-get install python-pip

then you can use pip to install other Python packages e.g. PySerial

sudo pip install pyserial

So to create the display I'm going to use PyGame. This may not be the most sensible thing to do, but it does seem to work. Alternative suggestions welcome.

I used a PyGame tutorial from Pete Shinners to get me started, which was very helpful.

This first version of the display creates some text in fixed positions in the display as placeholders until I can actually start reading some data. There are also a lot of hard coded positions , which at the moment doesn't matter because it is set up to be displayed on the MyVu glasses.

You can see that this is actually being run on a Mac, which is good for editing the display layout, maybe doing some keyboard based control later, but the actual display needs to run on the Pi connected to the glasses.

You can see the same here being displayed in the glasses.

As a side note, I'm actually getting the code onto the Pi by copying it to a public dropbox folder and downloading with wget. I'm doing a lot of this through SSH-ing into the Pi, but I don't know how to start the script from the remote login and have the display update on the glasses that are connected via composite. Please let me know if you know if this is possible. You can just about hear from the video that I have a keyboard connected the the Pi in order to run the Python script.

I also had to mess around quite a lot with the resolution of the display. If the MyVu didn't like the resolution I would get a blank screen inside the glasses and couldn't get rid of it without restarting the Pi. The line configuring the PyGame display:

size = width, height = 650, 400
isn't the maximum resolution that I could probably use, but it does work.