2025-12-19 22:41:25 +00:00
from pybricks . tools import wait , StopWatch
from pybricks import version
import OtherFunctions as debug
2026-01-22 16:25:09 -06:00
from MicroPythonDiagnostics import MicroPythonDiagnostics
from pybricks . parameters import Port
2025-12-19 22:41:25 +00:00
class HubDiagnostics :
def __init__ ( self , hub ) :
2026-01-22 16:25:09 -06:00
self . hub = hub
2025-12-19 22:41:25 +00:00
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 ) :
2026-01-22 16:25:09 -06:00
debug . log ( f " [Hub Diagnostics - Light Sources] Turning on pixel at position { x } , { y } ... " , v )
self . hub . display . pixel ( x , y , brightness = 100 )
2025-12-19 22:41:25 +00:00
wait ( 100 )
2026-01-22 16:25:09 -06:00
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