Dec 05

I pulled the Zork Twitter bot apart and rebuilt it using more sensible means.   HTMLUnit for scraping the actual WebZork game and Apache Commons Config for configuration reading.  The code was also restructured to support Twiiter Bot plugins. 

It is a failry simple interface constisting of 4 callbacks that are invoked on interesting Twitter events.
The methods are passed a Twitter client object that allows the bot to send tweets. 

The default example that simple echos any tweet sent to it is:

package com.glulogic.twitter.bot

public class DefaultTweetHandler {

  // Each method called is passed a 'context' hashmap
  // containing the following keys:
  //
  //  from    -  the shortname (login) of the user who sent the Tweet
  //  body    -  the contents of the Tweet (@... removed)
  //  twitter -  an object that can send tweets to Twitter users

  // called when someone sends an  metion (e.g. '@...')
  def mention(context) {
    context.twitter.mention('to': context.from, 'message': "You said ${context.body}")
  }

  // called when someone sends a direct message (e.g. 'd ...')
  def direct(context) {
    context.twitter.direct('to': context.from, 'message': "You said ${context.body}")
  }

  // called when a user begins following
  def follow(context) {
  }

  // called when a user stops following
  def unfollow(context) {
  }
}
Sep 08

It’s time to start the music, it’s time to light the lights….  Dedicated to Animal.

A while ago I responded to a call on the ‘b3ta’ mailing list which asked to able to play the air drums.  So, I created a Flash application that does movement detection using a webcam and plays drum kit sounds when certain parts of the screen/camera detect movement. You have in your kit: a snare, bass, kick,  symbols and a hi-hat.

I originally envisaged people just using their hands to tap a rhythm, but I discovered some people posted about using their tongues! Which is up close and personal!

You could also stand at a distance and dance to the beat of your own drum.

[flash /projects/DrumAnimal/swf/DrumAnimal.swf mode=1]

Note:

On Mac OS X the default webcam selected by Flash may not be appropriate, so you may have to open the Flash settings to change it to the built-in iSight.  For example:

Right Click on the Flash App:  Settings->[WebCam Icon]->[Camera DropDown]-> [ Select: USB Video Class Video]

Sep 06

Back in June I obtained a USB 3G Dongle and thought it would be great if the device could be shared by more than 1 PC/Mac device. I dubbed it ‘CloudSpot’

This sort of devices allows a number of benefits & usage scenarios:

  1. Macs/PCs not requiring drivers (as I have since found out the 3 ZTE dongle drivers do not work with Snow Leopard)
  2. Project teams onsite at customer locations have a private WiFi, thus avoiding restrictive customer site firewalls
  3. Games consoles such as PSP and Nintedo DS could use it (e.g. multiplayer action/web browsing on camping trips)
  4. The dataplan tarrif for the dongle might be better than the dataplan tarrif for a WiFi enabled Mobile Phone

Todo this I thought that it should be possible to present a software WiFi Access point by an embeded system and bridge the WLAN to the 3G dongle.

Initial investigation showed that this has been done before on embedded 486 and PCMCIA, called Stompbox.  But I thought what the hell…

I have experience of embedded systems, more recently the Calao USB9263, so I created a emebeded dev env in a Debian 5.0 VM and made progress into getting the software installed on the device.

The hardware setup looks as follows:

HardwareLayout

Components are:

ARM System on a Chip – A Calao USB9263 device (ARM9, 256Mb flash, 64Mb RAM)

USB Battery Pack – A rechargable module used to suply power to the device

BlueTooth Dongle – A DLink BT device

3G Dongle – THe Hutchinson 3G ZTE USB Dongle.

WiFi Dongle – An Edimax WiFi Dongle

BAterry Powered USB Hub – Gives more ampage to the wireless devices and saves on main device USB batter pack power.

The software development environemnt was based on Debian Lenny (5.0) -avoiding Ubuntu issues

I setup the project structure based on the book Building Embedded Systems

I used crosstools to create the Cross Compiler – avoiding BuildRoot issues

I used Linux kernel 2.6.30 – which contain Calao Device support as part of the mainline

I used emdebian to create the Root filesystem – avoiding Buildroot issues

The drivers for the Dongle’s are either part of the kernel tree or can be downloaded – there are numerous places that document how to get them to work with a Linux system.

I got to the point of having an (em)Debian Lenny with Java (JamVM) running on the device and part way device driver config.

Things left remaining:

  1. Configure 3g Dongle
  2. Configure WiFI dongle
  3. Configure bridging
  4. Support scripts
  5. Optionally addition of secondary services, e.g. support of local rsych backups for laptops via additional USB memory key.

Previous projects

During initial development I came across an old, and somewhat physically larger, project called Stompbox

Since I mothballed this projected a couple of decent looking commercial products have been release:

  1. Thje Hutchinson 3 MiFi
  2. An credit card sized (can’t remember the maker)

There are also a number of software solutions for a few (smart) phones that turn the phone into an AP.

Perhaps the fact that my CloudSpot could, in theory, support any manufacturers 3G dongle and also provide secondary services: small intranet for local workgroups,  backup and could be wired into a LAN; might make it worth continuing.  But one things for sure, it needs a decent box so it doesn’t look like a blaster from Starwars.

Tagged with:
Aug 19

These guys have done something interesting and useful by offering a free to use Geocode API for UK postcodes at

http://ernestmarples.com/

To support the cause I created a Groovy client lib over lunchtime.

Jun 02

Last night I packaged the Java Multitouch SwingTest into a Java WebStart (JNLP) deployment that can be launched from here.

As the package contains a native library it has to be signed, I have only ’self signed’ it; so you may, or may not, wish to accept my certificate.  But acceptence is required in order to run the demo as the native library is needed to register with the MacOSX Multitouch Event handler.

Have fun. :)

Tagged with:
May 31

About a month ago I created a Twitter Bot that lets people play their own instance of Zork. For example send a tweet to:  @zorkgame look http://twitter.com/zorkgame Its very rough and ready ,but have fun for a few minutes if that’s your thing. Some techincal details:

  1. It is written in Groovy,
  2. It has an XMPP client part using Smack API,
  3. It has a HTTP client part using HTTPBuilder
  4. Integration to Twitter is via tweet.im, a Twitter via XMPP service,
  5. Any Large Zork responses are refered to via a Tweet with a link to a temporary user specific drop box on Mailinator which will contain the large message
  6. The Zork game is provided by these guys,  the script POSTs and ‘parses’ the response (screen scrapes),
  7. The bot is hosted on an Amazon VM (as part of another plaything).
Tagged with:
May 30

All recent MacBooks have a Mulitouch touchpad. The raw finger data is not ‘officially’ avaialble, let alone available to Java apps. However some excellent native system digging found here, shows how to obtain the multitouch events, a big thank you to steike / Erling.

To make things simpler for Java development I have written a JNI library and wrapped that in an associated Java class based on the above work. The Java class implements an Observable Pattern, a base implementation is provided by the standard JDK. The end result is a very simple class which allows any number of Java listeners/observers to hook into the native multitouch events.

To excercise the API I have written a Swing and Console test client, I hope to add a WebStart (JNLP) wrapper. EDIT:  Webstart SwingTest can be found here.

Screenshot of Swing app:

swingtest1

Above you can see four of my mucky prints. The numbers represent the finger/blob id, which stays with the finger during contact; interestingly if you release and replace your finger back in the roughly the same point it tends to get the same id.
The ellipsoid shape and rotation are based on values that come from the trackpad.
The Mac trackpad can report up to 11 ‘blobs’ and also reports on size and angle, as well as a number of touch states such as hover – I have had to guess at the meanings of some of the state values as some are obvious, e.g. ‘pressed’, but some other seem very transitional e.g begining hover/ begining press.

An example of the Multitouch Observer API usage can be found below in the Console test Java source:

package com.alderstone.multitouch.mac.touchpad.tests;

import java.util.Observer;
import java.util.Observable;
import com.alderstone.multitouch.mac.touchpad.TouchpadObservable;
import com.alderstone.multitouch.mac.touchpad.Finger;
import com.alderstone.multitouch.mac.touchpad.FingerState;

public class ConsoleTest implements Observer {

        // Class that is resposible for registering with the Trackpad
        // and notifies registered clients of Touchpad Multitouch Events
        TouchpadObservable tpo;

        // Touchpad Multitouch update event handler,
        // called on single MT Finger event

        public void update( Observable obj, Object arg ) {

                // The event 'arg' is of type: com.alderstone.multitouch.mac.touchpad.Finger
                Finger f = (Finger) arg;

                int             frame = f.getFrame();
                double  timestamp = f.getTimestamp();
                int             id = f. getID();
                FingerState             state = f.getState();
                float   size = f.getSize();
                float   angRad = f.getAngleInRadians();
                int             angle = f.getAngle(); // return in Degrees
                float   majorAxis = f.getMajorAxis();
                float   minorAxis = f.getMinorAxis();
                float   x = f.getX();
                float   y = f.getY();
                float   dx = f.getXVelocity();
                float   dy = f.getYVelocity();

                System.out.println( "frame="+frame +
                               "\ttimestamp=" + timestamp +
                               "\tid=" +  id +
                               "\tstate=" + state +
                               "\tsize=" + size  +
                               "\tx,y=(" + x+ "," +  y+
                               ")\tdx,dy=(" + dx + "," + dy +")\t" +
                               "angle=" + angle  +
                               "majAxis=" + majorAxis  +
                               "\tminAxis=" + minorAxis);
        }       

        public void run() {
                tpo = TouchpadObservable.getInstance();
                tpo.addObserver(this);
        }

        public static void main(String[] args) {

                ConsoleTest ct = new ConsoleTest();
                ct.run();
                System.out.println("CTRL-C to exit.");
                try { while(true) {Thread.sleep(5000); }
                } catch (Exception e) {}
        }
}

Attached Files:

Tagged with: