Description
Im new to LVGL and Im currently trying to set it up. I want to develop an application for my RPI4 which should run on a linux framebuffer. Im currently using CLion with an SSH Remote Project to develop the project.
Im currently trying to create a simple HelloWorld program but Im failing at including the framebuffer driver correctly. All its functions (e.g. ‘fbdev_init()’, ‘lv_linux_fbdev_set_file’…) are marked as undeclared even tho I included ‘fbdev.h’ and CMake does not output any errors.
What MCU/Processor/Board and compiler are you using?
My source code is on my host machine (Windows 10) and CLion syncs it with my RaspberryPi 4. It executes CMake and compiles on the RPI.
What do you want to achieve?
I want to start working with LVGL and Im trying to create a simple HelloWorld project which is displayed on a linux framebuffer (which is displayed on a GC9A01 connected via SPI).
What have you tried so far?
I tried manually cloning and including lvgl and lv-drivers, fetching it with CMake and other kinds of inclusions I found online. I set #define LV_USE_LINUX_FBDEV 1
in the lv_conf.h
Code to reproduce
My CMakeLists.txt
cmake_minimum_required(VERSION 3.25)
include(FetchContent)
project(LVGL-Display-C LANGUAGES C CXX)
set(CMAKE_C_STANDARD 99)
# Build an executable called "LVGL-Display-C"
add_executable(LVGL-Display-C src/main.c)
# Specify path to own LVGL config header
set(LV_CONF_PATH
${CMAKE_CURRENT_SOURCE_DIR}/src/lv_conf.h
CACHE STRING "" FORCE)
# Fetch LVGL from GitHub
FetchContent_Declare(lvgl GIT_REPOSITORY https://github.com/lvgl/lvgl.git)
FetchContent_MakeAvailable(lvgl)
# Fetch LVGL drivers from GitHub
FetchContent_Declare(lv_drivers GIT_REPOSITORY https://github.com/lvgl/lv_drivers)
FetchContent_MakeAvailable(lv_drivers)
# Include directories
target_include_directories(LVGL-Display-C PRIVATE
${lvgl_SOURCE_DIR}
${lv_drivers_SOURCE_DIR}
${lv_drivers_SOURCE_DIR}/display
)
# The target "LVGL-Display-C" depends on LVGL
target_link_libraries(LVGL-Display-C PRIVATE lvgl::lvgl lvgl::drivers)
# Add definitions
target_compile_definitions(LVGL-Display-C PRIVATE LV_CONF_INCLUDE_SIMPLE=1)
My main.c
// lib includes
#include "lvgl.h"
#include "display/fbdev.h"
int main(void)
{
// Init LVGL
lv_init();
// Create display
lv_display_t *disp = lv_linux_fbdev_create();
lv_linux_fbdev_set_file(disp, "/dev/fb0");
return 0;
}
The “Create display” lines are copied from the wiki.
Screenshot and/or video
Here is a screenshot of the error Im getting. IntelliSense doesnt even suggest the fbdev functions so it doesnt find them at all…