@@ -51,7 +51,7 @@ def __init__(self, address, num_gpios):
5151 if num_gpios <= 8 :
5252 self .i2c .write8 (MCP23008_IODIRA , 0xFF ) # all inputs on port A
5353 self .direction = self .i2c .readU8 (MCP23008_IODIRA )
54- self .i2c .write8 (MCP23008_GPPU , 0x00 )
54+ self .i2c .write8 (MCP23008_GPPUA , 0x00 )
5555 elif num_gpios > 8 and num_gpios <= 16 :
5656 self .i2c .write8 (MCP23017_IODIRA , 0xFF ) # all inputs on port A
5757 self .i2c .write8 (MCP23017_IODIRB , 0xFF ) # all inputs on port B
@@ -79,7 +79,7 @@ def _readandchangepin(self, port, pin, value, currvalue = None):
7979
8080 def pullup (self , pin , value ):
8181 if self .num_gpios <= 8 :
82- return self ._readandchangepin (MCP23008_GPPU , pin , value )
82+ return self ._readandchangepin (MCP23008_GPPUA , pin , value )
8383 if self .num_gpios <= 16 :
8484 if (pin < 8 ):
8585 return self ._readandchangepin (MCP23017_GPPUA , pin , value )
@@ -89,7 +89,7 @@ def pullup(self, pin, value):
8989 # Set pin to either input or output mode
9090 def config (self , pin , mode ):
9191 if self .num_gpios <= 8 :
92- self .direction = self ._readandchangepin (MCP23008_IODIR , pin , mode )
92+ self .direction = self ._readandchangepin (MCP23008_IODIRA , pin , mode )
9393 if self .num_gpios <= 16 :
9494 if (pin < 8 ):
9595 self .direction = self ._readandchangepin (MCP23017_IODIRA , pin , mode )
@@ -101,7 +101,7 @@ def config(self, pin, mode):
101101 def output (self , pin , value ):
102102 # assert self.direction & (1 << pin) == 0, "Pin %s not set to output" % pin
103103 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 ))
105105 if self .num_gpios <= 16 :
106106 if (pin < 8 ):
107107 self .outputvalue = self ._readandchangepin (MCP23017_GPIOA , pin , value , self .i2c .readU8 (MCP23017_OLATA ))
@@ -118,7 +118,7 @@ def input(self, pin):
118118 assert pin >= 0 and pin < self .num_gpios , "Pin number %s is invalid, only 0-%s are valid" % (pin , self .num_gpios )
119119 assert self .direction & (1 << pin ) != 0 , "Pin %s not set to input" % pin
120120 if self .num_gpios <= 8 :
121- value = self .i2c .readU8 (MCP23008_GPIO )
121+ value = self .i2c .readU8 (MCP23008_GPIOA )
122122 elif self .num_gpios > 8 and self .num_gpios <= 16 :
123123 value = self .i2c .readU16 (MCP23017_GPIOA )
124124 temp = value >> 8
0 commit comments