Skip to content

Commit 1eedd1f

Browse files
author
Martin O'Hanlon
committed
added docstrings
1 parent ea3c326 commit 1eedd1f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

picozero/picozero.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,21 @@ def close(self):
286286
self._pin = None
287287

288288
class PWMLED(PWMOutputDevice):
289+
"""
290+
Represents an LED driven by a PWM pin whose brightness can be changed.
291+
292+
:param int pin:
293+
The pin that the device is connected to.
294+
295+
:param bool active_high:
296+
If :data:`True` (the default), the :meth:`on` method will set the Pin
297+
to HIGH. If :data:`False`, the :meth:`on` method will set the Pin to
298+
LOW (the :meth:`off` method always does the opposite).
299+
300+
:param bool initial_value:
301+
If :data:`False` (the default), the LED will be off initially. If
302+
:data:`True`, the LED will be switched on initially.
303+
"""
289304
def __init__(self, pin, active_high=True, initial_value=False):
290305
self._brightness = 1
291306
super().__init__(pin=pin,
@@ -854,6 +869,9 @@ def value(self):
854869

855870
class DigitalInputDevice(InputDevice):
856871
"""
872+
Represents a generic input device with digital functionality e.g. buttons
873+
which can be either active or inactive.
874+
857875
:param int pin:
858876
The pin that the device is connected to.
859877
@@ -978,6 +996,8 @@ def close(self):
978996

979997
class Switch(DigitalInputDevice):
980998
"""
999+
Represents a toggle switch which is either open or closed.
1000+
9811001
:param int pin:
9821002
The pin that the device is connected to.
9831003
@@ -1001,6 +1021,23 @@ def __init__(self, pin, pull_up=True, bounce_time=0.02):
10011021
Switch.when_opened = Switch.when_deactivated
10021022

10031023
class Button(Switch):
1024+
"""
1025+
Represents a push button which can be either pressed or released.
1026+
1027+
:param int pin:
1028+
The pin that the device is connected to.
1029+
1030+
:param bool pull_up:
1031+
If :data:`True` (the default), the device will be pulled up to
1032+
HIGH. If :data:`False`, the device will be pulled down to LOW.
1033+
1034+
:param float bounce_time:
1035+
The bounce time for the device. If set, the device will ignore
1036+
any button presses that happen within the bounce time after a
1037+
button release. This is useful to prevent accidental button
1038+
presses from registering as multiple presses. Defaults to 0.02
1039+
seconds.
1040+
"""
10041041
pass
10051042

10061043
Button.is_pressed = Button.is_active

0 commit comments

Comments
 (0)