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

Commit 5d38766

Browse files
committed
Merge pull request #41 from kenrbell/patch-1
Update Adafruit_CharLCDPlate.py
2 parents b11eda5 + e285397 commit 5d38766

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
@@ -90,7 +90,7 @@ def __init__(self, busnum=-1, addr=0x20, debug=False, backlight=ON):
9090

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

9595
# Set initial backlight color.
9696
c = ~backlight
@@ -200,7 +200,7 @@ def write(self, value, char_mode=False):
200200
""" Send command/data to LCD """
201201

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

219219
# Polling complete, change D7 pin to output
220-
self.ddrb &= 0b11101111
220+
self.ddrb &= 0b11111101
221221
self.i2c.bus.write_byte_data(self.i2c.address,
222222
self.MCP23017_IODIRB, self.ddrb)
223223

@@ -262,7 +262,7 @@ def write(self, value, char_mode=False):
262262
# If a poll-worthy instruction was issued, reconfigure D7
263263
# pin as input to indicate need for polling on next call.
264264
if (not char_mode) and (value in self.pollables):
265-
self.ddrb |= 0b00010000
265+
self.ddrb |= 0b00000010
266266
self.i2c.bus.write_byte_data(self.i2c.address,
267267
self.MCP23017_IODIRB, self.ddrb)
268268

0 commit comments

Comments
 (0)