Unified AppEsp and AppSim into a single App module (#94)
This commit is contained in:
parent
d7b151ab88
commit
03d14ef74b
44
App/CMakeLists.txt
Normal file
44
App/CMakeLists.txt
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
if (DEFINED ENV{ESP_IDF_VERSION})
|
||||||
|
set(BOARD_COMPONENTS Tactility)
|
||||||
|
|
||||||
|
if("${IDF_TARGET}" STREQUAL "esp32")
|
||||||
|
list(APPEND BOARD_COMPONENTS
|
||||||
|
YellowBoard
|
||||||
|
M5stackCore2
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# T-Deck is an S3 platform
|
||||||
|
if("${IDF_TARGET}" STREQUAL "esp32s3")
|
||||||
|
list(APPEND BOARD_COMPONENTS
|
||||||
|
LilygoTdeck
|
||||||
|
M5stackCoreS3
|
||||||
|
WaveshareS3Touch
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
idf_component_register(
|
||||||
|
SRC_DIRS "Source"
|
||||||
|
"Source/HelloWorld"
|
||||||
|
REQUIRES ${BOARD_COMPONENTS}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
|
||||||
|
file(GLOB_RECURSE SOURCES "Source/*.c*")
|
||||||
|
add_executable(AppSim ${SOURCES})
|
||||||
|
target_link_libraries(AppSim
|
||||||
|
PRIVATE Tactility
|
||||||
|
PRIVATE TactilityCore
|
||||||
|
PRIVATE TactilityHeadless
|
||||||
|
PRIVATE Simulator
|
||||||
|
)
|
||||||
|
|
||||||
|
find_package(SDL2 REQUIRED CONFIG)
|
||||||
|
target_link_libraries(AppSim PRIVATE ${SDL2_LIBRARIES})
|
||||||
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
add_definitions(-D_Nullable=)
|
||||||
|
add_definitions(-D_Nonnull=)
|
||||||
|
endif()
|
||||||
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef ESP_PLATFORM
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
// Supported hardware:
|
// Supported hardware:
|
||||||
@ -22,3 +23,23 @@
|
|||||||
#define TT_BOARD_HARDWARE NULL
|
#define TT_BOARD_HARDWARE NULL
|
||||||
#error Replace TT_BOARD_HARDWARE in main.c with your own. Or copy one of the ./sdkconfig.board.* files into ./sdkconfig.
|
#error Replace TT_BOARD_HARDWARE in main.c with your own. Or copy one of the ./sdkconfig.board.* files into ./sdkconfig.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#else // else simulator
|
||||||
|
|
||||||
|
#include "Simulator.h"
|
||||||
|
|
||||||
|
#define TT_BOARD_HARDWARE &sim_hardware
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
void app_main();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main_stub(); // Main function logic from Simulator board project
|
||||||
|
|
||||||
|
// Actual main that passes on app_main (to be executed in a FreeRTOS task) and bootstraps FreeRTOS
|
||||||
|
int main() {
|
||||||
|
setMainForSim(app_main);
|
||||||
|
return main_stub();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // ESP_PLATFORM
|
||||||
@ -1,25 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
|
||||||
|
|
||||||
set(BOARD_COMPONENTS Tactility)
|
|
||||||
|
|
||||||
if("${IDF_TARGET}" STREQUAL "esp32")
|
|
||||||
list(APPEND BOARD_COMPONENTS
|
|
||||||
YellowBoard
|
|
||||||
M5stackCore2
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# T-Deck is an S3 platform
|
|
||||||
if("${IDF_TARGET}" STREQUAL "esp32s3")
|
|
||||||
list(APPEND BOARD_COMPONENTS
|
|
||||||
LilygoTdeck
|
|
||||||
M5stackCoreS3
|
|
||||||
WaveshareS3Touch
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
idf_component_register(
|
|
||||||
SRC_DIRS "Source"
|
|
||||||
"Source/HelloWorld"
|
|
||||||
REQUIRES ${BOARD_COMPONENTS}
|
|
||||||
)
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
|
||||||
|
|
||||||
file(GLOB_RECURSE SOURCES "Source/*.c*")
|
|
||||||
add_executable(AppSim ${SOURCES})
|
|
||||||
target_link_libraries(AppSim
|
|
||||||
PRIVATE Tactility
|
|
||||||
PRIVATE TactilityCore
|
|
||||||
PRIVATE TactilityHeadless
|
|
||||||
PRIVATE lvgl
|
|
||||||
)
|
|
||||||
|
|
||||||
find_package(SDL2 REQUIRED CONFIG)
|
|
||||||
target_link_libraries(AppSim PRIVATE ${SDL2_LIBRARIES})
|
|
||||||
include_directories(${SDL2_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
add_definitions(-D_Nullable=)
|
|
||||||
add_definitions(-D_Nonnull=)
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
#include "lvgl/Toolbar.h"
|
|
||||||
|
|
||||||
static void app_show(tt::app::App& app, lv_obj_t* parent) {
|
|
||||||
lv_obj_t* toolbar = tt::lvgl::toolbar_create(parent, app);
|
|
||||||
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
|
||||||
|
|
||||||
lv_obj_t* label = lv_label_create(parent);
|
|
||||||
lv_label_set_text(label, "Hello, world!");
|
|
||||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern const tt::app::Manifest hello_world_app = {
|
|
||||||
.id = "HelloWorld",
|
|
||||||
.name = "Hello World",
|
|
||||||
.type = tt::app::TypeUser,
|
|
||||||
.onShow = &app_show
|
|
||||||
};
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
#include "Tactility.h"
|
|
||||||
|
|
||||||
extern const tt::hal::Configuration sim_hardware;
|
|
||||||
extern const tt::app::Manifest hello_world_app;
|
|
||||||
|
|
||||||
void app_main() {
|
|
||||||
static const tt::Configuration config = {
|
|
||||||
.hardware = &sim_hardware,
|
|
||||||
.apps = {
|
|
||||||
&hello_world_app
|
|
||||||
},
|
|
||||||
.services = {},
|
|
||||||
.auto_start_app_id = nullptr
|
|
||||||
};
|
|
||||||
|
|
||||||
tt::init(&config);
|
|
||||||
}
|
|
||||||
24
Boards/Simulator/CMakeLists.txt
Normal file
24
Boards/Simulator/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
if (NOT DEFINED ENV{ESP_IDF_VERSION})
|
||||||
|
|
||||||
|
file(GLOB_RECURSE SOURCES "Source/*.c*")
|
||||||
|
file(GLOB_RECURSE HEADERS "Source/*.h*")
|
||||||
|
|
||||||
|
add_library(Simulator OBJECT)
|
||||||
|
|
||||||
|
target_sources(Simulator
|
||||||
|
PRIVATE ${SOURCES}
|
||||||
|
PUBLIC ${HEADERS}
|
||||||
|
)
|
||||||
|
target_link_libraries(Simulator
|
||||||
|
PRIVATE Tactility
|
||||||
|
PRIVATE TactilityCore
|
||||||
|
PRIVATE TactilityHeadless
|
||||||
|
PRIVATE lvgl
|
||||||
|
)
|
||||||
|
|
||||||
|
add_definitions(-D_Nullable=)
|
||||||
|
add_definitions(-D_Nonnull=)
|
||||||
|
|
||||||
|
endif()
|
||||||
12
Boards/Simulator/Source/Simulator.cpp
Normal file
12
Boards/Simulator/Source/Simulator.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "Simulator.h"
|
||||||
|
|
||||||
|
MainFunction mainFunction = nullptr;
|
||||||
|
|
||||||
|
void setMainForSim(MainFunction newMainFunction) {
|
||||||
|
mainFunction = newMainFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
void executeMainFunction() {
|
||||||
|
assert(mainFunction);
|
||||||
|
mainFunction();
|
||||||
|
}
|
||||||
10
Boards/Simulator/Source/Simulator.h
Normal file
10
Boards/Simulator/Source/Simulator.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "hal/Configuration.h"
|
||||||
|
|
||||||
|
extern const tt::hal::Configuration sim_hardware;
|
||||||
|
|
||||||
|
typedef void (*MainFunction)();
|
||||||
|
void setMainForSim(MainFunction mainFunction);
|
||||||
|
void executeMainFunction();
|
||||||
|
int main_stub();
|
||||||
@ -1,21 +1,19 @@
|
|||||||
#include "Tactility.h"
|
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
|
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
#include "Simulator.h"
|
||||||
|
|
||||||
#define TAG "freertos"
|
#define TAG "freertos"
|
||||||
|
|
||||||
void app_main();
|
|
||||||
|
|
||||||
static void main_task(TT_UNUSED void* parameter) {
|
static void main_task(TT_UNUSED void* parameter) {
|
||||||
TT_LOG_I(TAG, "starting app_main()");
|
TT_LOG_I(TAG, "starting app_main()");
|
||||||
app_main();
|
executeMainFunction();
|
||||||
TT_LOG_I(TAG, "returned from app_main()");
|
TT_LOG_I(TAG, "returned from app_main()");
|
||||||
vTaskDelete(nullptr);
|
vTaskDelete(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main_stub() {
|
||||||
BaseType_t task_result = xTaskCreate(
|
BaseType_t task_result = xTaskCreate(
|
||||||
main_task,
|
main_task,
|
||||||
"main",
|
"main",
|
||||||
@ -16,10 +16,10 @@ if (DEFINED ENV{ESP_IDF_VERSION})
|
|||||||
add_definitions(-DARDUINO_M5STACK_CORE2)
|
add_definitions(-DARDUINO_M5STACK_CORE2)
|
||||||
add_compile_definitions(ARDUINO_M5STACK_CORE2)
|
add_compile_definitions(ARDUINO_M5STACK_CORE2)
|
||||||
|
|
||||||
set(COMPONENTS AppEsp32)
|
set(COMPONENTS App)
|
||||||
set(EXTRA_COMPONENT_DIRS
|
set(EXTRA_COMPONENT_DIRS
|
||||||
"Boards"
|
"Boards"
|
||||||
"AppEsp32"
|
"App"
|
||||||
"Tactility"
|
"Tactility"
|
||||||
"TactilityHeadless"
|
"TactilityHeadless"
|
||||||
"Libraries/esp_lvgl_port"
|
"Libraries/esp_lvgl_port"
|
||||||
@ -35,6 +35,10 @@ if (DEFINED ENV{ESP_IDF_VERSION})
|
|||||||
set(EXCLUDE_COMPONENTS "M5stackCoreS3")
|
set(EXCLUDE_COMPONENTS "M5stackCoreS3")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT "${IDF_TARGET}" STREQUAL "Simulator")
|
||||||
|
set(EXCLUDE_COMPONENTS "Simulator")
|
||||||
|
endif()
|
||||||
|
|
||||||
# ESP32-S3 boards
|
# ESP32-S3 boards
|
||||||
if(NOT "${IDF_TARGET}" STREQUAL "esp32s3")
|
if(NOT "${IDF_TARGET}" STREQUAL "esp32s3")
|
||||||
set(EXCLUDE_COMPONENTS "LilygoTdeck")
|
set(EXCLUDE_COMPONENTS "LilygoTdeck")
|
||||||
@ -50,6 +54,7 @@ project(TactilityRoot)
|
|||||||
if (NOT DEFINED ENV{ESP_IDF_VERSION})
|
if (NOT DEFINED ENV{ESP_IDF_VERSION})
|
||||||
add_subdirectory(Tactility)
|
add_subdirectory(Tactility)
|
||||||
add_subdirectory(TactilityHeadless)
|
add_subdirectory(TactilityHeadless)
|
||||||
|
add_subdirectory(Boards/Simulator)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(TactilityCore)
|
add_subdirectory(TactilityCore)
|
||||||
@ -58,30 +63,32 @@ add_subdirectory(Libraries/lv_screenshot)
|
|||||||
|
|
||||||
if (NOT DEFINED ENV{ESP_IDF_VERSION})
|
if (NOT DEFINED ENV{ESP_IDF_VERSION})
|
||||||
# FreeRTOS
|
# FreeRTOS
|
||||||
set(FREERTOS_CONFIG_FILE_DIRECTORY ${PROJECT_SOURCE_DIR}/AppSim/Source CACHE STRING "")
|
set(FREERTOS_CONFIG_FILE_DIRECTORY ${PROJECT_SOURCE_DIR}/Boards/Simulator/Source CACHE STRING "")
|
||||||
set(FREERTOS_PORT GCC_POSIX CACHE STRING "")
|
set(FREERTOS_PORT GCC_POSIX CACHE STRING "")
|
||||||
add_subdirectory(Libraries/FreeRTOS-Kernel)
|
add_subdirectory(Libraries/FreeRTOS-Kernel)
|
||||||
target_compile_definitions(freertos_kernel PUBLIC "projCOVERAGE_TEST=0")
|
target_compile_definitions(freertos_kernel PUBLIC "projCOVERAGE_TEST=0")
|
||||||
target_include_directories(freertos_kernel
|
target_include_directories(freertos_kernel
|
||||||
PUBLIC AppSim/Source # for FreeRTOSConfig.h
|
PUBLIC Boards/Simulator/Source # for FreeRTOSConfig.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# EmbedTLS
|
# EmbedTLS
|
||||||
|
set(ENABLE_TESTING OFF)
|
||||||
|
set(ENABLE_PROGRAMS OFF)
|
||||||
add_subdirectory(Libraries/mbedtls)
|
add_subdirectory(Libraries/mbedtls)
|
||||||
|
|
||||||
# Sim app
|
# Sim app
|
||||||
if (NOT DEFINED ENV{SKIP_SDL})
|
if (NOT DEFINED ENV{SKIP_SDL})
|
||||||
add_subdirectory(AppSim)
|
add_subdirectory(App)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
add_subdirectory(Tests)
|
add_subdirectory(Tests)
|
||||||
|
|
||||||
# SDL & LVGL
|
# SDL & LVGL
|
||||||
set(LV_CONF_PATH ${PROJECT_SOURCE_DIR}/AppSim/Source/lv_conf.h)
|
set(LV_CONF_PATH ${PROJECT_SOURCE_DIR}/Boards/Simulator/Source/lv_conf.h)
|
||||||
add_subdirectory(Libraries/lvgl) # Added as idf component for ESP and as library for other targets
|
add_subdirectory(Libraries/lvgl) # Added as idf component for ESP and as library for other targets
|
||||||
target_include_directories(lvgl
|
target_include_directories(lvgl
|
||||||
PUBLIC AppSim/Source # for lv_conf.h and lv_drv_conf.h
|
PUBLIC Boards/Source # for lv_conf.h and lv_drv_conf.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: This is a temporary skipping option for running unit tests
|
# TODO: This is a temporary skipping option for running unit tests
|
||||||
@ -108,6 +115,7 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION})
|
|||||||
find_package(SDL2_image REQUIRED)
|
find_package(SDL2_image REQUIRED)
|
||||||
target_include_directories(lvgl PUBLIC ${SDL2_IMAGE_INCLUDE_DIRS})
|
target_include_directories(lvgl PUBLIC ${SDL2_IMAGE_INCLUDE_DIRS})
|
||||||
target_link_libraries(AppSim ${SDL2_IMAGE_LIBRARIES})
|
target_link_libraries(AppSim ${SDL2_IMAGE_LIBRARIES})
|
||||||
|
target_link_libraries(Simulator ${SDL2_IMAGE_LIBRARIES})
|
||||||
endif(LV_USE_DRAW_SDL)
|
endif(LV_USE_DRAW_SDL)
|
||||||
|
|
||||||
if (LV_USE_LIBPNG)
|
if (LV_USE_LIBPNG)
|
||||||
|
|||||||
@ -8,16 +8,12 @@ note right of theadless : to build and use background services
|
|||||||
[TactilityCore] as tcore
|
[TactilityCore] as tcore
|
||||||
note right of tcore : defines, data types, logging, async, etc.
|
note right of tcore : defines, data types, logging, async, etc.
|
||||||
|
|
||||||
package "Applications" {
|
[App] as app
|
||||||
[AppSim] as appsim
|
|
||||||
[AppEsp32] as appesp
|
|
||||||
}
|
|
||||||
|
|
||||||
note right of appesp : AppEsp depends on the board \n projects for configuration
|
note right of app : App depends on the board \n projects for configuration
|
||||||
|
|
||||||
|
[app] ..> [t]
|
||||||
[t] ..> [theadless]
|
[t] ..> [theadless]
|
||||||
[theadless] ..> [tcore]
|
[theadless] ..> [tcore]
|
||||||
[appsim] ..> [t]
|
|
||||||
[appesp] ..> [t]
|
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
@ -124,9 +124,8 @@ Take a look at the [App Lifecycle](Documentation/app-lifecycle.md) or the [depen
|
|||||||
|
|
||||||
Directories explained:
|
Directories explained:
|
||||||
|
|
||||||
- `AppEsp32`: The ESP32 application example
|
- `App`: The application/firmware example project
|
||||||
- `AppSim`: The PC/simulator application example
|
- `Boards`: Contains board configuration projects with drivers (and simulator)
|
||||||
- `Boards`: Contains ESP modules with drivers
|
|
||||||
- `Tactility`: The main application platform code
|
- `Tactility`: The main application platform code
|
||||||
- `TactilityHeadless`: Service framework and default services.
|
- `TactilityHeadless`: Service framework and default services.
|
||||||
- `TactilityCore`: Core functionality regarding threads, stdlib, etc.
|
- `TactilityCore`: Core functionality regarding threads, stdlib, etc.
|
||||||
|
|||||||
@ -176,6 +176,10 @@ static void service_stop(TT_UNUSED Service& service) {
|
|||||||
wifi = nullptr;
|
wifi = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wifi_main(void*) {
|
||||||
|
// NO-OP
|
||||||
|
}
|
||||||
|
|
||||||
extern const Manifest manifest = {
|
extern const Manifest manifest = {
|
||||||
.id = "Wifi",
|
.id = "Wifi",
|
||||||
.onStart = &service_start,
|
.onStart = &service_start,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user