diff --git a/diagnostics/ColorSensorDiagnostics.py b/diagnostics/ColorSensorDiagnostics.py deleted file mode 100644 index a3fdf1a..0000000 --- a/diagnostics/ColorSensorDiagnostics.py +++ /dev/null @@ -1,47 +0,0 @@ -from pybricks.parameters import Color, Port, Stop -from pybricks.tools import wait, StopWatch - -class ColorSensorDiagnostics: - def __init__(self, hub, colorsensorclass): - self.colorsensor = None - self.PORT_MAP = { - "A": Port.A, - "B": Port.B, - "C": Port.C, - "D": Port.D, - "E": Port.E, - "F": Port.F, - } - def initializeColorSensor(self): - VALID_PORTS = {"A", "B", "C", "D", "E", "F"} - while True: - colorinput = input( - "This will test your color sensor.\n" - "Enter the port for the color sensor you would like to test (A, B, C, D, E, or F): " - ).strip().upper() - if colorinput not in VALID_PORTS: - print("Invalid port. Please enter A-F.") - continue - try: - if self.colorsensor is None: - self.colorsensor = self.colorsensorclass(self.PORT_MAP[colorinput]) - print(f"Color Sensor initialized on port {colorinput}.") - else: - print(f"Reusing existing color sensor on port {colorinput}.") - break - - except OSError as e: - if e.errno == 16: # EBUSY - print(f"Port {colorinput} is already in use. Reusing existing color sensor.") - break - else: - print(f"Error initializing color sensor on port {colorinput}: {e}") - print("Make sure a color sensor is actually connected to this port.") - self.colorsensor = None - self.colorsensor.detectable_colors(Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE, Color.WHITE, Color.NONE) - def printAll(self): - self.initializeColorSensor() - stopwatch = StopWatch() - while stopwatch.time < 5000: - print("HSV output:", self.colorsensor.hsv) - print("Detected color:", self.colorsensor.color()) \ No newline at end of file