Get iplayer on the Raspberry pi XBMC – RaspBMC

I wrote a post a while back about installing Sam Nazarko’s Raspberry Pi flavoured XBMC – Raspbmc, but now things have moved on a bit, rendering my original instructions out of date. Updated update: RaspBMC is now available as part of the NOOBS installer.

Sam has now released the final release version of Raspbmc so I thought I’d give it a go.

Raspbmc
Now with a lovely logo too!

My criteria in trying this out is, is this something I could use everyday and is this something I could set up for an older relative and just leave in place

The updated release version of Raspmbc now has a very easy to use installer, and is really simple to get running. Just prepare your SD card using the appropriate installer (I’ve been using the Mac version) pop it into your Raspberry Pi (ensuring it has an ethernet connection) switch on the power and then go and have a cup of tea.

Everything’s lovely and smooth – the menus work slickly, and the behind the scenes hard work on Raspbmc has really paid off. It behaves like a commercial product, and although it does pause occasionally it’s still far superior to the bundled apps that come with a lot of  (often very expensive) smart TVs.

It also works well on a Motorola Lapdock (adjusting the screen size automatically from the HDMI monitor I originally installed it on).

In face you often have to remind yourself that this is running off a $25 computer.

Once you’ve got it running adding WiFi is nice and straightforward – I’ve been using the Edimax EW-7711UAN 150Mbps Wireless adapter which is detected and works with my BT hub without any issues. You just need to enter your network SSID and login using the Raspbmc settings option which is under programs.

Installing iPlayer on RaspBMC

Youtube and Vimeo plugins can be found in the ‘add plugins’ section and work out of the box.

To add iplayer – possibly the main thing I use my streaming box for these days there are a few additional steps (for just iplayer follow the step by step guide see this blog)

You’ll need to add some additional repositories –

There’s actually a handy plugin which automates the addition of new repositories, so we’ll install that first.

With the Raspberry Pi connected to the internet:

Home Screen to Settings > System Information. You need to locate and take note of your Pi’s IP address – this usually starts with 192.168.1.(then a number)

Next on another computer, you’ll need to connect via SSH – on a Mac or Linux PC open the console and use:

ssh pi@(your IP address)

the standard password is raspberry. Select yes and enter your locale details in the menus that appear – this will then end up with a [email protected] prompt.

On a PC you’ll need an SSH tool like PuttY

Copy and paste the following into your terminal window:

get http://passion-xbmc.org/addons/Download.php/plugin.program.repo.installer/plugin.program.repo.installer-1.0.5.zip

Then back on the pi go to system -> addons (in XBMC backspace moves up through sub-menus, so you might have to hit this a few times to find the top menu) and select install from zip file option.

Select homefolder and then plugin.program.repo.installer-1.9.5.zip

you should get a little message in the bottom right hand corner to say it’s been installed.

then select the programs icon and run the Repositories Installer

There’s a long list – iplayer can be found in Hitchers Repo, 4OD in the Mossy repo. Once this is installed you can navigate to system – settings – add-ons to install, and then video- Add-ons to watch.

For much more – including things like setting this up for airplay, using an ipad as a remote – and to support this excellent project – check out Sam Nazarko’s book for more info: Raspberry Pi Media Center

Tweet your MP

Ever wanted to send a tweet to your MP? not sure if your Member of Parliament has embraced social media? want to put a handy tool to do so on your website?

Tweet Your MP
Tweet your MP

Here’s a little script I wrote to find your MP using a postcode (via the TheyWorkForYou.com API) and send them a tweet. Info, source and background below.

It’s possible to tweak this tool to return email address, postal address, phone number and facebook page (if they have one) – you can also add custom information to each MP as well. My data set includes 436 twitter accounts for MPs – slightly more than Tweetminster’s 409 but I have included auto twitter accounts (so people can see you’re tweeting your MP, even if they don’t respond). I’ve tried to avoid spoof accounts.

Bit of background about this tool

This tool works by converting the postcode into a constituency name on TheyWorkForYou.com, and then matching this constituency name with MP’s details on a local MySQL database table. If you don’t want to use TheyWorkForYou.com’s API it is possible to buy a constituency postcode database from Ordinance Survey for £350.

For a while I’ve been working on an open-source activism tool. It was born out of curiosity, an excuse to learn a bit more about php and as a way of proving email to MP actions courtesy of the very useful theyworkforyou.com API.

Unfortunately it became on of these projects that got more and more complicated – once I’d got round to adding a graphical user front end, SMS texting, and add on modules it started getting a bit too big for me to handle. Plus I started encountering problems with PHP’s send mail function getting blocked by outlook servers, experimented a bit with pop mail senders and then started looking at using online cloud services.

The past 2 organisations I’ve worked for have used off the shelf tools instead, making the aim of the project a little bit redundant.

I still have a copy of all the code (with lots of comments) if anyone would like it – it’s in an alpha sort of works if you’re prepared to spend a bit of time tinkering with it state. Just drop me a line. All I ask is that if you do improve on it, please make it publicly available (it is GPL licensed).

I’ve also been thinking about the effectiveness of email-your-mp actions with identikit emails embedded in them – I think using twitter or even printed out letters might be a better way forward to creatively attract attention, and avoid the boring accusations of ‘slacktivism’.

So in the meantime I’ve taken the bits of the tool that did work, and have reworked them into a much simpler ‘Tweet your MP’ toolkit. The idea of this is to provide a simple widget you can embed on your website – I’ve seen plenty of websites that just link to TheyWorkForYou.com, or refer people to google, so this provides a way of keeping activists on your page.

In the example above I’ve just gone for twitter and website information – but with a few tweaks to the code you can add email your MP (via a mailto link) phone your MP or write a paper letter to your MP functionality.

Requirements & the code

To get this to work you will need access to a MySQL database and PHP. This is currently running on my server which is a cheap-as-chips 123-reg setup. Check your ISP’s documentation for support on how to get these logins. I’ve labelled the code to show what it does.

If there are any corrections please get in touch with me and i’ll add them.

Download the code from GitHub

I’m updating this to fix problems and add enhancements. At the moment the code does contain a bit of stuff left over from the webtivist project. The GitHub version will always be the most up to date.

To make this work you’ll need to upload the MP data spreadsheet to your MySQL server (I used the import function on my 123reg hosting and it worked fine) this has every MP’s contact details – if you’d like access to this please drop me a line as I’d like to keep track of who’s using it!

Then you’ll need to edit the settings.php file to include the login for your MySQL database, the hostname and tablename for your MP database.

You’ll also need to apply for a theyworkforyou.com API key – there’s usually no charge to use this for small volumes. They prefer it if you ask them if you’re intending to use it a lot. Please Please don’t use this to send identical emails to MPs.

For the twitter part you’ll also need a Twitter API key  I changed this to use the more simple @mention option on twitter.

Corrections / suggestions and contributions

Thanks to MPs being arrested for things, standing down or departing, this data may become out of date over time.  If there is incorrect information please let me know and I’ll update it.

This script makes use of the TheyWorkForYou.com API and Ruben Arakelyan’s php script. Check the comments in the code for more information.

Update: this script has now moved to tweetyourMP.com

Raspberry Pi model A arrives…

A new Raspberry Pi model A arrived in the post yesterday. I’ve got a very specific project in mind for this slimmed down model – but for now a couple of pictures.

It lacks Ethernet and has 256mb of RAM, but consumes less power (about 1/3rd) –  than the existing model B version. It’s also a bit cheaper so you can now buy a computer which can do high definition video for less then the price of a blu-ray movie.

Raspberry Pi model A (fisheye view)
Via a big bendy eye camera…

From the side it’s noticeably thinner (1.7cm deep allowing for the SD card compared to 2cm) than the existing model B – the widest components on the board being the video connector, followed by the audio out and GPIO pins – the single width USB and HDMI connector being about the same width. So there’s also some scope here to make it even thinner with a bit of careful desoldering:

Raspberry Pi model A side view
and from the side

A year ago I’d never consider bringing a soldering iron near a PC, but perhaps that’s the effect of the super-low-cost computer.

Using a Raspberry Pi LEDborg as an IFTTT.com blinky LED notifier

Here’s a little project to build a very simple web-controlled multicoloured LED indicator with your Raspberry Pi and the PiBorg LEDBorg board.

Using IF This Then That (IFTTT.com) – a simple online service which allows you to daisy chain different web things together – you can light up your Pi’s LEDborg based on particular events.

Take for instance it’s predicted to be frosty outside – your Pi could light up blue, or perhaps someone’s just mentioned you on twitter – your Pi could light up green. Or your boss has just emailed you and your Pi lights up red. IFTTT allows you to set up alerts based on a wide range of events. You could even potentially use your Pi to trigger events by sending information to IFTTT – but in this example I’m just using it as a receiver.

LEDborg
Spidey checking out the LEDborg

At about a fiver, the LEDBorg is one of the cheapest add-ons available for the Pi that plugs directly into the GPIO (General Purpose Input and Output) pins. It consists of a single 3 colour LED surface mounted on a board with a controller chip. It’s fairly simple – if you’re feeling adventurous you could probably have a go at building your own version, although it would be tricky to make something so compact. The LEDBorg fits neatly over the GPIO pins and would probably fit inside most Pi cases – I’ve opted to use my upright lego case to show off the light better.

First you need to fit your LEDborg, and install the software according to which revision of the Pi you have.

The LEDborg comes with a nice app that runs in a window – you can use this to test that everything is working correctly. My first impression of the LEDborg was how bright it was – it’s considerably brighter than the on-board indicator lights:

LEDborg fitted to a Raspberry Pi
Resistance is futile

Next comes to automating the LEDborg to work with our online service IFTTT.

To do this I’m going to be using a specially created email account. There are other ways to do this which are a bit quicker, but email is easy, doesn’t require much setup and as long as the Pi has internet access it will work. In this example I’ve opted for gmail.

Next we need a bit of code on the Pi to check the gmail account, and fetch the subject of the latest email sent to it. This code then uses the email subject to program the LEDborg. This is my first attempt at writing Python (so be kind if you spot any mistakes!) – you just need to change the your_email_address and your_password for the bits you set up:

import imaplib
import email
#connect to gmail

mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('[email protected]','your_password')
mail.select('inbox')
mail.list()

typ, data = mail.search(None, 'ALL')
for num in data[0].split():
typ, data = mail.fetch(num, '(RFC822)')
typ, data = mail.search(None, 'All')	
ids = data[0]
id_list = ids.split()

# get most recent email id

latest_email_id = int( id_list[-1] )

for i in range( latest_email_id, latest_email_id-1, -1):
typ, data = mail.fetch( i, '(RFC822)')
for response_part in data:
if isinstance(response_part, tuple):
msg = email.message_from_string(response_part[1])
varSubject = msg['subject']
varFrom = msg['from']
varFrom = varFrom.replace('<','')
varFrom = varFrom.replace('>','')
if len( varSubject ) >35:
varSubject = varSubject[0:32] ='...'

#print the subject to test

print varSubject

#output the subject to the ledborg

LedBorg = open('/dev/ledborg', 'w')
LedBorg.write(varsubject)
del LedBorg

 


(you can also download this from Gist)

Save this as ledchecker.py

You can test this by sending an email with the subject line 111 to the gmail account and by then running the script with:

sudo python ledchecker.py

Hopefully your Pi should be bathed in white light!

The position of the number in the subject refers to the red green blue LEDs in the LEDborg, and the value the intensity 2= full 1=half 0=off

So 100 is dim red, 200 is bright red. You can mix colours by using different combinations. Sending an email with the subject 000 switches the LEDborg off.

Excellent – but we don’t want to be constantly typing in the commands to run the script all the time – to get by this we’re going to use cron (think of it as Linux’s cronometer – a regular clock that does things at regular intervals). For a bit more info about cron check out this blog from David Singleton.

We can set cron to run our ledchecker.py program every minute:

sudo crontab -e

Opens your cron table in the nano editor – you just need to add

* * * * * sudo python /home/ledchecker.py

and then control-O to save and control-X to exit. You might need to adjust the line above depending on where you saved your python script.

Now your Raspberry Pi should automatically check the email account every minute and light up the LEDborg if it receives the appropriate email.

The final step is to head over to IFTTT.com and try creating a ‘recipe’ to feed your Raspberry Pi with information – I’ve created a simple recipe to get you started. If you think of any good ones, please share in the comments below!

Next thoughts are how to improve on this – perhaps it could cycle through last 5 emails? blink if it’s something really important? have a wired up ‘reset’ button. Play a chime when the notification changes?

Update: Fork me!

Brilliant –  vwilcox has forked the original script and made it better – it’s now indented properly, and has a loop to check if there’s no email, for rejecting the email if the subject is too long, and a nice empty the inbox function. This is the first time anything I’ve written on gist has been forked, so that has made my day (in a very nerdy way) – thank you!

Check out the fork here.

Raspberry Pi as an adblock server for iPad, iPhone, Android and anything else on your network

Adblocker without Jailbreak:

On my computer I find using Adblock plus a handy way to speed up surfing and hide invasive pop-up ads.

Annoyingly you can’t install Adblock on an iPad without jailbreaking it – and I’ve yet to come across a way of installing it on Android devices easily without requiring root access.

Fortunately there’s an easy way to install Privoxy on a Raspberry Pi that can block adverts (and do a few other things as well) and that works seamlessly on iOS and more or less anything you attach to your network.

You could run this software on any PC attached to your network – but with the Pi’s low power consumption  (3.5 watts) you can afford to leave it on all the time. Plus you could combine this functionality with a fileserver or an airplay speaker for a bit of extra usefulness.

Setting up your Raspberry Pi for remote control by iPad

Raspberry Pi running as an Adblock for iOS
Nice conversation piece for geeky dinner parties

First step is to prepare an SD card for your Pi – I’ve been using the default Raspbian.

Next step is to boot up the Pi with a screen and keyboard attached, and connected to your home network with an Ethernet cable. This would also work with a wireless connection, but ethernet is a bit simpler, more stable and means the Pi will run happily off a low powered USB adapter (e.g. a kindle power supply). On it’s first boot the Pi will run the config app – if you’ve already run your Pi before you can restart the config app by typing the following into the console:

sudo raspi-config

Make sure you change the default Pi password, and enable SSH in the menu. We’ll be using SSH to control the Pi remotely.

Now find your Pi’s IP address – in the terminal type:

ifconfig

This will give you some information about how the Pi is connecting to the network – make a note of the inet addr – usually 192.168.1.number (I’ll use this notation to refer to this value in the guide)

Next you can connect to your Pi using an SSH client – I’ve been using Remoter Fusion on the iPad (other SSH apps are available but I was using Remoter for something else) note that you will need to purchase SSH support in app which adds £5 to it’s price.

To connect to your Raspberry Pi with Remoter Fusion, click on discovery list -> Add Session Manually. On the Server Type choose SSH.

In the box that says SSH Hostname enter your Pi’s IP address which you found out above:  192.168.1.number then choose Manual – leave the SSH Port setting at 22 and in SSH Username enter your Pi username and SSH Password your Pi password.

Remoter Fusion iPad with Raspberry Pi
Remoter Fusion

Then connect – you might get a warning message (just accept) and then you should be seeing the Linux prompt.

Now you need to change your Pi from having a dynamic IP address (given to it by the router every time it reboots) to a static IP address which will stay the same. In the prompt type:

cd /etc/network
sudo nano interfaces

this launches nano which is a basic text editor – the following settings will depend on your Router – most routers will have a configuration page which will give you this information if you visit their configuration page – usually found on your network by typing 192.168.1.1 into a browser. The following settings worked for the BT Homehub version 3.

auto eth0
iface eth0 inet static
address 192.168.1.number
gateway 192.168.1.254
netmask 255.255.255.0
network 192.168.1.1
broadcast 192.168.1.255

Press control and O and then enter to save, followed by control and X to exit.

You might want to test your settings – either by using the Ping command, or by attaching a monitor / keyboard / mouse directly to the Pi and firing up the web-browser – the Pi should be able to connect to the internet.

Installing Privoxy on your Raspberry Pi

Finally we just need to install Privoxy – with the nice simple:

sudo apt-get install privoxy

then start Privoxy

sudo /etc/init.d/privoxy start

Then you’ll need to setup Privoxy by editing the configuration file –

sudo nano /etc/privoxy/config

This is a long file with lots of options – scroll or do a search with control W and find the listen-address line. Change it to 192.168.1.number:8118

Control O to save in nano then control X to exit.

Restart Privoxy with:

sudo /etc/init.d/privoxy restart

Now on your iPad go to settings -> Wi-Fi -> your network name and then scroll to the HTTP proxy options. Choose Manual and where it says Server type your Pi’s IP address: 192.168.1.number and where it says port type 8118.

Finally go to config.privoxy.org and if it’s all working correctly you should see an enabled message.

Straight out of the box Privoxy started blocking ads for me – you can edit the exact way it does this in the configuration files. So websites like this:

Lots of Adverts
Lots of Adverts

Become websites like this:

After Adblock on iOS
Less adverts. Still rubbish.

You can take this a bit further by turning your Pi into a personal VPN for secure browsing on the go with this Lifehacker tutorial.

Probably an overkill using a Pi for this, but it is handy being able to work on the Pi using an iPad and as I mentioned before there are a few other useful things your Pi could be doing at the same time.

How to play the original 8-bit Elite on a Raspberry Pi

Ok, so after my last post about running the Archimedes 32-bit version of Elite on RISC OS on the Raspberry Pi I got a few comments about running the earlier (and more authentic) 8 bit version on modern hardware. So I thought I’d have a bit of a play and try out a few options for running the original version.

Probably the easiest way to get a taste is to run the NES version on an emulator – Elite co-creator Ian Bell describes this as “the best way to re-experience the feel of 8 bit Elite“.

There are NES emulators available for almost any platform – here it is running on my Android 4 MK802 lapdock using iNES. You can download the ROM freely (and legally) from Ian Bell’s website.

Elite running on the iNES emulator on an Android 4 MINI PC
Cobra mk III

If you find the display corrupts you need to make sure it’s set to PAL and not NTSC or ‘auto’ . iNES has a nice function where you can remap keys to the various buttons, which is handy when using an external USB keyboard with the MK802.

It works well- although Elite’s many keys are replicated through combination key presses which takes a bit of getting used to. You can fly, shoot, get shot at, and crash at docking.

As I mentioned in my previous post – it’s rather fun to play Elite on the Raspberry Pi computer – the original BBC B’s spiritual successor, which also shares a creator with Elite.

The Raspberry Pi also has (various) NES emulators available for it – although I’ve yet to find one that can run Elite smoothly and without any issues (consider this a work in progress). However you can emulate the machine where it all started back in 1984:

How to emulate the BBC Micro  (model B) on a Raspberry Pi (model B)

Bridge of the Cobra Mk III image from the Elite user manual
Bridge of the Cobra Mk III – uncanny how the console of a 31st century starship looks a bit like a 1981 microcomputer…

It is possible to run the original BBC B version of Elite using the !BeebIt emulator – this is an emulator that runs in RISC OS.

Compared to the linux and android based emulators available this runs much more quickly since RISC OS is a very lightweight operating system.

To relive the original Elite – I’ve prepared a step by step guide – make sure you do all this on a Raspberry Pi running RISC OS – particularly unpacking the zip files.

First create an SD card running RISC OS or just download the NOOBs installer.

RISC OS uses a 3 button mouse – you’ll need one to access menus using the middle button – applications have a ! at the beginning of their name, and shift-click opens the application folder. There’s more RISC OS info available here.

Note that it also helps to have a standard, full size keyboard.

Then download !BeebIT – of the two versions available I’ve been using Michael Foot’s.

Extract the archive on your Raspberry Pi by dragging and dropping the download file, and then double clicking and dragging the !Beebit application file to a new folder. (Note that RISC OS is very drag and drop orientated).

Next you’ll need some BBC ROMs – the ROMs download on Michael Foot’s page contain both the OS2 and DFS ROMs you’ll need:

Download

Open up this archive as before – this will contain a !Beebit application icon – just drag and drop this over the !Beebit application you extracted earlier. (Application files on RISC OS are folders containing the program and needed files – by dragging and dropping the ROM file you are just adding the files you need)

Double click !BeebIT to run – it should appear on your icon bar. If you get any errors for missing ROMS, check the steps above or try downloading them individually. f12 will exit the emulator back to the RISC OS desktop.

Download BBC Micro Elite extract and set the type to DFSImage (the icon should change to a floppy disc) – to do this click the middle (menu) button on the file > File ELITEBBC/SDD > Set type and change “Data” to “DFSImage”.

Double click on the image file to run.

Once in !BeebIT type *!BOOT (on my keyboard the @ was *)

then enjoy!

The classic loading screen
The classic loading screen

Have a go at playing with the settings – you can choose a high quality display mode, or set CPU speed to Full Speed. If you’re feeling a bit more adventurous !BeebIt also emulates the Master 128 which ran a full colour version of Elite which is similar to the NES version – you’ll need to download the correct ROMs but all the info is included in the !BeebIt help file (middle click on the !Beebit application App.> ‘!Beebit’ >Help)

Commander Jameson
Commander Jameson

The easiest way to save your progress is to hit f12 to return to the desktop and then the middle button on the !Beebit emulator icon to then choose Save >Save as snapshot. Dragging the snapshot file back to the !Beebit icon will reload your game in the same state you left it. Note for some reason double-clicking on the snapshot icon to load it won’t work.

If you’re interested in Elite you can read a bit more about the 32-bit version of the game in my previous post – or check out the Elite Dangerous Kickstarter which is collecting pledges for a 21st Century version.

Elite – making a game that looks as good as the box art

This week it’s been announced that one of the original creators of the classic 8 bit video game Elite is seeking funds to launch a version updated for the 21st century.

I grew up playing Elite – originally on a BBC B and then a few years later on it’s 32 bit successor the Archimedes, it was brilliant, addictive and years ahead of it’s time.

Elite was a 3d space exploration game which featured open-ended play – you could explore the galaxy, play as a trader, bounty hunter or pirate in your quest to gain enough kills to be ranked as ‘Elite’ (starting from ‘harmless’ and working your way through ‘mostly harmless’, ‘dangerous’ and other often amusingly named ranks). Elite rewarded good acts like hunting down pirates, and punished bad behaviour – if you became a pirate yourself your legal status changed to wanted and you attracted the attentions of bounty hunters and ultimately the police. With the occasional mission for the galactic navy thrown in for good measure, Elite had the qualities that would make games like Grand Theft Auto a success – many years in advance.

BBC B Elite (Master version)

One of the things I used to wonder playing Elite, was whether or not computers would exist in the future that could actually depict the game as it was featured on the beautiful box art:

Elite Box art
Beautiful 1980’s sci fi art

The Sci-Fi art of the 1980’s is easily possible with todays’ computing power. Although there were sequels to the original Elite (Elite II, Frontier) none of them captured the playable spirit of the original – something that will hopefully be addressed in the update which promises “joyous immediacy”. If you can’t wait until 2014, I’ve prepared a short guide on how to play Elite on (what is arguably the modern day successor to the BBC B) the Raspberry Pi:

How to play Elite on the Raspberry Pi

It’s quite easy to just download an emulator on any modern PC or Mac and play Arc Elite – regarded as the best version of the original game. For a bit of fun I thought I’d have a go at running Elite on my Raspberry Pi.

For starters you need to be running RISC OS – this is a lightweight operating system originally developed by Acorn back in the 80s to run on the first generation ARM chips – this runs incredibly quickly on the Raspberry Pi. You can run various emulators (for example the Sinclair Spectrum) on the Linux Raspberry Pi build, but I’ve found these tend to run quite slowly.

First download RISC OS from the Raspberry Pi website and copy it to an SD card (or you can purchase a ready-made card from RiscOS open – it’s only £10, and worth it to support their very handy work! )

Because Arc Elite was originally written for ARM 2 and ARM 3 machines, it won’t run on the ARM 6  chip in the Raspberry Pi – but don’t worry you can emulate the older hardware using ArcEm – which is available from: http://arcem.sourceforge.net/ 

Update: there is an issue transferring archived files between PC/Mac (which I’m writing this on) and RISC OS – which causes the filetype to be incorrect (StrongArm will open when you try to run !ArcEm) To fix this:

Open the original zip file on the Raspberry Pi in RISC OS, unpack !ArcEM
next re-download the !ArcEm archive: http://sourceforge.net/projects/arcem/files/arcem/1.50-alpha/arcem-1.50-alpha2-riscos.zip/download
open that in RISC OS using !sparkFS – then drag the unarchived files over your original copy (this preserves the ROM files you need)

!ArcEm should now run – if Elite gives you problems download the original archive:
http://www.iancgbell.clara.net/elite/archive/a/b5052410.arc

Sorry about this – I’ve ordered a copy of the nutpi pack which includes the full copy of !SparkFS – i’ll recreate the zip archive so everything will work more simply in future!

Run !ArcEm, then open the HostFS drive on the desktop – Elite, along with the Dark Wheel Novella and User Manual are all available on there.

Arc Elite running on the Raspberry Pi
It’s a bit stretched on my screen, but smooth and playable!

It runs as smoothly as I remember, and is very playable – I’m still rubbish at docking though. On my lapdock display the screen was stretched – it might be worth experimenting with different settings to see what works best for you.

Interestingly there were a lot of 16 bit Amiga and Atari games converted to run on the Archimedes – so for anyone interested in emulating old games this should work for those as well. ArcEm is still under active development, so it’s well worth checking out.

If you enjoy playing Elite as much as I have, (and are suffering from I-didn’t-pay-for-this-amazing-game guilt) please help fund the next version on Kickstarter.

*the files I’ve used to do this were freely available from these sources:

ArcElite

http://www.iancgbell.clara.net/elite/arc/index.htm

RiscOS 3 Rom

http://home.tiscali.nl/~jandboer/ (in the support2.zip archive)

ArcEm

GPL licensed

http://arcem.sourceforge.net/

Raspberry Pi + Arduino + 8×8 LED Matrix + Python = Raspberry Pi LED display

The other week at work we launched a petition to support lifesaving Aid using a Jumbotron display, so I’ve been inspired to have a go at building a (very) mini version using my Raspberry Pi and an Arduino.

This is a handy way of getting your Pi to display information from any Python app you may have written – so you could use it to make a new email notifier, flash up messages from twitter, or if you’re using your Pi as a server without a monitor – status update messages. I’m interested in using it as a ‘now playing’ message board for an email controlled spotify jukebox I’m working on (more updates to follow).

There are lots of ways you could achieve this – it’s certainly possible to drive LED displays directly from the Raspberry Pi GPIO pins, but this is method is easy to do as it uses off the shelf kits, provides a bit of soldering practice, and an opportunity to learn a bit about Arduinos, Python and serial communications. As with a lot of Arduino projects once you’ve got the hand of how things work you could easily build a cheaper version using only the parts you need. Plus these are my first steps getting an Arduino to do something more interesting than flash a single LED on and off.

I’ve been using a standard Arduino Uno which is available for around £20, and the LED Matrix Shield v.1 from Ciseco which is £5 – this is a Arduino add on board that sits on top of the Arduino. The Matrix shield is fun to put together and good for practising soldering, as a lot of the parts aren’t particularly heat sensitive.

Setting up the Arduino

The instructions that come with the Matix shield are a bit basic – for a much better step by step how to check out this tutorial which I found in the forums.

LED matrix shield Ciseco
LED matrix shield sat on top of an Arduino Duo

Next step is to prepare the Arduino with the code you need it to run. Unlike the Nerdkit microcontroller I mentioned in a previous post the Arduino has a nice user friendly graphical front end – the downside to this is that it runs quite slowly on the Raspberry Pi. I used my Mac to upload the code to the Arduino – just remember to connect it directly to the USB ports on your Mac and not via a USB hub.

First you’ll need to add frequencytimer.h to your Arduino Library – there are instructions on how to install libraries here and you can download frequency timer here.

Then you’ll need to download 8x8LEDMatrix written by Andy Lindsay who has all sorts of other interesting Arduino / Pi stuff on his blog.

The script includes a 5×7 font file which you can experiment with to get the display to show different characters. Compile and upload this to your Arduino to check that everything’s working properly.

Now you’ll need to modify Andy’s code to send the text you want your Arduino to display over the serial port. Using a tilda character clears the script (although I discovered you don’t actually need this as the Pi resets the Arduino when it communicates with it on the serial port)

/*
 * Show messages on an 8x8 led matrix,
 * scrolling from right to left.
 *
 * Uses FrequencyTimer2 library to
 * constantly run an interrupt routine
 * at a specified frequency. This
 * refreshes the display without the
 * main loop having to do anything.
 *
 */

#include
#include &amp;amp;quot;font5x7.h&amp;amp;quot;

#define DELAY 80

int incomingByte = 0;   // for incoming serial data
String incomingString; // for the incomming serial data string
char message[] = &amp;amp;quot;&amp;amp;quot;; // define the message

byte col = 0;
byte leds[8][8];

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[17]= {
  -1, 17, 8, 7, 19, 9, 13, 4, 10, 6, 5, 18, 3, 2, 11, 12, 16};

// col[xx] of leds = pin yy on led matrix
int cols[8] = {
  pins[13], pins[3], pins[4], pins[10], pins[06], pins[11], pins[15], pins[16]};

int rows[8] = {
  pins[9], pins[14], pins[8], pins[12], pins[1], pins[7], pins[2], pins[5]};


void setup() {

  // sets the pins as output
  for (int i = 1; i  0) {

                // read the incoming byte:
                char incomingByte = (char)Serial.read();

                incomingString += incomingByte;

                if (incomingByte == &amp;amp;#039;~&amp;amp;#039;) {
                  // using a tilda ~ clears the string

                incomingString = &amp;amp;quot;&amp;amp;quot;;

                }

                // check string for command variables

                incomingString.toCharArray(message, 160);



                }





  scrollMsg( message );




}

void clearLeds() {
  // Clear display array
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      leds[i][j] = 0;
    }
  }
}

void setChar(char ch) {

  for (int i = 0; i < 5; i++) {
    unsigned char bt = pgm_read_byte(&amp;amp;amp;(smallFont [(ch-32)*5 + i] ));
    for (int j = 0; j < 8; j++) {
      leds[j][i+1] = (bt &amp;amp;amp; 0x01);
      bt = bt >> 1;
    }
  }
}

void slideChar(char ch, int del) {
  for (int l = 0; l < 5; l++) {
    for (int i = 0; i < 7; i++) {
      for (int j = 0; j < 8; j++) {
        leds[j][i] = leds[j][i+1];
      }
    }
    unsigned char bt = pgm_read_byte(&amp;amp;amp;(smallFont [(ch-32)*5 + l] ));
    for (int j = 0; j < 8; j++) {
      leds[j][7] = (bt &amp;amp;amp; 0x01);
      bt = bt >> 1;
    }
    delay(del);
  }

  for (int i = 0; i < 7; i++) {
    for (int j = 0; j < 8; j++) {
      leds[j][i] = leds[j][i+1];
    }
  }

  for (int j = 0; j < 8; j++) {
    leds[j][7] = 0;
  }
  delay(del);
}


// Interrupt routine
void display() {
  digitalWrite(cols[col], LOW);  // Turn whole previous column off
  col++;
  if (col == 8) {
    col = 0;
  }
  for (int row = 0; row < 8; row++) {
    //    if (leds[col][7 - row] == 1) {
    if (leds[col][ row] == 1) {
      digitalWrite(rows[row], LOW);  // Turn on this led
    }
    else {
      digitalWrite(rows[row], HIGH); // Turn off this led
    }
  }
  digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
}

Once you’ve uploaded this you can test its working properly by clicking on the serial monitor icon (the magnifier glass on the right hand side) and typing some text – if everything is working OK you’ll see the text appear on your Arduino’s matrix display.

Arduino software
Click on the magnifier icon on the right hand side

Setting up the Raspberry Pi

Now you need to connect the Arduino to the Pi. I’ve used one of the Pi’s USB ports rather than via a USB hub – you could also use the serial pin on the GPIO port to do this as well. Make sure the Arduino is connected before you power up the Raspberry Pi.

You can test the Pi -> Arduino control with minicom (thankyou http://codeandlife.com/2012/07/29/arduino-and-raspberry-pi-serial-communication/

Install minicom on the pi via the console:

sudo apt-get install minicom

then run minicom and connect it to the Arduino:

minicom -b 9600 -o -D /dev/ttyAMA0

Hopefully everything you type into the console will be appearing on the Arduino Matrix.

Next is to get Python to send data to the Arduino over the serial port. Install the python serial libraries:

sudo apt-get install python-serial

Now you’re ready to write some Python code to control the Arduino’s LED display. I’ve been using the IDLE app on the Raspberry Pi. The following code is a super simple python script that can send some text to the LED Matrix:

import time
import serial

#configure the serial connection

ser = serial.Serial("/dev/ttyACM0",9600)

ser.open()

# add some time delays to stop the Arduino resetting

time.sleep(1.5)

ser.isOpen()

time.sleetp(1.5)

ser.write("Raspberry Pi")

Hit f5 and you should see this:

Arduino LED MAtrix Shield v1.0 IOT Research 2012
Bingo! or whatever you want it to say…

And that’s it – you now have a neat way of controlling an LED display with Python. The LED display always shows the last message it received until it gets a new one.

Update: Cisco – the company who made the lovely shield kit, are now doing a kickstarter for a Pi version with a lot more red or white LEDs that plugs directly into the GPIO. 

The Power of We: the revolution will made in a kitchen somewhere

I’m a great fan of kitchen-tivism (kitchtivism?) – and by that I mean the engineers who tinker away in their kitchens to come up with solutions to various problems.

kitchen-tivism isn’t a particularly new concept – it’s been around since the dawn of modern science. One such early inventor is the astronomer Herschel who made reflecting telescope mirrors in his kitchen, and perfected a process which enabled him to measure the distance between stars, discover Uranus, and for his sister to become a celebrated hunter of comets and pioneer female scientist. You can visit the site of Herschel’s kitchen today and even see the cracked paving stones which resulted from an early failed attempt to cast mirrors in lead – the molten mixture poured over the floor and shattered the stone beneath.

Shedtivism in action: Herschels mirror polisher
Kitchtivism in action: Herschel’s mirror polisher

There are many stories of such kitchtivists – people like the Reverend Stirling, who out of concern for his parishioners developed a hot air steam engine which worked at a much lower (and safer pressure). Perhaps not all of them created their works in kitchens – some used sheds, but you get the idea.

What perhaps is different now from the past, is that where before kitchtivists worked in isolation, often replicating work or encountering problems which were insurmountable on their own, today kitchtivists have the wonderful invention that is the internet to connect them with other activists around the world. Part of the success of the world wide web is the sharing of ideas – at no cost – and without boundaries. Experts and amateurs alike can pool ideas, and create technological mashups which combine bits of experience from a wide field of people.

Take for instance Frontline SMS – a handy bit of software which connects mobile phones with the internet, which was written by Ken Banks over five weeks on the laptop in his kitchen. In keeping with the spirit of the internet he gave Frontline SMS away.

“I made it a generic communications platform that could be used for almost anything, and I made it free.”

Frontline SMS was originally developed to help help South Africa’s Kruger National Park communicate and engage with its neighbouring communities – but since it’s inception it’s been used from earthquake survival information to providing radio shows with feedback via text from their listeners. The most notable Frontline SMS mashup being the Kenyan based Ushahidi – originally created to map post election conflict in Kenya, now being used anywhere map based tracking is needed.

There are many other examples – from the open source Arduino, to the Raspberry Pi teaching computer (created in their spare time by concerned computer science lecturers) – all demonstrating that the spirit of entrepreneurial experimentation made famous by the victorian pioneers is alive and well today.

The potential for the web – still a relatively young invention to not only mobilise activists on a global scale – but to potentially provide new solutions, ideas and technologies that are just given away for free is truly mind-boggling.

I for one are looking forward to the new and exciting technologies that kitchtivists are working on – and am certain that the next revolution will probably be made on kitchen table somewhere.

This was a post for Blog Action Day 2012.