Skip to content

Commit f5030e9

Browse files
author
Martin O'Hanlon
authored
Merge pull request #93 from RaspberryPiFoundation/dev
0.4.1
2 parents 8ee7226 + 28686b6 commit f5030e9

16 files changed

+155
-33
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

docs/changelog.rst

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@ Change log
33

44
.. currentmodule:: picozero
55

6+
0.4.1 - 2022-12-22
7+
------------------
8+
9+
+ Introduced ``pinout()``
10+
+ Bug fix with ``DigitalInputDevice.when_deactivated`` decorator
11+
+ Documentation tidy up and minor fixes
12+
613
0.4.0 - 2022-11-18
7-
~~~~~~~~~~~~~~~~~~
14+
------------------
815

916
+ Introduced ``Servo`` class
1017
+ Documentation fixes
1118

1219
0.3.0 - 2022-08-12
13-
~~~~~~~~~~~~~~~~~~
20+
------------------
1421

1522
+ Introduced ``Motor``, ``Robot``, and ``DistanceSensor`` classes.
1623
+ Renamed ``LED`` factory ``use_pwm`` parameter to ``pwm`` to match other classes. **Note:** This is an API breaking change.
@@ -20,12 +27,12 @@ Change log
2027
+ Documentation updates.
2128

2229
0.2.0 - 2022-06-29
23-
~~~~~~~~~~~~~~~~~~
30+
------------------
2431

2532
+ Pico W compatibility fix for onboard LED.
2633

2734
0.1.1 - 2022-06-08
28-
~~~~~~~~~~~~~~~~~~
35+
------------------
2936

3037
+ Minor fixes for bugs found during testing.
3138
+ Small improvements to exception messages.
@@ -34,19 +41,19 @@ Change log
3441
+ Added RGBLED.colour as an alias to RGBLED.color.
3542

3643
0.1.0 - 2022-04-08
37-
~~~~~~~~~~~~~~~~~~
44+
------------------
3845

3946
+ Beta release.
4047
+ Documentation updates.
4148
+ Minor bug fixes and refactoring.
4249

4350
0.0.2 - 2022-03-31
44-
~~~~~~~~~~~~~~~~~~
51+
------------------
4552

4653
+ Bug fixes and documentation updates.
4754

4855
0.0.1 - 2022-03-21
49-
~~~~~~~~~~~~~~~~~~
56+
------------------
5057

5158
+ Initial alpha release to test installation process.
5259

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __getattr__(cls, name):
4747
author = 'Raspberry Pi Foundation'
4848

4949
# The full version, including alpha/beta/rc tags
50-
release = '0.4.0'
50+
release = '0.4.1'
5151

5252

5353
# -- General configuration ---------------------------------------------------

docs/developing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ Install sphinx using ::
4040

4141
To test the documentation build, run the following command from the docs directory ::
4242

43-
$ make html
43+
$ ./make html
4444

4545
The website will be built in the directory docs/_build/html.
4646

47-
Documentation can be viewed at `picozero.readthedocs.io`_ and is automatically built and deployed on commit.
47+
Documentation can be viewed at `picozero.readthedocs.io`_ and is automatically built and deployed on push to github.
4848

4949
.. _picozero.readthedocs.io: https://picozero.readthedocs.io
5050

docs/examples/led_blink.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from picozero import LED
2-
from time import sleep
32

43
led = LED(14)
54

docs/examples/led_pulse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from time import sleep
21
from picozero import LED
2+
from time import sleep
33
from math import sin, radians
44

55
led = LED(14)

docs/examples/led_pulse_method.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from picozero import LED
2+
3+
led = LED(14)
4+
5+
led.pulse()

docs/examples/pico_temperature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Choose View -> Plotter in Thonny to see a graph of the results
22

3-
from time import sleep
43
from picozero import pico_temp_sensor
4+
from time import sleep
55

66
while True:
77
print(pico_temp_sensor.temp)

docs/examples/print_pinout.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from picozero import pinout
2+
3+
pinout()

docs/examples/robot_rover_square.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from picozero import Robot
2-
from time import sleep
32

43
robot_rover = Robot(left=(14,15), right=(12,13))
54

docs/gettingstarted.rst

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
..
33
.. SPDX short identifier: MIT
44
5+
===============
56
Getting started
67
===============
78

9+
Install using Thonny
10+
====================
11+
812
Requirements
913
------------
1014

@@ -20,36 +24,53 @@ Once Thonny is installed, you will need to ensure that you are using the latest
2024

2125
.. _Pico guide: https://learning-admin.raspberrypi.org/en/projects/introduction-to-the-pico/3
2226

23-
Use the MicroPython interpreter
24-
-------------------------------
27+
Select the MicroPython interpreter
28+
----------------------------------
2529

2630
You can change which interpreter you are using in Thonny by selecting the desired option at the bottom right of the screen. Make sure that **MicroPython (Raspberry Pi Pico)** is selected.
2731

2832
.. image:: images/thonny-switch-interpreter.jpg
33+
:alt: Selecting MicroPython (Raspberry Pi Pico) from the interpreter menu in the bottom right of the Thonny IDE
2934

3035
Install picozero from PyPI in Thonny
3136
------------------------------------
3237

3338
To install picozero within Thonny, select **Tools** > **Manage packages...**
3439

3540
.. image:: images/thonny-manage-packages.jpg
41+
:alt: Selecting Manage Packages from the Tools menu in Thonny
3642

3743
Search for `picozero` on PyPI.
3844

3945
.. image:: images/thonny-packages-picozero.jpg
46+
:alt: picozero entered in the Search box of the Manage Packages window in Thonny
4047

4148
Click on **install** to download the package.
4249

4350
.. image:: images/thonny-install-package.jpg
51+
:alt: Information about the picozero package shown in the Manage Packages window
52+
53+
Manual install
54+
==============
55+
56+
picozero can be installed by copying the ``picozero.py`` code to your Raspberry Pi Pico.
57+
58+
Either clone the picozero `GitHub repository`_ or copy the code from the `picozero.py`_ file and save it on your main computer.
59+
60+
.. _GitHub repository: https://github.com/RaspberryPiFoundation/picozero
61+
.. _picozero.py: https://raw.githubusercontent.com/RaspberryPiFoundation/picozero/master/picozero/picozero.py?token=GHSAT0AAAAAABRLTKWZDBSYBE54NJ7AIZ6MYSENI2A
62+
63+
Create a new file called picozero.py, copy code into the file and save it on your Raspberry Pi Pico.
4464

45-
Other install options
46-
---------------------
65+
Copy picozero.py using Thonny
66+
-----------------------------
4767

48-
You can use the Thonny file manager to transfer a ``picozero.py`` file to your Raspberry Pi Pico.
68+
Alternatively, you can use the Thonny file manager to transfer the ``picozero.py`` file to your Raspberry Pi Pico.
4969

5070
In the **View** menu, ensure that the **Files** option has a tick. This will let you see the files.
5171

5272
.. image:: images/thonny-view-files.jpg
73+
:alt: The Files option selected from the View menu
5374

5475
Either clone the picozero `GitHub repository`_ or copy the code from the `picozero.py`_ file and save it on your main computer.
5576

@@ -63,10 +84,12 @@ In Thonny, navigate to the cloned directory or location you saved the file in an
6384
Right click on the file and select the **Upload to /** option. You should see a copy of the ``picozero.py`` file on the Raspberry Pi Pico.
6485

6586
.. image:: images/thonny-upload-files.jpg
87+
:alt: The "Upload to /" option selected in the picozero.py file menu
6688
.. image:: images/thonny-copy-picozero.jpg
89+
:alt: The picozero.py file shown in the Raspberry Pi Pico file viewer.
6790

6891
Write a program to control the onboard LED
69-
------------------------------------------
92+
==========================================
7093

7194
The following code will blink the onboard LED at a frequency of once per second.::
7295

@@ -79,8 +102,8 @@ The following code will blink the onboard LED at a frequency of once per second.
79102
pico_led.off()
80103
sleep(0.5)
81104

82-
Run a program on your computer
83-
------------------------------
105+
Run the program on your computer
106+
--------------------------------
84107

85108
You can choose to run the program from your computer.
86109

@@ -92,8 +115,8 @@ Choose to save the script on **This computer** and provide a filename.
92115

93116
.. image:: images/save-this-computer.png
94117

95-
Run a program on your Raspberry Pi Pico
96-
----------------------------------
118+
Run the program on your Raspberry Pi Pico
119+
-----------------------------------------
97120

98121
You can choose to run the program from the Raspberry Pi Pico.
99122

docs/recipes.rst

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,38 @@ Using the :obj:`pico_led` is equivalent to::
4848

4949
You can use :obj:`pico_led` in the same way as external LEDs created using :class:`LED`.
5050

51+
Pin out
52+
-------
53+
54+
You can output a *diagram* of the Raspberry Pi Pico which displays its pins and their numbers.
55+
56+
.. literalinclude:: examples/print_pinout.py
57+
58+
::
59+
60+
---usb---
61+
GP0 1 |o o| -1 VBUS
62+
GP1 2 |o o| -2 VSYS
63+
GND 3 |o o| -3 GND
64+
GP2 4 |o o| -4 3V3_EN
65+
GP3 5 |o o| -5 3V3(OUT)
66+
GP4 6 |o o| -6 ADC_VREF
67+
GP5 7 |o o| -7 GP28 ADC2
68+
GND 8 |o o| -8 GND AGND
69+
GP6 9 |o o| -9 GP27 ADC1
70+
GP7 10 |o o| -10 GP26 ADC0
71+
GP8 11 |o o| -11 RUN
72+
GP9 12 |o o| -12 GP22
73+
GND 13 |o o| -13 GND
74+
GP10 14 |o o| -14 GP21
75+
GP11 15 |o o| -15 GP20
76+
GP12 16 |o o| -16 GP19
77+
GP13 17 |o o| -17 GP18
78+
GND 18 |o o| -18 GND
79+
GP14 19 |o o| -19 GP17
80+
GP15 20 |o o| -20 GP16
81+
---------
82+
5183
LEDs
5284
------
5385

@@ -82,8 +114,12 @@ Create a pulse effect:
82114

83115
.. literalinclude:: examples/led_pulse.py
84116

117+
Alternatively, you can use the :meth:`~picozero.LED.pulse` method.
118+
119+
.. literalinclude:: examples/led_pulse_method.py
120+
85121
Buttons
86-
------
122+
-------
87123

88124
You can connect buttons and switches to a Raspberry Pi Pico and detect when they are pressed.
89125

@@ -110,7 +146,7 @@ Turn the :obj:`pico_led` on when a :class:`Button` is pressed and off when it is
110146
.. literalinclude:: examples/button_led.py
111147

112148
RGB LEDs
113-
------
149+
--------
114150

115151
Set colours with an :class:`RGBLED`:
116152

@@ -144,7 +180,7 @@ The default for :meth:`~picozero.RGBLED.cycle` is to cycle from red to green, th
144180
.. literalinclude:: examples/rgb_cycle.py
145181

146182
Potentiometer
147-
---------------
183+
-------------
148184

149185
Print the value, voltage, and percent reported by a potentiometer:
150186

@@ -166,7 +202,7 @@ Control an active buzzer that plays a note when powered:
166202
.. literalinclude:: examples/buzzer.py
167203

168204
Speaker
169-
--------
205+
-------
170206

171207
Control a passive buzzer or speaker that can play different tones or frequencies:
172208

@@ -214,7 +250,7 @@ Move a motor connected via two pins (forward and backward) and a motor controlle
214250
.. literalinclude:: examples/motor_move.py
215251

216252
Robot rover
217-
-------------
253+
-----------
218254

219255
Make a simple two-wheeled robot rover.
220256

picozero/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
__name__ = "picozero"
22
__package__ = "picozero"
3-
__version__ = '0.4.0'
3+
__version__ = '0.4.1'
44
__author__ = "Raspberry Pi Foundation"
55

66
from .picozero import (
77
PWMChannelAlreadyInUse,
88
EventFailedScheduleQueueFull,
99

10+
pinout,
11+
1012
DigitalOutputDevice,
1113
DigitalLED,
1214
Buzzer,

picozero/picozero.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,41 @@ class EventFailedScheduleQueueFull(Exception):
1818

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

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---
30+
GP0 1 |o o| -1 VBUS
31+
GP1 2 |o o| -2 VSYS
32+
GND 3 |o o| -3 GND
33+
GP2 4 |o o| -4 3V3_EN
34+
GP3 5 |o o| -5 3V3(OUT)
35+
GP4 6 |o o| -6 ADC_VREF
36+
GP5 7 |o o| -7 GP28 ADC2
37+
GND 8 |o o| -8 GND AGND
38+
GP6 9 |o o| -9 GP27 ADC1
39+
GP7 10 |o o| -10 GP26 ADC0
40+
GP8 11 |o o| -11 RUN
41+
GP9 12 |o o| -12 GP22
42+
GND 13 |o o| -13 GND
43+
GP10 14 |o o| -14 GP21
44+
GP11 15 |o o| -15 GP20
45+
GP12 16 |o o| -16 GP19
46+
GP13 17 |o o| -17 GP18
47+
GND 18 |o o| -18 GND
48+
GP14 19 |o o| -19 GP17
49+
GP15 20 |o o| -20 GP16
50+
---------"""
51+
52+
if output:
53+
print(pins)
54+
return pins
55+
2156
class PinMixin:
2257
"""
2358
Mixin used by devices that have a single pin number.
@@ -1630,7 +1665,7 @@ def when_deactivated(self):
16301665
"""
16311666
return self._when_deactivated
16321667

1633-
@when_activated.setter
1668+
@when_deactivated.setter
16341669
def when_deactivated(self, value):
16351670
self._when_deactivated = value
16361671

0 commit comments

Comments
 (0)