forked from Arcmyx/pynamics
Fixed everything, final commit before 1.0.0
This commit is contained in:
@@ -8,10 +8,12 @@ from BatteryDiagnostics import BatteryDiagnostics
|
||||
from MotorDiagnostics import MotorDiagnostics
|
||||
from ColorSensorDiagnostics import ColorSensorDiagnostics
|
||||
from DriveBaseDiagnostics import DriveBaseDiagnostics
|
||||
from HubDiagnostics import HubDiagnostics
|
||||
battery = BatteryDiagnostics(HUB)
|
||||
motor = MotorDiagnostics(HUB, Motor)
|
||||
colorsensor = ColorSensorDiagnostics(HUB, ColorSensor)
|
||||
drivebase = DriveBaseDiagnostics(HUB, Motor, DriveBase)
|
||||
hubdiagnostics = HubDiagnostics(HUB)
|
||||
CLEARCONFIRM = input("Clear the console before proceeding? Y/N (default: yes): ")
|
||||
if(CLEARCONFIRM == "Y" or CLEARCONFIRM == "y" or CLEARCONFIRM == "yes" or CLEARCONFIRM == ""):
|
||||
print("Clearing console... \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
|
||||
@@ -35,6 +37,8 @@ while True:
|
||||
print("Enter 'b' for battery diagnostics")
|
||||
print("Enter 'm' for motor diagnostics")
|
||||
print("Enter 'cs' for color sensor diagnostics")
|
||||
print("Enter 'db' for drive base diagnostics")
|
||||
print("Enter 'h' for hub diagnostics")
|
||||
print("Enter 'q' to quit")
|
||||
|
||||
choice = input("Your choice: ").strip().lower()
|
||||
@@ -49,7 +53,7 @@ while True:
|
||||
elif choice == "m":
|
||||
print("------------------------MOTOR DIAGNOSTICS------------------------")
|
||||
motor.fullTest()
|
||||
print("Motor diagnostics completed.")
|
||||
print("[Motor Diagnostics] Motor diagnostics completed.")
|
||||
|
||||
elif choice == "q":
|
||||
print("Diagnostics completed successfully. Exiting program.")
|
||||
@@ -57,10 +61,13 @@ while True:
|
||||
elif choice == "cs":
|
||||
print("---------------------COLOR SENSOR DIAGNOSTICS---------------------")
|
||||
colorsensor.printAll()
|
||||
print("Color sensor diagnostics completed.")
|
||||
print("[Color Sensor Diagnostics] Color sensor diagnostics completed.")
|
||||
elif choice == "db":
|
||||
print("----------------------DRIVE BASE DIAGNOSTICS----------------------")
|
||||
drivebase.printAll()
|
||||
print("Drivebase diagnostics completed.")
|
||||
print("[Drivebase Diagnostics] Drivebase diagnostics completed.")
|
||||
elif choice == "h":
|
||||
print("--------------------------HUB DIAGNOSTICS--------------------------")
|
||||
hubdiagnostics.printAll(False)
|
||||
else:
|
||||
print("Invalid choice. Please enter 'b', 'm', or 'q'.")
|
||||
@@ -1,13 +1,11 @@
|
||||
from pybricks.tools import wait, StopWatch
|
||||
from pybricks import version
|
||||
import OtherFunctions as debug
|
||||
import usys
|
||||
|
||||
print("Pybricks version information:", version)
|
||||
print("MicroPython information:", usys.implementation)
|
||||
print("MicroPython version:", usys.version)
|
||||
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,
|
||||
@@ -21,8 +19,23 @@ class HubDiagnostics:
|
||||
self.hub.display.off()
|
||||
for x in range(5):
|
||||
for y in range(5):
|
||||
debug.log(f"Turning on pixel at position {x}, {y}...", v)
|
||||
display.pixel(x, y, brightness=100)
|
||||
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"Turning off pixel at position {x}, {y}...", v)
|
||||
display.pixel(x, y, brightness=0)
|
||||
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
|
||||
11
diagnostics/MicroPythonDiagnostics.py
Normal file
11
diagnostics/MicroPythonDiagnostics.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import usys
|
||||
from pybricks import version
|
||||
class MicroPythonDiagnostics:
|
||||
def __init__(self, hub):
|
||||
pass
|
||||
def printAll():
|
||||
print("[Hub Diagnostics - MicroPython] Hub version information:", version)
|
||||
print("[Hub Diagnostics - MicroPython] MicroPython version:", usys.version)
|
||||
print("[Hub Diagnostics - MicroPython] Pybricks version information:", usys.version_info)
|
||||
print("[Hub Diagnostics - MicroPython] MicroPython information:", usys.implementation)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
verbose = True
|
||||
def log(string):
|
||||
def log(string, verbose):
|
||||
if(verbose):
|
||||
print("[LOG (verbose)]", string)
|
||||
|
||||
Reference in New Issue
Block a user