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
30 changed files with 506 additions and 127 deletions
+5 -10
View File
@@ -27,8 +27,7 @@ void loader_callback(const void* message, TT_UNUSED void* context) {
}
Gui* gui_alloc() {
auto* instance = static_cast<Gui*>(malloc(sizeof(Gui)));
memset(instance, 0, sizeof(Gui));
auto* instance = new Gui();
tt_check(instance != nullptr);
instance->thread = new Thread(
"gui",
@@ -36,8 +35,6 @@ Gui* gui_alloc() {
&gui_main,
nullptr
);
instance->mutex = tt_mutex_alloc(Mutex::TypeRecursive);
instance->keyboard = nullptr;
instance->loader_pubsub_subscription = tt_pubsub_subscribe(loader::getPubsub(), &loader_callback, instance);
tt_check(lvgl::lock(1000 / portTICK_PERIOD_MS));
instance->keyboard_group = lv_group_create();
@@ -50,25 +47,23 @@ Gui* gui_alloc() {
void gui_free(Gui* instance) {
tt_assert(instance != nullptr);
delete instance->thread;
tt_mutex_free(instance->mutex);
lv_group_delete(instance->keyboard_group);
tt_check(lvgl::lock(1000 / portTICK_PERIOD_MS));
lv_group_del(instance->keyboard_group);
lvgl::unlock();
free(instance);
delete instance;
}
void lock() {
tt_assert(gui);
tt_assert(gui->mutex);
tt_check(tt_mutex_acquire(gui->mutex, configTICK_RATE_HZ) == TtStatusOk);
tt_check(gui->mutex.acquire(configTICK_RATE_HZ) == TtStatusOk);
}
void unlock() {
tt_assert(gui);
tt_assert(gui->mutex);
tt_check(tt_mutex_release(gui->mutex) == TtStatusOk);
tt_check(gui->mutex.release() == TtStatusOk);
}
void requestDraw() {
@@ -6,7 +6,6 @@
#include "ScreenshotTask.h"
#include "service/ServiceContext.h"
#include "service/ServiceRegistry.h"
#include "TactilityCore.h"
namespace tt::service::screenshot {
@@ -17,36 +17,31 @@ namespace tt::service::screenshot::task {
#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 {
Thread* thread;
Mutex* mutex;
bool interrupted;
struct ScreenshotTaskWork {
int type = TASK_WORK_TYPE_DELAY ;
uint8_t delay_in_seconds = 0;
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;
} ScreenshotTaskData;
};
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) {
tt_check(tt_mutex_release(data->mutex) == TtStatusOk);
tt_check(data->mutex.release() == TtStatusOk);
}
ScreenshotTask* alloc() {
auto* data = static_cast<ScreenshotTaskData*>(malloc(sizeof(ScreenshotTaskData)));
*data = (ScreenshotTaskData) {
.thread = nullptr,
.mutex = tt_mutex_alloc(Mutex::TypeRecursive),
.interrupted = false
};
return data;
return new ScreenshotTaskData();
}
void free(ScreenshotTask* task) {
@@ -54,6 +49,7 @@ void free(ScreenshotTask* task) {
if (data->thread) {
stop(data);
}
delete data;
}
static bool is_interrupted(ScreenshotTaskData* data) {