def activate(self): GPIO.output(self.gpio, GPIO.HIGH) if self.get_register(self.__VL6180X_SYSTEM_FRESH_OUT_OF_RESET) == 1: print("ToF sensor is ready.") self.ready = True else: print("ToF sensor reset failure.") self.ready = False # Required by datasheet # http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/DM00122600.pdf self.set_register(0x0207, 0x01) self.set_register(0x0208, 0x01) self.set_register(0x0096, 0x00) self.set_register(0x0097, 0xfd) self.set_register(0x00e3, 0x00) self.set_register(0x00e4, 0x04) self.set_register(0x00e5, 0x02) self.set_register(0x00e6, 0x01) self.set_register(0x00e7, 0x03) self.set_register(0x00f5, 0x02) self.set_register(0x00d9, 0x05) self.set_register(0x00db, 0xce) self.set_register(0x00dc, 0x03) self.set_register(0x00dd, 0xf8) self.set_register(0x009f, 0x00) self.set_register(0x00a3, 0x3c) self.set_register(0x00b7, 0x00) self.set_register(0x00bb, 0x3c) self.set_register(0x00b2, 0x09) self.set_register(0x00ca, 0x09) self.set_register(0x0198, 0x01) self.set_register(0x01b0, 0x17) self.set_register(0x01ad, 0x00) self.set_register(0x00ff, 0x05) self.set_register(0x0100, 0x05) self.set_register(0x0199, 0x05) self.set_register(0x01a6, 0x1b) self.set_register(0x01ac, 0x3e) self.set_register(0x01a7, 0x1f) self.set_register(0x0030, 0x00) # Change address if requested if self.wanted_address != 0x29: self.change_address(0x29, self.wanted_address) self.get_distance( ) # This is needed because sometimes the very first measurement is 0
def setSpeedRight(self, power, coeff=0): if (power < 0): GPIO.output(self.pins['dir_fr'], GPIO.LOW) GPIO.output(self.pins['dir_rr'], GPIO.LOW) else: GPIO.output(self.pins['dir_fr'], GPIO.HIGH) GPIO.output(self.pins['dir_rr'], GPIO.HIGH) power = abs(power) if power > 100: power = 100 if power + coeff > 100: coeff = 100 elif power + coeff < 0: coeff = 0 else: coeff = power + coeff PWM.start(self.pins['fr'], power, 25000) PWM.start(self.pins['rr'], coeff, 25000) self.actual_r = power
def activate(self): GPIO.output(self.gpio, GPIO.HIGH) # Change address if requested if self.wanted_address != 0x29: self.change_address(0x29, self.wanted_address)
def deactivate(self): GPIO.output(self.gpio, GPIO.LOW)
def __init__(self, pin= params.LED_PIN): self.pin = pin GPIO.setup(self.pin, GPIO.OUT) GPIO.output(self.pin, GPIO.LOW)
def off(self): ''' Turn off the Led ''' GPIO.output(self.pin, GPIO.LOW)
def on(self): ''' Turn on the Led ''' GPIO.output(self.pin, GPIO.HIGH)