LVGL is a free, lightweight open-source graphics library. It features a rich set of components and advanced graphical capabilities, supports various input devices and multiple languages, and is hardware-independent.The main difference in LVGL configuration lies in the choice of rendering backend, with options currently available for direct display via DRM and display via SDL. The RK3506 platform currently supports display via SDL.This article demonstrates using the Haptic Intelligence RK3506 Star Flash development board, paired with theRK3506 core board (3-core [email protected] + M0@200MHz heterogeneous multi-core)with a tax-inclusive price of 59 yuan, which is also the bulk price. Product video:
(Click the video to unlock the RK3506 core board in 1 minute, a highly cost-effective solution at 59 yuan)
Configuring LVGL
- Buildroot Configuration
Basic configuration save path:$sdk/buildroot/configs/rockchip_rk3506_defconfig
# Buildroot related configuration
#include "base/base.config"
#include "chips/rk3506_arm.config"
#include "fs/vfat.config"
#include "wifibt/bt.config"
#include "wifibt/wireless.config"
#include "multimedia/audio.config"
#include "wifibt/bt.config"
#include "wifibt/wireless.config"
#include "lvgl/lvgl_rkadk.config"
#include "lvgl/rk_demo.config"
#include "fs/ntfs.config"
...
- LVGL Configuration
Basic configuration save path:$sdk/buildroot/configs/rockchip/lvgl/v8
$ ls buildroot/configs/rockchip/lvgl/v8
base.config lvgl_drm.config lvgl_rkadk.config lvgl_sdl.config
LVGL DEMO
- Source Code Directory Structure
Source path:<SDK>/app/lvgl_demo/
$ tree -L 1.
├── amp_monitor
├── cJSON # cJSON source code
├── CMakeLists.txt
├── common
├── flexbus
├── gallery
├── lv_demo # Basic example program, runs the official DEMO
├── lvgl8 # Default uses lvgl8
├── lvgl9
├── motor_demo
├── rk_demo # RK display control DEMO, includes smart home, appliance display control, intercom, system settings, etc.
├── sys # Timestamp, trace debug, etc.
└── tools
- rk_demo Code Explanation
Source path:<SDK>/app/lvgl_demo/rk_demoThis serves primarily as an example program demonstrating how to run the official DEMO. The following explanation omits some unrelated code, focusing only on the code that needs attention.
static void lvgl_init(void){
/* The start of all LVGL applications */
lv_port_init();
...
check_scr();
}
...
int main(int argc, char **argv){
signal(SIGINT, sigterm_handler);
struct sched_param param;
int max_priority;
max_priority = sched_get_priority_max(SCHED_FIFO);
param.sched_priority = max_priority;
if (sched_setscheduler(0, SCHED_FIFO, &param) == -1)
{
perror("sched_setscheduler failed");
}
/* Initialize the corresponding DEMO based on configuration, draw the corresponding UI */
#if ROCKIT_EN
RK_MPI_SYS_Init();
#endif
#if WIFIBT_EN
run_wifibt_server();
#endif
lvgl_init();
app_init();
rk_demo_init();
while (!quit)
{
/* Call LVGL task processing function, all LVGL events, drawing, display, etc. are completed in this interface */
lv_task_handler();
usleep(100);
}
#if ROCKIT_EN
RK_MPI_SYS_Exit();
#endif
return 0;
}
Source Code Compilation Instructions
After modifying the source code, delete the previous lvgl_demo before recompiling:
$ rm -rf <SDK>/buildroot/output/rockchip_rk3506/build/lvgl_demo/ -rf
Recompile buildroot:
$ ./build.sh buildroot
DEMO Compilation Instructions
Haptic Intelligence RK3506 materials provide the lvgl demo in the cloud disk, below are the compilation methods and demo running methods.
- Unzip
Command as follows:
$ mkdir demo
$ unzip lvgl_demo.zip -d demo/
$ cd demo/lvgl_demo
- Modify and Compile
Modify the cross-compilation toolchain:
$ cat Makefile ## Makefile
##CC ?= gcc
CC = /home/rk3506/rk3506_linux-250211/rk3506_linux6.1/buildroot/output/rockchip_rk3506/host/bin/arm-buildroot-linux-gnueabihf-gcc
LVGL_DIR_NAME ?= lvgl
LVGL_DIR ?= ${shell pwd}
CFLAGS ?= -O3 -g0 -I$(LVGL_DIR)/ -Wall -Wshadow -Wundef -Wmissing-prototypes -Wno-discarded-qualifiers -Wno-unused-function -Wno-error=strict-prototypes -Wpointer-arith -fno-strict-aliasing -Wno-error=cpp -Wuninitialized -Wmaybe-uninitialized -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wno-cast-qual -Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wformat-security -Wno-ignored-qualifiers -Wno-error=pedantic -Wno-sign-compare -Wno-error=missing-prototypes -Wdouble-promotion -Wclobbered -Wdeprecated -Wempty-body -Wtype-limits -Wshift-negative-value -Wstack-usage=2048 -Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers -Wuninitialized -Wmaybe-uninitialized -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wpointer-arith -Wno-cast-qual -Wmissing-prototypes -Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wno-discarded-qualifiers -Wformat-security -Wno-ignored-qualifiers -Wno-sign-compare
LDFLAGS ?= -lm
BIN = demo
#Collect the files to compile
MAINSRC = ./main.c
include $(LVGL_DIR)/lvgl/lvgl.mk
include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
#CSRCS +=$(LVGL_DIR)/mouse_cursor_icon.c
OBJEXT ?= .o
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
OBJS = $(AOBJS) $(COBJS)
## MAINOBJ -> OBJFILES
all: default
%.o: %.c @$(CC) $(CFLAGS) -c $< -o $@ @echo "CC $<"
default: $(AOBJS) $(COBJS) $(MAINOBJ)
$(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
clean: rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ)
Modify the DEMO,as shown in the figure, set the resolution displayed in main.c to correspond with the screen resolution:Compile (Note: Change the path of the cross-compilation toolchain according to the actual situation.):
$ make
Finally, push the compiled demo to the development board via adb.
C:\Users\industio_mhk>adb push Z:\rk\rk3506\rk3506_linux-250211\rk3506_linux6.1\app\test\demo\lvgl_demo\demo /Z:\rk\rk3506\rk3506_linux-250211\rk3506_linux6.1\app\test\...ile pushed, 0 skipped. 24.4 MB/s (1127184 bytes in 0.044s)
root@rk3506-buildroot:/# chmod a+x /demo
root@rk3506-buildroot:/# /demo
END