Introducing the cwiid gem

First of all install the cwiid libraries including the boost C++ libraries, and then install the cwiid gem. See my blog entry for more information.

Here's the code I used in an IRB session:

require 'cwiid'
puts 'Put Wiimote in discoverable mode now (press 1+2)...'
wiimote = WiiMote.new

(wiimote.public_methods - Object.public_methods).sort
#=> [:acc, :battery, :buttons, :close, :get_state, :ir, :led, :led=, :orig_battery, :request_status, :rpt_mode, :rpt_mode=, :rumble, :rumble=]

wiimote.rumble = true 
#=> true # I heard it rumbling
wiimote.rumble = false
#=> false # the rumbling stopped
wiimote.led
#=> 0
wiimote.battery
#=> 0.0
wiimote.ir
#=> []
wiimote.led = 1
#=> 1 # observed the 1st led light up
wiimote.led = 2
#=> 2 # observed the 2nd led light up
wiimote.led = 3
#=> 3 # observed the 3rd led light up
wiimote.led = 4
#=> 4 # observed the 4th led light up
wiimote.led = 5
#=> 5 # observed the 1st and the 3rd led light up
wiimote.led = 6
#=> 6 # observed the 2nd and the 4th led light up
wiimote.led = 7
#=> 7 # observed the 1st, 2nd and the 3rd leds light up

wiimote.led = 0
#=> 0 # observed no leds light up

Note: The LEDs are programmed using binary log (8 4 2 1).

Tags:
Source:
1157hrs.txt
Published:
13-12-2011 11:57