Skip to content

Commit e01e618

Browse files
committed
Merge branch 'main' of https://github.com/lvgl-micropython/lvgl_micropython into threading
# Conflicts: # builder/esp32.py # ext_mod/lcd_bus/esp32_src/rgb_bus.c
2 parents 74db177 + 50327e5 commit e01e618

File tree

14 files changed

+704
-629
lines changed

14 files changed

+704
-629
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ Compiling for ESP32
663663
* cmake
664664
* ninja-build
665665
* python
666+
* libusb-1.0-0-dev
666667

667668
* macOS
668669
* `xcode-select -–install`
@@ -1260,4 +1261,13 @@ Bit orders are a tuple of durations. The first 2 numbers define a bit as 0 and t
12601261
| WS2812B | 400 | -850 | 800 | -450 | -5000 | GRB |
12611262
| SK6813 | 240 | -800 | 740 | -200 | -800 | GRB |
12621263

1264+
<br>
1265+
1266+
# Projects made with this Binding...
1267+
1268+
-----------------------------------------------------------
1269+
1270+
https://github.com/fabse-hack/temp_humidity_micropython_lvgl
1271+
1272+
12631273

api_drivers/common_api_drivers/display/st7789/st7789.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from micropython import const # NOQA
22
import display_driver_framework
33
import lcd_bus
4+
import lvgl as lv
45

56

67
STATE_HIGH = display_driver_framework.STATE_HIGH

builder/__init__.py

Lines changed: 116 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import shutil
12
import sys
23
import os
34
import subprocess
@@ -8,6 +9,106 @@
89
_windows_env = None
910

1011

12+
def scrub_build_folder():
13+
for f in os.listdir('build'):
14+
f = os.path.join('build', f)
15+
for pattern in ('.h', 'manifest.py', '.board'):
16+
if f.endswith(pattern):
17+
os.remove(f)
18+
19+
20+
def revert_files(port):
21+
if port in ('macOS', 'raspberry_pi'):
22+
revert_files('unix')
23+
24+
src_path = f'micropy_updates/originals/{port}'
25+
26+
if port in ('raspberry_pi', 'macOS'):
27+
port = 'unix'
28+
29+
dst_path = f'lib/micropython/ports/{port}'
30+
31+
if not os.path.exists(src_path) or not os.listdir(src_path):
32+
return
33+
34+
def iter_path(src_p, dst_p):
35+
for file in os.listdir(src_p):
36+
src_file = os.path.join(src_p, file)
37+
dst_file = os.path.join(dst_p, file)
38+
39+
if os.path.isdir(src_file):
40+
iter_path(src_file, dst_file)
41+
os.rmdir(src_file)
42+
else:
43+
shutil.copyfile(src_file, dst_file)
44+
os.remove(src_file)
45+
46+
iter_path(src_path, dst_path)
47+
48+
49+
def copy_micropy_updates(port):
50+
51+
src_path = f'micropy_updates/{port}'
52+
org_path = f'micropy_updates/originals/{port}'
53+
54+
if port in ('raspberry_pi', 'macOS'):
55+
port = 'unix'
56+
57+
dst_path = f'lib/micropython/ports/{port}'
58+
59+
def iter_files(s_path, d_path, o_path):
60+
for file in os.listdir(s_path):
61+
src_file = os.path.join(s_path, file)
62+
dst_file = os.path.join(d_path, file)
63+
org_file = os.path.join(o_path, file)
64+
65+
if os.path.isdir(src_file):
66+
if not os.path.exists(org_file):
67+
os.makedirs(org_file)
68+
69+
iter_files(src_file, dst_file, org_file)
70+
else:
71+
shutil.copyfile(dst_file, org_file)
72+
shutil.copyfile(src_file, dst_file)
73+
74+
iter_files(src_path, dst_path, org_path)
75+
76+
77+
def write_file(file, data):
78+
with open(file, 'wb') as f:
79+
f.write(data.encode('utf-8'))
80+
81+
82+
def read_file(port, file):
83+
org_path = f'micropy_updates/originals/{port}'
84+
85+
filepath, filename = os.path.split(file)
86+
87+
if port in ('raspberry_pi', 'macOS'):
88+
port = 'unix'
89+
90+
head, tail = os.path.split(filepath)
91+
save_path = []
92+
while tail != port:
93+
save_path.insert(0, tail)
94+
head, tail = os.path.split(head)
95+
96+
if save_path:
97+
org_path = os.path.join(org_path, *save_path)
98+
99+
if not os.path.exists(org_path):
100+
os.makedirs(org_path)
101+
102+
org_file = os.path.join(org_path, filename)
103+
if not os.path.exists(org_file):
104+
shutil.copyfile(file, org_file)
105+
106+
with open(file, 'rb') as f:
107+
data = f.read()
108+
109+
return data.decode('utf-8')
110+
111+
11112
def setup_windows_build():
12113

13114
global _windows_env
@@ -63,13 +164,7 @@ def set_mp_version(port):
63164

64165

65166
def update_mphalport(target):
66-
if target == 'esp8266':
67-
mphalport_path = f'lib/micropython/ports/{target}/esp_mphal.h'
68-
elif target == 'pic16bit':
69-
mphalport_path = f'lib/micropython/ports/{target}/pic16bit_mphal.h'
70-
elif target == 'teensy':
71-
mphalport_path = f'lib/micropython/ports/{target}/teensy_hal.h'
72-
elif target == 'macOS':
167+
if target in ('macOS', 'raspberry_pi'):
73168
mphalport_path = f'lib/micropython/ports/unix/mphalport.h'
74169
elif target == 'windows':
75170
mphalport_path = f'lib/micropython/ports/{target}/windows_mphal.h'
@@ -79,18 +174,17 @@ def update_mphalport(target):
79174
if not os.path.exists(mphalport_path):
80175
raise RuntimeError(mphalport_path)
81176

82-
with open(mphalport_path, 'rb') as f:
83-
data = f.read().decode('utf-8')
177+
data = read_file(target, mphalport_path)
84178

85-
if '#ifndef _MPHALPORT_H_' not in data:
179+
if '__MPHALPORT_H__' not in data:
86180
data = (
87-
f'#ifndef _MPHALPORT_H_\n'
88-
f'#define _MPHALPORT_H_\n'
181+
f'#ifndef __MPHALPORT_H__\n'
182+
f'#define __MPHALPORT_H__\n'
89183
f'{data}\n'
90-
f'#endif /* _MPHALPORT_H_ */\n'
184+
f'#endif /* __MPHALPORT_H__ */\n'
91185
)
92-
with open(mphalport_path, 'wb') as f:
93-
f.write(data.encode('utf-8'))
186+
187+
write_file(mphalport_path, data)
94188

95189

96190
def generate_manifest(
@@ -157,7 +251,7 @@ def generate_manifest(
157251
for file in indevs:
158252
if not os.path.exists(file):
159253
tmp_file = (
160-
f'{script_dir}/api_drivers/common_api_drivers/indev/{file}.py'
254+
f'{script_dir}/api_drivers/common_api_drivers/indev/{file.lower()}.py'
161255
)
162256

163257
if not os.path.exists(tmp_file):
@@ -176,11 +270,11 @@ def generate_manifest(
176270
file = tmp_file
177271

178272
directory, file_name = os.path.split(file)
179-
extension_file = file_name.rsplit('.')[0] + '_extension.py'
273+
extension_file = file_name.rsplit('.', 1)[0] + '_extension.py'
180274
extension = os.path.join(directory, extension_file)
181275

182276
if os.path.exists(extension):
183-
print(extension_file)
277+
print(extension)
184278
entry = f"freeze('{directory}', '{extension_file}')"
185279
manifest_files.append(entry)
186280

@@ -194,7 +288,7 @@ def generate_manifest(
194288
for file in displays:
195289
if not os.path.exists(file):
196290
tmp_file = (
197-
f'{script_dir}/api_drivers/common_api_drivers/display/{file}'
291+
f'{script_dir}/api_drivers/common_api_drivers/display/{file.lower()}'
198292
)
199293

200294
if not os.path.exists(tmp_file):
@@ -205,7 +299,7 @@ def generate_manifest(
205299
if not file_name.endswith('.py'):
206300
continue
207301

208-
print(file_name)
302+
print(os.path.join(tmp_file, file_name))
209303

210304
entry = f"freeze('{tmp_file}', '{file_name}')"
211305
manifest_files.append(entry)
@@ -225,13 +319,7 @@ def generate_manifest(
225319

226320
def get_lvgl():
227321
cmd_ = [
228-
'git',
229-
'submodule',
230-
'update',
231-
'--init',
232-
'--depth=1',
233-
'--',
234-
f'lib/lvgl'
322+
'git submodule update --init --depth=1 -- lib/lvgl'
235323
]
236324
print()
237325
print('collecting LVGL')
@@ -244,13 +332,7 @@ def get_lvgl():
244332
def get_micropython():
245333

246334
cmd_ = [
247-
'git',
248-
'submodule',
249-
'update',
250-
'--init',
251-
'--depth=1',
252-
'--',
253-
f'lib/micropython'
335+
'git submodule update --init --depth=1 -- lib/micropython',
254336
]
255337
print()
256338
print('collecting MicroPython 1.23.0')

0 commit comments

Comments
 (0)