X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/blobdiff_plain/b1d5972142e87c4cc58e08e44cbd025cf5f6b26c..079242f81791daf1901745704c12da8214cd92b9:/src/pywiiuse/example.py diff --git a/src/pywiiuse/example.py b/src/pywiiuse/example.py index 27721b4..a37bf56 100755 --- a/src/pywiiuse/example.py +++ b/src/pywiiuse/example.py @@ -10,8 +10,9 @@ import os nmotes = 2 -def handle_event(wm): - print '--- EVENT [wiimote id %i] ---' % wm.unid, wm.btns, wm.btns_held, wm.btns_released +def handle_event(wmp): + wm = wmp[0] + print '--- EVENT [wiimote id %i] ---' % wm.unid if wm.btns: for name,b in wiiuse.button.items(): if wiiuse.is_pressed(wm, b): @@ -84,6 +85,7 @@ else: for i in range(nmotes): wiiuse.set_leds(wiimotes[i], wiiuse.LED[i]) + print 'adr:', wiimotes[i][0].bdaddr_str #wiiuse.rumble(wiimotes[i], 1) # for i in range(nmotes): @@ -93,22 +95,16 @@ for i in range(nmotes): wiiuse.motion_sensing(wiimotes[0], 1) -fp = file('mydata.txt', 'w') -t0 = time.time() try: while True: if wiiuse.poll(wiimotes, nmotes): for i in range(nmotes): m = wiimotes[i][0] if wiimotes[i][0].event == wiiuse.EVENT: - #handle_event(wiimotes[i][0]) - wm = wiimotes[i][0] - t = time.time() - t0 - print >>fp, i, t, wm.gforce.x, wm.gforce.y, wm.gforce.z + handle_event(wiimotes[i]) except KeyboardInterrupt: for i in range(nmotes): wiiuse.set_leds(wiimotes[i], 0) #wiiuse.disconnect(wiimotes[i]) -fp.close() print 'done'