|
1 |
| -import time, board, pwmio, digitalio as dio, analogio as aio, adafruit_hcsr04, neopixel, busio, fourwire, displayio, audiopwmio |
| 1 | +import time, board, pwmio, digitalio as dio, analogio as aio, adafruit_hcsr04, neopixel, busio, fourwire, displayio |
2 | 2 | from adafruit_st7789 import ST7789
|
3 | 3 |
|
4 |
| -def sleep_us(microseconds : int): |
5 |
| - start = time.monotonic_ns() |
6 |
| - while time.monotonic_ns() - start < microseconds * 1000: |
7 |
| - pass |
8 |
| - |
9 | 4 | class PicoGo:
|
10 |
| - def __init__(self, np_auto_write : bool = True, use_onboard_ble : bool = True): |
| 5 | + def __init__(self, np_auto_write : bool = True): |
11 | 6 | # Motor
|
12 | 7 | self.MOTOR_PWM_A = pwmio.PWMOut(board.GP16, frequency=1000)
|
13 | 8 | self.MOTOR_PWM_B = pwmio.PWMOut(board.GP21, frequency=1000)
|
@@ -48,13 +43,14 @@ def __init__(self, np_auto_write : bool = True, use_onboard_ble : bool = True):
|
48 | 43 | self.DISPLAY = ST7789(self.DISPLAY_BUS, width=240, height=135, rotation=270, rowstart=40, colstart=53)
|
49 | 44 |
|
50 | 45 | # Buzzer
|
51 |
| - # No working, because all timers are in use |
52 |
| - # self.SPEKER = audiopwmio.PWMAudioOut(board.GP4) |
| 46 | + # Not working, because all timers are in use |
| 47 | + # self.SPEAKER = audiopwmio.PWMAudioOut(board.GP4) |
53 | 48 |
|
54 | 49 | # Bluetooth module
|
55 | 50 | # No Adafruit BLE, because CTS and RTS aren't connected
|
56 | 51 | self.BLE = busio.UART(board.GP0, board.GP1, baudrate=115200)
|
57 |
| - |
| 52 | + |
| 53 | + # Range: -1.0 (backwards) to 1.0 (forwards), 0 (stop) |
58 | 54 | def set_motors(self, a : float | None, b : float | None):
|
59 | 55 | if a != None:
|
60 | 56 | a = min(1, max(-1, a))
|
@@ -91,6 +87,7 @@ def read_battery_percentage(self):
|
91 | 87 | # No freaking clue what this does, just copied it from the original
|
92 | 88 | return min(max((self.BATTERY.value * 3.3 / 65535 * 2 - 3) * 100 / 1.2, 0), 100)
|
93 | 89 |
|
| 90 | +# Run module directly to check if everything initilizes properly |
94 | 91 | if __name__ == "__main__":
|
95 | 92 | print("Initializing...")
|
96 | 93 | go = PicoGo()
|
|
0 commit comments