samples

Module Contents

samples.simple_stub = Multiline-String
Show Value
 1"""
 2Module: 'machine' on micropython-esp32-1.15
 3"""
 4# MCU: {'ver': '1.15', 'port': 'esp32', 'arch': 'xtensawin', 'sysname': 'esp32', 'release': '1.15.0', 'name': 'micropython', 'mpy': 10757, 'version': '1.15.0', 'machine': 'ESP32 module (spiram) with ESP32', 'build': '', 'nodename': 'esp32', 'platform': 'esp32', 'family': 'micropython'}
 5# Stubber: 1.3.11
 6from typing import Any
 7
 8class Signal:
 9    ''
10    def __init__(self):
11        pass
12
13    def off(self) -> Any:
14        pass
15
16    def on(self) -> Any:
17        pass
18
19    def value(self) -> Any:
20        pass
21
22def time_pulse_us() -> Any:
23    pass
24
25def unique_id() -> Any:
26    pass
27
28def wake_reason() -> Any:
29    pass
samples.rich_source = Multiline-String
Show Value
 1def time_pulse_us(pin:Pin, pulse_level:int, timeout_us:int=1000000, /) -> int:
 2    """
 3    Time a pulse on the given *pin*, and return the duration of the pulse in
 4    microseconds.  The *pulse_level* argument should be 0 to time a low pulse
 5    or 1 to time a high pulse.
 6
 7    If the current input value of the pin is different to *pulse_level*,
 8    the function first (*) waits until the pin input becomes equal to *pulse_level*,
 9    then (**) times the duration that the pin is equal to *pulse_level*.
10    If the pin is already equal to *pulse_level* then timing starts straight away.
11
12    The function will return -2 if there was timeout waiting for condition marked
13    (*) above, and -1 if there was timeout during the main measurement, marked (**)
14    above. The timeout is the same for both cases and given by *timeout_us* (which
15    is in microseconds).
16    """
17    ...
18
19
20class Signal(Pin):
21    """The Signal class is a simple extension of the Pin class. Unlike Pin, which can be only in “absolute”
22    0 and 1 states, a Signal can be in “asserted” (on) or “deasserted” (off) states, while being inverted (active-low) or not.
23    In other words, it adds logical inversion support to Pin functionality. While this may seem a simple addition, it is exactly what
24    is needed to support wide array of simple digital devices in a way portable across different boards, which is one of the major
25    MicroPython goals. Regardless of whether different users have an active-high or active-low LED, a normally open or normally closed
26    relay - you can develop a single, nicely looking application which works with each of them, and capture hardware configuration
27    differences in few lines in the config file of your app.
28
29    """
30    def __init__(self, pin_obj:Pin, *,invert:bool=False):
31        """ Create a Signal object. There’re two ways to create it:
32        By wrapping existing Pin object - universal method which works for any board.
33        By passing required Pin parameters directly to Signal constructor, skipping the need to create intermediate Pin object. Available on many, but not all boards.
34        The arguments are:
35        pin_obj is existing Pin object.
36        pin_arguments are the same arguments as can be passed to Pin constructor.
37        invert - if True, the signal will be inverted (active low).
38        """
39        pass
40
41
42    def off(self) -> None:
43        """ Activate signal.
44        """
45        pass
46
47
48    def on(self) -> None:
49        """ Deactivate signal.
50        """
51        pass
52
53    def value(self) -> None:
54        """ This method allows to set and get the value of the signal, depending on whether the argument x is supplied or not.
55            If the argument is omitted then this method gets the signal level, 1 meaning signal is asserted (active) and 0 - signal inactive.
56            If the argument is supplied then this method sets the signal level. The argument x can be anything that converts to a boolean.
57            If it converts to True, the signal is active, otherwise it is inactive.
58            Correspondence between signal being active and actual logic level on the underlying pin depends on whether signal is inverted (active-low) or not.
59            For non-inverted signal, active status corresponds to logical 1, inactive - to logical 0. For inverted/active-low signal, active status corresponds to logical 0,
60            while inactive - to logical 1.
61        """
62        pass