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:
committed by
GitHub
parent
3be251d8fb
commit
d86dc40472
@@ -135,7 +135,7 @@ static void register_and_start_user_services(const std::vector<const service::Se
|
||||
void run(const Configuration& config) {
|
||||
TT_LOG_D(TAG, "run");
|
||||
|
||||
tt_assert(config.hardware);
|
||||
assert(config.hardware);
|
||||
const hal::Configuration& hardware = *config.hardware;
|
||||
|
||||
// Assign early so starting services can use it
|
||||
|
||||
@@ -25,7 +25,7 @@ State AppInstance::getState() const {
|
||||
* Consider not exposing bundle, but expose `app_get_bundle_int(key)` methods with locking in it.
|
||||
*/
|
||||
const AppManifest& AppInstance::getManifest() const {
|
||||
tt_assert(manifest != nullptr);
|
||||
assert(manifest != nullptr);
|
||||
return *manifest;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ std::shared_ptr<const Bundle> AppInstance::getParameters() const {
|
||||
}
|
||||
|
||||
std::unique_ptr<Paths> AppInstance::getPaths() const {
|
||||
tt_assert(manifest != nullptr);
|
||||
assert(manifest != nullptr);
|
||||
return std::make_unique<AppInstancePaths>(*manifest);
|
||||
}
|
||||
|
||||
|
||||
@@ -188,8 +188,8 @@ bool registerElfApp(const std::string& filePath) {
|
||||
|
||||
std::shared_ptr<App> createElfApp(const std::shared_ptr<AppManifest>& manifest) {
|
||||
TT_LOG_I(TAG, "createElfApp");
|
||||
tt_assert(manifest != nullptr);
|
||||
tt_assert(manifest->location.isExternal());
|
||||
assert(manifest != nullptr);
|
||||
assert(manifest->location.isExternal());
|
||||
return std::make_shared<ElfApp>(manifest->location.getPath());
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
|
||||
static void onButtonClickedCallback(lv_event_t* e) {
|
||||
auto appContext = service::loader::getCurrentAppContext();
|
||||
tt_assert(appContext != nullptr);
|
||||
assert(appContext != nullptr);
|
||||
auto app = std::static_pointer_cast<AlertDialogApp>(appContext->getApp());
|
||||
app->onButtonClicked(e);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ private:
|
||||
kernel::systemEventPublish(kernel::SystemEvent::BootSplash);
|
||||
|
||||
auto* lvgl_display = lv_display_get_default();
|
||||
tt_assert(lvgl_display != nullptr);
|
||||
assert(lvgl_display != nullptr);
|
||||
auto* hal_display = (hal::Display*)lv_display_get_user_data(lvgl_display);
|
||||
tt_assert(hal_display != nullptr);
|
||||
assert(hal_display != nullptr);
|
||||
if (hal_display->supportsBacklightDuty()) {
|
||||
int32_t backlight_duty = app::display::getBacklightDuty();
|
||||
hal_display->setBacklightDuty(backlight_duty);
|
||||
|
||||
@@ -24,9 +24,9 @@ static uint8_t gamma = 255;
|
||||
static void onBacklightSliderEvent(lv_event_t* event) {
|
||||
auto* slider = static_cast<lv_obj_t*>(lv_event_get_target(event));
|
||||
auto* lvgl_display = lv_display_get_default();
|
||||
tt_assert(lvgl_display != nullptr);
|
||||
assert(lvgl_display != nullptr);
|
||||
auto* hal_display = (tt::hal::Display*)lv_display_get_user_data(lvgl_display);
|
||||
tt_assert(hal_display != nullptr);
|
||||
assert(hal_display != nullptr);
|
||||
|
||||
if (hal_display->supportsBacklightDuty()) {
|
||||
int32_t slider_value = lv_slider_get_value(slider);
|
||||
@@ -41,9 +41,9 @@ static void onBacklightSliderEvent(lv_event_t* event) {
|
||||
static void onGammaSliderEvent(lv_event_t* event) {
|
||||
auto* slider = static_cast<lv_obj_t*>(lv_event_get_target(event));
|
||||
auto* lvgl_display = lv_display_get_default();
|
||||
tt_assert(lvgl_display != nullptr);
|
||||
assert(lvgl_display != nullptr);
|
||||
auto* hal_display = (tt::hal::Display*)lv_display_get_user_data(lvgl_display);
|
||||
tt_assert(hal_display != nullptr);
|
||||
assert(hal_display != nullptr);
|
||||
|
||||
if (hal_display->getGammaCurveCount() > 0) {
|
||||
int32_t slider_value = lv_slider_get_value(slider);
|
||||
@@ -57,9 +57,9 @@ static void onGammaSliderEvent(lv_event_t* event) {
|
||||
|
||||
static tt::hal::Display* getHalDisplay(lv_obj_t* widget) {
|
||||
auto* lvgl_display = lv_obj_get_display(widget);
|
||||
tt_assert(lvgl_display != nullptr);
|
||||
assert(lvgl_display != nullptr);
|
||||
auto* hal_display = (tt::hal::Display*)lv_display_get_user_data(lvgl_display);
|
||||
tt_assert(hal_display != nullptr);
|
||||
assert(hal_display != nullptr);
|
||||
return hal_display;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ class DisplayApp : public App {
|
||||
lv_obj_add_event_cb(gamma_slider, onGammaSliderEvent, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
|
||||
auto* hal_display = getHalDisplay(parent);
|
||||
tt_assert(hal_display != nullptr);
|
||||
assert(hal_display != nullptr);
|
||||
|
||||
if (!hal_display->supportsBacklightDuty()) {
|
||||
lv_slider_set_value(brightness_slider, 255, LV_ANIM_OFF);
|
||||
|
||||
@@ -101,7 +101,7 @@ void GpioApp::onTimer(TT_UNUSED std::shared_ptr<void> context) {
|
||||
|
||||
void GpioApp::startTask() {
|
||||
lock();
|
||||
tt_assert(timer == nullptr);
|
||||
assert(timer == nullptr);
|
||||
timer = std::make_unique<Timer>(
|
||||
Timer::Type::Periodic,
|
||||
&onTimer
|
||||
@@ -111,7 +111,7 @@ void GpioApp::startTask() {
|
||||
}
|
||||
|
||||
void GpioApp::stopTask() {
|
||||
tt_assert(timer);
|
||||
assert(timer);
|
||||
|
||||
timer->stop();
|
||||
timer = nullptr;
|
||||
|
||||
@@ -160,7 +160,7 @@ void I2cScannerApp::onScanTimerCallback(TT_UNUSED std::shared_ptr<void> context)
|
||||
bool I2cScannerApp::getPort(i2c_port_t* outPort) {
|
||||
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
|
||||
*outPort = this->port;
|
||||
tt_assert(mutex.release() == TtStatusOk);
|
||||
assert(mutex.release() == TtStatusOk);
|
||||
return true;
|
||||
} else {
|
||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "getPort");
|
||||
@@ -171,7 +171,7 @@ bool I2cScannerApp::getPort(i2c_port_t* outPort) {
|
||||
bool I2cScannerApp::addAddressToList(uint8_t address) {
|
||||
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
|
||||
scannedAddresses.push_back(address);
|
||||
tt_assert(mutex.release() == TtStatusOk);
|
||||
assert(mutex.release() == TtStatusOk);
|
||||
return true;
|
||||
} else {
|
||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "addAddressToList");
|
||||
@@ -257,7 +257,7 @@ void I2cScannerApp::startScanning() {
|
||||
}
|
||||
void I2cScannerApp::stopScanning() {
|
||||
if (mutex.acquire(250 / portTICK_PERIOD_MS) == TtStatusOk) {
|
||||
tt_assert(scanTimer != nullptr);
|
||||
assert(scanTimer != nullptr);
|
||||
scanState = ScanStateStopped;
|
||||
tt_check(mutex.release() == TtStatusOk);
|
||||
} else {
|
||||
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
|
||||
static void onButtonClickedCallback(lv_event_t* e) {
|
||||
auto appContext = service::loader::getCurrentAppContext();
|
||||
tt_assert(appContext != nullptr);
|
||||
assert(appContext != nullptr);
|
||||
auto app = std::static_pointer_cast<InputDialogApp>(appContext->getApp());
|
||||
app->onButtonClicked(e);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ private:
|
||||
|
||||
static void onListItemSelectedCallback(lv_event_t* e) {
|
||||
auto appContext = service::loader::getCurrentAppContext();
|
||||
tt_assert(appContext != nullptr);
|
||||
assert(appContext != nullptr);
|
||||
auto app = std::static_pointer_cast<SelectionDialogApp>(appContext->getApp());
|
||||
app->onListItemSelected(e);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ bool initDisplay(const hal::Configuration& config) {
|
||||
}
|
||||
|
||||
lv_display_t* lvgl_display = display->getLvglDisplay();
|
||||
tt_assert(lvgl_display);
|
||||
assert(lvgl_display);
|
||||
|
||||
if (display->supportsBacklightDuty()) {
|
||||
display->setBacklightDuty(0);
|
||||
@@ -30,7 +30,7 @@ bool initDisplay(const hal::Configuration& config) {
|
||||
void* existing_display_user_data = lv_display_get_user_data(lvgl_display);
|
||||
// esp_lvgl_port users user_data by default, so we have to modify the source
|
||||
// this is a check for when we upgrade esp_lvgl_port and forget to modify it again
|
||||
tt_assert(existing_display_user_data == nullptr);
|
||||
assert(existing_display_user_data == nullptr);
|
||||
lv_display_set_user_data(lvgl_display, display);
|
||||
|
||||
lv_display_rotation_t rotation = app::display::getRotation();
|
||||
@@ -43,8 +43,8 @@ bool initDisplay(const hal::Configuration& config) {
|
||||
|
||||
bool initTouch(hal::Display* display, hal::Touch* touch) {
|
||||
TT_LOG_I(TAG, "Touch init");
|
||||
tt_assert(display);
|
||||
tt_assert(touch);
|
||||
assert(display);
|
||||
assert(touch);
|
||||
if (touch->start(display->getLvglDisplay())) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -55,8 +55,8 @@ bool initTouch(hal::Display* display, hal::Touch* touch) {
|
||||
|
||||
bool initKeyboard(hal::Display* display, hal::Keyboard* keyboard) {
|
||||
TT_LOG_I(TAG, "Keyboard init");
|
||||
tt_assert(display);
|
||||
tt_assert(keyboard);
|
||||
assert(display);
|
||||
assert(keyboard);
|
||||
if (keyboard->isAttached()) {
|
||||
if (keyboard->start(display->getLvglDisplay())) {
|
||||
lv_indev_t* keyboard_indev = keyboard->getLvglIndev();
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace tt::lvgl {
|
||||
|
||||
hal::Display* getDisplay() {
|
||||
auto* lvgl_display = lv_display_get_default();
|
||||
tt_assert(lvgl_display != nullptr);
|
||||
assert(lvgl_display != nullptr);
|
||||
auto* hal_display = (tt::hal::Display*)lv_display_get_user_data(lvgl_display);
|
||||
tt_assert(hal_display != nullptr);
|
||||
assert(hal_display != nullptr);
|
||||
return hal_display;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user