Browse Source

Battery voltages and weights can now be retrieved on the network port

feature/balanceutils
klonfish 8 years ago committed by klonfish
parent
commit
46c8208e26
  1. 32
      wii-pair/daemon.py

32
wii-pair/daemon.py

@ -190,16 +190,30 @@ try: @@ -190,16 +190,30 @@ try:
r = b''
for w in wiis:
if w.pos_x is None:
v = -128
if m[0] == ord('w'):
# Return weight
v = 0
if w.weight is not None:
v = round(w.weight)
r += struct.pack('b', v)
elif m[0] == ord('b'):
# Return battery
v = 0
if w.board.battery is not None:
v = round(w.board.battery*100)
r += struct.pack('b', v)
else:
v = int(round(w.pos_x*100))
r += struct.pack('b', v)
if w.pos_y is None:
v = -128
else:
v = int(round(w.pos_y*100))
r += struct.pack('b', v)
# Return balance
if w.pos_x is None:
v = -128
else:
v = int(round(w.pos_x*100))
r += struct.pack('b', v)
if w.pos_y is None:
v = -128
else:
v = int(round(w.pos_y*100))
r += struct.pack('b', v)
try:
sock.send(r)

Loading…
Cancel
Save