preface
After sharing how to transplant lvgl, an open source gui library, to run on your own development board, I saw a message asking if you had transplanted the official demo routine. Today, I just have time to try to transplant the official demo. The following is the general process.
1, Preparatory work
Before transplanting the official demo, we need to ensure that the lvgl gui library has been transplanted to our development board and runs normally. You can directly refer to the previous articles here, and the links are as follows:
lvgl-7.11.0 for 4412 development board
Download the official LV from github_ demos:
lv_demos v7.11.0
Here I directly use the previously transplanted project:
Transplanted lvgl-v7 project
Let's start the migration of the official demo
2, Migration steps
1.lv_demos v7.11.0 decompression
Let's unzip the downloaded LV first_ Demos-7.11.0.zip, and then rename the extracted file lv_examples and move to the lvgl path.
View the contents of the extracted file as follows:
You can see the same lvgl core library and Lv_ Similar to the drivers library, there is also a LV in this folder_ ex_ conf_ Template. h file, copy this. h file
Lv of copy_ ex_ Change #if 0 in the conf.h file to #if 1, and then open the macro definition of a demo:
/*Music player for LVGL*/ #define LV_USE_DEMO_MUSIC 1 #if LV_USE_DEMO_MUSIC #define LV_DEMO_MUSIC_AUTO_PLAY 0 #endif
2. Compile lv_demos
Change the Makefile under the lvgl path:
CC := arm-none-linux-gnueabi-gcc RM := rm MV := mv MKDIR := mkdir CUR_PATH=$(shell pwd) LVGL_DIR = $(CUR_PATH) LVGL_DIR_NAME ?= lvgl include $(LVGL_DIR)/lvgl/lvgl.mk include $(LVGL_DIR)/lv_drivers/lv_drivers.mk include $(LVGL_DIR)/lv_examples/lv_examples.mk OBJDIR:=./__tmp__ OBJEXT ?= .o AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) SRC = $(ASRCS) $(CSRCS) OBJ = $(AOBJS) $(COBJS) CFLAGS:=-g -Wall -std=c99 -I$(LVGL_DIR)/lvgl -I$(LVGL_DIR)/lv_drivers -I$(LVGL_DIR)/lv_examples \ -DLV_CONF_INCLUDE_SIMPLE -DLV_LVGL_H_INCLUDE_SIMPLE -DLV_EX_CONF_INCLUDE_SIMPLE .PHONY: all .DEFAULT: all all: $(OBJ) $(MKDIR) $(OBJDIR) -p $(MV) $(OBJ) $(OBJDIR) clean: $(RM) $(OBJDIR) -rf
After the change, first try to make the file in the lvgl path, and send the following error message:
Prompt lv_font_montserrat_12 and v_font_montserrat_30 is undefined. Here we only need to use lvgl / LV_ Open the relevant macro definition in the conf.h file
/* Montserrat fonts with bpp = 4 * https://fonts.google.com/specimen/Montserrat */ #define LV_FONT_MONTSERRAT_8 0 #define LV_FONT_MONTSERRAT_10 0 #define LV_FONT_MONTSERRAT_12 0 #define LV_FONT_MONTSERRAT_14 1 #define LV_FONT_MONTSERRAT_16 0 #define LV_FONT_MONTSERRAT_18 0 #define LV_FONT_MONTSERRAT_20 0 #define LV_FONT_MONTSERRAT_22 0 #define LV_FONT_MONTSERRAT_24 0 #define LV_FONT_MONTSERRAT_26 0 #define LV_FONT_MONTSERRAT_28 0 #define LV_FONT_MONTSERRAT_30 0 #define LV_FONT_MONTSERRAT_32 0 #define LV_FONT_MONTSERRAT_34 0 #define LV_FONT_MONTSERRAT_36 0 #define LV_FONT_MONTSERRAT_38 0 #define LV_FONT_MONTSERRAT_40 0 #define LV_FONT_MONTSERRAT_42 0 #define LV_FONT_MONTSERRAT_44 0 #define LV_FONT_MONTSERRAT_46 0 #define LV_FONT_MONTSERRAT_48 0
After compiling, we can see about the lvgl library and lvgl_demos related intermediate files can be generated normally.
3. Call demo
main.c
#include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> #include <sys/time.h> #include <linux/fb.h> #include "lvgl.h" #include "lv_examples.h" #include "display/fbdev.h" #include "indev/evdev.h" int main(int argc, char *argv[]) { lv_init(); fbdev_init(); static lv_color_t buf[DISP_BUF_SIZE]; static lv_disp_buf_t disp_buf; /* fb init */ lv_disp_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE); lv_disp_drv_t disp_drv; lv_disp_drv_init(&disp_drv); disp_drv.buffer = &disp_buf; disp_drv.flush_cb = fbdev_flush; lv_disp_drv_register(&disp_drv); lv_demo_music(); while (1) { lv_task_handler(); usleep(5000); } }
Synchronize changes to Makefile:
SRCDIR:=. OBJDIR:=. TOP_PATH=$(shell pwd) CC:=arm-none-linux-gnueabi-gcc #STRIP:=strip RM := rm MV := mv CD := cd LVGL_DIR = $(TOP_PATH)/external/lvgl LVGL_DIR_NAME ?= lvgl include $(LVGL_DIR)/lvgl/lvgl.mk include $(LVGL_DIR)/lv_drivers/lv_drivers.mk include $(LVGL_DIR)/lv_examples/lv_examples.mk CFLAGS:=-w -O2 -O3 -g0 -std=c99 -I$(LVGL_DIR)/lvgl -I$(LVGL_DIR)/lv_drivers -I$(LVGL_DIR)/lv_examples \ -DPLAYER_DEBUG_VER -DLV_CONF_INCLUDE_SIMPLE -DLV_LVGL_H_INCLUDE_SIMPLE -DLV_EX_CONF_INCLUDE_SIMPLE .PHONY: all .DEFAULT: all LVGL_OBJDIR:=./external/lvgl/__tmp__ #LVGL_OBJS:=$(wildcard $(LVGL_OBJDIR)/*.o) OBJDIR:=./__tmp__ SRCS:=$(wildcard $(SRCDIR)/*.c) OBJS:=$(addprefix $(OBJDIR)/,$(patsubst %.c,%.o,$(SRCS))) PROGRAM:=player all: $(LVGL_OBJDIR) $(PROGRAM) $(LVGL_OBJDIR) : $(CD) $(LVGL_DIR) && make $(OBJS) : $(OBJDIR)/%.o : %.c @if [ ! -d $(dir $@) ] ; then mkdir -v -p $(dir $@) ; fi @echo compile: $< $(CC) $(CFLAGS) -c $< -o $@ $(PROGRAM): $(OBJS) $(LVGL_OBJDIR) $(CC) $(OBJS) $(wildcard $(LVGL_OBJDIR)/*.o) -o $(PROGRAM) -lpthread -static -lm $(MV) $(PROGRAM) $(OBJDIR) clean: $(RM) -rf $(LVGL_OBJDIR) $(RM) -rf $(OBJDIR)
Finally, no errors were found below make clean and make all
Copy the player execution program to the development board and run it
The operation results are as follows:
summary
The above is the transplant Lv_ The whole process of demos. If you want to run other routines, you only need to run it in Lv_ ex_ Open the corresponding macro definition in conf.h, which will not be repeated here.