Skip to content

Commit 1469299

Browse files
committed
feat(docs): support micropython
1 parent 4c1cdee commit 1469299

9 files changed

+261
-49
lines changed

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v2
1313
- uses: actions/setup-python@v2
14-
- uses: pre-commit/action@v2.0.3
14+
- uses: pre-commit/action@v3.0.1

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ChangeLog
22

3+
## v1.0.3 - 2025-04-27
4+
5+
### Enhancements:
6+
7+
* feat(docs): provides an example of how to integrate this library into micropython by @tsteinruecken (#190)
8+
39
## v1.0.2 - 2025-04-23
410

511
### Enhancements:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The functional block diagram is shown below:
4545
* [ESP-IDF](./docs/envs/use_with_idf.md)
4646
* [Arduino IDE](./docs/envs/use_with_arduino.md)
4747
* [PlatformIO](./examples/platformio/lvgl_v8_port/README.md)
48-
* [Micropython](./mpy_support/README.md)
48+
* [Micropython](./docs/envs/use_with_micropython.md)
4949

5050
## Supported Boards
5151

README_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ ESP32_Display_Panel 的主要特性如下:
4545
* [ESP-IDF](./docs/envs/use_with_idf_cn.md)
4646
* [Arduino IDE](./docs/envs/use_with_arduino_cn.md)
4747
* [PlatformIO](./examples/platformio/lvgl_v8_port/README.md)
48+
* [Micropython](./docs/envs/use_with_micropython_cn.md)
4849

4950
## 支持的开发板
5051

mpy_support/README.md renamed to docs/envs/use_with_micropython.md

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Using with micropython
22

3-
This is an example of how to integrate this library into micropython. It's written for an ESP32-S3, however
4-
it should be easy to adapt to different supported ESP-Chips. Please note, that you'll need at least 4mb of flash.
5-
3+
This is an example of how to integrate this library into micropython. It's written for an ESP32-S3, however it should be easy to adapt to different supported ESP-Chips. Please note, that you'll need at least 4mb of flash.
64

75
## Step-by-Step instructions
86

@@ -25,33 +23,36 @@ it should be easy to adapt to different supported ESP-Chips. Please note, that y
2523
```
2624

2725
2. Ensure, you can build a working firmware
28-
26+
2927
```bash
3028
make BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT -C ports/esp32
3129
pushd ports/esp32
3230
python -m esptool --port /dev/ttyACM0 --chip esp32s3 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 4MB --flash_freq 80m 0x0 build-ESP32_GENERIC_S3-SPIRAM_OCT/bootloader/bootloader.bin 0x8000 build-ESP32_GENERIC_S3-SPIRAM_OCT/partition_table/partition-table.bin 0x10000 build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin
3331
popd
34-
popd
32+
popd
3533
```
3634
Now, test the board and ensure your build of micropython works.
3735

3836
3. Download ESP32_Display_Panel and it's dependencies
37+
3938
```bash
4039
git clone https://github.com/esp-arduino-libs/ESP32_Display_Panel.git
4140
git clone https://github.com/esp-arduino-libs/esp-lib-utils.git
4241
git clone https://github.com/esp-arduino-libs/ESP32_IO_Expander.git
4342
```
44-
43+
4544
4. Create a custom user-module definition
45+
4646
```bash
4747
cat > micropython.cmake << EOF
4848
include(~/esp32build/ESP32_Display_Panel/micropython.cmake)
4949
include(~/esp32build/esp-lib-utils/micropython.cmake)
5050
include(~/esp32build/ESP32_IO_Expander/micropython.cmake)
5151
EOF
5252
```
53-
53+
5454
5. Copy some header-files
55+
5556
```bash
5657
cp esp-idf/components/esp_lcd/include/esp_lcd_panel_commands.h ESP32_Display_Panel/mpy_support/
5758
cp esp-idf/components/esp_lcd/interface/esp_lcd_panel_interface.h ESP32_Display_Panel/mpy_support/
@@ -64,40 +65,46 @@ it should be easy to adapt to different supported ESP-Chips. Please note, that y
6465
```
6566
6667
6. Rebuild micropython to include the new modules
68+
6769
```bash
6870
pushd micropython
69-
make BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT USER_C_MODULES=~/esp32build/micropython.cmake -C ports/esp32
71+
make BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT USER_C_MODULES=~/esp32build/micropython.cmake -C ports/esp32
7072
pushd ports/esp32
7173
python -m esptool --port /dev/ttyACM0 --chip esp32s3 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 4MB --flash_freq 80m 0x0 build-ESP32_GENERIC_S3-SPIRAM_OCT/bootloader/bootloader.bin 0x8000 build-ESP32_GENERIC_S3-SPIRAM_OCT/partition_table/partition-table.bin 0x10000 build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin
7274
popd
73-
popd
75+
popd
7476
```
75-
This may fail if your chip has a small flash size, in this case you have to increase the size of the
76-
application partition. E.g. for a 4mb flash chip edit micropython/ports/esp32/partitions-4MiB.csv and change the last
77-
two lines from:
7877
79-
```csv
80-
factory, app, factory, 0x10000, 0x1F0000,
81-
vfs, data, fat, 0x200000, 0x200000,
78+
This may fail if your chip has a small flash size, in this case you have to increase the size of the application partition. E.g. for a 4mb flash chip edit *micropython/ports/esp32/partitions-4MiB.csv* and change the last two lines from:
79+
80+
```csv
81+
factory, app, factory, 0x10000, 0x1F0000,
82+
vfs, data, fat, 0x200000, 0x200000,
8283
```
83-
to
84-
```csv
85-
factory, app, factory, 0x10000, 0x2F0000,
86-
vfs, data, fat, 0x300000, 0x100000,
84+
85+
to
86+
87+
```csv
88+
factory, app, factory, 0x10000, 0x2F0000,
89+
vfs, data, fat, 0x300000, 0x100000,
8790
```
8891
8992
7. Test the module
90-
Connect to your board and run:
93+
94+
Connect to your board and run:
95+
9196
```python
92-
from esp_panel import Board
93-
board = Board()
94-
board.init()
97+
from esp_panel import Board
98+
board = Board()
99+
board.init()
95100
```
96-
board.init() should return False, as we yet have to define a board.
101+
102+
`board.init()` should return False, as we yet have to define a board.
97103
98104
8. Define your Board
99-
Edit ESP32_Display_Panel/mpy_support/esp_panel_mp_board.cpp.
100-
Add a Board definition:
105+
106+
Edit *ESP32_Display_Panel/mpy_support/esp_panel_mp_board.cpp*. Add a Board definition:
107+
101108
```c++
102109
const BoardConfig BOARD_EXTERNAL_CONFIG = {
103110
/* General */
@@ -142,40 +149,45 @@ it should be easy to adapt to different supported ESP-Chips. Please note, that y
142149
},
143150
};
144151
```
145-
Then replace the constructor
146-
```c++
147-
self->board = utils::make_shared<Board>()
152+
153+
Then replace the constructor
154+
155+
```c++
156+
self->board = utils::make_shared<Board>()
148157
```
149-
with
150-
```c++
151-
self->board = utils::make_shared<Board>(BOARD_EXTERNAL_CONFIG);
158+
159+
with
160+
161+
```c++
162+
self->board = utils::make_shared<Board>(BOARD_EXTERNAL_CONFIG);
152163
```
164+
153165
9. Edit esp_panel_drivers_conf.h
154-
Edit ESP32_Display_Panel/esp_panel_drivers_conf.h and ensure, the drivers referenced in your board config are being
155-
build. Warning: ESP_PANEL_DRIVERS_BUS_USE_ALL does not seem to work. Set to 0 and manually include the bus driver
156-
you need. Same goes for ESP_PANEL_DRIVERS_BUS_COMPILE_UNUSED_DRIVERS.
157166
158-
10. Repeat Step 6 to rebuild micropython
167+
Edit *ESP32_Display_Panel/esp_panel_drivers_conf.h* and ensure, the drivers referenced in your board config are being
168+
build. **Warning**: `ESP_PANEL_DRIVERS_BUS_USE_ALL` does not seem to work. Set to 0 and manually include the bus driver
169+
you need. Same goes for `ESP_PANEL_DRIVERS_BUS_COMPILE_UNUSED_DRIVERS`.
170+
171+
10. Repeat **Step 6** to rebuild micropython
159172
160173
11. Test your display
174+
161175
Connect to your board and run:
176+
162177
```python
163178
from esp_panel import Board
164179
board = Board()
165180
board.init()
166181
board.begin()
167182
board.color_bar_test()
168183
```
169-
184+
170185
12. Profit! :)
171186
172-
To include touch support, see ESP32_Display_Panel/examples/arduino/board/board_dynamic_config/board_external_config.cpp
173-
for an example touch definition.
174-
187+
To include touch support, see *ESP32_Display_Panel/examples/arduino/board/board_dynamic_config/board_external_config.cpp* for an example touch definition.
175188
176189
## Known Pitfalls
177190
178-
1. When board.init() returns false, likely your driver-definition in esp_panel_drivers_conf.h does not match.
179-
2. board.begin() crashes, if you rely on ESP_PANEL_DRIVERS_BUS_USE_ALL
180-
3. If you edit ESP32_Display_Panel/esp_panel_drivers_conf.h, also modify ESP32_Display_Panel/mpy_support/esp_panel_mp_board.cpp
181-
(like add or remove an empty line). Otherwise, changes to esp_panel_drivers_conf.h will not be recognized.
191+
1. When `board.init()` returns false, likely your driver-definition in *esp_panel_drivers_conf.h* does not match.
192+
2. `board.begin()` crashes, if you rely on `ESP_PANEL_DRIVERS_BUS_USE_ALL`
193+
3. If you edit *ESP32_Display_Panel/esp_panel_drivers_conf.h*, also modify *ESP32_Display_Panel/mpy_support/esp_panel_mp_board.cpp* (like add or remove an empty line). Otherwise, changes to *esp_panel_drivers_conf.h* will not be recognized.

0 commit comments

Comments
 (0)