@@ -48,14 +48,8 @@ def init(self, mode=IN, pull=None):
4848 """Initialize the Pin"""
4949 # Input,
5050 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 :
5851 line_config = gpiod .LineSettings ()
52+
5953 if mode == self .IN :
6054 line_config .direction = gpiod .line .Direction .INPUT
6155 if pull is not None :
@@ -68,24 +62,18 @@ def init(self, mode=IN, pull=None):
6862 else :
6963 raise RuntimeError (f"Invalid pull for pin: { self .id } " )
7064
71- self ._mode = self .IN
72- self ._line_request .reconfigure_lines (
73- {
74- int (self ._num ): line_config ,
75- }
76- )
7765 elif mode == self .OUT :
7866 if pull is not None :
7967 raise RuntimeError ("Cannot set pull resistor on output" )
80- self ._mode = self .OUT
8168 line_config .direction = gpiod .line .Direction .OUTPUT
82- self ._line_request .reconfigure_lines (
83- {
84- int (self ._num ): line_config ,
85- }
86- )
69+
8770 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+ )
8977
9078 def value (self , val = None ):
9179 """Set or return the Pin Value"""
0 commit comments