* SdCard HAL refactored (#135) - Refactor SdCard HAL - introduce Lockable * Screenshot and FatFS improvements (#136) - Fix screenshots on ESP32 - Improve Screenshot service - Convert Screenshot app to class-based instead of structs - Screenshot app now automatically updates when task is finished - Enable FatFS long filename support * Re-use common log messages (#138) For consistency and binary size reduction * Toolbar spinner should get margin to the right * More TactilityC features (#139) * Rewrote Loader - Simplified Loader by removing custom threa - Created DispatcherThread - Move auto-starting apps to Boot app - Fixed Dispatcher bug where it could get stuck not processing new messages * Hide AP settings if the AP is not saved * Missing from previous commit * Replace LV_EVENT_CLICKED with LV_EVENT_SHORT_CLICKED * Refactored files app and created InputDialog (#140) - Changed Files app so that it has a View and State - Files app now allows for long-pressing on files to perform actions - Files app now has rename and delete actions - Created InputDialog app - Improved AlertDialog app layout
113 lines
2.8 KiB
C++
113 lines
2.8 KiB
C++
#include "Assets.h"
|
|
#include "TactilityCore.h"
|
|
|
|
#include "app/AppContext.h"
|
|
#include "app/display/DisplaySettings.h"
|
|
#include "hal/Display.h"
|
|
#include "service/loader/Loader.h"
|
|
#include "lvgl/Style.h"
|
|
|
|
#include "lvgl.h"
|
|
#include "Tactility.h"
|
|
|
|
#ifdef ESP_PLATFORM
|
|
#include "kernel/PanicHandler.h"
|
|
#include "sdkconfig.h"
|
|
#else
|
|
#define CONFIG_TT_SPLASH_DURATION 0
|
|
#endif
|
|
|
|
#define TAG "Boot"
|
|
|
|
namespace tt::app::boot {
|
|
|
|
static int32_t bootThreadCallback(void* context);
|
|
static void startNextApp();
|
|
|
|
struct Data {
|
|
Data() : thread("boot", 4096, bootThreadCallback, this) {}
|
|
|
|
Thread thread;
|
|
};
|
|
|
|
static int32_t bootThreadCallback(TT_UNUSED void* context) {
|
|
TickType_t start_time = tt::kernel::getTicks();
|
|
|
|
auto* lvgl_display = lv_display_get_default();
|
|
tt_assert(lvgl_display != nullptr);
|
|
auto* hal_display = (tt::hal::Display*)lv_display_get_user_data(lvgl_display);
|
|
tt_assert(hal_display != nullptr);
|
|
if (hal_display->supportsBacklightDuty()) {
|
|
int32_t backlight_duty = app::display::getBacklightDuty();
|
|
hal_display->setBacklightDuty(backlight_duty);
|
|
}
|
|
|
|
TickType_t end_time = tt::kernel::getTicks();
|
|
TickType_t ticks_passed = end_time - start_time;
|
|
TickType_t minimum_ticks = (CONFIG_TT_SPLASH_DURATION / portTICK_PERIOD_MS);
|
|
if (minimum_ticks > ticks_passed) {
|
|
tt::kernel::delayTicks(minimum_ticks - ticks_passed);
|
|
}
|
|
|
|
tt::service::loader::stopApp();
|
|
|
|
|
|
startNextApp();
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void startNextApp() {
|
|
auto config = tt::getConfiguration();
|
|
std::string next_app;
|
|
if (config->autoStartAppId) {
|
|
TT_LOG_I(TAG, "init auto-starting %s", config->autoStartAppId);
|
|
next_app = config->autoStartAppId;
|
|
} else {
|
|
next_app = "Desktop";
|
|
}
|
|
|
|
#ifdef ESP_PLATFORM
|
|
esp_reset_reason_t reason = esp_reset_reason();
|
|
if (reason == ESP_RST_PANIC) {
|
|
tt::service::loader::startApp("CrashDiagnostics");
|
|
} else {
|
|
tt::service::loader::startApp(next_app);
|
|
}
|
|
#else
|
|
tt::service::loader::startApp(next_app);
|
|
#endif
|
|
}
|
|
|
|
static void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) {
|
|
auto data = std::static_pointer_cast<Data>(app.getData());
|
|
|
|
lv_obj_t* image = lv_image_create(parent);
|
|
lv_obj_set_size(image, LV_PCT(100), LV_PCT(100));
|
|
lv_image_set_src(image, TT_ASSETS_BOOT_LOGO);
|
|
lvgl::obj_set_style_bg_blacken(parent);
|
|
|
|
data->thread.start();
|
|
}
|
|
|
|
static void onStart(AppContext& app) {
|
|
auto data = std::make_shared<Data>();
|
|
app.setData(data);
|
|
}
|
|
|
|
static void onStop(AppContext& app) {
|
|
auto data = std::static_pointer_cast<Data>(app.getData());
|
|
data->thread.join();
|
|
}
|
|
|
|
extern const AppManifest manifest = {
|
|
.id = "Boot",
|
|
.name = "Boot",
|
|
.type = TypeBoot,
|
|
.onStart = onStart,
|
|
.onStop = onStop,
|
|
.onShow = onShow,
|
|
};
|
|
|
|
} // namespace
|