Debian Codegraph @

bindings/python/gpiod/line_info.py

raw symbols SCIP
1 # SPDX-License-Identifier: LGPL-2.1-or-later
2 # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <[email protected]>
3
4 from . import _ext
5 from dataclasses import dataclass
6 from datetime import timedelta
7 from gpiod.line import Direction, Bias, Drive, Edge, Clock
8
9 __all__ = "LineInfo"
10
11
12 @dataclass(frozen=True, init=False, repr=False)
13 class LineInfo:
14 """
15 Snapshot of a line's status.
16 """
17
18 offset: int
19 """Offset of the line."""
20 name: str
21 """Name of the line."""
22 used: bool
23 """Indicates whether line is in use."""
24 consumer: str
25 """Name of the consumer of the line."""
26 direction: Direction
27 """Direction setting of the line."""
28 active_low: bool
29 """Active-low setting of the line."""
30 bias: Bias
31 """Bias setting of the line."""
32 drive: Drive
33 """Drive setting of the line."""
34 edge_detection: Edge
35 """Edge detection setting of the line."""
36 event_clock: Clock
37 """Event clock setting used for edge event timestamps for the line."""
38 debounced: bool
39 """Indicates whether line is debounced."""
40 debounce_period: timedelta
41 """Debounce period of the line."""
42
43 def __init__(
44 self,
45 offset: int,
46 name: str,
47 used: bool,
48 consumer: str,
49 direction: int,
50 active_low: bool,
51 bias: int,
52 drive: int,
53 edge_detection: int,
54 event_clock: int,
55 debounced: bool,
56 debounce_period_us: int,
57 ):
58 object.__setattr__(self, "offset", offset)
59 object.__setattr__(self, "name", name)
60 object.__setattr__(self, "used", used)
61 object.__setattr__(self, "consumer", consumer)
62 object.__setattr__(self, "direction", Direction(direction))
63 object.__setattr__(self, "active_low", active_low)
64 object.__setattr__(self, "bias", Bias(bias))
65 object.__setattr__(self, "drive", Drive(drive))
66 object.__setattr__(self, "edge_detection", Edge(edge_detection))
67 object.__setattr__(self, "event_clock", Clock(event_clock))
68 object.__setattr__(self, "debounced", debounced)
69 object.__setattr__(
70 self, "debounce_period", timedelta(microseconds=debounce_period_us)
71 )
72
73 def __str__(self):
74 return '<LineInfo offset={} name="{}" used={} consumer="{}" direction={} active_low={} bias={} drive={} edge_detection={} event_clock={} debounced={} debounce_period={}>'.format(
75 self.offset,
76 self.name,
77 self.used,
78 self.consumer,
79 self.direction,
80 self.active_low,
81 self.bias,
82 self.drive,
83 self.edge_detection,
84 self.event_clock,
85 self.debounced,
86 self.debounce_period,
87 )