Simple test

Ensure your device works with this simple test.

examples/laser_at_simpletest.py
 1# SPDX-FileCopyrightText: Copyright (c) 2022 Phil Underwood for Underwood Underground
 2#
 3# SPDX-License-Identifier: Unlicense
 4import time
 5import board
 6from laser_at import Laser
 7
 8
 9uart = board.UART()
10uart.baudrate = 19200
11laser = Laser(uart, speed=Laser.FAST)
12now = time.monotonic()
13print("BEGIN!\n")
14print(f"FAST: {laser.distance}cm")
15print(f"Time: {time.monotonic()-now}")
16
17laser.speed = Laser.MEDIUM
18now = time.monotonic()
19print(f"MEDIUM: {laser.distance}cm")
20print(f"Time: {time.monotonic()-now}")
21
22laser.speed = Laser.SLOW
23now = time.monotonic()
24print(f"SLOW: {laser.distance}cm")
25print(f"SLOW: {laser.distance}cm")
26print(f"Time: {time.monotonic()-now}")
27
28
29time.sleep(2)
30print(f"Laser is {laser.on}")
31print("Turning laser on")
32laser.on = True
33time.sleep(2)
34print(f"Laser is {laser.on}")
35laser.on = False
36print(f"Laser is {laser.on}")