diff --git a/src/abstract.py b/src/abstract.py index 0b5841dc128faa4b216b378c9c2632802d8ad322..cf5cdcc5de42fb3156ba3c2a8e8a6be20839e593 100644 --- a/src/abstract.py +++ b/src/abstract.py @@ -1,4 +1,11 @@ -"""Collection of abstract classes for type hinting in the rest of the project.""" +"""Collection of abstract classes for type hinting in the rest of the project. + +(For students: don't worry about the code that's in here. +These classes are just providing examples of how to use the proximity sensor, +the LED controller, and the touch sensor for type hinting. +The actual implementations of the classes are on the device. +You'll learn more about abstract classes in CS2. +""" # We aren't using the abc module because it isn't available on circuitpy. class ProximitySensor: @@ -6,14 +13,30 @@ class ProximitySensor: @property def proximity(self) -> int: - return -1 + """Integer in [0, 255] indicating proximity of object to sensor. + + Lower is farther away and higher is closer. + + Example: + `apds.proximity` + """ + raise NotImplementedError class LEDController: """Abstract LED controller.""" def fill(self, color: tuple[int, int, int]) -> None: - pass + """Change the color of the LED being controlled. + + Args: + color: Three-tuple of integers in [0, 255] representing the values + of red, green, and blue to display on the LED. + + Example: + `px.fill((0, 0, 0))` turns the LED off + """ + raise NotImplementedError class TouchSensor: @@ -21,4 +44,9 @@ class TouchSensor: @property def value(self) -> bool: - return False + """If the sensor is being touched. + + Example: + `touch.value` + """ + raise NotImplementedError