41 lines
1.8 KiB
Python
41 lines
1.8 KiB
Python
from pybricks.tools import wait, StopWatch
|
|
from pybricks import version
|
|
import OtherFunctions as debug
|
|
from MicroPythonDiagnostics import MicroPythonDiagnostics
|
|
from pybricks.parameters import Port
|
|
class HubDiagnostics:
|
|
def __init__(self, hub):
|
|
self.hub = hub
|
|
self.port_map = {
|
|
"A": Port.A,
|
|
"B": Port.B,
|
|
"C": Port.C,
|
|
"D": Port.D,
|
|
"E": Port.E,
|
|
"F": Port.F,
|
|
}
|
|
def testLightSources(self, verbose):
|
|
v = verbose
|
|
self.hub.display.off()
|
|
for x in range(5):
|
|
for y in range(5):
|
|
debug.log(f"[Hub Diagnostics - Light Sources] Turning on pixel at position {x}, {y}...", v)
|
|
self.hub.display.pixel(x, y, brightness=100)
|
|
wait(100)
|
|
debug.log(f"[Hub Diagnostics - Light Sources] Turning off pixel at position {x}, {y}...", v)
|
|
self.hub.display.pixel(x, y, brightness=0)
|
|
|
|
def printAll(self, verbose=True):
|
|
v = verbose
|
|
debug.log("[Hub Diagnostics] Starting hub diagnostics...", v)
|
|
while True:
|
|
choice = input("[Hub Diagnostics] Which hub diagnostic would you like to run?\n[Hub Diagnostics] Enter 'l' for light source test\n[Hub Diagnostics] Enter 'm' for MicroPython diagnostics\n[Hub Diagnostics] Enter 'q' to quit\n[Hub Diagnostics] Your choice: ").strip().lower()
|
|
if choice == "l":
|
|
debug.log("[Hub Diagnostics] Running light source test...", v)
|
|
self.testLightSources(v)
|
|
if choice == "m":
|
|
debug.log("[Hub Diagnostics] Running MicroPython diagnostics...", v)
|
|
MicroPythonDiagnostics.printAll()
|
|
if choice == "q":
|
|
print("[Hub Diagnostics] Hub diagnostics completed.")
|
|
return |