forked from Arcmyx/pynamics
Update diagnostics/hub_diagnostics.py
This commit is contained in:
41
diagnostics/hub_diagnostics.py
Normal file
41
diagnostics/hub_diagnostics.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from pybricks.tools import wait, StopWatch
|
||||
from pybricks import version
|
||||
import other_functions as debug
|
||||
from micropython_diagnostics 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
|
||||
Reference in New Issue
Block a user