contact Me

Use the form on the right to contact me.

You are welcome, to contact me regarding the topics of this page, my open source projects, or my work. Please use the contact form and leave a valid email address for me to respond to.

Thank you.

Egidestr. 9
44892 Bochum
Germany

/brain/dump

Random thoughts, bright ideas and interesting experiments. In short the ramblings of a fulltime nerd.

 

My first application for the Openmoko Neo Freerunner

Jakob Westhoff

The university semester is over since last Friday. Therefore I found some time this weekend to play around with my newest gadget the Openmoko Neo Freerunner. Among other things like playing around with its internal GPS and tracking my positions, I wanted to write a small kind of "Hello World" application for it using one of its great capabilities.

What application would it be?

I finally decided to create an application which should behave like a Magic Eightball. I wanted it not only to be capable of telling the future, but also to react on real shaking of the device. With the accelerometers inside the Freerunner this was quite easily achieved.

Which language to use?

After I had this idea for an application I thought about the language and the libraries for creating this neat little tool. Because it was a just for fun project I decided to use a language I wanted to look further into for a long time. Vala. Using Vala the natural choice was to use GTK as a widget toolkit. After I clicked together some graphics using Inkscape I started to code. It worked like a charm. Vala is a very modern and nearly intuitively usable object oriented language. It has many analogies to C#, which - in my opinion - is a really well designed language. At first I started writing the parts of the program which are reading the accelerometers event data, because this is the thing I wanted to play around with. But before I could do this I had to find out what kind of data the accelerometers were presenting to me. After I got quite an idea of it I wrote my findings down in the Openmoko Wiki. You can take a look there if you are interested in the basics. After this initial findings writing an event interface for it was done in no time.

Some thoughts about the drawing speed

I began to think about the drawing, possibly animating the eightball. I decided to use Cairo for on screen drawing and started hacking some code together. I realized quite soon, that simple drawing would not be of any problem. The animation tests I did however showed to me that the whole drawing process was quite slow. Without a significant increase in speed there would be no animations possible. I decided to consult some guys at the #openmoko and #neo1973-germany channels on Freenode evaluating alternative possibilities.

Some guys there suggested to take a look at the drawing backend which was originally created for Enlightenment. This library called evas is well written and optimized for speed. With its big brother edje there even is a great language to design and implement GUI behavior and user interaction. My first tests with these libraries looked really promising. I was able to draw quite fluently fading and moving objects to my openmoko screen. Therefore I decided to write the interfaces using this libs, which I might even use for some desktop apps in the future. The main problem with this decision was that at the current time no vala binding for evas, edje or any other Enlightenment library exists. After looking into the process on how to create these bindings, I decided to rewrite the accelerometer code I got in another language which already has got the needed bindings and runs fine on the Freerunner. I must say that I got the impression that it would not be too hard to create vala bindings for the mentioned libraries and that I might do this in the future. But for this task it seemed to be a little bit oversized.

Language going twice

I came to the decision to use Python for the second approach. I created a really little and hackish script using Python once. After that I never touched the language again. Not because I did not like it, but because I never had the opportunity to use it again. After reading a lot about all the new features Python incorporated since I last used it, I have to say that Python has quite some really interesting concepts which I would like to test out in future projects. On the other hand it has some concepts or better the absence of some concepts like attribute visibility in classes, which I don't really like. The time will show if I will use it more often in the future or not. After I defined the complete GUI using edje and embryo code, the amount of Python which needed to be written was quite small.

Take a look at the outcome

I really like what came out of the whole process in the end. The Moko Eightball seems nearly to be as geeky and real as its real life model.

I have created a little video which shows how it works and what it looks like.

A small demonstration video about what the Moko Eightball application can do using the Accelerometers of the Neo Freerunner

Download and install instructions

If you want to test the eightball on your own Freerunner you can install the ipk package I created. Unfortunately there is currently a bug in the neod executable which blocks the accelerometer events from being read by another application. Therefore the eightball will kind of crash on a default Freerunner. You will need to replace the neod against a patched version which allows the usage of the accelerometers by other applications. To accomplish this execute the following commands on your Freerunner:

cd /tmp
wget http://westhoffswelt.de/s/neod
cp neod /usr/bin/neod
chmod u+x /usr/bin/neod

The file can be downloaded separately here

After that reboot your Freerunner and the patched neod should be in effect. Now you can install the Moko Eightball by issuing the following command: :

opkg install http://westhoffswelt.de/s/moko-eightball_0.20080721_om-gta02.ipk

The ipk is for download as well.

After restarting the X-Server or rebooting the neo again you should see a new entry in the application menu called "Moko Eightball". Just tap it and start shaking.

Sourcecode?

The Moko Eightball is licensed under the GPLv3. You can checkout the sources from a Subversion repository at: :

svn co svn://svn.pureenergy.cc/moko_eightball

If you have got any questions feel free to comment on this post or drop me a line.