File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 39
39
# pylint: disable=bad-whitespace
40
40
_MCP23008_ADDRESS = const (0x20 )
41
41
_MCP23008_IODIR = const (0x00 )
42
+ _MCP23008_IPOL = const (0x01 )
43
+ _MCP23008_GPINTEN = const (0x02 )
44
+ _MCP23008_DEFVAL = const (0x03 )
45
+ _MCP23008_INTCON = const (0x04 )
46
+ _MCP23008_IOCON = const (0x05 )
42
47
_MCP23008_GPPU = const (0x06 )
48
+ _MCP23008_INTF = const (0x07 )
49
+ _MCP23008_INTCAP = const (0x08 )
43
50
_MCP23008_GPIO = const (0x09 )
44
51
45
52
@@ -50,11 +57,11 @@ class MCP23008(MCP230XX):
50
57
51
58
def __init__ (self , i2c , address = _MCP23008_ADDRESS ):
52
59
super ().__init__ (i2c , address )
53
- # Reset device state to all pins as inputs (safest option).
54
- with self . _device as device :
55
- # Write to MCP23008_IODIR register 0xFF followed by 9 zeros
56
- # for defaults of other registers.
57
- device . write ( ' \x00 \xFF \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 ' )
60
+
61
+ # Reset to all inputs with no pull-ups and no inverted polarity.
62
+ self . iodir = 0xFF
63
+ self . gppu = 0x00
64
+ self . _write_u8 ( _MCP23008_IPOL , 0x00 )
58
65
59
66
@property
60
67
def gpio (self ):
You can’t perform that action at this time.
0 commit comments