Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
st7789_mpy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
st7789_mpy
Commits
b3022817
Commit
b3022817
authored
Oct 24, 2021
by
russhughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chinese proverbs in chinese example
parent
d34d2199
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
520 additions
and
0 deletions
+520
-0
examples/T-DISPLAY/proverbs/NotoSansSC-Regular.otf
examples/T-DISPLAY/proverbs/NotoSansSC-Regular.otf
+0
-0
examples/T-DISPLAY/proverbs/makefont
examples/T-DISPLAY/proverbs/makefont
+5
-0
examples/T-DISPLAY/proverbs/proverbs.py
examples/T-DISPLAY/proverbs/proverbs.py
+80
-0
examples/T-DISPLAY/proverbs/proverbs_font.py
examples/T-DISPLAY/proverbs/proverbs_font.py
+435
-0
No files found.
examples/T-DISPLAY/proverbs/NotoSansSC-Regular.otf
0 → 100644
View file @
b3022817
File added
examples/T-DISPLAY/proverbs/makefont
0 → 100755
View file @
b3022817
#!/bin/sh
../../../utils/font2bitmap.py
\
-s
"万事起头难。熟能生巧。冰冻三尺,非一日之寒。三个臭皮匠,胜过诸葛亮。今日事,今日毕。师父领进门,修行在个人。一口吃不成胖子。欲速则不达。百闻不如一见。不入虎穴,焉得虎子。"
\
NotoSansSC-Regular.otf 30
>
proverbs_font.py
examples/T-DISPLAY/proverbs/proverbs.py
0 → 100644
View file @
b3022817
import
random
import
math
import
utime
from
machine
import
Pin
,
SPI
import
proverbs_font
as
font
import
st7789
def
color_wheel
(
WheelPos
):
"""returns a 565 color from the given position of the color wheel"""
WheelPos
=
(
255
-
WheelPos
)
%
255
if
WheelPos
<
85
:
return
st7789
.
color565
(
255
-
WheelPos
*
3
,
0
,
WheelPos
*
3
)
if
WheelPos
<
170
:
WheelPos
-=
85
return
st7789
.
color565
(
0
,
WheelPos
*
3
,
255
-
WheelPos
*
3
)
WheelPos
-=
170
return
st7789
.
color565
(
WheelPos
*
3
,
255
-
WheelPos
*
3
,
0
)
def
main
():
proverbs
=
[
"万事起头难"
,
"熟能生巧"
,
"冰冻三尺,非一日之寒"
,
"三个臭皮匠,胜过诸葛亮"
,
"今日事,今日毕"
,
"师父领进门,修行在个人"
,
"一口吃不成胖子"
,
"欲速则不达"
,
"百闻不如一见"
,
"不入虎穴,焉得虎子"
]
# initialize display
tft
=
st7789
.
ST7789
(
SPI
(
1
,
baudrate
=
30000000
,
sck
=
Pin
(
18
),
mosi
=
Pin
(
19
)),
135
,
240
,
reset
=
Pin
(
23
,
Pin
.
OUT
),
cs
=
Pin
(
5
,
Pin
.
OUT
),
dc
=
Pin
(
16
,
Pin
.
OUT
),
backlight
=
Pin
(
4
,
Pin
.
OUT
),
rotation
=
1
)
tft
.
init
()
line_height
=
font
.
HEIGHT
+
8
half_height
=
tft
.
height
()
//
2
half_width
=
tft
.
width
()
//
2
wheel
=
0
tft
.
fill
(
st7789
.
BLACK
)
while
True
:
for
proverb
in
proverbs
:
proverb_lines
=
proverb
.
split
(
','
)
half_lines_height
=
len
(
proverb_lines
)
*
line_height
//
2
tft
.
fill
(
st7789
.
BLACK
)
for
count
,
proverb_line
in
enumerate
(
proverb_lines
):
half_length
=
tft
.
write_len
(
font
,
proverb_line
)
//
2
tft
.
write
(
font
,
proverb_line
,
half_width
-
half_length
,
half_height
-
half_lines_height
+
count
*
line_height
,
color_wheel
(
wheel
))
wheel
+=
5
wheel
%=
256
# pause to slow down scrolling
utime
.
sleep
(
5
)
main
()
examples/T-DISPLAY/proverbs/proverbs_font.py
0 → 100644
View file @
b3022817
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment