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 <kisvegabor@gmail.com>

* Update README.md

* Update main/src/FreeRTOS_Posix_Port.c

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>

* Update main/src/main.c

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>

* Update README.md

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>

* 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 <kisvegabor@gmail.com>
This commit is contained in:
MootSeeker 2024-09-18 08:47:44 +02:00 committed by GitHub
parent 0a8220a874
commit c5fc48a2b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 20 deletions

View File

@ -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($<$<BOOL:${LV_USE_FFMPEG}>: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()

View File

@ -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