Preprocess lvgl.h on Makefile, and allow overriding macros with LV_CFLAGS. Build and register ESP32 driver and ESP32-ILI9341 driver in ESP32 Makefile. Update lv-bindings sub module. Updated README with make command line and ESP32 example.
This commit is contained in:
parent
9aded358b1
commit
8cf56e3e12
28
README.md
28
README.md
@ -15,8 +15,13 @@ Please set `ESPIDF` parameter for the esp-idf install dir.
|
|||||||
It needs to match Micropython expected esp-idf, otherwise a warning will be displayed (and build will probably fail)
|
It needs to match Micropython expected esp-idf, otherwise a warning will be displayed (and build will probably fail)
|
||||||
For more details refer to [Setting up the toolchain and ESP-IDF](https://github.com/littlevgl/lv_micropython/blob/master/ports/esp32/README.md#setting-up-the-toolchain-and-esp-idf)
|
For more details refer to [Setting up the toolchain and ESP-IDF](https://github.com/littlevgl/lv_micropython/blob/master/ports/esp32/README.md#setting-up-the-toolchain-and-esp-idf)
|
||||||
|
|
||||||
For example:
|
When using IL9341 driver, the width height and color need to be set to match ILI9341. This can be done from the command line.
|
||||||
`make -C ports/esp32/ ESPIDF=~/esp/projects/lv_mpy_deps/esp-idf`
|
Here is the command to build ESP32 + LittlevGL which is compatible with ILI9341 driver:
|
||||||
|
|
||||||
|
`make -C ports/esp32/ ESPIDF=~/esp/projects/lv_mpy_deps/esp-idf -j4 LV_CFLAGS="-DLV_HOR_RES=240 -DLV_VER_RES=320 -DLV_COLOR_DEPTH=16" deploy`
|
||||||
|
|
||||||
|
This make command will create ESP32 port of Micropython, and will try to deploy it through USB-UART bridge.
|
||||||
|
`LV_CFLAGS` are used to override width height and color, for ILI9341 compatibility.
|
||||||
|
|
||||||
## Super Simple Example
|
## Super Simple Example
|
||||||
|
|
||||||
@ -52,6 +57,25 @@ indev_drv.read = SDL.mouse_read;
|
|||||||
lv.indev_drv_register(indev_drv);
|
lv.indev_drv_register(indev_drv);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Here is an alternative example, for registering ILI9341 drivers on Micropython ESP32 port:
|
||||||
|
|
||||||
|
```python
|
||||||
|
# Import ESP32 driver (advnaces tick count and schedules tasks)
|
||||||
|
|
||||||
|
import lvesp32
|
||||||
|
|
||||||
|
# Import ILI9341, initialize it and register it to LittlevGL
|
||||||
|
|
||||||
|
import ILI9341 as ili
|
||||||
|
d = ili.display(miso=5, mosi=18, clk=19, cs=13, dc=12, rst=4, backlight=2)
|
||||||
|
d.init()
|
||||||
|
disp_drv = lv.disp_drv_t()
|
||||||
|
lv.disp_drv_init(disp_drv)
|
||||||
|
disp_drv.disp_flush = d.flush
|
||||||
|
disp_drv.disp_fill = d.fill
|
||||||
|
lv.disp_drv_register(disp_drv)
|
||||||
|
```
|
||||||
|
|
||||||
Now you can create the GUI itself
|
Now you can create the GUI itself
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit c60795596686072f0b28e794af6b1685115cbf86
|
Subproject commit a62689186c2e67fa145601565ff13af328310641
|
||||||
@ -39,8 +39,13 @@
|
|||||||
*===================*/
|
*===================*/
|
||||||
|
|
||||||
/* Horizontal and vertical resolution of the library.*/
|
/* Horizontal and vertical resolution of the library.*/
|
||||||
|
#ifndef LV_HOR_RES
|
||||||
#define LV_HOR_RES (440)
|
#define LV_HOR_RES (440)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LV_VER_RES
|
||||||
#define LV_VER_RES (340)
|
#define LV_VER_RES (340)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide
|
/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide
|
||||||
* (Not so important, you can adjust it to modify default sizes and spaces)*/
|
* (Not so important, you can adjust it to modify default sizes and spaces)*/
|
||||||
@ -108,7 +113,10 @@
|
|||||||
#define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
|
#define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
|
||||||
|
|
||||||
/*Color settings*/
|
/*Color settings*/
|
||||||
|
#ifndef LV_COLOR_DEPTH
|
||||||
#define LV_COLOR_DEPTH 32 /*Color depth: 1/8/16/32*/
|
#define LV_COLOR_DEPTH 32 /*Color depth: 1/8/16/32*/
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/
|
#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/
|
||||||
#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/
|
#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/
|
||||||
#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/
|
#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/
|
||||||
|
|||||||
@ -197,6 +197,12 @@ LIB_SRC_C += \
|
|||||||
lib/oofatfs/option/unicode.c
|
lib/oofatfs/option/unicode.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(MICROPY_PY_LVGL), 1)
|
||||||
|
LIB_SRC_C += \
|
||||||
|
lib/lv_bindings/driver/esp32/modlvesp32.c \
|
||||||
|
lib/lv_bindings/driver/esp32/modILI9341.c
|
||||||
|
endif
|
||||||
|
|
||||||
DRIVERS_SRC_C = $(addprefix drivers/,\
|
DRIVERS_SRC_C = $(addprefix drivers/,\
|
||||||
bus/softspi.c \
|
bus/softspi.c \
|
||||||
dht/dht.c \
|
dht/dht.c \
|
||||||
|
|||||||
@ -180,6 +180,8 @@ extern const struct _mp_obj_module_t mp_module_machine;
|
|||||||
extern const struct _mp_obj_module_t mp_module_network;
|
extern const struct _mp_obj_module_t mp_module_network;
|
||||||
extern const struct _mp_obj_module_t mp_module_onewire;
|
extern const struct _mp_obj_module_t mp_module_onewire;
|
||||||
extern const struct _mp_obj_module_t mp_module_lvgl;
|
extern const struct _mp_obj_module_t mp_module_lvgl;
|
||||||
|
extern const struct _mp_obj_module_t mp_module_lvesp32;
|
||||||
|
extern const struct _mp_obj_module_t mp_module_ILI9341;
|
||||||
|
|
||||||
#define MICROPY_PORT_BUILTIN_MODULES \
|
#define MICROPY_PORT_BUILTIN_MODULES \
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_esp), (mp_obj_t)&esp_module }, \
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_esp), (mp_obj_t)&esp_module }, \
|
||||||
@ -210,6 +212,8 @@ extern const struct _mp_obj_module_t mp_module_lvgl;
|
|||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&utime_module }, \
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&utime_module }, \
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_zlib), (mp_obj_t)&mp_module_uzlib }, \
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_zlib), (mp_obj_t)&mp_module_uzlib }, \
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_lvgl), (mp_obj_t)&mp_module_lvgl }, \
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_lvgl), (mp_obj_t)&mp_module_lvgl }, \
|
||||||
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_lvesp32), (mp_obj_t)&mp_module_lvesp32 }, \
|
||||||
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_ILI9341), (mp_obj_t)&mp_module_ILI9341 }, \
|
||||||
|
|
||||||
#define MP_STATE_PORT MP_STATE_VM
|
#define MP_STATE_PORT MP_STATE_VM
|
||||||
|
|
||||||
|
|||||||
5
py/py.mk
5
py/py.mk
@ -124,13 +124,16 @@ LVGL_BINDING_DIR = $(TOP)/lib/lv_bindings
|
|||||||
LVGL_DIR = $(LVGL_BINDING_DIR)/lvgl
|
LVGL_DIR = $(LVGL_BINDING_DIR)/lvgl
|
||||||
INC += -I$(LVGL_DIR) -I$(LVGL_BINDING_DIR)/include
|
INC += -I$(LVGL_DIR) -I$(LVGL_BINDING_DIR)/include
|
||||||
ALL_LVGL_SRC = $(shell find $(LVGL_DIR) -type f) $(TOP)/lib/lv_conf.h
|
ALL_LVGL_SRC = $(shell find $(LVGL_DIR) -type f) $(TOP)/lib/lv_conf.h
|
||||||
|
LVGL_PP = $(BUILD)/lvgl/lvgl.pp.c
|
||||||
LVGL_MPY = $(BUILD)/lvgl/lv_mpy.c
|
LVGL_MPY = $(BUILD)/lvgl/lv_mpy.c
|
||||||
QSTR_GLOBAL_DEPENDENCIES += $(LVGL_MPY)
|
QSTR_GLOBAL_DEPENDENCIES += $(LVGL_MPY)
|
||||||
|
CFLAGS_MOD += $(LV_CFLAGS)
|
||||||
|
|
||||||
$(LVGL_MPY): $(ALL_LVGL_SRC) $(LVGL_BINDING_DIR)/gen/gen_mpy.py
|
$(LVGL_MPY): $(ALL_LVGL_SRC) $(LVGL_BINDING_DIR)/gen/gen_mpy.py
|
||||||
$(ECHO) "LVGL-GEN $@"
|
$(ECHO) "LVGL-GEN $@"
|
||||||
$(Q)mkdir -p $(dir $@)
|
$(Q)mkdir -p $(dir $@)
|
||||||
$(Q)$(PYTHON) $(LVGL_BINDING_DIR)/gen/gen_mpy.py -X anim -X group -X task $(INC) -I $(LVGL_BINDING_DIR)/pycparser/utils/fake_libc_include $(LVGL_DIR)/lvgl.h > $@
|
$(Q)$(CPP) $(LV_CFLAGS) $(INC) -I $(LVGL_BINDING_DIR)/pycparser/utils/fake_libc_include $(LVGL_DIR)/lvgl.h > $(LVGL_PP)
|
||||||
|
$(Q)$(PYTHON) $(LVGL_BINDING_DIR)/gen/gen_mpy.py -X anim -X group -X task -E $(LVGL_PP) $(LVGL_DIR)/lvgl.h > $@
|
||||||
|
|
||||||
CFLAGS_MOD += -Wno-unused-function
|
CFLAGS_MOD += -Wno-unused-function
|
||||||
SRC_MOD += $(subst $(TOP)/,,$(shell find $(LVGL_DIR) -type f -name "*.c") $(LVGL_MPY))
|
SRC_MOD += $(subst $(TOP)/,,$(shell find $(LVGL_DIR) -type f -name "*.c") $(LVGL_MPY))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user