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

Update Adafruit_CharLCDPlate.py #41

Merged
merged 1 commit into from
Jul 15, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down