@@ -48,14 +48,8 @@ def init(self, mode=IN, pull=None):
48
48
"""Initialize the Pin"""
49
49
# Input,
50
50
if not self ._line_request :
51
- self ._line_request = self ._chip .request_lines (
52
- config = {int (self ._num ): None },
53
- consumer = self ._CONSUMER ,
54
- )
55
- # print("init line: ", self.id, self._line)
56
-
57
- if mode is not None :
58
51
line_config = gpiod .LineSettings ()
52
+
59
53
if mode == self .IN :
60
54
line_config .direction = gpiod .line .Direction .INPUT
61
55
if pull is not None :
@@ -68,24 +62,18 @@ def init(self, mode=IN, pull=None):
68
62
else :
69
63
raise RuntimeError (f"Invalid pull for pin: { self .id } " )
70
64
71
- self ._mode = self .IN
72
- self ._line_request .reconfigure_lines (
73
- {
74
- int (self ._num ): line_config ,
75
- }
76
- )
77
65
elif mode == self .OUT :
78
66
if pull is not None :
79
67
raise RuntimeError ("Cannot set pull resistor on output" )
80
- self ._mode = self .OUT
81
68
line_config .direction = gpiod .line .Direction .OUTPUT
82
- self ._line_request .reconfigure_lines (
83
- {
84
- int (self ._num ): line_config ,
85
- }
86
- )
69
+
87
70
else :
88
- raise RuntimeError ("Invalid mode for pin: %s" % self .id )
71
+ raise RuntimeError (f"Invalid mode for pin: { self .id } " )
72
+
73
+ self ._line_request = self ._chip .request_lines (
74
+ {int (self ._num ): line_config },
75
+ consumer = self ._CONSUMER ,
76
+ )
89
77
90
78
def value (self , val = None ):
91
79
"""Set or return the Pin Value"""
0 commit comments