Commit 78fada5e authored by Antonio Caceres's avatar Antonio Caceres
Browse files

Add documentation and NotImplementedError to abstract classes in abstract.py.

parent 15279f68
No related merge requests found
Showing with 32 additions and 4 deletions
+32 -4
"""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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment