My first Application for the Openmoko Neo Freerunner
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 higher resolution version of this video can be downloaded here
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/data/blog/moko_eightball/neod
cp neod /usr/bin/neod
chmod u+x /usr/bin/neodAfter 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/data/blog/moko_eightball/moko-eightball_0.20080721_om-gta02.ipkAfter 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_eightballIf you have got any questions feel free to comment on this post or drop me a line.
Mickey Lauer on Tue, 22 Jul 2008 01:16:42 +0200
Cool, good work.
Link to commentI agree that a Vala binding for the EFL would be an amazing thing. I think a lot of folks would be interested to help you on that, if you would launch that. If you are interested, just drop a mail to openmoko-devel and lets see whether we can pull something off.
Cheers,
Mickey.
Jakob on Wed, 23 Jul 2008 16:32:02 +0200
Hi Mickey.
Link to commentI have started to write EFL Bindings for vala yesterday, to get a general idea about the work that needs to be done. Even though it seems to be a lot more work than I originally predicted I think it is quite doable.
Before searching for volunteers for this project I want to create two or three bindings including tests for the correct functionality. Therefore I already wrote a little testing framework.
Stay tuned. I will keep you informed about the progress on this project.
greetings,
Jakob
Spydon on Mon, 04 Aug 2008 22:59:57 +0200
Looks like an awesum application, but where do I get the dependencies?
Link to comment* ERROR: Cannot satisfy the following dependencies for moko-eightball:
* python-evas * python-ecore * python-edje *
Timo Juhani Lindfors on Thu, 07 Aug 2008 10:29:35 +0200
Hi, can I get source code for your patched version of neod somewhere? Please contact me at timo.lindfors@iki.fi
Link to commentYorick on Thu, 07 Aug 2008 10:48:43 +0200
I did
Link to commentcd /tmp wget
http://westhoffswelt.de/data/blog/moko_eightball/neod cp neod /usr/bin/neod chmod u+x /usr/bin/neod
and rebooted the freerunner,
afterwards he wouldn't boot into x anymore,
i just get:
ERROR ERROR: Error magic check failed
in ecore_event_handler_del()
input handler is NULL
I still can ssh in...
Jakob on Thu, 07 Aug 2008 20:52:16 +0200
@Spydon:
Link to commentThe needed packages should be available in the default buildsystem repository which is already configured in the 2007.2 image. If you are using another you might need to enter the server manually.
@Timo Juhani Lindfors:
The patched neod was send to me by Marcus Bauer, after I asked about it on the devel mailing list. Unfortunately I am not in possesion of the patched sources. Just take a look at the mailing list, to contact Marcus for the patch.
@Yorick:
I am not quite sure whats the problem with you system. I is possible that in a newer Image some packages or package names have changed and therefore the installed dependencies conflict with something already installed on your device. At the moment I do not have a lot of freetime. Therefore I have not testet the eightball with anything else than the 2007.2 image
greetings
Jakob
Axel on Fri, 08 Aug 2008 11:57:19 +0200
Hi, I installed your Moko Eightball but unfortunately it doesn't start.
Link to commenttail -f x.log says:
<schnipp>
Traceback (most recent call last):
File "/usr/bin/eightball", line 30, in <module>
import random
ImportError: No module named random
<schnapp>
Cheers
Axel
Axel on Sun, 10 Aug 2008 18:30:23 +0200
Ok, I needed to do a
Link to commentopkg install python-math
. The error message is now gone but the application doesn't start correctly. For some reason I don't get any data from my accelerometers (hexdump /dev/input/event3 or hexdump /dev/input/event2).
I'm using
"Linux om-gta02 2.6.24 #1 PREEMPT Fri Aug 8 06:20:35 CST 2008 armv4tl unknown"
Jakob on Mon, 11 Aug 2008 04:18:38 +0200
Did you install the patched neod?
Link to commentThe problem with not being able to access the accelerometers is caused by another application accessing them most of the time.
greetings
Jakob
Yorick on Tue, 26 Aug 2008 12:29:37 +0200
It works without patching the neod on Om2008.8-upgrade!
Link to commentyou really should make this a page on the wiki, it's a very nice application! (maybe you can add some sound effects?)
Yorick on Tue, 26 Aug 2008 13:03:44 +0200
on 2007.2 you can see the name in the upper left corner, but you can't see the eightball; the application windows stays visible
Link to commentit's also hard to kill it (I had to do killall -9)
On 2008.8 it stops working when gestures is installed
Timo Juhani Lindfors on Sun, 07 Sep 2008 16:54:53 +0200
Jakob , it took me a month to notice you had replied :-) Is there some way to get email when you reply to blog posts?
Link to commentneod is not important for me anymore since I am using fso-frameworkd. However, since Bob has given you the right to distribute neod under GPLv2 you should really be offering the source code yourself too, right?
Jakob on Sun, 07 Sep 2008 19:44:38 +0200
At the moment there is no mail notification system for new comments. Nevertheless you may watch the rss feed of a selected blogentry, which will show any new comments postet to it.
Link to commentRegarding the neod: As I mentioned before I am not in possesion of the patched neod sources. I was happy that Marcus Bauer mailed me the patched binary. I think I even saw a patchset for it posted to the mailing list. Concerning the GPLv2 you may be right that I need to provide you with the source code. But as I take it from your last comment you are no longer really interested in it. If you still need the sources and you are not capable of contacting Marcus and asking him for the sources, drop me a line and I will do my best to send you the patchset.
greetings
Jakob
jec at jesc dot ch on Wed, 10 Sep 2008 12:28:03 +0200
I have no access to svn:// protocol from here... Our access is http/ftp only...
Link to commentCould you please send me a tarball of the svn repo?
Thanks.
Brenda on Thu, 27 Nov 2008 11:32:04 +0100
I am the wiki editor of Openmoko (wiki.openmoko.org .)
Link to commentI would like to invite you to write an introduction page for your interesting program.
This page will help people easily to find all information of your program.
And share their ideas with you via wiki page.
Your help will be sincerely appreciated.
Best Regards
Brenda
Openmoko Wiki editor
Steven on Tue, 24 Nov 2009 10:20:08 +0100
It does not work on recent kernels,
Link to commentcould you update it please? It really was a cool application!