Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs1-24fa
project03
Commits
78fada5e
Commit
78fada5e
authored
6 months ago
by
Antonio Caceres
Browse files
Options
Download
Email Patches
Plain Diff
Add documentation and NotImplementedError to abstract classes in abstract.py.
parent
15279f68
master
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/abstract.py
+32
-4
src/abstract.py
with
32 additions
and
4 deletions
+32
-4
src/abstract.py
View file @
78fada5e
"""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
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help