-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_lcd.py
74 lines (55 loc) · 1.5 KB
/
test_lcd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from utime import sleep_ms
from i2c_lcd import LCD
if __name__ == "__main__":
""" Test all the LCD functions. """
# The WiPY 2.0 has one I2C connection (id=0).
# The PCF8574 in my (16x2) I2C LCD interface module has I2C address 0x27
# This address was found by the scan() function from WiPy's I2C library.
from machine import I2C
lcd = LCD(I2C(0, I2C.MASTER), addr=39, lines=2, columns=16)
print("Cursor blink")
lcd.blink()
sleep_ms(5000)
print("Print alfabet")
for i in range(0, 26):
lcd.putch(chr(ord('A') + i))
sleep_ms(100)
sleep_ms(2000)
print("Display off")
lcd.display_off()
sleep_ms(5000)
print("Cursor solid")
lcd.solid()
sleep_ms(5000)
print("Display on (cursor now solid)")
lcd.display_on()
sleep_ms(5000)
print("Cursor off")
lcd.cursor_off()
sleep_ms(5000)
print("Cursor on")
lcd.cursor_on()
sleep_ms(5000)
print("Print 0 to 9")
for i in range(0, 10):
lcd.putch(chr(ord('0') + i))
sleep_ms(5000)
print("Print string HELLO")
lcd.puts("HELLO")
sleep_ms(5000)
print("Backlight off")
lcd.backlight_off()
sleep_ms(5000)
print("Clear and cursor off")
lcd.clear()
lcd.cursor_off()
print("Backlight on")
lcd.backlight_on()
sleep_ms(5000)
print("Print Ready bottom right")
lcd.move_to(11, 1)
lcd.puts("Ready")
sleep_ms(5000)
print("Move cursor outside display")
lcd.blink()
lcd.move_to(100, 100)