Exemple #1
0
    def test_read_value(self):
        import adafruit_blinka

        adafruit_blinka.patch_system(
        )  # needed before adafruit_gps imports time

        import microcontroller.pin

        gc.collect()
        import busio

        gc.collect()
        import adafruit_gps

        gc.collect()

        # configure the last available UART (first uart often for REPL)
        uartId, uartTx, uartRx = microcontroller.pin.uartPorts[0]
        uart = busio.UART(uartTx, uartRx, baudrate=9600, timeout=3000)

        gps = adafruit_gps.GPS(uart)

        gps.send_command("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
        gps.send_command("PMTK220,1000")

        def try_fix():
            gps.update()
            return gps.has_fix

        await_true("GPS fix", try_fix)

        self.assertTrue(gps.satellites is not None)
        self.assertTrue(-90 <= gps.latitude < 90)
        self.assertTrue(-180 <= gps.longitude < 180)
Exemple #2
0
 def test_button_pull_down(self):
     print()
     """Pull-down button configured and detected"""
     with DigitalInOut(default_pin) as button:
         #button.direction = Direction.INPUT # implied
         try:
             button.pull = Pull.DOWN
         except NotImplementedError as e:
             print(e)
             return  # pull unsupported, test trivially passed
         except Exception as e:
             print(e)
             return  # pull unsupported, test trivially passed
         if (yes_no("Is Button wired from {} to VCC".format(default_pin))):
             self.assertTrue(button.value == False)
             self.assertTrue(
                 await_true("button pressed", lambda: button.value == True))