mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
19 lines
568 B
Python
19 lines
568 B
Python
from pylgbst.hub import MoveHub
|
|
from pylgbst.peripherals import VisionSensor, EncodedMotor
|
|
|
|
|
|
class Joystick(object):
|
|
def __init__(self):
|
|
super(Joystick, self).__init__()
|
|
self._hub = MoveHub()
|
|
self._sensor = []
|
|
|
|
def disconnect(self):
|
|
self._hub.disconnect()
|
|
|
|
def on_color_sensor(self, callback):
|
|
self._hub.vision_sensor.subscribe(callback, VisionSensor.COLOR_RGB, granularity=5)
|
|
|
|
def on_external_motor(self, callback):
|
|
self._hub.motor_external.subscribe(callback, EncodedMotor.SENSOR_ANGLE, granularity=5)
|