Compiler warning cleanup (#113)

Cleanup + expose more methods for external ELFs
This commit is contained in:
Ken Van Hoeylandt 2024-12-08 19:59:01 +01:00 committed by GitHub
parent 415442e410
commit e4206e8637
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 506 additions and 127 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.20)
if (DEFINED ENV{ESP_IDF_VERSION}) if (DEFINED ENV{ESP_IDF_VERSION})
set(BOARD_COMPONENTS Tactility TactilityC) set(BOARD_COMPONENTS Tactility TactilityC)

View File

@ -97,7 +97,6 @@ static void* sdcard_mount(const char* mount_point) {
return data; return data;
} }
static void* sdcard_init_and_mount(const char* mount_point) { static void* sdcard_init_and_mount(const char* mount_point) {
if (!sdcard_init()) { if (!sdcard_init()) {
TT_LOG_E(TAG, "Failed to set SPI CS pins high. This is a pre-requisite for mounting."); TT_LOG_E(TAG, "Failed to set SPI CS pins high. This is a pre-requisite for mounting.");

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.20)
if (NOT DEFINED ENV{ESP_IDF_VERSION}) if (NOT DEFINED ENV{ESP_IDF_VERSION})

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.20)
add_definitions(-DTT_DEBUG) add_definitions(-DTT_DEBUG)
@ -48,6 +48,12 @@ if (DEFINED ENV{ESP_IDF_VERSION})
# TEMP - DO NOT COMMIT # TEMP - DO NOT COMMIT
set(EXCLUDE_COMPONENTS "YellowBoard" "M5stackCore2" "WaveshareS3Touch") set(EXCLUDE_COMPONENTS "YellowBoard" "M5stackCore2" "WaveshareS3Touch")
# LVGL
get_filename_component(
LVGL_CONFIG_FULL_PATH Libraries/lvgl_conf ABSOLUTE
)
add_compile_definitions(LV_CONF_PATH=${LVGL_CONFIG_FULL_PATH}/lv_conf_kconfig.h)
else() else()
message("Building for sim target") message("Building for sim target")
endif() endif()
@ -74,7 +80,6 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION})
PUBLIC Boards/Simulator/Source # for FreeRTOSConfig.h PUBLIC Boards/Simulator/Source # for FreeRTOSConfig.h
) )
# EmbedTLS # EmbedTLS
set(ENABLE_TESTING OFF) set(ENABLE_TESTING OFF)
set(ENABLE_PROGRAMS OFF) set(ENABLE_PROGRAMS OFF)
@ -88,13 +93,16 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION})
# Tests # Tests
add_subdirectory(Tests) add_subdirectory(Tests)
# SDL & LVGL # LVGL
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
target_include_directories(lvgl
PUBLIC Boards/Source # for lv_conf.h and lv_drv_conf.h
)
add_subdirectory(Libraries/lvgl) # Added as idf component for ESP and as library for other targets
include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR}/Libraries/lvgl_conf)
if (NOT DEFINED ENV{SKIP_SDL})
target_include_directories(lvgl PUBLIC ${SDL2_IMAGE_INCLUDE_DIRS})
endif()
target_compile_definitions(lvgl PUBLIC "-DLV_CONF_PATH=${PROJECT_SOURCE_DIR}/Libraries/lvgl_conf/lv_conf_simulator.h")
# SDL
# TODO: This is a temporary skipping option for running unit tests # TODO: This is a temporary skipping option for running unit tests
# TODO: Remove when github action for SDL is working again # TODO: Remove when github action for SDL is working again
if (NOT DEFINED ENV{SKIP_SDL}) if (NOT DEFINED ENV{SKIP_SDL})
@ -117,7 +125,7 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION})
# `sudo apt install libsdl2-image-dev` # `sudo apt install libsdl2-image-dev`
# `brew install sdl2_image` # `brew install sdl2_image`
find_package(SDL2_image REQUIRED) find_package(SDL2_image REQUIRED)
target_include_directories(lvgl PUBLIC ${SDL2_IMAGE_INCLUDE_DIRS}) include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR}/Libraries/lvgl_conf)
target_link_libraries(AppSim ${SDL2_IMAGE_LIBRARIES}) target_link_libraries(AppSim ${SDL2_IMAGE_LIBRARIES})
target_link_libraries(Simulator ${SDL2_IMAGE_LIBRARIES}) target_link_libraries(Simulator ${SDL2_IMAGE_LIBRARIES})
endif(LV_USE_DRAW_SDL) endif(LV_USE_DRAW_SDL)

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.20)
set(TACTILITY_SKIP_SPIFFS 1) set(TACTILITY_SKIP_SPIFFS 1)
add_definitions(-DESP_TARGET) add_definitions(-DESP_TARGET)

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)

View File

@ -0,0 +1,244 @@
/** * @file lv_conf_kconfig.h * Configs that need special handling when LVGL is used with Kconfig */
#ifndef LV_CONF_KCONFIG_CUSTOM_H
#define LV_CONF_KCONFIG_CUSTOM_H
#define LV_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef LV_CONF_KCONFIG_EXTERNAL_INCLUDE
# include LV_CONF_KCONFIG_EXTERNAL_INCLUDE
#else
# ifdef ESP_PLATFORM
# include "sdkconfig.h"
# include "esp_attr.h"
# endif
# ifdef __NuttX__
# include <nuttx/config.h>
# elif defined(__RTTHREAD__)
# define LV_CONF_INCLUDE_SIMPLE
# include <lv_rt_thread_conf.h>
# endif
#endif /*LV_CONF_KCONFIG_EXTERNAL_INCLUDE*/
/*******************
* LV_USE_STDLIB_MALLOC
*******************/
#ifdef CONFIG_LV_USE_BUILTIN_MALLOC
# define CONFIG_LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN
#elif defined(CONFIG_LV_USE_CLIB_MALLOC)
# define CONFIG_LV_USE_STDLIB_MALLOC LV_STDLIB_CLIB
#elif defined(CONFIG_LV_USE_MICROPYTHON_MALLOC)
# define CONFIG_LV_USE_STDLIB_MALLOC LV_STDLIB_MICROPYTHON
#elif defined(CONFIG_LV_USE_RTTHREAD_MALLOC)
# define CONFIG_LV_USE_STDLIB_MALLOC LV_STDLIB_RTTHREAD
#elif defined (CONFIG_LV_USE_CUSTOM_MALLOC)
# define CONFIG_LV_USE_STDLIB_MALLOC LV_STDLIB_CUSTOM
#endif
/*******************
* LV_USE_STDLIB_STRING
*******************/
#ifdef CONFIG_LV_USE_BUILTIN_STRING
# define CONFIG_LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN
#elif defined(CONFIG_LV_USE_CLIB_STRING)
# define CONFIG_LV_USE_STDLIB_STRING LV_STDLIB_CLIB
#elif defined(CONFIG_LV_USE_MICROPYTHON_STRING)
# define CONFIG_LV_USE_STDLIB_STRING LV_STDLIB_MICROPYTHON
#elif defined(CONFIG_LV_USE_RTTHREAD_STRING)
# define CONFIG_LV_USE_STDLIB_STRING LV_STDLIB_RTTHREAD
#elif defined (CONFIG_LV_USE_CUSTOM_STRING)
# define CONFIG_LV_USE_STDLIB_STRING LV_STDLIB_CUSTOM
#endif
/*******************
* LV_USE_STDLIB_SPRINTF
*******************/
#ifdef CONFIG_LV_USE_BUILTIN_SPRINTF
# define CONFIG_LV_USE_STDLIB_SPRINTF LV_STDLIB_BUILTIN
#elif defined(CONFIG_LV_USE_CLIB_SPRINTF)
# define CONFIG_LV_USE_STDLIB_SPRINTF LV_STDLIB_CLIB
#elif defined(CONFIG_LV_USE_MICROPYTHON_SPRINTF)
# define CONFIG_LV_USE_STDLIB_SPRINTF LV_STDLIB_MICROPYTHON
#elif defined(CONFIG_LV_USE_RTTHREAD_SPRINTF)
# define CONFIG_LV_USE_STDLIB_SPRINTF LV_STDLIB_RTTHREAD
#elif defined (CONFIG_LV_USE_CUSTOM_SPRINTF)
# define CONFIG_LV_USE_STDLIB_SPRINTF LV_STDLIB_CUSTOM
#endif
/*******************
* LV_MEM_SIZE
*******************/
#ifdef CONFIG_LV_MEM_SIZE_KILOBYTES
# if(CONFIG_LV_MEM_SIZE_KILOBYTES < 2)
# error "LV_MEM_SIZE >= 2kB is required"
# endif
# define CONFIG_LV_MEM_SIZE (CONFIG_LV_MEM_SIZE_KILOBYTES * 1024U)
#endif
#ifdef CONFIG_LV_MEM_POOL_EXPAND_SIZE_KILOBYTES
# define CONFIG_LV_MEM_POOL_EXPAND_SIZE (CONFIG_LV_MEM_POOL_EXPAND_SIZE_KILOBYTES * 1024U)
#endif
/*------------------
* MONITOR POSITION
*-----------------*/
#ifdef CONFIG_LV_PERF_MONITOR_ALIGN_TOP_LEFT
# define CONFIG_LV_USE_PERF_MONITOR_POS LV_ALIGN_TOP_LEFT
#elif defined(CONFIG_LV_USE_PERF_MONITOR_ALIGN_TOP_MID)
# define CONFIG_LV_USE_PERF_MONITOR_POS LV_ALIGN_TOP_MID
#elif defined(CONFIG_LV_PERF_MONITOR_ALIGN_TOP_RIGHT)
# define CONFIG_LV_USE_PERF_MONITOR_POS LV_ALIGN_TOP_RIGHT
#elif defined(CONFIG_LV_PERF_MONITOR_ALIGN_BOTTOM_LEFT)
# define CONFIG_LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
#elif defined(CONFIG_LV_PERF_MONITOR_ALIGN_BOTTOM_MID)
# define CONFIG_LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_MID
#elif defined(CONFIG_LV_PERF_MONITOR_ALIGN_BOTTOM_RIGHT)
# define CONFIG_LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
#elif defined(CONFIG_LV_PERF_MONITOR_ALIGN_LEFT_MID)
# define CONFIG_LV_USE_PERF_MONITOR_POS LV_ALIGN_LEFT_MID
#elif defined(CONFIG_LV_PERF_MONITOR_ALIGN_RIGHT_MID)
# define CONFIG_LV_USE_PERF_MONITOR_POS LV_ALIGN_RIGHT_MID
#elif defined(CONFIG_LV_PERF_MONITOR_ALIGN_CENTER)
# define CONFIG_LV_USE_PERF_MONITOR_POS LV_ALIGN_CENTER
#endif
#ifdef CONFIG_LV_MEM_MONITOR_ALIGN_TOP_LEFT
# define CONFIG_LV_USE_MEM_MONITOR_POS LV_ALIGN_TOP_LEFT
#elif defined(CONFIG_LV_USE_MEM_MONITOR_ALIGN_TOP_MID)
# define CONFIG_LV_USE_MEM_MONITOR_POS LV_ALIGN_TOP_MID
#elif defined(CONFIG_LV_MEM_MONITOR_ALIGN_TOP_RIGHT)
# define CONFIG_LV_USE_MEM_MONITOR_POS LV_ALIGN_TOP_RIGHT
#elif defined(CONFIG_LV_MEM_MONITOR_ALIGN_BOTTOM_LEFT)
# define CONFIG_LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
#elif defined(CONFIG_LV_MEM_MONITOR_ALIGN_BOTTOM_MID)
# define CONFIG_LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_MID
#elif defined(CONFIG_LV_MEM_MONITOR_ALIGN_BOTTOM_RIGHT)
# define CONFIG_LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
#elif defined(CONFIG_LV_MEM_MONITOR_ALIGN_LEFT_MID)
# define CONFIG_LV_USE_MEM_MONITOR_POS LV_ALIGN_LEFT_MID
#elif defined(CONFIG_LV_MEM_MONITOR_ALIGN_RIGHT_MID)
# define CONFIG_LV_USE_MEM_MONITOR_POS LV_ALIGN_RIGHT_MID
#elif defined(CONFIG_LV_MEM_MONITOR_ALIGN_CENTER)
# define CONFIG_LV_USE_MEM_MONITOR_POS LV_ALIGN_CENTER
#endif
/********************
* FONT SELECTION
*******************/
/**
* NOTE: In Kconfig instead of `LV_DEFAULT_FONT`
* `CONFIG_LV_FONT_DEFAULT_<font_name>` is defined
* hence the large selection with if-s
*/
/*------------------
* DEFAULT FONT
*-----------------*/
#ifdef CONFIG_LV_FONT_DEFAULT_MONTSERRAT_8
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_8
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_10)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_10
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_12)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_12
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_14)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_14
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_16)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_16
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_18)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_18
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_20)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_20
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_22)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_22
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_24)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_24
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_26)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_26
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_28)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_28
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_30)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_30
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_32)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_32
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_34)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_34
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_36)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_36
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_38)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_38
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_40)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_40
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_42)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_42
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_44)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_44
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_46)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_46
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_48)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_48
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_12_SUBPX)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_12_subpx
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_28_COMPRESSED)
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_28_compressed
#elif defined(CONFIG_LV_FONT_DEFAULT_DEJAVU_16_PERSIAN_HEBREW)
# define CONFIG_LV_FONT_DEFAULT &lv_font_dejavu_16_persian_hebrew
#elif defined(CONFIG_LV_FONT_DEFAULT_SIMSUN_16_CJK)
# define CONFIG_LV_FONT_DEFAULT &lv_font_simsun_16_cjk
#elif defined(CONFIG_LV_FONT_DEFAULT_UNSCII_8)
# define CONFIG_LV_FONT_DEFAULT &lv_font_unscii_8
#elif defined(CONFIG_LV_FONT_DEFAULT_UNSCII_16)
# define CONFIG_LV_FONT_DEFAULT &lv_font_unscii_16
#endif
/*------------------
* TEXT ENCODING
*-----------------*/
#ifdef CONFIG_LV_TXT_ENC_UTF8
# define CONFIG_LV_TXT_ENC LV_TXT_ENC_UTF8
#elif defined(CONFIG_LV_TXT_ENC_ASCII)
# define CONFIG_LV_TXT_ENC LV_TXT_ENC_ASCII
#endif
/*------------------
* BIDI DIRECTION
*-----------------*/
#ifdef CONFIG_LV_BASE_DIR_LTR
# define CONFIG_LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_LTR
#elif defined(CONFIG_LV_BASE_DIR_RTL)
# define CONFIG_LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_RTL
#elif defined(CONFIG_LV_BASE_DIR_AUTO)
# define CONFIG_LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO
#endif
/*------------------
* LINUX FBDEV
*-----------------*/
#ifdef CONFIG_LV_LINUX_FBDEV_RENDER_MODE_PARTIAL
# define CONFIG_LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL
#elif defined(CONFIG_LV_LINUX_FBDEV_RENDER_MODE_DIRECT)
# define CONFIG_LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT
#elif defined(CONFIG_LV_LINUX_FBDEV_RENDER_MODE_FULL)
# define CONFIG_LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_FULL
#endif
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_CONF_KCONFIG_H*/

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -14,6 +14,10 @@ if (DEFINED ENV{ESP_IDF_VERSION})
) )
add_definitions(-DESP_PLATFORM) add_definitions(-DESP_PLATFORM)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${COMPONENT_LIB} PUBLIC -Wno-unused-variable)
endif()
else() else()
file(GLOB_RECURSE SOURCES "Source/*.c*") file(GLOB_RECURSE SOURCES "Source/*.c*")
file(GLOB_RECURSE HEADERS "Source/*.h*") file(GLOB_RECURSE HEADERS "Source/*.h*")

View File

@ -18,18 +18,18 @@ namespace tt::service::gui {
/** Gui structure */ /** Gui structure */
struct Gui { struct Gui {
// Thread and lock // Thread and lock
Thread* thread; Thread* thread = nullptr;
Mutex* mutex; Mutex mutex = Mutex(Mutex::TypeRecursive);
PubSubSubscription* loader_pubsub_subscription; PubSubSubscription* loader_pubsub_subscription = nullptr;
// Layers and Canvas // Layers and Canvas
lv_obj_t* lvgl_parent; lv_obj_t* lvgl_parent = nullptr;
// App-specific // App-specific
ViewPort* app_view_port; ViewPort* app_view_port = nullptr;
lv_obj_t* _Nullable keyboard; lv_obj_t* _Nullable keyboard = nullptr;
lv_group_t* keyboard_group; lv_group_t* keyboard_group = nullptr;
}; };
/** Update GUI, request redraw */ /** Update GUI, request redraw */

View File

@ -16,12 +16,12 @@ extern const AppManifest manifest;
static void on_timer(TT_UNUSED std::shared_ptr<void> context); static void on_timer(TT_UNUSED std::shared_ptr<void> context);
struct Data { struct Data {
std::unique_ptr<Timer> update_timer = std::unique_ptr<Timer>(new Timer(Timer::TypePeriodic, &on_timer, nullptr)); Timer update_timer = Timer(Timer::TypePeriodic, &on_timer, nullptr);
const hal::Power* power; const hal::Power* power = getConfiguration()->hardware->power;
lv_obj_t* enable_switch; lv_obj_t* enable_switch = nullptr;
lv_obj_t* charge_state; lv_obj_t* charge_state = nullptr;
lv_obj_t* charge_level; lv_obj_t* charge_level = nullptr;
lv_obj_t* current; lv_obj_t* current = nullptr;
}; };
/** Returns the app data if the app is active. Note that this could clash if the same app is started twice and a background thread is slow. */ /** Returns the app data if the app is active. Note that this could clash if the same app is started twice and a background thread is slow. */
@ -53,7 +53,7 @@ static void updateUi(std::shared_ptr<Data> data) {
lvgl::unlock(); lvgl::unlock();
} }
static void on_timer(TT_UNUSED void* context) { static void on_timer(TT_UNUSED std::shared_ptr<void> context) {
auto data = optData(); auto data = optData();
if (data != nullptr) { if (data != nullptr) {
updateUi(data); updateUi(data);
@ -110,18 +110,17 @@ static void onShow(AppContext& app, lv_obj_t* parent) {
data->current = lv_label_create(wrapper); data->current = lv_label_create(wrapper);
updateUi(data); updateUi(data);
data->update_timer->start(kernel::millisToTicks(1000)); data->update_timer.start(kernel::millisToTicks(1000));
} }
static void onHide(TT_UNUSED AppContext& app) { static void onHide(TT_UNUSED AppContext& app) {
auto data = std::static_pointer_cast<Data>(app.getData()); auto data = std::static_pointer_cast<Data>(app.getData());
data->update_timer->stop(); data->update_timer.stop();
} }
static void onStart(AppContext& app) { static void onStart(AppContext& app) {
auto data = std::shared_ptr<Data>(); auto data = std::shared_ptr<Data>();
app.setData(data); app.setData(data);
data->power = getConfiguration()->hardware->power;
assert(data->power != nullptr); // The Power app only shows up on supported devices assert(data->power != nullptr); // The Power app only shows up on supported devices
} }

View File

@ -14,23 +14,20 @@ namespace tt::lvgl {
#define TAG "statusbar" #define TAG "statusbar"
typedef struct { struct StatusbarIcon {
const char* image; const char* image = nullptr;
bool visible; bool visible = false;
bool claimed; bool claimed = false;
} StatusbarIcon;
typedef struct {
Mutex* mutex;
std::shared_ptr<PubSub> pubsub;
StatusbarIcon icons[STATUSBAR_ICON_LIMIT];
} StatusbarData;
static StatusbarData statusbar_data = {
.mutex = nullptr,
.icons = {}
}; };
struct StatusbarData {
Mutex mutex = Mutex(Mutex::TypeRecursive);
std::shared_ptr<PubSub> pubsub = std::make_shared<PubSub>();
StatusbarIcon icons[STATUSBAR_ICON_LIMIT] = {};
};
static StatusbarData statusbar_data;
typedef struct { typedef struct {
lv_obj_t obj; lv_obj_t obj;
lv_obj_t* icons[STATUSBAR_ICON_LIMIT]; lv_obj_t* icons[STATUSBAR_ICON_LIMIT];
@ -38,29 +35,12 @@ typedef struct {
PubSubSubscription* pubsub_subscription; PubSubSubscription* pubsub_subscription;
} Statusbar; } Statusbar;
static void statusbar_init() {
statusbar_data.mutex = tt_mutex_alloc(Mutex::TypeRecursive);
statusbar_data.pubsub = std::make_shared<PubSub>();
for (int i = 0; i < STATUSBAR_ICON_LIMIT; i++) {
statusbar_data.icons[i].image = nullptr;
statusbar_data.icons[i].visible = false;
statusbar_data.icons[i].claimed = false;
}
}
static void statusbar_ensure_initialized() {
if (statusbar_data.mutex == nullptr) {
statusbar_init();
}
}
static void statusbar_lock() { static void statusbar_lock() {
statusbar_ensure_initialized(); statusbar_data.mutex.acquire(TtWaitForever);
tt_mutex_acquire(statusbar_data.mutex, TtWaitForever);
} }
static void statusbar_unlock() { static void statusbar_unlock() {
tt_mutex_release(statusbar_data.mutex); statusbar_data.mutex.release();
} }
static void statusbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj); static void statusbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj);
@ -74,10 +54,14 @@ static const lv_obj_class_t statusbar_class = {
.constructor_cb = &statusbar_constructor, .constructor_cb = &statusbar_constructor,
.destructor_cb = &statusbar_destructor, .destructor_cb = &statusbar_destructor,
.event_cb = &statusbar_event, .event_cb = &statusbar_event,
.user_data = nullptr,
.name = nullptr,
.width_def = LV_PCT(100), .width_def = LV_PCT(100),
.height_def = STATUSBAR_HEIGHT, .height_def = STATUSBAR_HEIGHT,
.editable = false,
.group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE, .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE,
.instance_size = sizeof(Statusbar) .instance_size = sizeof(Statusbar),
.theme_inheritable = false
}; };
static void statusbar_pubsub_event(TT_UNUSED const void* message, void* obj) { static void statusbar_pubsub_event(TT_UNUSED const void* message, void* obj) {
@ -96,7 +80,6 @@ static void statusbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
lv_obj_remove_flag(obj, LV_OBJ_FLAG_SCROLLABLE); lv_obj_remove_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
LV_TRACE_OBJ_CREATE("finished"); LV_TRACE_OBJ_CREATE("finished");
auto* statusbar = (Statusbar*)obj; auto* statusbar = (Statusbar*)obj;
statusbar_ensure_initialized();
statusbar->pubsub_subscription = tt_pubsub_subscribe(statusbar_data.pubsub, &statusbar_pubsub_event, statusbar); statusbar->pubsub_subscription = tt_pubsub_subscribe(statusbar_data.pubsub, &statusbar_pubsub_event, statusbar);
} }
@ -168,6 +151,7 @@ static void statusbar_event(TT_UNUSED const lv_obj_class_t* class_p, lv_event_t*
if (code == LV_EVENT_VALUE_CHANGED) { if (code == LV_EVENT_VALUE_CHANGED) {
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
} else if (code == LV_EVENT_DRAW_MAIN) { } else if (code == LV_EVENT_DRAW_MAIN) {
// NO-OP
} }
} }

View File

@ -26,10 +26,15 @@ static const lv_obj_class_t toolbar_class = {
.base_class = &lv_obj_class, .base_class = &lv_obj_class,
.constructor_cb = &toolbar_constructor, .constructor_cb = &toolbar_constructor,
.destructor_cb = nullptr, .destructor_cb = nullptr,
.event_cb = nullptr,
.user_data = nullptr,
.name = nullptr,
.width_def = LV_PCT(100), .width_def = LV_PCT(100),
.height_def = TOOLBAR_HEIGHT, .height_def = TOOLBAR_HEIGHT,
.editable = false,
.group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE, .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE,
.instance_size = sizeof(Toolbar), .instance_size = sizeof(Toolbar),
.theme_inheritable = false
}; };
static void stop_app(TT_UNUSED lv_event_t* event) { static void stop_app(TT_UNUSED lv_event_t* event) {

View File

@ -27,8 +27,7 @@ void loader_callback(const void* message, TT_UNUSED void* context) {
} }
Gui* gui_alloc() { Gui* gui_alloc() {
auto* instance = static_cast<Gui*>(malloc(sizeof(Gui))); auto* instance = new Gui();
memset(instance, 0, sizeof(Gui));
tt_check(instance != nullptr); tt_check(instance != nullptr);
instance->thread = new Thread( instance->thread = new Thread(
"gui", "gui",
@ -36,8 +35,6 @@ Gui* gui_alloc() {
&gui_main, &gui_main,
nullptr nullptr
); );
instance->mutex = tt_mutex_alloc(Mutex::TypeRecursive);
instance->keyboard = nullptr;
instance->loader_pubsub_subscription = tt_pubsub_subscribe(loader::getPubsub(), &loader_callback, instance); instance->loader_pubsub_subscription = tt_pubsub_subscribe(loader::getPubsub(), &loader_callback, instance);
tt_check(lvgl::lock(1000 / portTICK_PERIOD_MS)); tt_check(lvgl::lock(1000 / portTICK_PERIOD_MS));
instance->keyboard_group = lv_group_create(); instance->keyboard_group = lv_group_create();
@ -50,25 +47,23 @@ Gui* gui_alloc() {
void gui_free(Gui* instance) { void gui_free(Gui* instance) {
tt_assert(instance != nullptr); tt_assert(instance != nullptr);
delete instance->thread; delete instance->thread;
tt_mutex_free(instance->mutex);
lv_group_delete(instance->keyboard_group);
tt_check(lvgl::lock(1000 / portTICK_PERIOD_MS)); tt_check(lvgl::lock(1000 / portTICK_PERIOD_MS));
lv_group_del(instance->keyboard_group); lv_group_del(instance->keyboard_group);
lvgl::unlock(); lvgl::unlock();
free(instance); delete instance;
} }
void lock() { void lock() {
tt_assert(gui); tt_assert(gui);
tt_assert(gui->mutex); tt_check(gui->mutex.acquire(configTICK_RATE_HZ) == TtStatusOk);
tt_check(tt_mutex_acquire(gui->mutex, configTICK_RATE_HZ) == TtStatusOk);
} }
void unlock() { void unlock() {
tt_assert(gui); tt_assert(gui);
tt_assert(gui->mutex); tt_check(gui->mutex.release() == TtStatusOk);
tt_check(tt_mutex_release(gui->mutex) == TtStatusOk);
} }
void requestDraw() { void requestDraw() {

View File

@ -6,7 +6,6 @@
#include "ScreenshotTask.h" #include "ScreenshotTask.h"
#include "service/ServiceContext.h" #include "service/ServiceContext.h"
#include "service/ServiceRegistry.h" #include "service/ServiceRegistry.h"
#include "TactilityCore.h"
namespace tt::service::screenshot { namespace tt::service::screenshot {

View File

@ -17,36 +17,31 @@ namespace tt::service::screenshot::task {
#define SCREENSHOT_PATH_LIMIT 128 #define SCREENSHOT_PATH_LIMIT 128
typedef struct {
int type;
uint8_t delay_in_seconds;
uint8_t amount;
char path[SCREENSHOT_PATH_LIMIT];
} ScreenshotTaskWork;
typedef struct { struct ScreenshotTaskWork {
Thread* thread; int type = TASK_WORK_TYPE_DELAY ;
Mutex* mutex; uint8_t delay_in_seconds = 0;
bool interrupted; uint8_t amount = 0;
char path[SCREENSHOT_PATH_LIMIT] = { 0 };
};
struct ScreenshotTaskData {
Thread* thread = nullptr;
Mutex mutex = Mutex(Mutex::TypeRecursive);
bool interrupted = false;
ScreenshotTaskWork work; ScreenshotTaskWork work;
} ScreenshotTaskData; };
static void task_lock(ScreenshotTaskData* data) { static void task_lock(ScreenshotTaskData* data) {
tt_check(tt_mutex_acquire(data->mutex, TtWaitForever) == TtStatusOk); tt_check(data->mutex.acquire(TtWaitForever) == TtStatusOk);
} }
static void task_unlock(ScreenshotTaskData* data) { static void task_unlock(ScreenshotTaskData* data) {
tt_check(tt_mutex_release(data->mutex) == TtStatusOk); tt_check(data->mutex.release() == TtStatusOk);
} }
ScreenshotTask* alloc() { ScreenshotTask* alloc() {
auto* data = static_cast<ScreenshotTaskData*>(malloc(sizeof(ScreenshotTaskData))); return new ScreenshotTaskData();
*data = (ScreenshotTaskData) {
.thread = nullptr,
.mutex = tt_mutex_alloc(Mutex::TypeRecursive),
.interrupted = false
};
return data;
} }
void free(ScreenshotTask* task) { void free(ScreenshotTask* task) {
@ -54,6 +49,7 @@ void free(ScreenshotTask* task) {
if (data->thread) { if (data->thread) {
stop(data); stop(data);
} }
delete data;
} }
static bool is_interrupted(ScreenshotTaskData* data) { static bool is_interrupted(ScreenshotTaskData* data) {

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -13,6 +13,10 @@ if (DEFINED ENV{ESP_IDF_VERSION})
) )
add_definitions(-DESP_PLATFORM) add_definitions(-DESP_PLATFORM)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${COMPONENT_LIB} PUBLIC -Wno-unused-variable)
endif()
else() else()
file(GLOB_RECURSE SOURCES "Source/*.c**") file(GLOB_RECURSE SOURCES "Source/*.c**")
file(GLOB_RECURSE HEADERS "Source/*.h**") file(GLOB_RECURSE HEADERS "Source/*.h**")

View File

@ -1,3 +1,5 @@
extern "C" {
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include "elf_symbol.h" #include "elf_symbol.h"
@ -8,8 +10,6 @@
#include "lvgl.h" #include "lvgl.h"
extern "C" {
const struct esp_elfsym elf_symbols[] { const struct esp_elfsym elf_symbols[] {
// Tactility // Tactility
ESP_ELFSYM_EXPORT(tt_app_selectiondialog_start), ESP_ELFSYM_EXPORT(tt_app_selectiondialog_start),
@ -20,18 +20,118 @@ const struct esp_elfsym elf_symbols[] {
ESP_ELFSYM_EXPORT(lv_obj_add_event_cb), ESP_ELFSYM_EXPORT(lv_obj_add_event_cb),
ESP_ELFSYM_EXPORT(lv_obj_align), ESP_ELFSYM_EXPORT(lv_obj_align),
ESP_ELFSYM_EXPORT(lv_obj_align_to), ESP_ELFSYM_EXPORT(lv_obj_align_to),
ESP_ELFSYM_EXPORT(lv_obj_get_parent),
ESP_ELFSYM_EXPORT(lv_obj_get_height),
ESP_ELFSYM_EXPORT(lv_obj_get_width),
ESP_ELFSYM_EXPORT(lv_obj_get_coords),
ESP_ELFSYM_EXPORT(lv_obj_get_x),
ESP_ELFSYM_EXPORT(lv_obj_get_display),
ESP_ELFSYM_EXPORT(lv_obj_get_y),
ESP_ELFSYM_EXPORT(lv_obj_get_content_width),
ESP_ELFSYM_EXPORT(lv_obj_get_content_height),
ESP_ELFSYM_EXPORT(lv_obj_center),
ESP_ELFSYM_EXPORT(lv_color_make),
ESP_ELFSYM_EXPORT(lv_obj_remove_event_cb),
ESP_ELFSYM_EXPORT(lv_obj_get_user_data), ESP_ELFSYM_EXPORT(lv_obj_get_user_data),
ESP_ELFSYM_EXPORT(lv_obj_set_user_data), ESP_ELFSYM_EXPORT(lv_obj_set_user_data),
ESP_ELFSYM_EXPORT(lv_obj_set_pos),
ESP_ELFSYM_EXPORT(lv_obj_set_style_margin_hor),
ESP_ELFSYM_EXPORT(lv_obj_set_style_margin_ver),
ESP_ELFSYM_EXPORT(lv_obj_set_style_margin_top),
ESP_ELFSYM_EXPORT(lv_obj_set_style_margin_bottom),
ESP_ELFSYM_EXPORT(lv_obj_set_style_margin_left),
ESP_ELFSYM_EXPORT(lv_obj_set_style_margin_right),
ESP_ELFSYM_EXPORT(lv_obj_set_style_margin_all), ESP_ELFSYM_EXPORT(lv_obj_set_style_margin_all),
ESP_ELFSYM_EXPORT(lv_obj_set_style_pad_all), ESP_ELFSYM_EXPORT(lv_obj_set_style_pad_all),
ESP_ELFSYM_EXPORT(lv_obj_set_style_pad_hor),
ESP_ELFSYM_EXPORT(lv_obj_set_style_pad_ver),
ESP_ELFSYM_EXPORT(lv_obj_set_style_pad_top),
ESP_ELFSYM_EXPORT(lv_obj_set_style_pad_bottom),
ESP_ELFSYM_EXPORT(lv_obj_set_style_pad_left),
ESP_ELFSYM_EXPORT(lv_obj_set_style_pad_right),
ESP_ELFSYM_EXPORT(lv_obj_set_style_border_width), ESP_ELFSYM_EXPORT(lv_obj_set_style_border_width),
ESP_ELFSYM_EXPORT(lv_obj_set_style_border_opa),
ESP_ELFSYM_EXPORT(lv_obj_set_style_border_post),
ESP_ELFSYM_EXPORT(lv_obj_set_style_border_side),
ESP_ELFSYM_EXPORT(lv_obj_set_style_border_color), ESP_ELFSYM_EXPORT(lv_obj_set_style_border_color),
ESP_ELFSYM_EXPORT(lv_obj_set_x),
ESP_ELFSYM_EXPORT(lv_obj_set_y),
ESP_ELFSYM_EXPORT(lv_obj_set_width),
ESP_ELFSYM_EXPORT(lv_obj_set_height),
ESP_ELFSYM_EXPORT(lv_theme_get_color_primary),
ESP_ELFSYM_EXPORT(lv_theme_get_color_secondary),
// lv_button // lv_button
ESP_ELFSYM_EXPORT(lv_button_create), ESP_ELFSYM_EXPORT(lv_button_create),
// lv_label // lv_label
ESP_ELFSYM_EXPORT(lv_label_create), ESP_ELFSYM_EXPORT(lv_label_create),
ESP_ELFSYM_EXPORT(lv_label_cut_text),
ESP_ELFSYM_EXPORT(lv_label_get_long_mode),
ESP_ELFSYM_EXPORT(lv_label_set_long_mode),
ESP_ELFSYM_EXPORT(lv_label_get_text),
ESP_ELFSYM_EXPORT(lv_label_set_text), ESP_ELFSYM_EXPORT(lv_label_set_text),
ESP_ELFSYM_EXPORT(lv_label_set_text_fmt), ESP_ELFSYM_EXPORT(lv_label_set_text_fmt),
// lv_switch
ESP_ELFSYM_EXPORT(lv_switch_create),
// lv_checkbox
ESP_ELFSYM_EXPORT(lv_checkbox_create),
ESP_ELFSYM_EXPORT(lv_checkbox_set_text),
ESP_ELFSYM_EXPORT(lv_checkbox_get_text),
ESP_ELFSYM_EXPORT(lv_checkbox_set_text_static),
// lv_bar
ESP_ELFSYM_EXPORT(lv_bar_create),
ESP_ELFSYM_EXPORT(lv_bar_get_max_value),
ESP_ELFSYM_EXPORT(lv_bar_get_min_value),
ESP_ELFSYM_EXPORT(lv_bar_get_mode),
ESP_ELFSYM_EXPORT(lv_bar_get_start_value),
ESP_ELFSYM_EXPORT(lv_bar_get_value),
ESP_ELFSYM_EXPORT(lv_bar_set_mode),
ESP_ELFSYM_EXPORT(lv_bar_set_range),
ESP_ELFSYM_EXPORT(lv_bar_set_start_value),
ESP_ELFSYM_EXPORT(lv_bar_set_value),
ESP_ELFSYM_EXPORT(lv_bar_is_symmetrical),
// lv_dropdown
ESP_ELFSYM_EXPORT(lv_dropdown_create),
ESP_ELFSYM_EXPORT(lv_dropdown_add_option),
ESP_ELFSYM_EXPORT(lv_dropdown_clear_options),
ESP_ELFSYM_EXPORT(lv_dropdown_close),
ESP_ELFSYM_EXPORT(lv_dropdown_get_dir),
ESP_ELFSYM_EXPORT(lv_dropdown_get_list),
ESP_ELFSYM_EXPORT(lv_dropdown_get_option_count),
ESP_ELFSYM_EXPORT(lv_dropdown_get_option_index),
ESP_ELFSYM_EXPORT(lv_dropdown_get_options),
ESP_ELFSYM_EXPORT(lv_dropdown_set_dir),
ESP_ELFSYM_EXPORT(lv_dropdown_set_options),
ESP_ELFSYM_EXPORT(lv_dropdown_set_options_static),
ESP_ELFSYM_EXPORT(lv_dropdown_set_selected),
ESP_ELFSYM_EXPORT(lv_dropdown_set_selected_highlight),
ESP_ELFSYM_EXPORT(lv_dropdown_set_symbol),
ESP_ELFSYM_EXPORT(lv_dropdown_set_text),
ESP_ELFSYM_EXPORT(lv_dropdown_open),
// lv_list
ESP_ELFSYM_EXPORT(lv_list_create),
ESP_ELFSYM_EXPORT(lv_list_add_text),
ESP_ELFSYM_EXPORT(lv_list_add_button),
ESP_ELFSYM_EXPORT(lv_list_get_button_text),
ESP_ELFSYM_EXPORT(lv_list_set_button_text),
// lv_spinner
ESP_ELFSYM_EXPORT(lv_spinner_create),
ESP_ELFSYM_EXPORT(lv_spinner_set_anim_params),
// lv_textarea
ESP_ELFSYM_EXPORT(lv_textarea_create),
ESP_ELFSYM_EXPORT(lv_textarea_get_accepted_chars),
ESP_ELFSYM_EXPORT(lv_textarea_get_label),
ESP_ELFSYM_EXPORT(lv_textarea_get_max_length),
ESP_ELFSYM_EXPORT(lv_textarea_get_one_line),
ESP_ELFSYM_EXPORT(lv_textarea_set_one_line),
ESP_ELFSYM_EXPORT(lv_textarea_set_accepted_chars),
ESP_ELFSYM_EXPORT(lv_textarea_set_align),
ESP_ELFSYM_EXPORT(lv_textarea_set_password_bullet),
ESP_ELFSYM_EXPORT(lv_textarea_set_password_mode),
ESP_ELFSYM_EXPORT(lv_textarea_set_password_show_time),
ESP_ELFSYM_EXPORT(lv_textarea_set_placeholder_text),
ESP_ELFSYM_EXPORT(lv_textarea_set_text),
ESP_ELFSYM_EXPORT(lv_textarea_set_text_selection),
// delimiter
ESP_ELFSYM_END ESP_ELFSYM_END
}; };
@ -39,7 +139,7 @@ void tt_init_tactility_c() {
elf_set_custom_symbols(elf_symbols); elf_set_custom_symbols(elf_symbols);
} }
#else // PC #else // Simulator
void tt_init_tactility_c() { void tt_init_tactility_c() {
} }
@ -47,4 +147,3 @@ void tt_init_tactility_c() {
#endif // ESP_PLATFORM #endif // ESP_PLATFORM
} }

View File

@ -1,3 +1,4 @@
#include <Check.h>
#include "App.h" #include "App.h"
#include "Log.h" #include "Log.h"
#include "app/ElfApp.h" #include "app/ElfApp.h"
@ -49,19 +50,19 @@ static void onHideWrapper(tt::app::AppContext& context) {
static void onResultWrapper(tt::app::AppContext& context, tt::app::Result result, const tt::Bundle& resultData) { static void onResultWrapper(tt::app::AppContext& context, tt::app::Result result, const tt::Bundle& resultData) {
if (elfOnResult != nullptr) { if (elfOnResult != nullptr) {
TT_LOG_I(TAG, "onResultWrapper"); TT_LOG_I(TAG, "onResultWrapper");
// Result convertedResult = AppResultError; Result convertedResult = AppResultError;
// switch (result) { switch (result) {
// case tt::app::ResultOk: case tt::app::ResultOk:
// convertedResult = AppResultOk; convertedResult = AppResultOk;
// break; break;
// case tt::app::ResultCancelled: case tt::app::ResultCancelled:
// convertedResult = AppResultCancelled; convertedResult = AppResultCancelled;
// break; break;
// case tt::app::ResultError: case tt::app::ResultError:
// convertedResult = AppResultError; convertedResult = AppResultError;
// break; break;
// } }
// elfOnResult(&context, convertedResult, (BundleHandle)&resultData); elfOnResult(&context, convertedResult, (BundleHandle)&resultData);
} else { } else {
TT_LOG_W(TAG, "onResultWrapper not set"); TT_LOG_W(TAG, "onResultWrapper not set");
} }
@ -89,6 +90,7 @@ void tt_set_app_manifest(
AppOnHide _Nullable onHide, AppOnHide _Nullable onHide,
AppOnResult _Nullable onResult AppOnResult _Nullable onResult
) { ) {
#ifdef ESP_PLATFORM
manifest.name = name; manifest.name = name;
manifest.icon = icon ? icon : ""; manifest.icon = icon ? icon : "";
elfOnStart = onStart; elfOnStart = onStart;
@ -97,6 +99,9 @@ void tt_set_app_manifest(
elfOnHide = onHide; elfOnHide = onHide;
elfOnResult = onResult; elfOnResult = onResult;
tt::app::setElfAppManifest(manifest); tt::app::setElfAppManifest(manifest);
#else
tt_crash("Not intended for PC");
#endif
} }
} }

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -13,6 +13,10 @@ if (DEFINED ENV{ESP_IDF_VERSION})
) )
add_definitions(-DESP_PLATFORM) add_definitions(-DESP_PLATFORM)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${COMPONENT_LIB} PUBLIC -Wno-unused-variable)
endif()
else() else()
file(GLOB_RECURSE SOURCES "Source/*.c*") file(GLOB_RECURSE SOURCES "Source/*.c*")
file(GLOB_RECURSE HEADERS "Source/*.h*") file(GLOB_RECURSE HEADERS "Source/*.h*")

View File

@ -62,20 +62,23 @@ bool Bundle::optString(const std::string& key, std::string& out) const {
void Bundle::putBool(const std::string& key, bool value) { void Bundle::putBool(const std::string& key, bool value) {
this->entries[key] = { this->entries[key] = {
.type = TypeBool, .type = TypeBool,
.value_bool = value .value_bool = value,
.value_string = ""
}; };
} }
void Bundle::putInt32(const std::string& key, int32_t value) { void Bundle::putInt32(const std::string& key, int32_t value) {
this->entries[key] = { this->entries[key] = {
.type = TypeInt32, .type = TypeInt32,
.value_int32 = value .value_int32 = value,
.value_string = ""
}; };
} }
void Bundle::putString(const std::string& key, const std::string& value) { void Bundle::putString(const std::string& key, const std::string& value) {
this->entries[key] = { this->entries[key] = {
.type = TypeString, .type = TypeString,
.value_bool = false,
.value_string = value .value_string = value
}; };
} }

View File

@ -23,7 +23,6 @@ private:
} Type; } Type;
typedef struct { typedef struct {
std::string key;
Type type; Type type;
union { union {
bool value_bool; bool value_bool;

View File

@ -1,6 +1,5 @@
#include "Pubsub.h" #include "Pubsub.h"
#include "Check.h" #include "Check.h"
#include <list>
namespace tt { namespace tt {

View File

@ -6,7 +6,7 @@
namespace tt::string { namespace tt::string {
int findLastIndex(const char* text, size_t from_index, char find) { int findLastIndex(const char* text, size_t from_index, char find) {
for (size_t i = from_index; i >= 0; i--) { for (int i = (int)from_index; i >= 0; i--) {
if (text[i] == find) { if (text[i] == find) {
return (int)i; return (int)i;
} }

View File

@ -71,6 +71,7 @@ static void thread_body(void* context) {
Thread::Thread() : Thread::Thread() :
data({ data({
.thread = nullptr,
.taskHandle = nullptr, .taskHandle = nullptr,
.state = StateStopped, .state = StateStopped,
.callback = nullptr, .callback = nullptr,
@ -90,6 +91,7 @@ Thread::Thread(
Callback callback, Callback callback,
_Nullable void* callbackContext) : _Nullable void* callbackContext) :
data({ data({
.thread = nullptr,
.taskHandle = nullptr, .taskHandle = nullptr,
.state = StateStopped, .state = StateStopped,
.callback = callback, .callback = callback,

View File

@ -5,8 +5,6 @@
namespace tt::file { namespace tt::file {
#define TAG "file"
long getSize(FILE* file); long getSize(FILE* file);
std::unique_ptr<uint8_t[]> readBinary(const char* filepath, size_t& outSize); std::unique_ptr<uint8_t[]> readBinary(const char* filepath, size_t& outSize);

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -21,6 +21,10 @@ if (DEFINED ENV{ESP_IDF_VERSION})
endif() endif()
add_definitions(-DESP_PLATFORM) add_definitions(-DESP_PLATFORM)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${COMPONENT_LIB} PUBLIC -Wno-unused-variable)
endif()
else() else()
file(GLOB_RECURSE SOURCES "Source/*.c*") file(GLOB_RECURSE SOURCES "Source/*.c*")
file(GLOB_RECURSE HEADERS "Source/*.h*") file(GLOB_RECURSE HEADERS "Source/*.h*")

View File

@ -12,7 +12,6 @@
namespace tt::service::sdcard { namespace tt::service::sdcard {
static int32_t sdcard_task(void* context);
extern const ServiceManifest manifest; extern const ServiceManifest manifest;
struct ServiceData { struct ServiceData {

View File

@ -820,11 +820,39 @@ static void dispatchDisconnectButKeepActive(std::shared_ptr<void> context) {
.sta = { .sta = {
.ssid = {0}, .ssid = {0},
.password = {0}, .password = {0},
.scan_method = WIFI_ALL_CHANNEL_SCAN,
.bssid_set = false,
.bssid = { 0 },
.channel = 0,
.listen_interval = 0,
.sort_method = WIFI_CONNECT_AP_BY_SIGNAL,
.threshold = { .threshold = {
.rssi = 0, .rssi = 0,
.authmode = WIFI_AUTH_OPEN, .authmode = WIFI_AUTH_OPEN,
}, },
.pmf_cfg = {
.capable = false,
.required = false,
},
.rm_enabled = false,
.btm_enabled = false,
.mbo_enabled = false,
.ft_enabled = false,
.owe_enabled = false,
.transition_disable = false,
.reserved = 0,
.sae_pwe_h2e = WPA3_SAE_PWE_UNSPECIFIED, .sae_pwe_h2e = WPA3_SAE_PWE_UNSPECIFIED,
.sae_pk_mode = WPA3_SAE_PK_MODE_AUTOMATIC,
.failure_retry_cnt = 0,
.he_dcm_set = false,
.he_dcm_max_constellation_tx = false,
.he_dcm_max_constellation_rx = false,
.he_mcs9_enabled = false,
.he_su_beamformee_disabled = false,
.he_trig_su_bmforming_feedback_disabled = false,
.he_trig_mu_bmforming_partial_feedback_disabled = false,
.he_trig_cqi_feedback_disabled = false,
.he_reserved = 0,
.sae_h2e_identifier = {0}, .sae_h2e_identifier = {0},
}, },
}; };

View File

@ -90,6 +90,8 @@ bool save(const WifiApSettings* settings) {
} }
WifiApSettings encrypted_settings = { WifiApSettings encrypted_settings = {
.ssid = { 0 },
.password = { 0 },
.auto_connect = settings->auto_connect, .auto_connect = settings->auto_connect,
}; };
strcpy((char*)encrypted_settings.ssid, settings->ssid); strcpy((char*)encrypted_settings.ssid, settings->ssid);