Entries with the tag Groovy

MongoSF videos

10 May, 2010

 If you weren't able to attend MongoSF, you can now view the videos and slides from some of the sessions here. All the videos haven't been uploaded yet so check that link and often over the next week or so to see what's new.

Below is the video from my afternoon session. The morning session went without a hitch so karma fated this one to have technical difficulties (oh well). Enjoy!

 

Motej with Groovy

14 May, 2010

In my presentation at GeeCon 2010, I showed how you could use Groovy to interact with the Nintendo Wiimote, here is the code and a little explanation from one of my demos.

  • Install OS specific native Bluetooth libraries
  • Grab the jars for the Java JSR 82 implementation. Either BlueCove or Aventa. Note that Aventa only has a 14day trial and BlueCove requires linking to an extra gpl jar if you use it on Linux. Mac users on Snow Leopard will have to compile Bluecove from source.
  • Grab slf4j-api-1.5.8.jar and slf4j-simple-1.5.8.jar.

Open a Groovy console and add all the jars (bluecove-2.1.0.jar, bluecove-gpl-2.1.0.jar [if on Linux] and the slf4j jars) to the classpath using Script -> Add Jar to classpath.
Copy the following code into the console.

import motej.*
import motej.event.*

def listener = [moteFound:{Mote mote ->
      println("Found mote: " + mote.getBluetoothAddress())
      mote.setPlayerLeds([false, true, false, true] as boolean[])
      mote.rumble(2000l)
      Thread.sleep(10000l)
      mote.disconnect()
   }
] as MoteFinderListener        
                
MoteFinder finder = MoteFinder.getMoteFinder()
finder.addMoteFinderListener(listener)
                
finder.startDiscovery()
Thread.sleep(30000l)
finder.stopDiscovery()

The above code starts discovery for controllers, registers a listener that rumbles the wiimote and changes the LEDs, and disconnects and stops discovery after a delay. You can activate your Wiimote for discovery by pressing the 1 & 2 buttons at the same time.

You can also download the source and libs in a ready-made project here.

Griffon at Chicago Groovy Users Group

18 May, 2010

Next month, on June 8th, I'll be presenting at the Chicago Groovy Users Group on Griffon. I'll be covering the basics of Griffon development and give some tips on how to port legacy applications from Java. Come one, come all.

You can sign up to attend here.