Skip to content

Commit 4fae3e1

Browse files
authored
Update readme files (lvgl#90)
* Update readme files and fix ESP-IDF path in scripts folder * Update LVGL readme file
1 parent e3d9310 commit 4fae3e1

File tree

3 files changed

+65
-20
lines changed

3 files changed

+65
-20
lines changed

README-LVGL.md

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,58 +19,87 @@ Original micropython README: https://github.com/micropython/micropython/blob/mas
1919
## Relationship between `lv_micropython` and `lv_binding_micropython`
2020

2121
Originally, `lv_micropython` was created as an example of how to use [lv_binding_micropython](https://github.com/lvgl/lv_binding_micropython) on a Micropython fork.
22-
As such, we try to keep changes here as minimal as possible and we try to keep it in sync with Micropython upstream releases. We also try to add changes to `lv_binding_micropython` instead of to `lv_micropython`, when possible. (for example we keep all drivers in `lv_binding_micropython`, the ESP32 CMake functionality etc.)
22+
23+
As such, we try to keep changes here as minimal as possible and we try to keep it in sync with Micropython upstream releases. We also try to add changes to `lv_binding_micropython` instead of to `lv_micropython`, when possible. (for example we keep all drivers in `lv_binding_micropython`, etc.)
2324

2425
Eventually it turned out that many people prefer using `lv_micropython` directly and only a few use it as a reference to support LVGL on their own Micropython fork.
26+
2527
If you are only starting with Micropython+LVGL, it's recommended that you use `lv_micropython`, while porting a Micropython fork to LVGL is for advanced users.
2628

29+
Actual `lv_micropython` repo is using [LVGL binding](https://github.com/lvgl/lv_binding_micropython) as MicroPython C module.
30+
31+
More details: https://docs.micropython.org/en/latest/develop/cmodules.html
32+
2733
## Build Instructions
2834

29-
First step is always to clone lv_micropython and update its submodules recursively:
35+
First step is always to clone `lv_micropython` and update its submodules recursively:
3036

3137
```
3238
git clone https://github.com/lvgl/lv_micropython.git
3339
cd lv_micropython
34-
git submodule update --init --recursive lib/lv_bindings
40+
git submodule update --init --recursive user_modules/lv_binding_micropython
3541
```
3642

37-
Next you should build mpy-cross
43+
Next step is to build the port you want to use.
3844

39-
```
40-
make -C mpy-cross
41-
```
45+
Some basic build and deploy scripts are added to `scripts` folder, to easily build and deploy firmware to your device (or use unix port).
4246

43-
Port specific steps usually include updating the port's submodules with `make submodules` and running make for the port itself.
47+
You can of course build firmwares manually with `make` commands, if build script is missing for the port or you want to override some build parameters.
4448

4549
### Unix (Linux) port
4650

51+
Using build script:
52+
53+
```
54+
cd scripts
55+
./build-unix.sh
56+
cd ..
57+
./ports/unix/build-lvgl/micropython
58+
```
59+
60+
Manual build:
61+
4762
1. `sudo apt-get install build-essential libreadline-dev libffi-dev git pkg-config libsdl2-2.0-0 libsdl2-dev python3.8 parallel`
4863
Python 3 is required, but you can install some other version of python3 instead of 3.8, if needed.
4964
2. `git clone https://github.com/lvgl/lv_micropython.git`
5065
3. `cd lv_micropython`
51-
4. `git submodule update --init --recursive lib/lv_bindings`
66+
4. `git submodule update --init --recursive user_modules/lv_binding_micropython`
5267
5. `make -C mpy-cross`
5368
6. `make -C ports/unix submodules`
5469
7. `make -C ports/unix`
55-
8. `./ports/unix/micropython`
70+
8. `./ports/unix/build-lvgl/micropython`
5671

5772
## Unix (MAC OS) port
5873

5974
1. `brew install sdl2 pkg-config`
6075
2. `git clone https://github.com/lvgl/lv_micropython.git`
6176
3. `cd lv_micropython`
62-
4. `git submodule update --init --recursive lib/lv_bindings`
77+
4. `git submodule update --init --recursive user_modules/lv_binding_micropython`
6378
5. `sudo mkdir -p /usr/local/lib/`
6479
6. `sudo cp /opt/homebrew/Cellar/sdl2/2.24.0/lib/libSDL2.dylib /usr/local/lib/`
6580
7. `sudo cp -r /opt/homebrew/Cellar/sdl2/2.24.0/include /usr/local/`
6681
8. `sed -i '' 's/ -Werror//' ports/unix/Makefile mpy-cross/Makefile` Remove -Werror from compiler parameters as Mac fails compilation otherwise
6782
9. `make -C mpy-cross`
6883
10. `make -C ports/unix submodules`
6984
11. `make -C ports/unix`
70-
12. `./ports/unix/build-standard/micropython`
85+
12. `./ports/unix/build-lvgl/micropython`
7186

7287
### ESP32 port
7388

89+
Install ESP-IDF v5.x: https://docs.espressif.com/projects/esp-idf/en/v5.2.3/esp32/get-started/index.html#manual-installation
90+
91+
(you can configure ESP-IDF path in [scripts/env-variables-esp32.sh](./scripts/env-variables-esp32.sh) file)
92+
93+
Build and deploy with scripts:
94+
95+
```
96+
cd scripts
97+
./build-esp32.sh
98+
./deploy-esp32.sh
99+
```
100+
101+
Manual build:
102+
74103
Please run `esp-idf/export.sh` from your ESP-IDF installation directory as explained in the [Micropython ESP32 Getting Started documentation](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/#get-started-export)
75104
ESP-IDF version needs to match Micropython expected esp-idf, otherwise a warning will be displayed (and build will probably fail)
76105
For more details refer to [Setting up the toolchain and ESP-IDF](https://github.com/lvgl/lv_micropython/blob/master/ports/esp32/README.md#setting-up-the-toolchain-and-esp-idf)
@@ -80,7 +109,7 @@ Here is the command to build ESP32 + LVGL which is compatible with ILI9341 drive
80109

81110
```
82111
make -C mpy-cross
83-
make -C ports/esp32 LV_CFLAGS="-DLV_COLOR_DEPTH=16" BOARD=GENERIC_SPIRAM deploy
112+
make -C ports/esp32 LV_CFLAGS="-DLV_COLOR_DEPTH=16" BOARD=ESP32_GENERIC VARIANT=SPIRAM deploy
84113
```
85114

86115
Explanation about the parameters:
@@ -101,10 +130,10 @@ This port uses [Micropython infrastructure for C modules](https://docs.micropyth
101130

102131
1. `git clone https://github.com/lvgl/lv_micropython.git`
103132
2. `cd lv_micropython`
104-
3. `git submodule update --init --recursive lib/lv_bindings`
133+
3. `git submodule update --init --recursive user_modules/lv_binding_micropython`
105134
4. `make -C ports/rp2 BOARD=PICO submodules`
106135
5. `make -j -C mpy-cross`
107-
6. `make -j -C ports/rp2 BOARD=PICO USER_C_MODULES=../../lib/lv_bindings/bindings.cmake`
136+
6. `make -j -C ports/rp2 BOARD=PICO USER_C_MODULES=../../user_modules/lv_binding_micropython/bindings.cmake`
108137

109138
#### Troubleshooting
110139

@@ -133,9 +162,19 @@ HEIGHT = 320
133162

134163
event_loop = event_loop()
135164
disp_drv = lv.sdl_window_create(WIDTH, HEIGHT)
165+
disp_drv.set_default()
166+
display = lv.display_get_default()
167+
168+
group = lv.group_create()
169+
group.set_default()
170+
136171
mouse = lv.sdl_mouse_create()
172+
mouse.set_display(display)
173+
mouse.set_group(group)
174+
137175
keyboard = lv.sdl_keyboard_create()
138-
keyboard.set_group(self.group)
176+
keyboard.set_display(display)
177+
keyboard.set_group(group)
139178
```
140179

141180
Here is an alternative example, for registering ILI9341 drivers on Micropython ESP32 port:
@@ -169,14 +208,14 @@ Now you can create the GUI itself:
169208
# Create a screen with a button and a label
170209

171210
scr = lv.obj()
172-
btn = lv.btn(scr)
211+
btn = lv.button(scr)
173212
btn.align_to(lv.scr_act(), lv.ALIGN.CENTER, 0, 0)
174213
label = lv.label(btn)
175214
label.set_text("Hello World!")
176215

177216
# Load the screen
178217

179-
lv.scr_load(scr)
218+
lv.screen_load(scr)
180219

181220
```
182221

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
[MicroPython-LVGL project](README-LVGL.md)
1+
# Micropython + LVGL
2+
3+
**Micropython bindings to LVGL for Embedded devices, Unix and JavaScript**
4+
5+
More information about MicroPython-LVGL binding and how to build it, see: [README-LVGL.md](README-LVGL.md)
6+
7+
---
28

39
The MicroPython project
410
=======================

scripts/env-variables-esp32.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
# Set environment variables for ESP32 development
44

5-
ESPIDF=~/esp/esp-idf-5-2-3
5+
ESPIDF=~/esp/esp-idf
66
source $ESPIDF/export.sh
77

0 commit comments

Comments
 (0)