File tree 1 file changed +9
-3
lines changed 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -148,13 +148,19 @@ def invert_polarity(self) -> bool:
148
148
"""The polarity of the pin, either True for an Inverted or
149
149
False for an normal.
150
150
"""
151
- if _get_bit (self ._mcp .ipol , self ._pin ):
151
+ if hasattr ( self . _mcp , "ipol" ) and _get_bit (self ._mcp .ipol , self ._pin ):
152
152
return True
153
153
return False
154
154
155
155
@invert_polarity .setter
156
156
def invert_polarity (self , val : bool ) -> None :
157
157
if val :
158
- self ._mcp .ipol = _enable_bit (self ._mcp .ipol , self ._pin )
158
+ if hasattr (self ._mcp , "ipol" ):
159
+ self ._mcp .ipol = _enable_bit (self ._mcp .ipol , self ._pin )
160
+ else :
161
+ raise ValueError ("Inverted polarity is not supported." )
159
162
else :
160
- self ._mcp .ipol = _clear_bit (self ._mcp .ipol , self ._pin )
163
+ if hasattr (self ._mcp , "ipol" ):
164
+ self ._mcp .ipol = _clear_bit (self ._mcp .ipol , self ._pin )
165
+ else :
166
+ return
You can’t perform that action at this time.
0 commit comments