Westhoffswelt - Welcome to the real world ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Author: Jakob Westhoff :Date: Wed, 04 Feb 2009 23:44:26 +0100 :Revision: 9 :Copyright: CC by-nc-sa ==================================================== My first Application for the Openmoko Neo Freerunner ==================================================== :Keywords: openmoko, freerunner, eightball, cairo, efl, mobile, programming, application :Description: A little story about what I experienced during the first steps towards writing an application for the Freerunner by myself. You will find a download link and a demonstration video inside. :Abstract: A little story about what I experienced during the first steps towards writing an application for the Freerunner by myself. You will find a download link and a demonstration video inside. 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. __ http://openmoko.com/product.html 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. __ http://en.wikipedia.org/wiki/Magic_Eightball 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. __ http://live.gnome.org/Vala/ __ http://live.gnome.org/Vala/ __ http://www.gtk.org/ __ http://www.inkscape.org/ __ http://wiki.openmoko.org/wiki/Accelerometer_data_retrieval 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. __ http://www.cairographics.org/ __ http://freenode.net/ 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. __ http://enlightenment.org/ __ http://docs.enlightenment.org/api/evas/html/ __ http://docs.enlightenment.org/api/edje/html/ __ http://docs.enlightenment.org/api/evas/html/ __ http://docs.enlightenment.org/api/edje/html/ __ http://enlightenment.org/ 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. __ http://www.python.org/ __ http://www.python.org/ __ http://www.python.org/ __ http://docs.enlightenment.org/api/edje/html/ __ http://docs.enlightenment.org/api/embryo/html/ __ http://www.python.org/ 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. .. image:: http://www.youtube.com/v/_5Um7Chd30Y&hl=en&fs=1&.swf :width: 425 :height: 344 :alt: Moko Eightball in action :align: center A higher resolution version of this video can be downloaded here__ __ http://westhoffswelt.de/data/blog/moko_eightball/eightball_demo.avi 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/neod 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/data/blog/moko_eightball/moko-eightball_0.20080721_om-gta02.ipk 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 __ http://subversion.tigris.org/ If you have got any questions feel free to comment on this post or drop me a line. Trackbacks ========== Comments ======== - Mickey Lauer at Tue, 22 Jul 2008 01:16:42 +0200 Cool, good work. I 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 at Wed, 23 Jul 2008 16:32:02 +0200 Hi Mickey. I 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 at Mon, 04 Aug 2008 22:59:57 +0200 Looks like an awesum application, but where do I get the dependencies? * ERROR: Cannot satisfy the following dependencies for moko-eightball: * python-evas * python-ecore * python-edje * - Timo Juhani Lindfors at 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 - Yorick at Thu, 07 Aug 2008 10:48:43 +0200 I did cd /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 at Thu, 07 Aug 2008 20:52:16 +0200 @Spydon: The 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 at Fri, 08 Aug 2008 11:57:19 +0200 Hi, I installed your Moko Eightball but unfortunately it doesn't start. tail -f x.log says: Traceback (most recent call last): File "/usr/bin/eightball", line 30, in import random ImportError: No module named random Cheers Axel - Axel at Sun, 10 Aug 2008 18:30:23 +0200 Ok, I needed to do a opkg 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 at Mon, 11 Aug 2008 04:18:38 +0200 Did you install the patched neod? The problem with not being able to access the accelerometers is caused by another application accessing them most of the time. greetings Jakob - Yorick at Tue, 26 Aug 2008 12:29:37 +0200 It works without patching the neod on Om2008.8-upgrade! you really should make this a page on the wiki, it's a very nice application! (maybe you can add some sound effects?) - Yorick at 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 it'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 at 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? neod 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 at 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. Regarding 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 at Wed, 10 Sep 2008 12:28:03 +0200 I have no access to svn:// protocol from here... Our access is http/ftp only... Could you please send me a tarball of the svn repo? Thanks. - Brenda at Thu, 27 Nov 2008 11:32:04 +0100 I am the wiki editor of Openmoko (wiki.openmoko.org .) I 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 at Tue, 24 Nov 2009 10:20:08 +0100 It does not work on recent kernels, could you update it please? It really was a cool application!