-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
44 lines (35 loc) · 1.28 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import wiiboard
import pygame
import time
def main():
board = wiiboard.Wiiboard()
pygame.init()
address = board.discover()
board.connect(address) #The wii board must be in sync mode at this time
time.sleep(0.1)
board.setLight(True)
done = False
while (not done):
time.sleep(0.05)
for event in pygame.event.get():
if event.type == wiiboard.WIIBOARD_MASS:
#if (event.mass.totalWeight > 10): #10KG. otherwise you would get alot of useless small events!
# print "--Mass event-- Total weight: " + `event.mass.totalWeight` + ". Top left: " + `event.mass.topLeft`
#etc for topRight, bottomRight, bottomLeft. buttonPressed and buttonReleased also available but easier to use in seperate event
if(event.mass.totalWeight > 10):
print event.mass.topLeft, event.mass.topRight
print event.mass.bottomLeft, event.mass.bottomRight
print '____'
elif event.type == wiiboard.WIIBOARD_BUTTON_PRESS:
print "Button pressed!"
elif event.type == wiiboard.WIIBOARD_BUTTON_RELEASE:
print "Button released"
done = True
#Other event types:
#wiiboard.WIIBOARD_CONNECTED
#wiiboard.WIIBOARD_DISCONNECTED
board.disconnect()
pygame.quit()
#Run the script if executed
if __name__ == "__main__":
main()