Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3540c29
Added distance sensor
Jun 10, 2022
865350d
pico w change log
Jul 8, 2022
124f35d
fixed PinsMixin
Jul 8, 2022
6012083
fixed LED(on_time=0)
Jul 8, 2022
1ba10fa
Merge pull request #65 from RaspberryPiFoundation/dev
Jul 8, 2022
65d31b5
add doc strings
Jul 8, 2022
23cbb00
fix pulse
Jul 8, 2022
f06a5d4
add temp sensor tests
Jul 14, 2022
d7784f9
added pico_led test
Jul 14, 2022
d8cada3
added distance sensor
Jul 22, 2022
2f6ea8d
Merge pull request #66 from RaspberryPiFoundation/distance_sensor
Jul 22, 2022
baad7be
minor doc string update
Jul 22, 2022
602e893
added motor prototype
Jul 22, 2022
ce2c018
fixed motor value
martinohanlon Jul 24, 2022
962177a
added motor doc strings
martinohanlon Jul 24, 2022
3d7cfc5
motor tests
martinohanlon Jul 24, 2022
eb4781c
added a move method to Motor
martinohanlon Jul 27, 2022
34c6be4
added motor example
martinohanlon Jul 27, 2022
7a80872
fixed docs
martinohanlon Jul 28, 2022
bde721b
Merge pull request #68 from RaspberryPiFoundation/dev
Jul 28, 2022
2ed17de
updates dev docs
martinohanlon Jul 28, 2022
88f80ac
added robot
martinohanlon Jul 28, 2022
727e2bf
fix RGBLED
Aug 1, 2022
193eefc
Merge branch 'dev' of https://github.com/RaspberryPiFoundation/picoze…
Aug 1, 2022
b48f031
typo
Aug 2, 2022
e1460c0
added rgbled tests
Aug 2, 2022
714fcf6
Merge pull request #71 from RaspberryPiFoundation/dev
Aug 2, 2022
0e2c1fe
flip pins for docs
Aug 10, 2022
fde2fec
added robot image
Aug 10, 2022
722e725
Merge branch 'motor' of https://github.com/RaspberryPiFoundation/pico…
Aug 10, 2022
83351e4
added distance sensor
Aug 10, 2022
7b6d930
doc updates
Aug 11, 2022
9f4debe
refactored motor
Aug 11, 2022
a17a544
refactored motor
Aug 11, 2022
b6f3a79
Merge pull request #72 from RaspberryPiFoundation/motor
Aug 11, 2022
773cb32
rename use_pwm
Aug 11, 2022
ef9ed53
added alias
Aug 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ Speaker
:inherited-members:
:members:

Motor
-----

.. autoclass:: Motor
:show-inheritance:
:inherited-members:
:members:

Robot / Rover
-------------

.. autoclass:: Robot
:show-inheritance:
:inherited-members:
:members:

DigitalOutputDevice
-------------------
Expand Down Expand Up @@ -87,22 +102,30 @@ Switch
:inherited-members:
:members:

Potentiometer
-------------
Potentiometer / Pot
-------------------

.. autoclass:: Potentiometer
:show-inheritance:
:inherited-members:
:members:

TemperatureSensor
-----------------
TemperatureSensor / TempSensor / Thermistor
-------------------------------------------

.. autoclass:: TemperatureSensor
:show-inheritance:
:inherited-members:
:members:

DistanceSensor
--------------

.. autoclass:: DistanceSensor
:show-inheritance:
:inherited-members:
:members:

DigitalInputDevice
------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Change log
0.2.0 - 2022-06-29
~~~~~~~~~~~~~~~~~~

+ Compatibility fix LED
+ Pico W compatibility fix for onboard LED

0.1.1 - 2022-06-08
~~~~~~~~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __getattr__(cls, name):
# add the ticks_ms function to time (as it is in micropython)
import time
setattr(time, 'ticks_ms', lambda x: None)
setattr(time, 'ticks_us', lambda x: None)

# -- Project information -----------------------------------------------------

Expand Down
18 changes: 15 additions & 3 deletions docs/developing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ Install sphinx using ::

pip3 install sphinx

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

$ make html

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

Documentation can be viewed at `picozero.readthedocs.io`_.
Documentation can be viewed at `picozero.readthedocs.io`_ and is automatically built and deployed on commit.

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

Expand All @@ -59,4 +59,16 @@ The tests are design to be run on a Raspberry Pi Pico.

3. Copy the ``test_picozero.py`` to the pico.

4. Run the ``test_picozero.py`` file.
4. Run the ``test_picozero.py`` file.

If a test fails it is helpful to be able to see verbose error messages. To see error messages you need to modify the ``lib/unittest.py`` file on the pico.

Locate the following code in the ``run_class`` function::

# Uncomment to investigate failure in detail
#raise

Uncomment ``raise``::

# Uncomment to investigate failure in detail
raise
8 changes: 8 additions & 0 deletions docs/examples/motor_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from picozero import Motor
from time import sleep

motor = Motor(14, 15)

motor.move()
sleep(1)
motor.stop()
9 changes: 9 additions & 0 deletions docs/examples/robot_rover_forward.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from picozero import Robot
from time import sleep

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

# move forward
robot_rover.forward()
sleep(1)
robot_rover.stop()
10 changes: 10 additions & 0 deletions docs/examples/robot_rover_square.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from picozero import Robot
from time import sleep

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

for i in range(4):
# move forward for 1 second
robot_rover.forward(t=1, wait=True)
# rotate to the left for 1 second
robot_rover.left(t=1, wait=True)
8 changes: 8 additions & 0 deletions docs/examples/ultrasonic_distance_sensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from picozero import DistanceSensor
from time import sleep

ds = DistanceSensor(echo=4, trigger=5)

while True:
print(ds.distance)
sleep(0.1)
817 changes: 817 additions & 0 deletions docs/images/distance_sensor_bb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8,150 changes: 8,150 additions & 0 deletions docs/images/robot_bb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 34 additions & 2 deletions docs/recipes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ Print the value, voltage and percent reported by a potentiometer:

In the Thonny Python editor, choose View->Plotter to plot the output of :meth:`print`.


Buzzer
------

Expand All @@ -169,6 +168,29 @@ Control a passive buzzer or speaker that can play different tones or frequencies

.. literalinclude:: examples/speaker.py

Motor
-----

Move a motor which is connected via 2 pins (forward / backward) and a motor controller board

.. literalinclude:: examples/motor_move.py

Robot rover
-------------

Make a simple 2 wheeled robot rover.

.. image:: images/robot_bb.svg
:alt: A diagram of the Raspberry Pi Pico connected to 2 motors via a motor controller board powered by a battery pack

Move the rover forward for 1 second and stop.

.. literalinclude:: examples/robot_rover_forward.py

Move the rover *roughly* in a square:

.. literalinclude:: examples/robot_rover_square.py

Play a tune
~~~~~~~~~~~

Expand All @@ -188,4 +210,14 @@ Internal Temperature Sensor

Check the internal temperature of the Raspberry Pi Pico in degrees Celcius:

.. literalinclude:: examples/pico_temperature.py
.. literalinclude:: examples/pico_temperature.py

Ultrasonic Distance Sensor
--------------------------

Get the distance in metres from an ultrasonic distance sensor (HC-SR04).

.. image:: images/distance_sensor_bb.svg
:alt: A diagram of the Raspberry Pi Pico connected to HC-SR04 distance sensor

.. literalinclude:: examples/ultrasonic_distance_sensor.py
Binary file added docs/sketches/distance_sensor.fzz
Binary file not shown.
File renamed without changes.
Binary file added docs/sketches/robot.fzz
Binary file not shown.
14 changes: 14 additions & 0 deletions examples/motor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from picozero import Motor
from time import sleep

m = Motor(12, 13)

# turn the motor for 1 second
print("the motor is turning")
m.move()
sleep(1)
m.stop()

# or alternatively turn it at half speed for 2 seconds
m.move(speed=0.5, t=2)
print("the motor will turn at half speed and stop after 2 seconds")
8 changes: 8 additions & 0 deletions examples/ultrasonic_distance_sensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from picozero import DistanceSensor
from time import sleep

ds = DistanceSensor(5, 4)

while True:
print(ds.distance)
sleep(0.1)
4 changes: 4 additions & 0 deletions picozero/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
Speaker,

RGBLED,
Motor,
Robot,

DigitalInputDevice,
Switch,
Expand All @@ -32,4 +34,6 @@
pico_temp_sensor,
TempSensor,
Thermistor,

DistanceSensor,
)
Loading