a guest Oct 30th, 2013 5 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- class ServoController():
- """ Object that chats with controller over serial and sends him values
- with syntax: <value><servo_letter>"""
- def __init__(self, loop, tty):
- """ we need functional loop and tty we should connec to """
- self._s = serial.Serial(tty, 57600)
- self._tty_handle = pyuv.TTY(loop, self._s.fileno(), True)
- def _on_read(self, status_handle, data, error):
- """ callback called everytime that our pyuv.TTY receives something, in
- this case we didn't defined any response from controller!'"""
- def setPosition(self, position, letter):
- """sets servo to position based on it's letter'"""
- assert 500 <= position <= 2500
- position = str(position)
- string = position + letter
- print(("ServoController output: ", string))
RAW Paste Data