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