Michael Sheldon's Stuff

Michael Sheldon (mike at mikeasoft dot com)

May 16, 2012

Those Funny Funguloids
Mike @ 12:23 pm


Recently I’ve spent a little time getting the Ogre3D engine into a state where it’ll work on the Nokia N9 and N950 MeeGo phones.

To test the port out a bit more extensively I decided it’d be a good idea to try porting an existing game, at which point rzr suggested Those Funny Funguloids. So after a fair amount of hacking to make it compatible with my version of Ogre and to make the controls work reasonably on a touch screen device I have a playable version.

The aim of the game is to collect mushrooms (…IN SPACE), and bring them back to your base without running into any asteroids. Only mushrooms of the same colour as your base are added to your score and your base changes colour each level (but you can hang on to mushrooms between levels and score them later). The controls are fairly simple, touch the left side of the screen to turn left, the right side to turn right and the middle to start moving.

When I have a bit more time I’ll see about writing a little tutorial on making use of my modified version of Ogre3D to create 3D applications and games in a way that’s easy to distribute.


Funguloids menu screenFunguloids menu screen


Video of gameplay




Modified version of Funguloids 1.06
Modified version of Ogre 1.7.4

April 27, 2012

Seagull Strike
Mike @ 5:58 pm


A while back a wrote a little game for the Nokia N9 and N950, mostly as a way to explore the QML Box2D bindings. However, whilst packaging up my StatusNet client I thought I might as well release this as well since it can be a fairly enjoyable distraction. Below is a short video demonstrating how it works, and at the end of the post you can find details on where to get hold of it.


You can either download it via Apps for Meego, or get hold of the package directly here: http://mikeasoft.com/~mike/seagullstrike_0.1-2_armel.deb.


License: GPL version 3.0 or later
Gitorious repository: https://gitorious.org/seagull-strike
Ohloh project page: https://www.ohloh.net/p/seagull-strike

April 26, 2012

StatusNet for MeeGo 0.2.1
Mike @ 12:57 am

StatusNet for MeeGo displaying clickable links


StatusNet for MeeGo makes it possible for Nokia N9, N950 and similar phones to connect to StatusNet compatible microblogging services such as Identi.ca. It supports viewing statuses in the phone’s event feed alongside Twitter and Facebook updates, viewing conversations, posting new status updates and replying to other people.

New Features

  • Support for followings links in posts.
  • Links to groups, tags, and users.
  • Support for posting messages using UTF-8 characters.
  • Slight improvements to the clarity of the login screen.


Ovi Store: StatusNet for MeeGo
Direct download: statusnet-meego_0.2.1-1_armel.deb


License: GPL version 3.0 or later
Gitorious repository: https://gitorious.org/statusnet-meego-plugin
Ohloh project page: https://www.ohloh.net/p/statusnet-meego

April 7, 2012

StatusNet for MeeGo 0.2
Mike @ 12:45 am

StatusNet for MeeGo sending messages and replies


StatusNet for MeeGo makes it possible for Nokia N9, N950 and similar phones to connect to StatusNet compatible microblogging services such as Identi.ca. It supports viewing statuses in the phone’s event feed alongside Twitter and Facebook updates, viewing conversations, posting new status updates and replying to other people.

Assuming no issues are encountered by testers I plan on submitting this version to the Apps For MeeGo repository, and later also the Nokia Ovi Store.

You’ll need to restart your phone before statuses start appearing in the events feed, although you’ll be able to use the main app straight away. Because of some changes in the dbus services its also necessary to restart your phone even if you’ve already installed version 0.1 (this won’t be needed after future updates though).

New features

  • Posting updates.
  • Posting replies.
  • Viewing messages in the application.
  • Display full conversations.
  • Load additional statuses from earlier in time.
  • Splash screen while connecting.
  • Improved dbus handling.
  • Asynchronous message loading and posting.

Planned features

  • Support for displaying rich content (pictures, videos, etc.)
  • Ability to mark statuses as being “favourites”.
  • Option to subscribe to new users in the app.


Ovi Store: StatusNet for MeeGo
Direct download: statusnet-meego_0.2-4_armel.deb


License: GPL version 3.0 or later
Gitorious repository: https://gitorious.org/statusnet-meego-plugin
Ohloh project page: https://www.ohloh.net/p/statusnet-meego

April 3, 2012

StatusNet client for the Nokia N9/N950
Mike @ 3:58 pm

StatusNet messages in the MeeGo events feed

There’s one thing that my Nokia N950 has been lacking and that’s a StatusNet client, so I set about hacking one together. I love the way that the N9/N950 events feed displays messages from Twitter and Facebook, so my main focus so far has been to integrate with this. I’ve now got my client to a stage at which it covers most of my own needs so I thought I’d make an early release for others to play with.

Once I’ve extended it a little further I plan on submitting it to both Apps For Meego and the general Nokia Ovi Store, but for now you can download the Debian package directly here.

One thing to note is that you will need to restart your phone before events will start to appear (this is due to a limitation in the way the SyncFW framework loads plugins).

The client is written mostly in Python, with a little C++ for integrating with the events synchronisation framework. It makes use of the StatusNet module written for the command line StatusNet client IdentiCurse and the python-eventfeed module written by Thomas Perl.


* OAuth login for identi.ca.
* Standard login for any other StatusNet services.
* Shows messages in the events feed.
* Fetches (and caches) user avatars.
* Displays messages from the events feed in the browser when clicked.
* Automatically fetches new messages in the events feed based on your events feed preferences.
* Can manually fetch new messages via the events feed ‘Refresh’ button.

Not yet implemented

* Posting messages.
* Displaying messages locally within the application.
* Displaying rich content (messages with multimedia attachments)


Ovi Store: StatusNet for MeeGo
Direct download: statusnet-meego_0.1-3_armel.deb


License: GPL version 3.0 or later
Gitorious repository: https://gitorious.org/statusnet-meego-plugin
Ohloh project page: https://www.ohloh.net/p/statusnet-meego

July 15, 2011

Box2D and Box2D-QML for Harmattan
Mike @ 4:44 pm

I’ve just built some Box2D and Box2D-QML packages for Harmattan. The Box2D-QML package is especially interesting, this wraps the Box2D API as QObjects allowing them to be made use of directly from within QML. So you don’t need any extra C++ to handle physics simulation for simple games or similar. Here’s a short video of one of the demos running on an N950:

The source code for the above demo can be seen in the Box2D-QML repository here: Monera Example and thanks to these wrappers is very simple.

Packages for the N9/N950 can be found in my OBS repository, simply download elleo.list into /etc/apt/sources.list.d/ and run apt-get update to make the repository available on your device, or just download the packages you’re interested in directly from http://repo.pub.meego.com/home:/elleo/Harmattan/armel/.

Many thanks to the Box2D and Box2D-QML teams for creating such nice tools, I’d certainly recommend them to anyone interested in 2D game development on the N9/N950 phones.

July 2, 2011

Libre.fm Radio Client for MeeGo Under Development
Mike @ 1:08 pm

Last week I got the news that I’d been accepted into Nokia’s community device program and would be receiving a Nokia N950 so that I could help produce some nice open source MeeGo apps ready for the launch of the Nokia N9 later in the year. The device hasn’t arrived yet, but I’ve already started on the first of my projects which is to create a Libre.fm radio client. Most of the basic functionality now works including authentication, tuning to stations, playing, pausing and skipping back and forth through the playlist. I won’t be making a release until after I’ve had a chance to actually test it on the device itself, but the code is all in the GNU FM git repository. Here’s a quick video of it in action:

January 5, 2011

Free (as in GPL2) translation dictionaries for the Kindle
Mike @ 3:52 pm

Update: All dictionaries except for Welsh and Esperanto (which aren’t supported by kindlegen) have been updated to work with the Kindle 4.

I’ve had a Kindle for a little while and really like it, but one of the areas it seems to be somewhat lacking in is the availability of translation dictionaries, as such I knocked up a quick script to convert TinyLex dictionaries from the Apertium project into indexed Kindle dictionaries. The most useful of these is probably the German – English dictionaries as these are very complete (over 160,000 entries).

One thing that I find quite useful is setting the German -> English dictionary as my primary dictionary (instructions below) then opening the English -> German dictionary and searching for words (or vice versa), this way you can get an instant re-translation of any words suggested to you.


Kindle 3

  1. Download whichever dictionary you’re interested in from the list below.
  2. Transfer the file across to your Kindle as normal.
  3. Press the menu key on your Kindle.
  4. Select Settings.
  5. Press the menu key again.
  6. Select Change Primary Dictionary.
  7. Select your new dictionary from the list.

Kindle 4

  1. Download whichever dictionary you’re interested in from the list below.
  2. Transfer the file across to your Kindle as normal.

If this is the only dictionary you have for this language you’re now done. If you have multiple dictionaries continue:

  1. Press the menu key on your Kindle.
  2. Select Settings.
  3. Select edit next to Dictionaries on the second page.
  4. Select the language you wish to set the dictionary for.
  5. Select your new dictionary from the list.


English -> Afrikaans 5165 entries
Afrikaans -> English 5195 entries


English -> Esperanto 12344 entries
Esperanto -> English 21316 entries


English -> French 6315 entries
French -> English 6304 entries

German (includes phrases)

English -> German 162004 entries
German -> English 166733 entries


English -> Polish 8107 entries
Polish -> English 9373 entries


English -> Portuguese 4759 entries
Portuguese -> English 4609 entries


English -> Spanish 8488 entries
Spanish -> English 8769 entries


English -> Welsh 6674 entries
Welsh -> English 8632 entries


For those of you interested in the scripts used to generate these dictionaries, they can now be downloaded here: kindle-dict.tar.gz.

Most of the heavy lifting is done by the tab2opf.py script from StarDict-Lingea, the tinylex.sh script will do the necessary conversion to get a tinylex dictionary into a tab delimited format suitable for use by tab2opf.py, it’ll then run tab2opf.py and kindlegen on the output, providing you with a Mobipocket dictionary for use with the Kindle. See the README for more in depth instructions on how to make use of it.

October 16, 2010

Libre Droid 1.4 Released
Mike @ 8:58 pm

I’ve just released a new version of Libre Droid onto the Android Market (also downloadable here: http://mikeasoft.com/~mike/libredroid-1.4.apk). The main changes in this release are:

  • Android 2.2 (Froyo) support – Previous versions didn’t work under Froyo due to the new streaming framework (libstagefright) not supporting HTTP redirection, so resolving the final URL is now handled by Libre Droid itself.
  • Ability to add custom tag stations – You’re no longer restricted to the preset tag stations so if you want to listen to female vocals, finger picked guitar, monkeys or anything else our music might be tagged with then you can create a dedicated station for it.
  • Support for playing a user’s loved station – All the music you’ve ever loved in one easy station.
  • Support for the community loved station – The Libre.fm community’s favourite music, this is a selection of all the music that’s ever been loved by any of our users with the most popular tracks playing most frequently.
  • New artwork.
  • Plus a few miscellaneous bug fixes.

New menu page in Libre Droid

Libre Droid playing some music

To access it directly on your phone either scan the QR code below or click on it from within your phone’s browser. Alternatively you can simply search for “Libre Droid” in the Android Market.

QR code for Libre Droid

September 24, 2010

Local map rendering and route finding with libchamplain, Spatialite and Open Street Map
Mike @ 3:07 pm

This tutorial takes you through the steps necessary to build a simple application which is capable of displaying data from OpenStreetMap and find driving routes between two locations without the need for any network services.

The final application will look something like this:

Final application demonstrating local render and routing

And can even be used on the Nokia N900 mobile phone (running Maemo):

Local map rendering and routing on the Nokia n900 mobile phone


The libraries you’ll need to install for this are:

  • Memphis – A map renderer. Version 0.2.1 or later.
  • libchamplain – Provides clutter based mapping widgets. You’ll need version 0.7.1 or later for memphis support, when compiling add –enable-memphis to the ./configure parameters.
  • Spatialite – Provides OpenGIS compatible routing (and more) on top of SQLite. This needs to be version 2.4rc3 or later. You’ll also need the spatialite-tools package for importing OSM data

Next we’ll need to acquire some OSM data to work with, for this example we’ll be using a small area around Nantwich in the UK, which can be download here. Data for entire countries can be downloaded from CloudMade, or data from a smaller specific area can be obtained from the OpenStreetMap API.

Displaying the map

#include <gtk/gtk.h>
#include <champlain/champlain.h>
#include <champlain/champlain-memphis-renderer.h>
#include <champlain-gtk/champlain-gtk.h>
#include <clutter-gtk/clutter-gtk.h>

#define MAP "nantwich.osm"
#define RULES "default-rules.xml"

static GtkWidget *window;
static ChamplainMapSource *tile_source = NULL;
static ChamplainMemoryCache *memory_cache = NULL;
static ChamplainView *champlain_view;

static void on_destroy(GtkWidget *widget, gpointer data) {

static void zoom_to_map_data(ChamplainView *view) {
        ChamplainMemphisRenderer *renderer;
        ChamplainBoundingBox *bbox;
        gdouble lat, lon;

        /* Fetch a reference to the memphis renderer */
        /* Find what section of the world it covers */
        g_object_get(G_OBJECT(renderer), "bounding-box", &bbox, NULL);
        /* Find the centre of that region */
        champlain_bounding_box_get_center(bbox, &lat, &lon);

        /* Zoom in on that position */
        champlain_view_center_on(CHAMPLAIN_VIEW(view), lat, lon);
        champlain_view_set_zoom_level(CHAMPLAIN_VIEW(view), 14);

int main(int argc, char *argv[]) {
        GtkWidget *widget, *vbox, *bbox, *button, *viewport, *label;
        ChamplainMapSource *source;
        ChamplainRenderer *renderer;
        ChamplainMapSourceChain *source_chain;
        ChamplainMapSource *src;
        ChamplainRenderer *image_renderer;
        guint tile_size;

        /* Initialize libraries */
        gtk_clutter_init(&argc, &argv);

        /* Create a GTK window */
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(window), "Local rendering and routing tutorial");
        g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(on_destroy), NULL);

        /* Create an embedded champlain GTK widget */
        widget = gtk_champlain_embed_new();
        /* Get the ChamplainView contained within the GTK widget */
        champlain_view = gtk_champlain_embed_get_view(GTK_CHAMPLAIN_EMBED(widget));

        /* Setup memphis as our tile source. Normally champlain would download tile images
         * from one of a number of online services, by using memphis we can render all
         * the tiles locally without the need for a network connection. */
        ChamplainMapSourceFactory *factory = champlain_map_source_factory_dup_default();
        source = champlain_map_source_factory_create(factory, "memphis-local");
        renderer = champlain_map_source_get_renderer(CHAMPLAIN_MAP_SOURCE(source));
        champlain_memphis_renderer_load_rules(CHAMPLAIN_MEMPHIS_RENDERER(renderer), RULES);
        champlain_file_tile_source_load_map_data(CHAMPLAIN_FILE_TILE_SOURCE(source), MAP);
        tile_source = CHAMPLAIN_MAP_SOURCE(source);
        source_chain = champlain_map_source_chain_new();
        tile_size = champlain_map_source_get_tile_size(tile_source);
        src = champlain_map_source_factory_create_error_source(factory, tile_size);
        champlain_map_source_chain_push(source_chain, src);
        champlain_map_source_chain_push(source_chain, tile_source);

        /* Use a memory cache so that tiles don't have to be re-rendered everytime they're
         * displayed. Another option would be to use a file cache allowing the tiles to be
         * saved across multiple runs of the program (but at the expense of disk space). */
        image_renderer = CHAMPLAIN_RENDERER(champlain_image_renderer_new());
        /* We store up to 200 tiles in the cache */
        memory_cache = champlain_memory_cache_new_full(200, image_renderer); 
        champlain_map_source_chain_push(source_chain, CHAMPLAIN_MAP_SOURCE(memory_cache));
        g_object_set(G_OBJECT(champlain_view), "map-source", source_chain, NULL);

        /* Request a minimum size of 400x300 */
        gtk_widget_set_size_request(widget, 400, 300);

        /* Add our embedded champlain widget to the window */
        gtk_container_add(GTK_CONTAINER(window), widget);

        /* Display the window */

        /* Find our OSM data on the map and show it */

        /* Start the GTK main loop */

        return 0;

To compile this example (assuming you’ve saved it to ‘champlain-routing.c’) run:

gcc `pkg-config --cflags --libs spatialite champlain-0.8 champlain-gtk-0.8 champlain-memphis-0.8` champlain-routing.c -o champlain-routing

This is a fairly standard champlain program except it uses the memphis renderer to create tile images locally instead of fetching them from an online tile server. In addition to nantwich.osm you’ll also need default-rules.xml, which defines the appearance of the map.

The resulting program will give us a small window that displays our map data without the need for an internet connection:

Displaying the map via libchamplain

Creating routing data

Before we can performing any routing tasks we first need to import our OSM data into spatialite and create a routing network from it.

Importing OSM data into spatialite

spatialite_osm -o nantwich.osm -d nantwich.sqlite -T roads -m

Generating a routing table

spatialite_network -d nantwich.sqlite -T roads -g geometry -c cost -t node_to -f node_from -n name --oneway-fromto oneway_fromto --oneway-tofrom oneway_tofrom -o roads_net_data

spatialite nantwich.sqlite 'CREATE VIRTUAL TABLE "roads_net" USING VirtualNetwork("roads_net_data")'.

Automatic import

I’ve joined these stages together into a small script, available here: populate_spatialite.sh. It takes two parameters, the first being the OSM data to import and the second is the spatialite database to be created:

./populate_spatialite.sh nantwich.osm nantwich.sqlite

Finding and drawing a route

First we define a couple of new global variables for storing references to our route’s polygon, our Spatialite database, and our database’s filename:

#define SPATIAL "nantwich.sqlite"

ChamplainPolygon *route_polygon;
sqlite3 *handle;

Then we initialize Spatialite within our main setup:

int main(int argc, char *argv[]) {
        gtk_clutter_init(&argc, &argv);
        sqlite3_open_v2(SPATIAL, &handle, SQLITE_OPEN_READONLY, NULL);

Finally we can create a function for drawing the routes between two OSM nodes:

/* Takes two OSM node IDs representing the desired
 * start and end locations and draws the route between
 * them on the map. */
static void draw_route(int from, int to) { 
        ClutterColor color = { 0x00, 0x11, 0x33, 0x99 };
        int ret, n_rows, n_columns, i, points;
        float lat, lon;
        char sql[256];
        char **results;
        char *err_msg = NULL;

        /* Remove any previously displayed route */
        if(route_polygon != NULL) {
                champlain_view_remove_polygon(champlain_view, route_polygon);

        /* Find out how many points there are in the route */
        sprintf(sql, "SELECT NumPoints(Geometry) FROM Roads_net "
           "WHERE nodeFrom = %d AND nodeTo = %d LIMIT 1", from, to);
        ret = sqlite3_get_table(handle, sql, &results, &n_rows, &n_columns, &err_msg);
        if(ret != SQLITE_OK) {
                printf("SQL error: %s\n", err_msg);

        /* Check to see if we could find a route */
        if (n_rows == 0 || results[1] == 0) {
                printf("No route for %d -> %d\n", from, to);

        points = atoi(results[1]);

        /* Create a new champlain polygon */
        route_polygon = champlain_polygon_new();

        /* Add each point in the route to the polygon */
        for (i = 1; i < = points; i++) {
                sprintf(sql, "SELECT X(PointN(Geometry, %d)), Y(PointN(Geometry, %d)) "
                   "FROM Roads_net WHERE nodeFrom = %d and nodeTo = %d LIMIT 1", i, i, from, to);
                ret = sqlite3_get_table(handle, sql, &results, &n_rows, &n_columns, &err_msg);                  
                if(ret != SQLITE_OK) {                                          
                        printf("SQL error: %s\n", err_msg);
                sscanf(results[2], "%f", &lon);
                sscanf(results[3], "%f", &lat);
                champlain_polygon_append_point(route_polygon, lat, lon);

        /* Set the polygon's display properties */
        champlain_polygon_set_stroke_color(route_polygon, &color);
        champlain_polygon_set_stroke_width(route_polygon, 12.0);

        /* Show the polygon on the map */
        champlain_view_add_polygon(champlain_view, route_polygon);

To see what this does we can then try calling draw_route towards the end of our main function:

int main(int argc, char *argv[]) {
        /* Find our OSM data on the map and show it */

        /* Draw an example route */
        draw_route(291898931, 263396519);

        /* Start the GTK main loop */

The main part of this likely to need further explanation are the SQL queries being used. To find a route between locations a query can be performed on the Roads_Net virtual table, to see the sort of results this generates we can load the database into spatialite directly and try some queries.

spatialite nantwich.sqlite

This starts an sqlite session with the spatialite extensions already loaded, so we can just type out our query directly and see the results:

spatialite> SELECT * FROM Roads_Net WHERE NodeFrom = 291898931 AND NodeTo = 263694833;

Algorithm ArcRowid NodeFrom NodeTo Cost Geometry Name
Dijkstra 291898931 263694833 44.5477589762393
Dijkstra 625 291898931 30091396 9.26106988426742 Hawksey Drive
Dijkstra 863 30091396 291797647 8.05233487984465 Peter Destapleigh Way
Dijkstra 864 291797647 30091398 2.10526089940676 Peter Destapleigh Way
Dijkstra 865 30091398 30091397 2.57141142336182 Peter Destapleigh Way
Dijkstra 1100 30091397 30091385 10.1017580189628 Audlem Road
Dijkstra 1101 30091385 291797619 1.21093075722029 Audlem Road
Dijkstra 1102 291797619 30091384 2.78122691192808 Audlem Road
Dijkstra 1994 30091384 263694833 8.46376620124748 Wellington Road

The first row gives us details about the entire route, each following row is a single step along that route including the name of the road we’re travelling on at the time. You’ll notice that the Geometry column appears to be empty, this column is actually accessed through a number of different functions, to get a plain text representation of the geometry for our route we can do:

spatialite> SELECT AsText(Geometry) FROM Roads_Net WHERE NodeFrom = 291898931 AND NodeTo = 263694833 LIMIT 1;
LINESTRING(-2.509696 53.058716, -2.509586 53.058025, -2.512386 53.057934, -2.512593 53.05792, -2.513372 53.057853, -2.514185 53.057543, -2.514511 53.057525, -2.515953 53.057457, -2.51673 53.057505, -2.517495 53.058079, -2.517746 53.058306, -2.518433 53.058776, -2.519147 53.059387, -2.519725 53.06049)

Or to get the X, Y position for a single point along that line we can use the X(), Y() and PointN() functions as we do in our draw_route function. So to find the position of the 4th point we could do:

spatialite> SELECT X(PointN(Geometry, 4)), Y(PointN(Geometry, 4)) FROM Roads_Net WHERE NodeFrom = 291898931 AND NodeTo = 263694833 LIMIT 1;

From here the program could be easily extended to look up OSM IDs based on their street names (stored in the roads table), to find the nearest OSM ID to a GPS position or to display text based driving instructions, all with just a few SQL queries.

Complete listings

The full source code and data for this tutorial can be downloaded here: champlain-routing.tar.gz. The complete program includes some additional enhancements such as the ability to request routes based on street names (in a simple, but non-robust manner) and zoom level controls.

If you create anything based on this tutorial I’d be very interested to hear about it :).

« Previous PageNext Page »

Powered by WordPress