Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

Commit e285397

Browse files
committed
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.
1 parent baccabb commit e285397

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __init__(self, busnum=-1, addr=0x20, debug=False):
8282

8383
# I2C is relatively slow. MCP output port states are cached
8484
# so we don't need to constantly poll-and-change bit states.
85-
self.porta, self.portb, self.ddrb = 0, 0, 0b00010000
85+
self.porta, self.portb, self.ddrb = 0, 0, 0b00000010
8686

8787
# Set MCP23017 IOCON register to Bank 0 with sequential operation.
8888
# 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):
187187
""" Send command/data to LCD """
188188

189189
# If pin D7 is in input state, poll LCD busy flag until clear.
190-
if self.ddrb & 0b00010000:
190+
if self.ddrb & 0b00000010:
191191
lo = (self.portb & 0b00000001) | 0b01000000
192192
hi = lo | 0b00100000 # E=1 (strobe)
193193
self.i2c.bus.write_byte_data(
@@ -204,7 +204,7 @@ def write(self, value, char_mode=False):
204204
self.portb = lo
205205

206206
# Polling complete, change D7 pin to output
207-
self.ddrb &= 0b11101111
207+
self.ddrb &= 0b11111101
208208
self.i2c.bus.write_byte_data(self.i2c.address,
209209
self.MCP23017_IODIRB, self.ddrb)
210210

@@ -249,7 +249,7 @@ def write(self, value, char_mode=False):
249249
# If a poll-worthy instruction was issued, reconfigure D7
250250
# pin as input to indicate need for polling on next call.
251251
if (not char_mode) and (value in self.pollables):
252-
self.ddrb |= 0b00010000
252+
self.ddrb |= 0b00000010
253253
self.i2c.bus.write_byte_data(self.i2c.address,
254254
self.MCP23017_IODIRB, self.ddrb)
255255

0 commit comments

Comments
 (0)