Retrait debug print.
[minwii.git] / src / pywiiuse / example.py
index 27721b4..a37bf56 100755 (executable)
@@ -10,8 +10,9 @@ import os
 
 nmotes = 2
 
 
 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):
     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])
 
 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):
     #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)
 
 
 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:
 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])
 
 except KeyboardInterrupt:
     for i in range(nmotes):
         wiiuse.set_leds(wiimotes[i], 0)
         #wiiuse.disconnect(wiimotes[i])
 
-fp.close()
 print 'done'
 print 'done'