Author Archive for xhochy

Programming with the WiiMote (II)

I will use in the following posts Ubuntu Linux (8.04) as operating system, that I’ll give some specific tips only for it, on other systems some things might work different, but the code should work without modification everywhere. At first we need to install some software requirements, the python wrapper for the WiiMote and for general Bluetooth actions the bluez python wrapper:

sudo apt-get install python-cwiid python-bluez

To start simple, we have to read out the adress of the WiiMote we use, this is done by activating our bluetooth device, pressing 1+2 on the WiiMote and running the following command:

hcitool scan

After about 10 seconds this will produce an output like this:

00:1F:45:8B:22:6F    Nintendo RVL-CNT-01

The first of this two columns is the identifier of your WiiMote which we will need for our first python script. For the beginning we only want to connect with our WiiMote and let the LEDs blink. Knowing the Hardware adress of the WiiMotes simplifies the connection via python:

import cwiid

wiimote = cwiid.Wiimote(”00:1F:45:8B:22:6F”)

Now after we connected to the WiiMote via Python(you still need to press 1+2 while the connection is initiated) we want let the LEDs blink. This is done by setting the wiimote.led to valid mask. For example, if you want to turn on the LEDs 1, 3 and 4 this is done via this short code snippet:

wiimote.led = cwiid.LED1_ON | cwiid.LED3_ON | cwiid.LED4_ON

To let them blink, we put all in this in a never-ending while loop and get the following whole script:

import cwiid
import time

wiimote = cwiid.Wiimote("00:1F:45:8B:22:6F")

while True:
    time.sleep(0.1)
    s.led = cwiid.LED1_ON | cwiid.LED4_ON
    time.sleep(0.1)
    s.led = cwiid.LED2_ON | cwiid.LED3_ON

Share/Save/Bookmark

Programming with the WiiMote (I)

This year we will make a workshop at my school about programming with the WiiMote. In parallel to this workshop I will give a small round-up every week on our process in the form of a tutorial. Things mentioned in this tutorial are not all from the workshop since this article is published before any meeting of our workshop.

As the first step, we want just see what information the WiiMote provides. We are using the programm “WMGui”. The WiiMote is connected to use with this program by the following:

  1. Turn on the bluetooth of you PC
  2. Start wmgui
  3. Press the buttons 1 and 2 of the WiiMote simultaneously to make it discoverable
  4. Choose File->Connect in the wmgui-menu

By default only the Buttons section is enabled, here a button is highlighted green if it is pressed. You could press any button without fear, at the moment they do not modify anything. The most interesting thing on the WiiMote for a common user are the acceleration sensors which we could enable by Settings->Acc Data. X, Y, Z show the acceleration in the different coordinate directions. Acc shows the acceleration of the motion in all directions. Roll shows the position of the WiiMote, exactly its sidewards position, 0 is when it rests upside up on the table. Pitch shows the position on the other axis(front/back). There are only 2 values of positioning since the WiiMote could only be turned on two axes, front up/down or turning sidewards. People already knowing more about the WiiMote will be more interested in the IR camera which is activated through Settings->IR Data. If you want to play a bit, take a look under Controls->…, this gives you the probability to switch on the different LEDs on the WiiMote and to let it rumble!

Keep up for coming posts getting into detail with the WiiMote, we will start programming ;-)

Share/Save/Bookmark

Update on Schoorbs Versioning

Since there will be major changes in the next Schoorbs release, I will introduce a new versioning system for Schoorbs which will be the same as Ubuntu has(<year>.<month>). I want to do this now to confuse as less people as possible since Schoorbs user base is growing at the moment, but still is small. The next release will include changes which really makes a cut and after that there will be a big difference between Schoorbs and MRBS (but for compability reasons we’ll still use the same DB layout since this has be proven as good (but not as perfect)). So the next upcoming release will be either 8.10, 8.11 or 8.12. I can not say at the moment in which month it ships since there are more changes than I expected, but I hope to get it out before Christmas.

Share/Save/Bookmark

Preview of JS Effects in administration of Schoorbs

Just to show how the new interface looks like and behaves.

Share/Save/Bookmark

Inspecting Pidgin (II)

Using strace I wanted to make up some statistics how many files pidgin loads during a 5 second startup time. Using grep and regexes the following is shown:

Attempts to a open file: 2886

Failed Attempts: 1457

Opened(non-failed) for read-only: 1407

Opened(non-failed) for read-only without those from /var/cache: 1371

Shared libraries: 213

PNG-images: 90

ICON-images: 164

Share/Save/Bookmark