Skip to content

Commit 92e5d02

Browse files
OrBindhylands
authored andcommitted
Fixed nodemcu_gpio_lcd.py to match the up-to-date MicroPython API (Pin.low() and Pin.high() were removed in v1.4.6) (#16)
Looks good to me - Thanks
1 parent 00b7098 commit 92e5d02

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

lcd/nodemcu_gpio_lcd.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,32 @@ def __init__(self, rs_pin, enable_pin, d0_pin=None, d1_pin=None,
5555
self.d6_pin = d2_pin
5656
self.d7_pin = d3_pin
5757
self.rs_pin.init(Pin.OUT)
58-
self.rs_pin.low()
58+
self.rs_pin.value(0)
5959
if self.rw_pin:
6060
self.rw_pin.init(Pin.OUT)
61-
self.rw_pin.low()
61+
self.rw_pin.value(0)
6262
self.enable_pin.init(Pin.OUT)
63-
self.enable_pin.low()
63+
self.enable_pin.value(0)
6464
self.d4_pin.init(Pin.OUT)
6565
self.d5_pin.init(Pin.OUT)
6666
self.d6_pin.init(Pin.OUT)
6767
self.d7_pin.init(Pin.OUT)
68-
self.d4_pin.low()
69-
self.d5_pin.low()
70-
self.d6_pin.low()
71-
self.d7_pin.low()
68+
self.d4_pin.value(0)
69+
self.d5_pin.value(0)
70+
self.d6_pin.value(0)
71+
self.d7_pin.value(0)
7272
if not self._4bit:
7373
self.d0_pin.init(Pin.OUT)
7474
self.d1_pin.init(Pin.OUT)
7575
self.d2_pin.init(Pin.OUT)
7676
self.d3_pin.init(Pin.OUT)
77-
self.d0_pin.low()
78-
self.d1_pin.low()
79-
self.d2_pin.low()
80-
self.d3_pin.low()
77+
self.d0_pin.value(0)
78+
self.d1_pin.value(0)
79+
self.d2_pin.value(0)
80+
self.d3_pin.value(0)
8181
if self.backlight_pin is not None:
8282
self.backlight_pin.init(Pin.OUT)
83-
self.backlight_pin.low()
83+
self.backlight_pin.value(0)
8484

8585
# See about splitting this into begin
8686

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

105105
def hal_pulse_enable(self):
106106
"""Pulse the enable line high, and then low again."""
107-
self.enable_pin.low()
107+
self.enable_pin.value(0)
108108
sleep_us(1)
109-
self.enable_pin.high()
109+
self.enable_pin.value(1)
110110
sleep_us(1) # Enable pulse needs to be > 450 nsec
111-
self.enable_pin.low()
111+
self.enable_pin.value(0)
112112
sleep_us(100) # Commands need > 37us to settle
113113

114114
def hal_write_init_nibble(self, nibble):
@@ -121,19 +121,19 @@ def hal_write_init_nibble(self, nibble):
121121
def hal_backlight_on(self):
122122
"""Allows the hal layer to turn the backlight on."""
123123
if self.backlight_pin:
124-
self.backlight_pin.high()
124+
self.backlight_pin.value(1)
125125

126126
def hal_backlight_off(self):
127127
"""Allows the hal layer to turn the backlight off."""
128128
if self.backlight_pin:
129-
self.backlight_pin.low()
129+
self.backlight_pin.value(0)
130130

131131
def hal_write_command(self, cmd):
132132
"""Writes a command to the LCD.
133133
134134
Data is latched on the falling edge of E.
135135
"""
136-
self.rs_pin.low()
136+
self.rs_pin.value(0)
137137
self.hal_write_8bits(cmd)
138138
if cmd <= 3:
139139
# The home and clear commands require a worst
@@ -142,13 +142,13 @@ def hal_write_command(self, cmd):
142142

143143
def hal_write_data(self, data):
144144
"""Write data to the LCD."""
145-
self.rs_pin.high()
145+
self.rs_pin.value(1)
146146
self.hal_write_8bits(data)
147147

148148
def hal_write_8bits(self, value):
149149
"""Writes 8 bits of data to the LCD."""
150150
if self.rw_pin:
151-
self.rw_pin.low()
151+
self.rw_pin.value(0)
152152
if self._4bit:
153153
self.hal_write_4bits(value >> 4)
154154
self.hal_write_4bits(value)

0 commit comments

Comments
 (0)