Skip to content

Commit 7eb31fc

Browse files
authored
RPi Pico port (#42)
based on work of @jgpeiro https://forum.lvgl.io/t/build-lvgl-for-raspberry-pi-pico/5543 . * add brief documentation on building the port Related PR: lvgl/lv_binding_micropython#174
1 parent e71a972 commit 7eb31fc

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ For more details please refer to [Micropython ESP32 README](https://github.com/m
5858

5959
Refer to the README of the `lvgl_javascript` branch: https://github.com/lvgl/lv_micropython/tree/lvgl_javascript#for-javascript-port
6060

61+
### For Raspberry Pi Pico port
62+
63+
This port uses [Micropython infrastructure for C modules](https://docs.micropython.org/en/latest/develop/cmodules.html#compiling-the-cmodule-into-micropython) and `USER_C_MODULES` must be given:
64+
65+
```
66+
cd ports/rp2
67+
make USER_C_MODULES=../../lv_bindings/bindings.cmake
68+
```
69+
6170
## Super Simple Example
6271

6372
First, LVGL needs to be imported and initialized

ports/rp2/mpconfigport.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333

3434
#include "mpconfigboard.h"
3535

36+
#define MICROPY_PY_LVGL (1)
37+
#define MICROPY_PY_LODEPNG (1)
38+
3639
// Board and hardware specific configuration
3740
#define MICROPY_HW_MCU_NAME "RP2040"
3841
#define MICROPY_HW_ENABLE_UART_REPL (0) // useful if there is no USB
@@ -162,15 +165,47 @@ extern const struct _mp_obj_module_t mp_module_onewire;
162165
extern const struct _mp_obj_module_t mp_module_rp2;
163166
extern const struct _mp_obj_module_t mp_module_uos;
164167
extern const struct _mp_obj_module_t mp_module_utime;
168+
extern const struct _mp_obj_module_t mp_module_lvgl;
169+
extern const struct _mp_obj_module_t mp_module_lodepng;
170+
171+
#if MICROPY_PY_LVGL
172+
#define MICROPY_PORT_LVGL_DEF \
173+
{ MP_OBJ_NEW_QSTR(MP_QSTR_lvgl), (mp_obj_t)&mp_module_lvgl },
174+
175+
#else
176+
#define MICROPY_PORT_LVGL_DEF
177+
#endif
178+
179+
#if MICROPY_PY_LODEPNG
180+
#define MICROPY_PORT_LODEPNG_DEF { MP_OBJ_NEW_QSTR(MP_QSTR_lodepng), (mp_obj_t)&mp_module_lodepng },
181+
#else
182+
#define MICROPY_PORT_LODEPNG_DEF
183+
#endif
165184

166185
#define MICROPY_PORT_BUILTIN_MODULES \
167186
{ MP_OBJ_NEW_QSTR(MP_QSTR_machine), (mp_obj_t)&mp_module_machine }, \
168187
{ MP_OBJ_NEW_QSTR(MP_QSTR__onewire), (mp_obj_t)&mp_module_onewire }, \
169188
{ MP_OBJ_NEW_QSTR(MP_QSTR__rp2), (mp_obj_t)&mp_module_rp2 }, \
170189
{ MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_uos) }, \
171190
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) }, \
191+
MICROPY_PORT_LVGL_DEF \
192+
MICROPY_PORT_LODEPNG_DEF \
193+
194+
#if MICROPY_PY_LVGL
195+
#ifndef MICROPY_INCLUDED_PY_MPSTATE_H
196+
#define MICROPY_INCLUDED_PY_MPSTATE_H
197+
#include "lib/lv_bindings/lvgl/src/misc/lv_gc.h"
198+
#undef MICROPY_INCLUDED_PY_MPSTATE_H
199+
#else
200+
#include "lib/lv_bindings/lvgl/src/misc/lv_gc.h"
201+
#endif
202+
#else
203+
#define LV_ROOTS
204+
#endif
172205

173206
#define MICROPY_PORT_ROOT_POINTERS \
207+
LV_ROOTS \
208+
void *mp_lv_user_data; \
174209
const char *readline_hist[8]; \
175210
void *machine_pin_irq_obj[30]; \
176211
void *rp2_pio_irq_obj[2]; \

0 commit comments

Comments
 (0)