header text

a blog of things that I (eventually) make work

Sunday, 31 January 2016

The Bill Murray GIF Player (BMRGP)

I was bored on a train earlier, so I wrote this Processing sketch that pulls a random GIF of Bill Murray from the internet every time you click the mouse.

I guess it was inspired by an exhibition I went to at the Baltic in Gateshead, called Bill Murray: A Story of Distance, Size and Sincerity by Brian Griffiths. It's as cool as it sounds.

Anyway, the code is on my Github if you want to compile and play with it. You'll need the GifAnimation library and an internet connection, since it uses the Giphy API.

P.S. I didn't screw up and leave my API key in the code, it's a public beta key.


Friday, 29 January 2016

Code development - Now with icons!

After surprisingly little work, I've arrived at a version of the smart mirror Processing sketch that includes a limited amount of error checking and also displays icons to represent the weather.

The icons were sourced from an awesome pack called Climacons by Adam Whitcroft (thanks!).


Integrating them into the sketch was surprisingly simple; The Yahoo weather API includes a numeric parameter that indicates the current weather. This saves needing to do string comparisons to determine which icon to use. Instead, I was able to construct a CSV file which has columns for this numeric value, the corresponding weather, and the filename of the icon that most closely matches the weather state. Then it was a simple matter of pulling out the numeric value from the API, looking the value up in a table, and displaying the relevant graphic.

All of this serves to reinforce why Processing is such a great language for fast development of ideas, and makes me realise exactly why a program in Processing is referred to as a "sketch".

Raspberry Pi setup progress

Since the smart mirror project is essentially an embedded system, the easy choice for the hardware was a Raspberry Pi. They're cheap, well documented, and more than powerful enough for my needs (plus I wanted an excuse to buy one).

I also purchased a 5" TFT to use with it (<£15 on Amazon) which has a composite video input.

Having set everything up, I'm thinking of switching out the TFT for something that uses HDMI as an input. The resolution of the screen (800 x 480) is a lot to ask of composite video, and the result is a slightly flickery image.


Wifi was super easy to set up, generic drivers for the dongle I bought got installed straight away. Performance seems to be lacking but that's a problem that can probably be solved with a driver update. The (Poundland) bluetooth dongle I picked up doesn't seem to work OOB, so that will require a bit of work to investigate.

Next steps: installing Processing, Git and SSH to enable me to push code to the Pi and run it.

Sunday, 24 January 2016

Fun with the TfL API, Yahoo Weather and Processing

Recently I've been playing around with pulling data from the Transport for London API in Processing. There's a crazy amount of possibilities for what you can do with the data that TfL can serve up, but my idea is relatively simple.

I'm pulling live data on bus arrival times for the stop at the end of my street, as well as the current status of the Northern Line (my nearest tube line) and the current weather. The end idea is to have a small screen set up in my hall with a Processing sketch running on a Raspberry Pi that will constantly provide me with data about when my next bus to work is, if I would be better off taking the tube, and whether I should maybe take an umbrella.

By default, the TfL API returns data in JSON format. Before starting this project I'd never worked with JSON before, so there was a bit of a learning curve involved. Processing can natively import and manipulate JSON objects (since Processing is essentially Java), but some of its abilities are somewhat limited.

Because of this, my sketch takes the useful info from the JSON object (bus number, destination and arrival time) and turns it in to a Table, which Processing is much better at manipulating. This allows me to sort the data by arrival time, so I can display the next bus arrivals.

The result I currently have is something which mimics the electronic arrivals boards seen at some bus stops:


Compared to my version:


Check out that Helvetica.

At the bottom you can see the fruits of my efforts with the Yahoo Weather API. This is slightly easier to work with in Processing as it will directly serve XML to the sketch.

Code snippets will follow when I've properly optimised it and added in error handling. This is important since this sketch is intended to run indefinitely.

Friday, 22 January 2016

hello world

The intention is that this will be a blog where I post about projects. Projects in this sense meaning whatever development/DIY/arty things I'm doing at the time.

Sometimes I'll be posting enough detail to be able to replicate my results, sometimes I'll be posting a small code snippet when I get something working.

Firstly I'll be documenting my smart mirror project.

Watch this space!