Files
loustique-home/venv/lib/python3.11/site-packages/gpiozero/__pycache__/tools.cpython-311.pyc

467 lines
27 KiB
Plaintext
Raw Normal View History

2026-03-21 10:53:02 +01:00
<EFBFBD>
?<3F><>i|S<00><00><00>ddlmZddlmZddlmZddlmZmZmZm Z ddl
m Z ddl m Z d<08>Zd <09>Zd&d
<EFBFBD>Zd&d <0B>Zd <0C>Zd <0A>Zd&d<0E>Zd<0F>Zd&d<10>Zd'd<11>Zd<12>Zd<13>Zd<14>Zd<15>Zd<16>Zd<17>Ze fd<18>Zd<19>Zd<1A>Z d<1B>Z!d<1C>Z"d<1D>Z#d(d<1F>Z$d(d <20>Z%d)d"<22>Z&d(d#<23>Z'd$<24>Z(d%S)*<2A><00><01>random)<01>sleep)<01>cycle)<04>sin<69>cos<6F>pi<70>isclose)<01>mean<61>)<01> ValuesMixinc<00>><00>t|t<00><00>r|jS|S)a
If *values* is a ``ValuesMixin`` derivative, return ``values.values``,
otherwise return `values` as provided. Intended to allow support for::
led.source = foo(btn)
and::
led.source = foo(btn.values)
and::
led.source = foo(some_iterator)
)<03>
isinstancer <00>values<65>rs <20>Z/home/maxime/Documents/loustiques-home/venv/lib/python3.11/site-packages/gpiozero/tools.py<70>
_normalizers#<00><00><12>&<26>+<2B>&<26>&<26><1D><15>}<7D><1C> <11>M<EFBFBD>c#<00><K<00>t|<00><00>}|D]}| V<00><00>dS)an
Returns the negation of the supplied values (:data:`True` becomes
:data:`False`, and :data:`False` becomes :data:`True`). For example::
from gpiozero import Button, LED
from gpiozero.tools import negated
from signal import pause
led = LED(4)
btn = Button(17)
led.source = negated(btn)
pause()
N<>r<00>r<00>vs r<00>negatedr)s;<00><00><00><00> <18><06> <1F> <1F>F<EFBFBD> <13><14><14><01><13>e<EFBFBD> <0B> <0B> <0B> <0B><14>rc#<00>pK<00>t|<00><00>}||krtd<01><00><00>|D] }||z|z
V<00><00> dS)aT
Returns the inversion of the supplied values (*input_min* becomes
*input_max*, *input_max* becomes *input_min*, `input_min + 0.1` becomes
`input_max - 0.1`, etc.). All items in *values* are assumed to be between
*input_min* and *input_max* (which default to 0 and 1 respectively), and
the output will be in the same range. For example::
from gpiozero import MCP3008, PWMLED
from gpiozero.tools import inverted
from signal import pause
led = PWMLED(4)
pot = MCP3008(channel=0)
led.source = inverted(pot)
pause()
<20>(input_min must be smaller than input_maxN<78>r<00>
ValueError)r<00> input_min<69> input_maxrs r<00>invertedr >sa<00><00><00><00>&<18><06> <1F> <1F>F<EFBFBD><10>I<EFBFBD><1D><1D><18>C<>D<>D<>D<> <13>(<28>(<28><01><17>)<29>#<23>a<EFBFBD>'<27>'<27>'<27>'<27>'<27>(<28>(rc#<00><>K<00>t|<00><00>}||krtd<01><00><00>||z
}||z
}|D]}||z
|z |z|zV<00><00>dS)aP
Returns *values* scaled from *output_min* to *output_max*, assuming that
all items in *values* lie between *input_min* and *input_max* (which
default to 0 and 1 respectively). For example, to control the direction of
a motor (which is represented as a value between -1 and 1) using a
potentiometer (which typically provides values between 0 and 1)::
from gpiozero import Motor, MCP3008
from gpiozero.tools import scaled
from signal import pause
motor = Motor(20, 21)
pot = MCP3008(channel=0)
motor.source = scaled(pot, -1, 1)
pause()
.. warning::
If *values* contains elements that lie outside *input_min* to
*input_max* (inclusive) then the function will not produce values that
lie within *output_min* to *output_max* (inclusive).
rNr)r<00>
output_min<EFBFBD>
output_maxrr<00>
input_size<EFBFBD> output_sizers r<00>scaledr&Xs<><00><00><00><00>2<18><06> <1F> <1F>F<EFBFBD><10>I<EFBFBD><1D><1D><18>C<>D<>D<>D<><1A>Y<EFBFBD>&<26>J<EFBFBD><1C>z<EFBFBD>)<29>K<EFBFBD> <13>J<01>J<01><01><12>Y<EFBFBD><1D>*<2A>,<2C> <0B>;<3B>z<EFBFBD>I<>I<>I<>I<>I<>J<01>Jrc<00>(<00>t|dddd<02><00>S)z<>
A convenience function that builds on :func:`scaled`. It converts a
"half-range" value (0..1) to a "full-range" value (-1..1). This is
equivalent to calling::
scaled(values, -1, 1, 0, 1)
<20><><EFBFBD><EFBFBD><EFBFBD>r r<00>r&rs r<00> scaled_fullr*zs<00><00> <12>&<26>"<22>a<EFBFBD><11>A<EFBFBD> &<26> &<26>&rc<00>(<00>t|dddd<02><00>S)z<>
A convenience function that builds on :func:`scaled`. It converts a
"full-range" value (-1..1) to a "half-range" value (0..1). This is
equivalent to calling::
scaled(values, 0, 1, -1, 1)
rr r(r)rs r<00> scaled_halfr,<00>s<00><00> <12>&<26>!<21>Q<EFBFBD><02>A<EFBFBD> &<26> &<26>&rc#<00><>K<00>t|<00><00>}||krtd<01><00><00>|D]"}tt||<01><00>|<02><00>V<00><00>#dS)a 
Returns *values* clamped from *output_min* to *output_max*, i.e. any items
less than *output_min* will be returned as *output_min* and any items
larger than *output_max* will be returned as *output_max* (these default to
0 and 1 respectively). For example::
from gpiozero import PWMLED, MCP3008
from gpiozero.tools import clamped
from signal import pause
led = PWMLED(4)
pot = MCP3008(channel=0)
led.source = clamped(pot, 0.5, 1.0)
pause()
z*output_min must be smaller than output_maxN)rr<00>min<69>max)rr"r#rs r<00>clampedr0<00>sk<00><00><00><00>$<18><06> <1F> <1F>F<EFBFBD><11>Z<EFBFBD><1F><1F><18>E<>F<>F<>F<> <13>2<>2<><01><11>#<23>a<EFBFBD><1A>$<24>$<24>j<EFBFBD>1<>1<>1<>1<>1<>1<>2<>2rc#<00>TK<00>t|<00><00>}|D]}t|<01><00>V<00><00>dS)a<>
Returns *values* with all negative elements negated (so that they're
positive). For example::
from gpiozero import PWMLED, Motor, MCP3008
from gpiozero.tools import absoluted, scaled
from signal import pause
led = PWMLED(4)
motor = Motor(22, 27)
pot = MCP3008(channel=0)
motor.source = scaled(pot, -1, 1)
led.source = absoluted(motor)
pause()
N)r<00>absrs r<00> absolutedr3<00>s?<00><00><00><00>$<18><06> <1F> <1F>F<EFBFBD> <13><15><15><01><11>!<21>f<EFBFBD>f<EFBFBD> <0C> <0C> <0C> <0C><15>rc#<00><>K<00>t|<00><00>}|dkrtd<02><00><00>||krtd<03><00><00>||z
}t|dd||<03><00>D]}t||z<00><00>|z |z|zV<00><00> dS)a5
Returns *values* quantized to *steps* increments. All items in *values* are
assumed to be between *input_min* and *input_max* (which default to 0 and
1 respectively), and the output will be in the same range.
For example, to quantize values between 0 and 1 to 5 "steps" (0.0, 0.25,
0.5, 0.75, 1.0)::
from gpiozero import PWMLED, MCP3008
from gpiozero.tools import quantized
from signal import pause
led = PWMLED(4)
pot = MCP3008(channel=0)
led.source = quantized(pot, 4)
pause()
r zsteps must be 1 or largerrrN)rrr&<00>int)r<00>stepsrrr$rs r<00> quantizedr7<00>s<><00><00><00><00>(<18><06> <1F> <1F>F<EFBFBD> <0C>q<EFBFBD>y<EFBFBD>y<EFBFBD><18>4<>5<>5<>5<><10>I<EFBFBD><1D><1D><18>C<>D<>D<>D<><1A>Y<EFBFBD>&<26>J<EFBFBD> <13>F<EFBFBD>A<EFBFBD>q<EFBFBD>)<29>Y<EFBFBD> 7<> 7<>B<01>B<01><01><13>A<EFBFBD><05>I<EFBFBD><0E><0E><15>&<26>*<2A>4<> <09>A<>A<>A<>A<>A<>B<01>Brc#<00>0K<00>t|<00><00>}||krtd<01><00><00>t|<01><00>}t|<02><00>}|dkrtd<03><00><00>t|<03><00>}||z
|krtd<04><00><00>d}|D]<5D>}||krd}n ||krd}nd}d }|dks|sd
}na||krnZ|dkr|dkr
|||zk}nD|dkr|dkr
|||z
k}n.|dkr|dkr
|||zk}n|dkr|dkr
|||z
k}nd
}|r|}|dkV<00><00><>dS) u<>
Returns True for each item in *values* between *min_value* and
*max_value*, and False otherwise. *hysteresis* can optionally be used to
add `hysteresis`_ which prevents the output value rapidly flipping when
the input value is fluctuating near the *min_value* or *max_value*
thresholds. For example, to light an LED only when a potentiometer is
between ¼ and ¾ of its full range::
from gpiozero import LED, MCP3008
from gpiozero.tools import booleanized
from signal import pause
led = LED(4)
pot = MCP3008(channel=0)
led.source = booleanized(pot, 0.25, 0.75)
pause()
.. _hysteresis: https://en.wikipedia.org/wiki/Hysteresis
z(min_value must be smaller than max_valuerzhysteresis must be 0 or largerzFThe gap between min_value and max_value must be larger than hysteresisN<73>below<6F>above<76>inFT)rr<00>float)r<00> min_value<75> max_value<75>
hysteresis<EFBFBD>
last_stater<00> new_state<74>switchs r<00> booleanizedrC<00>s<><00><00><00><00>,<18><06> <1F> <1F>F<EFBFBD><10>I<EFBFBD><1D><1D><18>C<>D<>D<>D<><15>i<EFBFBD> <20> <20>I<EFBFBD><15>i<EFBFBD> <20> <20>I<EFBFBD><11>A<EFBFBD>~<7E>~<7E><18>9<>:<3A>:<3A>:<3A><1A>:<3A>&<26>&<26>
<EFBFBD><11>I<EFBFBD><1D>*<2A>,<2C>,<2C><18>2<>3<>3<> 3<><15>J<EFBFBD> <13>!<21>!<21><01> <0C>y<EFBFBD>=<3D>=<3D><1F>I<EFBFBD>I<EFBFBD> <0E><19>]<5D>]<5D><1F>I<EFBFBD>I<EFBFBD><1C>I<EFBFBD><16><06> <15><14> <1D> <1D>Z<EFBFBD> <1D><19>F<EFBFBD>F<EFBFBD> <16>*<2A> $<24> $<24> <10><19>W<EFBFBD>$<24>$<24><19>d<EFBFBD>):<3A>):<3A><1A>i<EFBFBD>*<2A>4<>4<><06><06><1B>t<EFBFBD>#<23>#<23> <09>W<EFBFBD>(<<3C>(<<3C><1A>Y<EFBFBD><1A>3<>3<><06><06><1B>t<EFBFBD>#<23>#<23> <09>W<EFBFBD>(<<3C>(<<3C><1A>Y<EFBFBD><1A>3<>3<><06><06><1B>w<EFBFBD>&<26>&<26>9<EFBFBD><04>+<<3C>+<<3C><1A>i<EFBFBD>*<2A>4<>4<><06><06><1D><06> <11> #<23>"<22>J<EFBFBD><18>D<EFBFBD> <20> <20> <20> <20> <20>3!<21>!rc'<00>\K<00>d<01>|D<00><00>}t|<00>D]}t|<01><00>V<00><00>dS)a<>
Returns the `logical conjunction`_ of all supplied values (the result is
only :data:`True` if and only if all input values are simultaneously
:data:`True`). One or more *values* can be specified. For example, to light
an :class:`~gpiozero.LED` only when *both* buttons are pressed::
from gpiozero import LED, Button
from gpiozero.tools import all_values
from signal import pause
led = LED(4)
btn1 = Button(20)
btn2 = Button(21)
led.source = all_values(btn1, btn2)
pause()
.. _logical conjunction: https://en.wikipedia.org/wiki/Logical_conjunction
c<00>,<00>g|]}t|<01><00><00><02>S<00>r<00><02>.0rs r<00>
<listcomp>zall_values.<locals>.<listcomp>2<00><00><00> ,<2C> ,<2C> ,<2C><01>j<EFBFBD><11>m<EFBFBD>m<EFBFBD> ,<2C> ,<2C> ,rN)<02>zip<69>allrs r<00>
all_valuesrM<00>I<00><00><00><00>*-<2D> ,<2C>V<EFBFBD> ,<2C> ,<2C> ,<2C>F<EFBFBD> <10>&<26>\<5C><15><15><01><11>!<21>f<EFBFBD>f<EFBFBD> <0C> <0C> <0C> <0C><15>rc'<00>\K<00>d<01>|D<00><00>}t|<00>D]}t|<01><00>V<00><00>dS)aj
Returns the `logical disjunction`_ of all supplied values (the result is
:data:`True` if any of the input values are currently :data:`True`). One or
more *values* can be specified. For example, to light an
:class:`~gpiozero.LED` when *any* button is pressed::
from gpiozero import LED, Button
from gpiozero.tools import any_values
from signal import pause
led = LED(4)
btn1 = Button(20)
btn2 = Button(21)
led.source = any_values(btn1, btn2)
pause()
.. _logical disjunction: https://en.wikipedia.org/wiki/Logical_disjunction
c<00>,<00>g|]}t|<01><00><00><02>SrFrrGs rrIzany_values.<locals>.<listcomp>LrJrN)rK<00>anyrs r<00>
any_valuesrR7rNrc'<00>\K<00>d<01>|D<00><00>}t|<00>D]}t|<01><00>V<00><00>dS)a)
Returns the mean of all supplied values. One or more *values* can be
specified. For example, to light a :class:`~gpiozero.PWMLED` as the average
of several potentiometers connected to an :class:`~gpiozero.MCP3008` ADC::
from gpiozero import MCP3008, PWMLED
from gpiozero.tools import averaged
from signal import pause
pot1 = MCP3008(channel=0)
pot2 = MCP3008(channel=1)
pot3 = MCP3008(channel=2)
led = PWMLED(4)
led.source = averaged(pot1, pot2, pot3)
pause()
c<00>,<00>g|]}t|<01><00><00><02>SrFrrGs rrIzaveraged.<locals>.<listcomp>drJrN)rKr rs r<00>averagedrUQsI<00><00><00><00>&-<2D> ,<2C>V<EFBFBD> ,<2C> ,<2C> ,<2C>F<EFBFBD> <10>&<26>\<5C><16><16><01><12>1<EFBFBD>g<EFBFBD>g<EFBFBD> <0A> <0A> <0A> <0A><16>rc'<00>\K<00>d<01>|D<00><00>}t|<00>D]}t|<01><00>V<00><00>dS)aI
Returns the sum of all supplied values. One or more *values* can be
specified. For example, to light a :class:`~gpiozero.PWMLED` as the
(scaled) sum of several potentiometers connected to an
:class:`~gpiozero.MCP3008` ADC::
from gpiozero import MCP3008, PWMLED
from gpiozero.tools import summed, scaled
from signal import pause
pot1 = MCP3008(channel=0)
pot2 = MCP3008(channel=1)
pot3 = MCP3008(channel=2)
led = PWMLED(4)
led.source = scaled(summed(pot1, pot2, pot3), 0, 1, 0, 3)
pause()
c<00>,<00>g|]}t|<01><00><00><02>SrFrrGs rrIzsummed.<locals>.<listcomp>}rJrN)rK<00>sumrs r<00>summedrYisI<00><00><00><00>(-<2D> ,<2C>V<EFBFBD> ,<2C> ,<2C> ,<2C>F<EFBFBD> <10>&<26>\<5C><15><15><01><11>!<21>f<EFBFBD>f<EFBFBD> <0C> <0C> <0C> <0C><15>rc'<00>ZK<00>d<01>|D<00><00>}d<02>}t|<00>D]}||<02><00>V<00><00>dS)aN
Returns the product of all supplied values. One or more *values* can be
specified. For example, to light a :class:`~gpiozero.PWMLED` as the product
(i.e. multiplication) of several potentiometers connected to an
:class:`~gpiozero.MCP3008`
ADC::
from gpiozero import MCP3008, PWMLED
from gpiozero.tools import multiplied
from signal import pause
pot1 = MCP3008(channel=0)
pot2 = MCP3008(channel=1)
pot3 = MCP3008(channel=2)
led = PWMLED(4)
led.source = multiplied(pot1, pot2, pot3)
pause()
c<00>,<00>g|]}t|<01><00><00><02>SrFrrGs rrIzmultiplied.<locals>.<listcomp><3E>rJrc<00><00>d}|D]}||z}<01>|S)Nr rF)<03>it<69>p<>ns r<00>_productzmultiplied.<locals>._product<63>s&<00><00> <0A><01><13> <13> <13>A<EFBFBD> <0A><11>F<EFBFBD>A<EFBFBD>A<EFBFBD><10>rN<>rK)rr`rs r<00>
multipliedrb<00>s`<00><00><00><00>*-<2D> ,<2C>V<EFBFBD> ,<2C> ,<2C> ,<2C>F<EFBFBD><11><11><11>
<11>&<26>\<5C><1A><1A><01><16>h<EFBFBD>q<EFBFBD>k<EFBFBD>k<EFBFBD><19><19><19><19><1A>rc#<00>pK<00>d<01>|D<00><00>}|dkrtd<03><00><00>g}t|<00><00>} t|<01><00>D]$}|<02>t |<03><00><00><00><00>%t t|<01><00><00><00>D]}||V<00>t |<03><00>||<<00>dS#t $rYdSwxYw)aD
Queues up readings from *values* (the number of readings queued is
determined by *qsize*) and begins yielding values only when the queue is
full. For example, to "cascade" values along a sequence of LEDs::
from gpiozero import LEDBoard, Button
from gpiozero.tools import queued
from signal import pause
leds = LEDBoard(5, 6, 13, 19, 26)
btn = Button(17)
for i in range(4):
leds[i].source = queued(leds[i + 1], 5)
leds[i].source_delay = 0.01
leds[4].source = btn
pause()
c<00>,<00>g|]}t|<01><00><00><02>SrFrrGs rrIzqueued.<locals>.<listcomp><3E>rJrr <00>qsize must be 1 or largerN)r<00>iter<65>range<67>append<6E>nextr<00> StopIteration)r<00>qsize<7A>qr]<00>is r<00>queuedrn<00>s<><00><00><00><00>*-<2D> ,<2C>V<EFBFBD> ,<2C> ,<2C> ,<2C>F<EFBFBD> <0C>q<EFBFBD>y<EFBFBD>y<EFBFBD><18>4<>5<>5<>5<>
<EFBFBD>A<EFBFBD> <0A>f<EFBFBD><1C><1C>B<EFBFBD> <0A><16>u<EFBFBD><1C><1C> <1F> <1F>A<EFBFBD> <0A>H<EFBFBD>H<EFBFBD>T<EFBFBD>"<22>X<EFBFBD>X<EFBFBD> <1E> <1E> <1E> <1E><16>u<EFBFBD>U<EFBFBD>|<7C>|<7C>$<24>$<24> <1C> <1C>A<EFBFBD><13>A<EFBFBD>$<24>J<EFBFBD>J<EFBFBD>J<EFBFBD><17><02>8<EFBFBD>8<EFBFBD>A<EFBFBD>a<EFBFBD>D<EFBFBD>D<EFBFBD> <1C> <1C><> <19> <0A> <0A> <0A> <0C><04><04> <0A><><EFBFBD>s<00>A/B'<00>'
B5<03>4B5c#<00>|K<00>t|<00><00>}|dkrtd<02><00><00>g}t|<00><00>} t|<01><00>D]$}|<03>t |<04><00><00><00><00>%t t|<01><00><00><00>D]!}||<03><00>V<00>t |<04><00>||<<00>"dS#t$rYdSwxYw)a<>
Queues up readings from *values* (the number of readings queued is
determined by *qsize*) and begins yielding the *average* of the last
*qsize* values when the queue is full. The larger the *qsize*, the more the
values are smoothed. For example, to smooth the analog values read from an
ADC::
from gpiozero import MCP3008
from gpiozero.tools import smoothed
adc = MCP3008(channel=0)
for value in smoothed(adc, 5):
print(value)
r reN)rrrfrgrhrirrj)rrk<00>averagerlr]rms r<00>smoothedrq<00>s<><00><00><00><00> <18><06> <1F> <1F>F<EFBFBD> <0C>q<EFBFBD>y<EFBFBD>y<EFBFBD><18>4<>5<>5<>5<>
<EFBFBD>A<EFBFBD> <0A>f<EFBFBD><1C><1C>B<EFBFBD> <0A><16>u<EFBFBD><1C><1C> <1F> <1F>A<EFBFBD> <0A>H<EFBFBD>H<EFBFBD>T<EFBFBD>"<22>X<EFBFBD>X<EFBFBD> <1E> <1E> <1E> <1E><16>u<EFBFBD>U<EFBFBD>|<7C>|<7C>$<24>$<24> <1C> <1C>A<EFBFBD><19>'<27>!<21>*<2A>*<2A> <1C> <1C> <1C><17><02>8<EFBFBD>8<EFBFBD>A<EFBFBD>a<EFBFBD>D<EFBFBD>D<EFBFBD> <1C> <1C><> <19> <0A> <0A> <0A> <0C><04><04> <0A><><EFBFBD>s<00>A2B-<00>-
B;<03>:B;c#<00><>K<00>t|<00><00>}|dkrtd<02><00><00>|D]}t|<01><00>|V<00><00>dS)zM
Waits for *delay* seconds before returning each item from *values*.
r<00>delay must be 0 or largerN<72>rrr<00>r<00>delayrs r<00> pre_delayedrw<00>s\<00><00><00><00><18><06> <1F> <1F>F<EFBFBD> <0C>q<EFBFBD>y<EFBFBD>y<EFBFBD><18>4<>5<>5<>5<> <13><10><10><01> <0A>e<EFBFBD> <0C> <0C> <0C><0F><07><07><07><07><10>rc#<00><>K<00>t|<00><00>}|dkrtd<02><00><00>|D]}|V<00>t|<01><00><00>dS)zL
Waits for *delay* seconds after returning each item from *values*.
rrsNrtrus r<00> post_delayedry<00>s\<00><00><00><00><18><06> <1F> <1F>F<EFBFBD> <0C>q<EFBFBD>y<EFBFBD>y<EFBFBD><18>4<>5<>5<>5<> <13><15><15><01><0F><07><07><07> <0A>e<EFBFBD> <0C> <0C> <0C> <0C><15>rc#<00><>K<00>t|<00><00>}|dkrtd<02><00><00>|dkrtd<04><00><00>t|<00><00>} |dkr4t|<01><00>D]}t |<03><00><00> t |<03><00>V<00><00> t|<01><00>D]}t |<03><00><00>t|<02><00>D]}t |<03><00>V<00><00><14>E#t
$rYdSwxYw)a<>
Blocks the first *block* items from *values*, repeating the block after
every *repeat_after* items, if *repeat_after* is non-zero. For example, to
discard the first 50 values read from an ADC::
from gpiozero import MCP3008
from gpiozero.tools import pre_periodic_filtered
adc = MCP3008(channel=0)
for value in pre_periodic_filtered(adc, 50, 0):
print(value)
Or to only display every even item read from an ADC::
from gpiozero import MCP3008
from gpiozero.tools import pre_periodic_filtered
adc = MCP3008(channel=0)
for value in pre_periodic_filtered(adc, 1, 1):
print(value)
r <00>block must be 1 or largerrz repeat_after must be 0 or largerTN<54>rrrfrgrirj)r<00>block<63> repeat_afterr]<00>_s r<00>pre_periodic_filteredr<64><00>s<00><00><00><00>0<18><06> <1F> <1F>F<EFBFBD> <0C>q<EFBFBD>y<EFBFBD>y<EFBFBD><18>4<>5<>5<>5<><13>a<EFBFBD><17><17><18>;<3B><<3C><<3C><<3C> <0A>f<EFBFBD><1C><1C>B<EFBFBD>  <0A> <17>1<EFBFBD> <1C> <1C><1A>5<EFBFBD>\<5C>\<5C> <19> <19><01><14>R<EFBFBD><08><08><08><08> <1F><1A>2<EFBFBD>h<EFBFBD>h<EFBFBD><0E><0E><0E> <1F> #<23><1E>u<EFBFBD><1C><1C><1D><1D>A<EFBFBD><18><12>H<EFBFBD>H<EFBFBD>H<EFBFBD>H<EFBFBD><1E>|<7C>,<2C>,<2C>#<23>#<23>A<EFBFBD><1E>r<EFBFBD>(<28>(<28>N<EFBFBD>N<EFBFBD>N<EFBFBD>N<EFBFBD>  #<23><>
<19> <0A> <0A> <0A> <0C><04><04> <0A><><EFBFBD>s<00> BC <00>
C<03>Cc#<00>FK<00>t|<00><00>}|dkrtd<02><00><00>|dkrtd<03><00><00>t|<00><00>} t|<01><00>D]}t |<03><00>V<00><00>t|<02><00>D]}t |<03><00><00><12>E#t
$rYdSwxYw)a<>
After every *repeat_after* items, blocks the next *block* items from
*values*. Note that unlike :func:`pre_periodic_filtered`, *repeat_after*
can't be 0. For example, to block every tenth item read from an ADC::
from gpiozero import MCP3008
from gpiozero.tools import post_periodic_filtered
adc = MCP3008(channel=0)
for value in post_periodic_filtered(adc, 9, 1):
print(value)
r z repeat_after must be 1 or largerr{TNr|)rr~r}r]rs r<00>post_periodic_filteredr<64>*s<><00><00><00><00><18><06> <1F> <1F>F<EFBFBD><13>a<EFBFBD><17><17><18>;<3B><<3C><<3C><<3C> <0C>q<EFBFBD>y<EFBFBD>y<EFBFBD><18>4<>5<>5<>5<> <0A>f<EFBFBD><1C><1C>B<EFBFBD> <0A> <19><1A><<3C>(<28>(<28> <1F> <1F><01><1A>2<EFBFBD>h<EFBFBD>h<EFBFBD><0E><0E><0E><0E><1A>5<EFBFBD>\<5C>\<5C> <19> <19><01><14>R<EFBFBD><08><08><08><08>  <19><>
<19> <0A> <0A> <0A> <0C><04><04> <0A><><EFBFBD>s<00> AB<00>
B <03>B c#<00>*K<00> t<00><00>V<00><00>)a<>
Provides an infinite source of random values between 0 and 1. For example,
to produce a "flickering candle" effect with an LED::
from gpiozero import PWMLED
from gpiozero.tools import random_values
from signal import pause
led = PWMLED(4)
led.source = random_values()
pause()
If you require a wider range than 0 to 1, see :func:`scaled`.
rrFrr<00> random_valuesr<73>Hs<00><00><00><00>"<17><14>h<EFBFBD>h<EFBFBD><0E><0E><0E>r<00>hc#<00><><00>K<00><00>fd<01>t<00><00><00>D<00><00>}t|<01><00>D]}t|<02><00>V<00><00>dS)a<>
Provides an infinite source of values representing a sine wave (from -1 to
+1) which repeats every *period* values. For example, to produce a "siren"
effect with a couple of LEDs that repeats once a second::
from gpiozero import PWMLED
from gpiozero.tools import sin_values, scaled_half, inverted
from signal import pause
red = PWMLED(2)
blue = PWMLED(3)
red.source_delay = 0.01
blue.source_delay = red.source_delay
red.source = scaled_half(sin_values(100))
blue.source = inverted(red)
pause()
If you require a different range than -1 to +1, see :func:`scaled`.
c3<00>8<00>K<00>|]}dtz|z<00>z V<00><00>dS<00><02>N<>r <00>rHrm<00>periods <20>r<00> <genexpr>zsin_values.<locals>.<genexpr>s<00>0<00><><00><00><00> 9<> 9<>a<EFBFBD>a<EFBFBD>"<22>f<EFBFBD>q<EFBFBD>j<EFBFBD>6<EFBFBD>!<21> 9<> 9<> 9<> 9<> 9<> 9rN)rgrr<00>r<><00>angles<65>as` r<00>
sin_valuesr<EFBFBD>]<00>X<00><><00><00><00>,:<3A> 9<> 9<> 9<>5<EFBFBD><16>=<3D>=<3D> 9<> 9<> 9<>F<EFBFBD> <12>6<EFBFBD>]<5D>]<5D><15><15><01><11>!<21>f<EFBFBD>f<EFBFBD> <0C> <0C> <0C> <0C><15>rc#<00><><00>K<00><00>fd<01>t<00><00><00>D<00><00>}t|<01><00>D]}t|<02><00>V<00><00>dS)a<>
Provides an infinite source of values representing a cosine wave (from -1
to +1) which repeats every *period* values. For example, to produce a
"siren" effect with a couple of LEDs that repeats once a second::
from gpiozero import PWMLED
from gpiozero.tools import cos_values, scaled_half, inverted
from signal import pause
red = PWMLED(2)
blue = PWMLED(3)
red.source_delay = 0.01
blue.source_delay = red.source_delay
red.source = scaled_half(cos_values(100))
blue.source = inverted(red)
pause()
If you require a different range than -1 to +1, see :func:`scaled`.
c3<00>8<00>K<00>|]}dtz|z<00>z V<00><00>dSr<>r<>r<>s <20>rr<>zcos_values.<locals>.<genexpr><3E>r<>rN)rgrrr<>s` r<00>
cos_valuesr<EFBFBD>xr<>rFc#<00>K<00>|} |V<00>| }<01>)a<>
Provides an infinite source of values alternating between :data:`True` and
:data:`False`, starting wth *initial_value* (which defaults to
:data:`False`). For example, to produce a flashing LED::
from gpiozero import LED
from gpiozero.tools import alternating_values
from signal import pause
red = LED(2)
red.source_delay = 0.5
red.source = alternating_values()
pause()
rF)<02> initial_value<75>values r<00>alternating_valuesr<73><00>s'<00><00><00><00>" <1A>E<EFBFBD><1A><13> <0B> <0B> <0B><19> <09><05>rc#<00><>K<00>d|z }d} |V<00>||z }t|dd<05><06><00>rd}|dz}n0t|dd<05><06><00>rd}|dz}n|dks|dkr
|dz}||z }<02>T)a<>
Provides an infinite source of values representing a triangle wave (from 0
to 1 and back again) which repeats every *period* values. For example, to
pulse an LED once a second::
from gpiozero import PWMLED
from gpiozero.tools import ramping_values
from signal import pause
red = PWMLED(2)
red.source_delay = 0.01
red.source = ramping_values(100)
pause()
If you require a wider range than 0 to 1, see :func:`scaled`.
r<>rTr g<><67>&<26> .>)<01>abs_tolr()r
)r<><00>stepr<70>s r<00>ramping_valuesr<73><00>s<><00><00><00><00>& <0A>v<EFBFBD>:<3A>D<EFBFBD> <0A>E<EFBFBD> <1A><13> <0B> <0B> <0B> <0A><14> <0A><05> <12>5<EFBFBD>!<21>T<EFBFBD> *<2A> *<2A> *<2A> <1A><15>E<EFBFBD> <10>B<EFBFBD>J<EFBFBD>D<EFBFBD>D<EFBFBD> <14>U<EFBFBD>A<EFBFBD>t<EFBFBD> ,<2C> ,<2C> ,<2C> <1A><15>E<EFBFBD> <10>B<EFBFBD>J<EFBFBD>D<EFBFBD>D<EFBFBD> <12>Q<EFBFBD>Y<EFBFBD>Y<EFBFBD>%<25>!<21>)<29>)<29> <10>B<EFBFBD>J<EFBFBD>D<EFBFBD> <11>T<EFBFBD>M<EFBFBD>E<EFBFBD> rc<00>(<00>td<01>|D<00><00><00>S)a<>
Provides a source constructed from the values of each item, for example::
from gpiozero import MCP3008, Robot
from gpiozero.tools import zip_values
from signal import pause
robot = Robot(left=(4, 14), right=(17, 18))
left = MCP3008(0)
right = MCP3008(1)
robot.source = zip_values(left, right)
pause()
``zip_values(left, right)`` is equivalent to ``zip(left.values,
right.values)``.
c<00><00>g|] }|j<00><02>
SrFr)rH<00>ds rrIzzip_values.<locals>.<listcomp><3E>s<00><00>+<2B>+<2B>+<2B>a<EFBFBD><11><18>+<2B>+<2B>+rra)<01>devicess r<00>
zip_valuesr<EFBFBD><00>s<00><00>( <0F>+<2B>+<2B>7<EFBFBD>+<2B>+<2B>+<2B> ,<2C>,rN)rr )r)r<>)F))r<00>timer<00> itertoolsr<00>mathrrr r
<00>
statisticsr <00>mixinsr rrr r&r*r,r0r3r7rCrMrRrUrYrbrnrqrwryr<>r<>r<>r<>r<>r<>r<>r<>rFrr<00><module>r<>sh<00><01><1A><19><19><19><19><19><16><16><16><16><16><16><1B><1B><1B><1B><1B><1B>&<26>&<26>&<26>&<26>&<26>&<26>&<26>&<26>&<26>&<26>&<26>&<26><1B><1B><1B><1B><1B><1B><1F><1F><1F><1F><1F><1F><12><12><12>(<14><14><14>*(<28>(<28>(<28>(<28>4J<01>J<01>J<01>J<01>D'<27>'<27>'<27>'<27>'<27>'<27>2<>2<>2<>2<>2<15><15><15>.B<01>B<01>B<01>B<01><<!<21><!<21><!<21><!<21>~<15><15><15>4<15><15><15>4<16><16><16>0<15><15><15>2<1A><1A><1A>>! <0A>! <0A>! <0A>H%)<29> <0A> <0A> <0A> <0A>> <10> <10> <10> <15> <15> <15>+ <0A>+ <0A>+ <0A>\ <0A> <0A> <0A><<17><17><17>*<15><15><15><15>6<15><15><15><15>6<1A><1A><1A><1A>. <1A> <1A> <1A> <1A>F-<2D>-<2D>-<2D>-<2D>-r