File: api_tools.rst

package info (click to toggle)
gpiozero 2.0.1-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,192 kB
  • sloc: python: 15,355; makefile: 246
file content (83 lines) | stat: -rw-r--r-- 1,861 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
.. GPIO Zero: a library for controlling the Raspberry Pi's GPIO pins
..
.. Copyright (c) 2016-2023 Dave Jones <dave@waveform.org.uk>
.. Copyright (c) 2017-2019 Ben Nuttall <ben@bennuttall.com>
.. Copyright (c) 2016 Edward Betts <edward@4angle.com>
.. Copyright (c) 2016 Andrew Scheller <github@loowis.durge.org>
..
.. SPDX-License-Identifier: BSD-3-Clause

=========================
API - Device Source Tools
=========================

.. module:: gpiozero.tools

GPIO Zero includes several utility routines which are intended to be used with
the :doc:`source_values` attributes common to most devices in the library.
These utility routines are in the ``tools`` module of GPIO Zero and are
typically imported as follows::

    from gpiozero.tools import scaled, negated, all_values

Given that :attr:`~gpiozero.SourceMixin.source` and
:attr:`~gpiozero.ValuesMixin.values` deal with infinite iterators, another
excellent source of utilities is the :mod:`itertools` module in the standard
library.

Single source conversions
=========================

.. autofunction:: absoluted

.. autofunction:: booleanized

.. autofunction:: clamped

.. autofunction:: inverted

.. autofunction:: negated

.. autofunction:: post_delayed

.. autofunction:: post_periodic_filtered

.. autofunction:: pre_delayed

.. autofunction:: pre_periodic_filtered

.. autofunction:: quantized

.. autofunction:: queued

.. autofunction:: smoothed

.. autofunction:: scaled

Combining sources
=================

.. autofunction:: all_values

.. autofunction:: any_values

.. autofunction:: averaged

.. autofunction:: multiplied

.. autofunction:: summed

.. autofunction:: zip_values

Artificial sources
==================

.. autofunction:: alternating_values

.. autofunction:: cos_values

.. autofunction:: ramping_values

.. autofunction:: random_values

.. autofunction:: sin_values