SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
(continued from previous page)
self
.
bus
.
writeto(
self
.
addr,
bytearray
([
0x08
]))
def
write_word
(
self
, data):
temp
=
data
if
self
.
blen
==
1
:
temp
|=
0x08
else
:
temp
&=
0xF7
self
.
bus
.
writeto(
self
.
addr,
bytearray
([temp]))
def
send_command
(
self
, cmd):
# Send bit7-4 firstly
buf
=
cmd
&
0xF0
buf
|=
0x04
# RS = 0, RW = 0, EN = 1
self
.
write_word(buf)
time
.
sleep(
0.002
)
buf
&=
0xFB
# Make EN = 0
self
.
write_word(buf)
# Send bit3-0 secondly
buf
=
(cmd
&
0x0F
)
<<
4
buf
|=
0x04
# RS = 0, RW = 0, EN = 1
self
.
write_word(buf)
time
.
sleep(
0.002
)
buf
&=
0xFB
# Make EN = 0
self
.
write_word(buf)
def
send_data
(
self
, data):
# Send bit7-4 firstly
buf
=
data
&
0xF0
buf
|=
0x05
# RS = 1, RW = 0, EN = 1
self
.
write_word(buf)
time
.
sleep(
0.002
)
buf
&=
0xFB
# Make EN = 0
self
.
write_word(buf)
# Send bit3-0 secondly
buf
=
(data
&
0x0F
)
<<
4
buf
|=
0x05
# RS = 1, RW = 0, EN = 1
self
.
write_word(buf)
time
.
sleep(
0.002
)
buf
&=
0xFB
# Make EN = 0
self
.
write_word(buf)
def
clear
(
self
):
self
.
send_command(
0x01
)
# Clear Screen
def
openlight
(
self
):
# Enable the backlight
self
.
bus
.
writeto(
self
.
addr,
bytearray
([
0x08
]))
# self.bus.close()
def
write
(
self
, x, y,
str
):
if
x
<
0
:
x
=
0
if
x
>
15
:
x
=
15
if
y
<
0
:
(continues on next page)
3.4. Projects
103
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 ...