@@ -51,7 +51,7 @@ def __init__(self, address, num_gpios):
51
51
if num_gpios <= 8 :
52
52
self .i2c .write8 (MCP23008_IODIRA , 0xFF ) # all inputs on port A
53
53
self .direction = self .i2c .readU8 (MCP23008_IODIRA )
54
- self .i2c .write8 (MCP23008_GPPU , 0x00 )
54
+ self .i2c .write8 (MCP23008_GPPUA , 0x00 )
55
55
elif num_gpios > 8 and num_gpios <= 16 :
56
56
self .i2c .write8 (MCP23017_IODIRA , 0xFF ) # all inputs on port A
57
57
self .i2c .write8 (MCP23017_IODIRB , 0xFF ) # all inputs on port B
@@ -79,7 +79,7 @@ def _readandchangepin(self, port, pin, value, currvalue = None):
79
79
80
80
def pullup (self , pin , value ):
81
81
if self .num_gpios <= 8 :
82
- return self ._readandchangepin (MCP23008_GPPU , pin , value )
82
+ return self ._readandchangepin (MCP23008_GPPUA , pin , value )
83
83
if self .num_gpios <= 16 :
84
84
if (pin < 8 ):
85
85
return self ._readandchangepin (MCP23017_GPPUA , pin , value )
@@ -89,7 +89,7 @@ def pullup(self, pin, value):
89
89
# Set pin to either input or output mode
90
90
def config (self , pin , mode ):
91
91
if self .num_gpios <= 8 :
92
- self .direction = self ._readandchangepin (MCP23008_IODIR , pin , mode )
92
+ self .direction = self ._readandchangepin (MCP23008_IODIRA , pin , mode )
93
93
if self .num_gpios <= 16 :
94
94
if (pin < 8 ):
95
95
self .direction = self ._readandchangepin (MCP23017_IODIRA , pin , mode )
@@ -101,7 +101,7 @@ def config(self, pin, mode):
101
101
def output (self , pin , value ):
102
102
# assert self.direction & (1 << pin) == 0, "Pin %s not set to output" % pin
103
103
if self .num_gpios <= 8 :
104
- self .outputvalue = self ._readandchangepin (MCP23008_GPIO , pin , value . self .i2c .readU8 (MCP23008_OLAT ))
104
+ self .outputvalue = self ._readandchangepin (MCP23008_GPIOA , pin , value . self .i2c .readU8 (MCP23008_OLATA ))
105
105
if self .num_gpios <= 16 :
106
106
if (pin < 8 ):
107
107
self .outputvalue = self ._readandchangepin (MCP23017_GPIOA , pin , value , self .i2c .readU8 (MCP23017_OLATA ))
@@ -118,7 +118,7 @@ def input(self, pin):
118
118
assert pin >= 0 and pin < self .num_gpios , "Pin number %s is invalid, only 0-%s are valid" % (pin , self .num_gpios )
119
119
assert self .direction & (1 << pin ) != 0 , "Pin %s not set to input" % pin
120
120
if self .num_gpios <= 8 :
121
- value = self .i2c .readU8 (MCP23008_GPIO )
121
+ value = self .i2c .readU8 (MCP23008_GPIOA )
122
122
elif self .num_gpios > 8 and self .num_gpios <= 16 :
123
123
value = self .i2c .readU16 (MCP23017_GPIOA )
124
124
temp = value >> 8
0 commit comments