|
|
|
@ -16,6 +16,7 @@ known_boards = {'niklas': '00:26:59:34:C8:69',
@@ -16,6 +16,7 @@ known_boards = {'niklas': '00:26:59:34:C8:69',
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
MIN_WEIGHT = 10 |
|
|
|
|
PLAYER_TIMEOUT = 3 |
|
|
|
|
|
|
|
|
|
class StatusThread(Thread): |
|
|
|
|
def __init__(self, t1, t2): |
|
|
|
@ -90,6 +91,7 @@ class WiiThread(Thread):
@@ -90,6 +91,7 @@ class WiiThread(Thread):
|
|
|
|
|
self.pos_x = None |
|
|
|
|
self.pos_y = None |
|
|
|
|
self.weight = 0 |
|
|
|
|
self.timeout = None |
|
|
|
|
|
|
|
|
|
def run(self): |
|
|
|
|
if self.addr != 'dummy': |
|
|
|
@ -111,6 +113,7 @@ class WiiThread(Thread):
@@ -111,6 +113,7 @@ class WiiThread(Thread):
|
|
|
|
|
while not self.stop and self.board.status == 'Connected': |
|
|
|
|
self.weight = self.board.mass.totalWeight |
|
|
|
|
if self.board.mass.totalWeight >= MIN_WEIGHT: |
|
|
|
|
self.timeout = None |
|
|
|
|
m = self.board.mass |
|
|
|
|
x_balance = -(m.topLeft+m.bottomLeft) + (m.topRight+m.bottomRight) |
|
|
|
|
x_balance = x_balance/float(m.totalWeight) |
|
|
|
@ -119,8 +122,12 @@ class WiiThread(Thread):
@@ -119,8 +122,12 @@ class WiiThread(Thread):
|
|
|
|
|
self.pos_x = x_balance |
|
|
|
|
self.pos_y = y_balance |
|
|
|
|
else: |
|
|
|
|
self.pos_x = None |
|
|
|
|
self.pos_y = None |
|
|
|
|
if self.timeout is None: |
|
|
|
|
self.timeout = time.time()+PLAYER_TIMEOUT |
|
|
|
|
else: |
|
|
|
|
if time.time() >= self.timeout: |
|
|
|
|
self.pos_x = None |
|
|
|
|
self.pos_y = None |
|
|
|
|
|
|
|
|
|
time.sleep(0.1) |
|
|
|
|
|
|
|
|
|