Fixes and improvements (#185)

- unPhone improvements related to power and boot (add boot count logging)
- Cleanup of Mutex acquire/release
- Removed `tt_assert()` in favour of `assert()`
- Fix sim build (likely failed due to migration of GitHub Actions to Ubuntu 24.04)
This commit is contained in:
Ken Van Hoeylandt
2025-01-24 22:49:29 +01:00
committed by GitHub
parent 3be251d8fb
commit d86dc40472
47 changed files with 223 additions and 177 deletions
+8 -8
View File
@@ -66,7 +66,7 @@ Gui* gui_alloc() {
}
void gui_free(Gui* instance) {
tt_assert(instance != nullptr);
assert(instance != nullptr);
delete instance->thread;
lv_group_delete(instance->keyboardGroup);
@@ -78,17 +78,17 @@ void gui_free(Gui* instance) {
}
void lock() {
tt_assert(gui);
tt_check(gui->mutex.acquire(configTICK_RATE_HZ) == TtStatusOk);
assert(gui);
tt_check(gui->mutex.lock(configTICK_RATE_HZ));
}
void unlock() {
tt_assert(gui);
tt_check(gui->mutex.release() == TtStatusOk);
assert(gui);
tt_check(gui->mutex.unlock());
}
void requestDraw() {
tt_assert(gui);
assert(gui);
ThreadId thread_id = gui->thread->getId();
thread_flags_set(thread_id, GUI_THREAD_FLAG_DRAW);
}
@@ -147,7 +147,7 @@ class GuiService : public Service {
public:
void onStart(TT_UNUSED ServiceContext& service) override {
tt_assert(gui == nullptr);
assert(gui == nullptr);
gui = gui_alloc();
gui->thread->setPriority(THREAD_PRIORITY_SERVICE);
@@ -155,7 +155,7 @@ public:
}
void onStop(TT_UNUSED ServiceContext& service) override {
tt_assert(gui != nullptr);
assert(gui != nullptr);
lock();
ThreadId thread_id = gui->thread->getId();
+1 -1
View File
@@ -27,7 +27,7 @@ static lv_obj_t* createAppViews(Gui* gui, lv_obj_t* parent) {
}
void redraw(Gui* gui) {
tt_assert(gui);
assert(gui);
// Lock GUI and LVGL
lock();
+5 -5
View File
@@ -44,14 +44,14 @@ static Loader* loader_alloc() {
}
static void loader_free() {
tt_assert(loader_singleton != nullptr);
assert(loader_singleton != nullptr);
delete loader_singleton;
loader_singleton = nullptr;
}
void startApp(const std::string& id, std::shared_ptr<const Bundle> parameters) {
TT_LOG_I(TAG, "Start app %s", id.c_str());
tt_assert(loader_singleton);
assert(loader_singleton);
auto message = std::make_shared<LoaderMessageAppStart>(id, std::move(parameters));
loader_singleton->dispatcherThread->dispatch(onStartAppMessage, message);
}
@@ -63,7 +63,7 @@ void stopApp() {
}
std::shared_ptr<app::AppContext> _Nullable getCurrentAppContext() {
tt_assert(loader_singleton);
assert(loader_singleton);
if (loader_singleton->mutex.lock(10 / portTICK_PERIOD_MS)) {
auto app = loader_singleton->appStack.top();
loader_singleton->mutex.unlock();
@@ -79,7 +79,7 @@ std::shared_ptr<app::App> _Nullable getCurrentApp() {
}
std::shared_ptr<PubSub> getPubsub() {
tt_assert(loader_singleton);
assert(loader_singleton);
// it's safe to return pubsub without locking
// because it's never freed and loader is never exited
// also the loader instance cannot be obtained until the pubsub is created
@@ -256,7 +256,7 @@ static void stopAppInternal() {
// If there's a previous app, resume it
if (!loader_singleton->appStack.empty()) {
instance_to_resume = loader_singleton->appStack.top();
tt_assert(instance_to_resume);
assert(instance_to_resume);
transitionAppToState(instance_to_resume, app::StateShowing);
}