def __init__(self, direction_channel, pwm=None, offset=True):
'''Init a motor on giving dir. channel and PWM channel.'''
if self._DEBUG:
print self._DEBUG_INFO, "Debug on"
self.direction_channel = direction_channel
self._pwm = pwm
self._offset = offset
self.forward_offset = self._offset
self.backward_offset = not self.forward_offset
self._speed = 0
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
if self._DEBUG:
print self._DEBUG_INFO, 'setup motor direction channel at', direction_channel
print self._DEBUG_INFO, 'setup motor pwm channel as', self._pwm.__name__
GPIO.setup(self.direction_channel, GPIO.OUT)
评论列表
文章目录