From c5fc48a2b013e1959e61b12b97cb2c7a6332364d Mon Sep 17 00:00:00 2001 From: MootSeeker Date: Wed, 18 Sep 2024 08:47:44 +0200 Subject: [PATCH] Disable RTOS Compilation with Cmake (#64) * Add FreeRTOS * Add FreeRTOS Task * Update README.md * Upgrade to C++ * Update Code to run multiple tasks * Add ui folder Add UI folder for SquareLine Studio files * Update ui.cpp * Add UI files to CMake from SquareLine Studio Add UI files to CMake path. UI folder setup so files from SquareLine Studio can be used. Add more heap to debug SDL. * Update README.md * Add drop den menu test * Add global include file * remove cpp file to test stability * Fixing wrong cmake configuration remove ui files from here * work * Change project structure Changed project structure and CMake file so freertos implementation will be activated when enabled in lv_conf.h * Refactor project structure and CMake configuration, remove unused UI components - Restructured the project and updated the CMake file to conditionally activate FreeRTOS based on lv_conf.h settings. - Removed UI files and C++ files related to SquareLine Studio to improve project stability. - Added a global include. - Updated the README.md to reflect the changes. - Increased heap size for debugging with SDL. * Move to CPP file Moved to cpp file created task with lv_thread_init() * Update freertos_main.cpp * Clean up code Not using task notification, since pxTCD is always NULL Changed back to LV_OS_NONE since user of this project has to device what he want to use Commented freertos posix file with AI :) Cleanup freertos_main.cpp as mentioned in PR * Update README.md Co-authored-by: Gabor Kiss-Vamosi * Update README.md * Update main/src/FreeRTOS_Posix_Port.c Co-authored-by: Gabor Kiss-Vamosi * Update main/src/main.c Co-authored-by: Gabor Kiss-Vamosi * Update README.md Co-authored-by: Gabor Kiss-Vamosi * Update README.md * Update README.md * Update CMakeLists.txt Update so FreeRTOS will not compile if not used * Update CMakeLists.txt * Update README.md --------- Co-authored-by: Gabor Kiss-Vamosi --- CMakeLists.txt | 47 ++++++++++++++++++++++++++++------------------- README.md | 3 ++- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f440664..337bbaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,33 +4,33 @@ project(lvgl C CXX) # Set the correct FreeRTOS port for your system (e.g., Posix for WSL) set(FREERTOS_PORT GCC_POSIX CACHE STRING "Port for FreeRTOS on Posix environment") -# Check if the FreeRTOS directory exists -if(EXISTS "${PROJECT_SOURCE_DIR}/FreeRTOS") - message(STATUS "FreeRTOS found, integrating into the build") +option(USE_FREERTOS "Enable FreeRTOS" OFF) # Turn this on to enable FreeRTOS - # Add FreeRTOS configuration as an interface library +if(USE_FREERTOS) + message(STATUS "FreeRTOS is enabled") + + # FreeRTOS integration when USE_FREERTOS is enabled add_library(freertos_config INTERFACE) target_include_directories(freertos_config SYSTEM INTERFACE ${PROJECT_SOURCE_DIR}/config) target_compile_definitions(freertos_config INTERFACE projCOVERAGE_TEST=0) - add_definitions(-DFREERTOS_PORT=${FREERTOS_PORT}) # Add FreeRTOS as a subdirectory add_subdirectory(FreeRTOS) - # Include directories for FreeRTOS headers + # FreeRTOS-specific include directories include_directories(${PROJECT_SOURCE_DIR}/FreeRTOS/include) include_directories(${PROJECT_SOURCE_DIR}/FreeRTOS/portable/ThirdParty/GCC/Posix) include_directories(${PROJECT_SOURCE_DIR}/config) - # Add FreeRTOS source files + # Add FreeRTOS sources file(GLOB FREERTOS_SOURCES "${PROJECT_SOURCE_DIR}/FreeRTOS/*.c" "${PROJECT_SOURCE_DIR}/FreeRTOS/portable/MemMang/heap_4.c" "${PROJECT_SOURCE_DIR}/FreeRTOS/portable/ThirdParty/GCC/Posix/*.c" ) else() - message(STATUS "FreeRTOS not found, skipping FreeRTOS integration") - set(FREERTOS_SOURCES "") + message(STATUS "FreeRTOS is disabled") + set(FREERTOS_SOURCES "") # No FreeRTOS sources if FreeRTOS is disabled endif() # Main include files of the project @@ -69,21 +69,30 @@ add_compile_definitions($<$:LV_USE_FFMPEG=1>) add_subdirectory(lvgl) target_include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR} ${SDL2_INCLUDE_DIRS}) -# Create the main executable and add source files -add_executable(main - ${PROJECT_SOURCE_DIR}/main/src/main.c - ${PROJECT_SOURCE_DIR}/main/src/freertos_main.cpp - ${PROJECT_SOURCE_DIR}/main/src/mouse_cursor_icon.c - ${PROJECT_SOURCE_DIR}/main/src/FreeRTOS_Posix_Port.c - ${FREERTOS_SOURCES} -) +# Create the main executable, depending on the FreeRTOS option +if(USE_FREERTOS) + add_executable(main + ${PROJECT_SOURCE_DIR}/main/src/main.c + ${PROJECT_SOURCE_DIR}/main/src/freertos_main.cpp + ${PROJECT_SOURCE_DIR}/main/src/mouse_cursor_icon.c + ${PROJECT_SOURCE_DIR}/main/src/FreeRTOS_Posix_Port.c + ${FREERTOS_SOURCES} # Add only if USE_FREERTOS is enabled + ) + # Link FreeRTOS libraries + target_link_libraries(main freertos_config FreeRTOS) +else() + add_executable(main + ${PROJECT_SOURCE_DIR}/main/src/main.c + ${PROJECT_SOURCE_DIR}/main/src/mouse_cursor_icon.c + ) +endif() # Define LVGL configuration as a simple include target_compile_definitions(main PRIVATE LV_CONF_INCLUDE_SIMPLE) target_link_libraries(main lvgl lvgl::examples lvgl::demos lvgl::thorvg ${SDL2_LIBRARIES} m pthread) -# Only link FreeRTOS if the FreeRTOS directory exists -if(EXISTS "${PROJECT_SOURCE_DIR}/FreeRTOS") +# Only link freertos_config if the FreeRTOS directory exists +if(USE_FREERTOS) target_link_libraries(main freertos_config) endif() diff --git a/README.md b/README.md index 0d69362..2aa34f0 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ Therefore, it is crucial to allocate sufficient heap memory to ensure smooth exe ### Enable FreeRTOS To enable the rtos part of this project select in lv_conf.h `#define LV_USE_OS LV_OS_NONE` to `#define LV_USE_OS LV_OS_FREERTOS` +Additionaly you have to enable the compilation of all FreeRTOS Files by turn on `option(USE_FREERTOS "Enable FreeRTOS" OFF) ` in the CMakeLists.txt file. ### CMake @@ -127,4 +128,4 @@ It requires a working version of GCC, GDB and make in your path. To allow debugging inside VSCode you will also require a GDB [extension](https://marketplace.visualstudio.com/items?itemName=webfreak.debug) or other suitable debugger. All the requirements, build and debug settings have been pre-configured in the [.workspace](simulator.code-workspace) file. -The project can use **SDL** but it can be easily relaced by any other built-in LVGL dirvers. \ No newline at end of file +The project can use **SDL** but it can be easily relaced by any other built-in LVGL dirvers.