Skip to content

Commit

Permalink
Fixed nodemcu_gpio_lcd.py to match the up-to-date MicroPython API (Pi…
Browse files Browse the repository at this point in the history
…n.low() and Pin.high() were removed in v1.4.6) (#16)

Looks good to me - Thanks
  • Loading branch information
OrBin authored and dhylands committed Jun 7, 2018
1 parent 00b7098 commit 92e5d02
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lcd/nodemcu_gpio_lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,32 @@ def __init__(self, rs_pin, enable_pin, d0_pin=None, d1_pin=None,
self.d6_pin = d2_pin
self.d7_pin = d3_pin
self.rs_pin.init(Pin.OUT)
self.rs_pin.low()
self.rs_pin.value(0)
if self.rw_pin:
self.rw_pin.init(Pin.OUT)
self.rw_pin.low()
self.rw_pin.value(0)
self.enable_pin.init(Pin.OUT)
self.enable_pin.low()
self.enable_pin.value(0)
self.d4_pin.init(Pin.OUT)
self.d5_pin.init(Pin.OUT)
self.d6_pin.init(Pin.OUT)
self.d7_pin.init(Pin.OUT)
self.d4_pin.low()
self.d5_pin.low()
self.d6_pin.low()
self.d7_pin.low()
self.d4_pin.value(0)
self.d5_pin.value(0)
self.d6_pin.value(0)
self.d7_pin.value(0)
if not self._4bit:
self.d0_pin.init(Pin.OUT)
self.d1_pin.init(Pin.OUT)
self.d2_pin.init(Pin.OUT)
self.d3_pin.init(Pin.OUT)
self.d0_pin.low()
self.d1_pin.low()
self.d2_pin.low()
self.d3_pin.low()
self.d0_pin.value(0)
self.d1_pin.value(0)
self.d2_pin.value(0)
self.d3_pin.value(0)
if self.backlight_pin is not None:
self.backlight_pin.init(Pin.OUT)
self.backlight_pin.low()
self.backlight_pin.value(0)

# See about splitting this into begin

Expand All @@ -104,11 +104,11 @@ def __init__(self, rs_pin, enable_pin, d0_pin=None, d1_pin=None,

def hal_pulse_enable(self):
"""Pulse the enable line high, and then low again."""
self.enable_pin.low()
self.enable_pin.value(0)
sleep_us(1)
self.enable_pin.high()
self.enable_pin.value(1)
sleep_us(1) # Enable pulse needs to be > 450 nsec
self.enable_pin.low()
self.enable_pin.value(0)
sleep_us(100) # Commands need > 37us to settle

def hal_write_init_nibble(self, nibble):
Expand All @@ -121,19 +121,19 @@ def hal_write_init_nibble(self, nibble):
def hal_backlight_on(self):
"""Allows the hal layer to turn the backlight on."""
if self.backlight_pin:
self.backlight_pin.high()
self.backlight_pin.value(1)

def hal_backlight_off(self):
"""Allows the hal layer to turn the backlight off."""
if self.backlight_pin:
self.backlight_pin.low()
self.backlight_pin.value(0)

def hal_write_command(self, cmd):
"""Writes a command to the LCD.
Data is latched on the falling edge of E.
"""
self.rs_pin.low()
self.rs_pin.value(0)
self.hal_write_8bits(cmd)
if cmd <= 3:
# The home and clear commands require a worst
Expand All @@ -142,13 +142,13 @@ def hal_write_command(self, cmd):

def hal_write_data(self, data):
"""Write data to the LCD."""
self.rs_pin.high()
self.rs_pin.value(1)
self.hal_write_8bits(data)

def hal_write_8bits(self, value):
"""Writes 8 bits of data to the LCD."""
if self.rw_pin:
self.rw_pin.low()
self.rw_pin.value(0)
if self._4bit:
self.hal_write_4bits(value >> 4)
self.hal_write_4bits(value)
Expand Down

0 comments on commit 92e5d02

Please sign in to comment.