Skip to content

Commit e61b932

Browse files
Mr-Gao7stephen.gao
andauthored
add (lvgl): 增加lvgl实例代码及资源 (#5)
Co-authored-by: stephen.gao <stephen.gao@quectel.com>
1 parent c71983f commit e61b932

File tree

2 files changed

+176
-0
lines changed

2 files changed

+176
-0
lines changed

lvgl/lvgl_sample.py

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
from machine import Pin
2+
from machine import LCD
3+
import lvgl as lv
4+
5+
gpio1 = Pin(Pin.GPIO25, Pin.OUT, Pin.PULL_DISABLE, 1)
6+
gpio2 = Pin(Pin.GPIO20, Pin.OUT, Pin.PULL_DISABLE, 1)
7+
8+
init_param=(
9+
0, 0, 0x11,
10+
2, 0, 120,
11+
0, 0, 0x00,
12+
0, 1, 0x36,
13+
1, 1, 0x00,
14+
0, 1, 0x3A,
15+
1, 1, 0x05,
16+
0, 1, 0x35,
17+
1, 1, 0x00,
18+
0, 1, 0xC7,
19+
1, 1, 0x00,
20+
0, 1, 0xCC,
21+
1, 1, 0x09,
22+
0, 5, 0xB2,
23+
1, 1, 0x0C,
24+
1, 1, 0x0C,
25+
1, 1, 0x00,
26+
1, 1, 0x33,
27+
1, 1, 0x33,
28+
0, 1, 0xB7,
29+
1, 1, 0x35,
30+
0, 1, 0xBB,
31+
1, 1, 0x36,
32+
0, 1, 0xC0,
33+
1, 1, 0x2C,
34+
0, 1, 0xC2,
35+
1, 1, 0x01,
36+
0, 1, 0xC3,
37+
1, 1, 0x0D,
38+
0, 1, 0xC4,
39+
1, 1, 0x20,
40+
0, 1, 0xC6,
41+
1, 1, 0x0F,
42+
0, 2, 0xD0,
43+
1, 1, 0xA4,
44+
1, 1, 0xA1,
45+
0, 14, 0xE0,
46+
1, 1, 0xD0,
47+
1, 1, 0x17,
48+
1, 1, 0x19,
49+
1, 1, 0x04,
50+
1, 1, 0x03,
51+
1, 1, 0x04,
52+
1, 1, 0x32,
53+
1, 1, 0x41,
54+
1, 1, 0x43,
55+
1, 1, 0x09,
56+
1, 1, 0x14,
57+
1, 1, 0x12,
58+
1, 1, 0x33,
59+
1, 1, 0x2C,
60+
0, 14, 0xE1,
61+
1, 1, 0xD0,
62+
1, 1, 0x18,
63+
1, 1, 0x17,
64+
1, 1, 0x04,
65+
1, 1, 0x03,
66+
1, 1, 0x04,
67+
1, 1, 0x31,
68+
1, 1, 0x46,
69+
1, 1, 0x43,
70+
1, 1, 0x09,
71+
1, 1, 0x14,
72+
1, 1, 0x13,
73+
1, 1, 0x31,
74+
1, 1, 0x2D,
75+
0, 0, 0x29,
76+
0, 1, 0x36,
77+
1, 1, 0x00,
78+
0, 0, 0x2c,
79+
)
80+
81+
XSTART_H = 0xf0
82+
XSTART_L = 0xf1
83+
YSTART_H = 0xf2
84+
YSTART_L = 0xf3
85+
XEND_H = 0xE0
86+
XEND_L = 0xE1
87+
YEND_H = 0xE2
88+
YEND_L = 0xE3
89+
90+
91+
XSTART = 0xD0
92+
XEND = 0xD1
93+
YSTART = 0xD2
94+
YEND = 0xD3
95+
96+
lcd = LCD()
97+
98+
init_data = bytearray(init_param)
99+
100+
101+
102+
invalid_param = (
103+
0,4,0x2a,
104+
1,1,0xf0,
105+
1,1,0xf1,
106+
1,1,0xe0,
107+
1,1,0xe1,
108+
0,4,0x2b,
109+
1,1,0xf2,
110+
1,1,0xf3,
111+
1,1,0xe2,
112+
1,1,0xe3,
113+
0,0,0x2c,
114+
115+
)
116+
test_invalid = bytearray(invalid_param)
117+
118+
test3 = (
119+
0,0,0x28,
120+
2,0,120,
121+
0,0,0x10,
122+
)
123+
test_displayoff = bytearray(test3)
124+
125+
test4 = (
126+
0,0,0x11,
127+
2,0,20,
128+
0,0,0x29,
129+
)
130+
test_displayon = bytearray(test4)
131+
132+
133+
lcd.lcd_init(init_data, 240, 320, 52000, 1, 4, 0, test_invalid, test_displayon, test_displayoff, None)
134+
135+
LCD_SIZE_W = 240
136+
LCD_SIZE_H = 320
137+
138+
lv.init()
139+
140+
# Register SDL display driver.
141+
disp_buf1 = lv.disp_draw_buf_t()
142+
buf1_1 = bytearray(LCD_SIZE_W * LCD_SIZE_H * 2)
143+
disp_buf1.init(buf1_1, None, len(buf1_1))
144+
disp_drv = lv.disp_drv_t()
145+
disp_drv.init()
146+
disp_drv.draw_buf = disp_buf1
147+
disp_drv.flush_cb = lcd.lcd_write
148+
disp_drv.hor_res = LCD_SIZE_W
149+
disp_drv.ver_res = LCD_SIZE_H
150+
disp_drv.register()
151+
152+
lv.tick_inc(5)
153+
lv.task_handler()
154+
155+
# create a screen object
156+
screen = lv.obj()
157+
158+
# create a image object
159+
img1 = lv.img(screen)
160+
img1.set_pos(80, 80)
161+
img1.set_src("U:/quectel.jpg")
162+
163+
# create a label object
164+
label1 = lv.label(screen)
165+
label1.set_text("Hello Quecpython")
166+
label1.center()
167+
label1.set_pos(0, 80)
168+
169+
# load the screen
170+
lv.scr_load(screen)
171+
172+
173+
174+
175+
176+

lvgl/quectel.jpg

3.29 KB
Loading

0 commit comments

Comments
 (0)