@@ -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