From e28539734dfbd6965395f0f0478ecad44ca0eaea Mon Sep 17 00:00:00 2001 From: Ken Bell Date: Thu, 2 May 2013 21:09:51 -0700 Subject: [PATCH] Update Adafruit_CharLCDPlate.py Setting read/write on wrong bit in GPIOB. Bit 7 from display is in bit 1 of GPIOB. Need to set/clear correct bit in IODIRB. --- Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py b/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py index 06b9300c..02fd782d 100644 --- a/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py +++ b/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py @@ -82,7 +82,7 @@ def __init__(self, busnum=-1, addr=0x20, debug=False): # I2C is relatively slow. MCP output port states are cached # so we don't need to constantly poll-and-change bit states. - self.porta, self.portb, self.ddrb = 0, 0, 0b00010000 + self.porta, self.portb, self.ddrb = 0, 0, 0b00000010 # Set MCP23017 IOCON register to Bank 0 with sequential operation. # If chip is already set for Bank 0, this will just write to OLATB, @@ -187,7 +187,7 @@ def write(self, value, char_mode=False): """ Send command/data to LCD """ # If pin D7 is in input state, poll LCD busy flag until clear. - if self.ddrb & 0b00010000: + if self.ddrb & 0b00000010: lo = (self.portb & 0b00000001) | 0b01000000 hi = lo | 0b00100000 # E=1 (strobe) self.i2c.bus.write_byte_data( @@ -204,7 +204,7 @@ def write(self, value, char_mode=False): self.portb = lo # Polling complete, change D7 pin to output - self.ddrb &= 0b11101111 + self.ddrb &= 0b11111101 self.i2c.bus.write_byte_data(self.i2c.address, self.MCP23017_IODIRB, self.ddrb) @@ -249,7 +249,7 @@ def write(self, value, char_mode=False): # If a poll-worthy instruction was issued, reconfigure D7 # pin as input to indicate need for polling on next call. if (not char_mode) and (value in self.pollables): - self.ddrb |= 0b00010000 + self.ddrb |= 0b00000010 self.i2c.bus.write_byte_data(self.i2c.address, self.MCP23017_IODIRB, self.ddrb)