Skip to content

Commit 786b984

Browse files
author
Martin O'Hanlon
committed
pinout tests and docs
1 parent b64cdae commit 786b984

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

docs/api.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,8 @@ DigitalInputDevice
140140
:show-inheritance:
141141
:inherited-members:
142142
:members:
143+
144+
pinout
145+
------
146+
147+
.. autofunction:: pinout

picozero/picozero.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@ class EventFailedScheduleQueueFull(Exception):
1818

1919
def clamp(n, low, high): return max(low, min(n, high))
2020

21-
def pinout():
22-
print(""" ---usb---
21+
def pinout(output=True):
22+
"""
23+
Returns a textual representation of the Raspberry Pi pico pins and functions.
24+
25+
:param bool output:
26+
If :data:`True` (the default) the pinout will be "printed".
27+
28+
"""
29+
pins = """ ---usb---
2330
GP0 1 |o o| -1 VBUS
2431
GP1 2 |o o| -2 VSYS
2532
GND 3 |o o| -3 GND
@@ -40,7 +47,11 @@ def pinout():
4047
GND 18 |o o| -18 GND
4148
GP14 19 |o o| -19 GP17
4249
GP15 20 |o o| -20 GP16
43-
---------""")
50+
---------"""
51+
52+
if output:
53+
print(pins)
54+
return pins
4455

4556
class PinMixin:
4657
"""

tests/test_picozero.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,15 @@ def assertInRange(self, value, lower, upper):
6767
msg = "Expected %r to be in range {} to {}".format(lower, upper)
6868
self.assertTrue(value <= upper, msg)
6969
self.assertTrue(value >= lower, msg)
70-
70+
71+
###########################################################################
72+
# SUPPORTING
73+
###########################################################################
74+
75+
def test_pinout(self):
76+
pins = pinout(output=False)
77+
self.assertIsNotNone(pins)
78+
7179
###########################################################################
7280
# OUTPUT DEVICES
7381
###########################################################################

0 commit comments

Comments
 (0)