def __init__(self, lidar, lights, servo, i2c, min_speed=20, max_speed=50):
     self.m0 = d1motor.Motor(0, i2c)
     self.m1 = d1motor.Motor(1, i2c)
     self.m0.frequency(10000)  # 10khz -> quiet
     self.m1.frequency(10000)  # 10khz -> quiet
     self.lidar = lidar
     self.lights = lights
     self.servo = servo
     self.current_speed = 0
     self.actual_speed = 0
     self.min_speed = min_speed
     self.max_speed = max_speed
     asyncio.get_event_loop().create_task(self.drive_autonomous())
Example #2
0
 def __init__(self, i2c, servo_pin, min_speed=100, max_speed=500):
     self.m0 = d1motor.Motor(0, i2c)
     self.m0.frequency(1000)  # 10khz -> quiet
     self.dist_sensor = VL53L0X(i2c)
     self.dist_sensor.start()
     self.dist = self.dist_sensor.read()
     #self.pause_pin=Pin(pause_pin, machine.Pin.IN, machine.Pin.PULL_UP) #its pulled low by a cable in operating mode
     #esp32.wake_on_ext0(pin = self.pause_pin, level = esp32.WAKEUP_ALL_LOW)
     #does not work because of exposed pins
     self.servo = PWM(Pin(servo_pin), freq=50)
     # duty for servo is between 26 - 122 (~180 degrees)
     self.servo.duty(79)  # about center
     self.direction = 0
     self.current_speed = 0
     self.actual_speed = 0
     self.steer()
     self.min_speed = min_speed
     self.max_speed = max_speed
Example #3
0
    def __init__(self):
        self.settings = Settings().load()
        self.i2c = I2C(scl=Pin(Gpio.I2C_SCL), sda=Pin(Gpio.I2C_SDA))
        self.motor_state = MotorState.STOPPED
        self.shade_state = ShadeState.UNKNOWN
        self.ir_sensor = ADC(Gpio.IR_SENSOR)
        self.ir_power = Pin(Gpio.IR_POWER, Pin.OUT)
        self.motor = d1motor.Motor(0, self.i2c)
        self.ir_check_timer = Timer(-1)
        self.motor_check_timer = Timer(-1)
        self.force_moving = 0
        self.stopped_by_ir_sensor = False
        self.speed = 10000
        self.ir_sensor_read = 0

        if self.settings.motor_reversed == b"1":
            self.speed = -10000

        self.motor.brake()
        self.ir_power.off()
Example #4
0
 def __init__(self):
     self.i2c = I2C(scl=Pin(5), sda=Pin(4))
     self.m1 = d1motor.Motor(0, self.i2c)
     self.m2 = d1motor.Motor(1, self.i2c)
Example #5
0
import d1motor
from machine import I2C, Pin
i2c = I2C(Pin(5), Pin(4), freq=10000)
m0 = d1motor.Motor(0, i2c)
m1 = d1motor.Motor(1, i2c)
m0.speed(5000)