Debian Codegraph @

bindings/python/gpiod/line.py

raw symbols SCIP
1 # SPDX-License-Identifier: LGPL-2.1-or-later
2 # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <[email protected]>
3
4
5 from . import _ext
6 from enum import Enum
7
8 __all__ = ["Value", "Direction", "Bias", "Drive", "Edge", "Clock"]
9
10
11 class Value(Enum):
12 """Logical line states."""
13
14 INACTIVE = _ext.VALUE_INACTIVE
15 """Line is logically inactive."""
16 ACTIVE = _ext.VALUE_ACTIVE
17 """Line is logically active."""
18
19 def __bool__(self):
20 return self == self.ACTIVE
21
22
23 class Direction(Enum):
24 """Direction settings."""
25
26 AS_IS = _ext.DIRECTION_AS_IS
27 """Request the line(s), but don't change direction."""
28 INPUT = _ext.DIRECTION_INPUT
29 """Direction is input - for reading the value of an externally driven GPIO line."""
30 OUTPUT = _ext.DIRECTION_OUTPUT
31 """Direction is output - for driving the GPIO line."""
32
33
34 class Bias(Enum):
35 """Internal bias settings."""
36
37 AS_IS = _ext.BIAS_AS_IS
38 """Don't change the bias setting when applying line config."""
39 UNKNOWN = _ext.BIAS_UNKNOWN
40 """The internal bias state is unknown."""
41 DISABLED = _ext.BIAS_DISABLED
42 """The internal bias is disabled."""
43 PULL_UP = _ext.BIAS_PULL_UP
44 """The internal pull-up bias is enabled."""
45 PULL_DOWN = _ext.BIAS_PULL_DOWN
46 """The internal pull-down bias is enabled."""
47
48
49 class Drive(Enum):
50 """Drive settings."""
51
52 PUSH_PULL = _ext.DRIVE_PUSH_PULL
53 """Drive setting is push-pull."""
54 OPEN_DRAIN = _ext.DRIVE_OPEN_DRAIN
55 """Line output is open-drain."""
56 OPEN_SOURCE = _ext.DRIVE_OPEN_SOURCE
57 """Line output is open-source."""
58
59
60 class Edge(Enum):
61 """Edge detection settings."""
62
63 NONE = _ext.EDGE_NONE
64 """Line edge detection is disabled."""
65 RISING = _ext.EDGE_RISING
66 """Line detects rising edge events."""
67 FALLING = _ext.EDGE_FALLING
68 """Line detects falling edge events."""
69 BOTH = _ext.EDGE_BOTH
70 """Line detects both rising and falling edge events."""
71
72
73 class Clock(Enum):
74 """Event clock settings."""
75
76 MONOTONIC = _ext.CLOCK_MONOTONIC
77 """Line uses the monotonic clock for edge event timestamps."""
78 REALTIME = _ext.CLOCK_REALTIME
79 """Line uses the realtime clock for edge event timestamps."""
80 HTE = _ext.CLOCK_HTE
81 """Line uses the hardware timestamp engine for event timestamps."""