Example #1
0
    def __init__(self,
                 channel,
                 invert=False,
                 frequency=60,
                 left_pulse=290,
                 right_pulse=490):
        from navio import util
        import RPi.GPIO as GPIO
        import Adafruit_PCA9685

        util.check_apm()

        #Navio+ requires the GPIO line 27 to be set to low
        #before the PCA9685 is accesed
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(27, GPIO.OUT)
        GPIO.output(27, GPIO.LOW)

        self.frequency = frequency
        self.channel = channel
        self.invert = invert
        self.left_pulse = left_pulse
        self.right_pulse = right_pulse
        self.pwm = Adafruit_PCA9685.PCA9685()
        self.pwm.set_pwm_freq(frequency)
Example #2
0
 def __init__(self, channel, frequency=50):
     from navio2 import pwm as navio_pwm
     from navio2 import util
     util.check_apm()
     self.pwm = navio_pwm.PWM(channel)
     self.pwm.initialize()
     self.channel = channel
     self.pwm.set_period(frequency)
Example #3
0
 async def start(self):
     util.check_apm()
     self.imu = mpu9250.MPU9250()
     try:
         self.imu.initialize()
     except:
         logging.error("Could not initialize IMU")
         return
     await asyncio.sleep(2)
     while not self.stopped:
         m9a, m9g, m9m = self.imu.getMotion9()
         await asyncio.sleep(0.1)
         self.cached = (m9a, m9g, m9m)
Example #4
0
    def __init__(self, channel, invert=False):
        from navio import adafruit_pwm_servo_driver as pwm
        from navio import util
        import RPi.GPIO as GPIO
        util.check_apm()

        #Navio+ requires the GPIO line 27 to be set to low
        #before the PCA9685 is accesed
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(27, GPIO.OUT)
        GPIO.output(27, GPIO.LOW)

        #GPIO.cleanup()
        self.frequency = 60
        self.channel = channel
        self.invert = invert
        self.pwm = pwm.PWM()
        self.pwm.setPWMFreq(self.frequency)
Example #5
0
 async def start(self):
     logging.info("Start StereoSonar")
     util.check_apm()
     logging.info("APM checked")
     try:
         self.adc = adc.ADC()
     except:
         logging.error("Could not load ADC, no sonar available")
         return
     logging.info("Created ADC")
     await asyncio.gather(self.__setup_pin(self.trigger_left),
                          self.__setup_pin(self.trigger_right))
     logging.info("Setup Sonar Pins")
     await asyncio.sleep(2)
     while not self.stopped:
         left_volts = await self.__read_pin(self.trigger_left,
                                            self.channel_left)
         self.cached = (left_volts, self.cached[1])
         right_volts = await self.__read_pin(self.trigger_right,
                                             self.channel_right)
         self.cached = (self.cached[0], right_volts)