Skip to content

Instantly share code, notes, and snippets.

@pbuyle
Created December 27, 2008 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbuyle/40256 to your computer and use it in GitHub Desktop.
Save pbuyle/40256 to your computer and use it in GitHub Desktop.
from tuxisalive.api import *
def start_spin(*args):
key = args[0]
if(key == K_LEFT):
tux.spinning.leftOnAsync(1.0, SPV_SLOW)
else:
tux.spinning.rightOnAsync(1.0, SPV_SLOW)
tux = TuxAPI('127.0.0.1', 270)
tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, 'MonScript', 'NONE')
tux.server.waitConnected(10.0)
tux.dongle.waitConnected(10.0)
tux.radio.waitConnected(10.0)
if tux.access.waitAcquire(10.0, ACCESS_PRIORITY_NORMAL):
tux.button.remote.registerEventOnPressed(start_spin, K_LEFT)
tux.button.remote.registerEventOnPressed(start_spin, K_RIGHT)
tux.button.remote.registerEventOnPressed(tux.spinning.off, K_OK)
tux.button.remote.registerEventOnPressed(tux.flippers.up, K_UP)
tux.button.remote.registerEventOnPressed(tux.flippers.down, K_DOWN)
while(not tux.button.remote.waitPressed(1000.0, K_STANDBY)):
pass
tux.access.release()
tux.server.disconnect()
tux.destroy();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment