
SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
(continued from previous page)
y
=
0
if
y
>
1
:
y
=
1
# Move cursor
addr
=
0x80
+
0x40
*
y
+
x
self
.
send_command(addr)
for
chr
in
str
:
self
.
send_data(
ord
(
chr
))
def
message
(
self
, text):
#print("message: %s"%text)
for
char
in
text:
if
char
==
'
\n
'
:
self
.
send_command(
0xC0
)
# next line
else
:
self
.
send_data(
ord
(char))
Then, create a new file, and call the lcd1602 library stored before in this file.
from
lcd1602
import
LCD
import
utime
lcd
=
LCD()
string
=
" Hello!
\n
"
lcd
.
message(string)
utime
.
sleep(
2
)
string
=
"
Sunfounder!"
lcd
.
message(string)
utime
.
sleep(
2
)
lcd
.
clear()
After the program runs, you will be able to see two lines of text appear on the LCD in turn, and then disappear.
How it works?
In the lcd1602 library, we integrate the relevant functions of lcd1602 into the LCD class.
Import lcd1602 library
from
lcd1602
import
LCD
Declare an object of the LCD class and name it lcd.
lcd
=
LCD()
This statement will display the text on the LCD. It should be noted that the argument must be a string type. If we want
to pass an integer or float, we must use the forced conversion statement
str()
.
lcd
.
message(string)
If you call this statement multiple times, lcd will superimpose the texts. This requires the use of the following statement
to clear the display.
104
Chapter 3. For MicroPython User
Summary of Contents for Thales Kit
Page 1: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 Jimmy SunFounder Jun 04 2021 ...
Page 2: ......
Page 4: ...ii ...
Page 6: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 2 CONTENTS ...
Page 140: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 136 Chapter 3 For MicroPython User ...
Page 164: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 160 Chapter 4 For Arduino User ...