mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-19 23:15:05 +00:00
Cleanup/improvements of Boot.cpp
This commit is contained in:
parent
470e65e90f
commit
c809cea6c8
@ -24,26 +24,20 @@
|
|||||||
|
|
||||||
namespace tt::app::boot {
|
namespace tt::app::boot {
|
||||||
|
|
||||||
static std::shared_ptr<tt::hal::display::DisplayDevice> getHalDisplay() {
|
static std::shared_ptr<hal::display::DisplayDevice> getHalDisplay() {
|
||||||
return hal::findFirstDevice<hal::display::DisplayDevice>(hal::Device::Type::Display);
|
return hal::findFirstDevice<hal::display::DisplayDevice>(hal::Device::Type::Display);
|
||||||
}
|
}
|
||||||
|
|
||||||
class BootApp : public App {
|
class BootApp : public App {
|
||||||
|
|
||||||
private:
|
Thread thread = Thread("boot", 4096, [] { return bootThreadCallback(); });
|
||||||
|
|
||||||
Thread thread = Thread("boot", 4096, [this]() { return bootThreadCallback(); });
|
static void setupDisplay() {
|
||||||
|
const auto hal_display = getHalDisplay();
|
||||||
int32_t bootThreadCallback() {
|
|
||||||
TickType_t start_time = kernel::getTicks();
|
|
||||||
|
|
||||||
kernel::publishSystemEvent(kernel::SystemEvent::BootSplash);
|
|
||||||
|
|
||||||
auto hal_display = getHalDisplay();
|
|
||||||
assert(hal_display != nullptr);
|
assert(hal_display != nullptr);
|
||||||
if (hal_display->supportsBacklightDuty()) {
|
if (hal_display->supportsBacklightDuty()) {
|
||||||
uint8_t backlight_duty = 200;
|
uint8_t backlight_duty = 200;
|
||||||
app::display::getBacklightDuty(backlight_duty);
|
display::getBacklightDuty(backlight_duty);
|
||||||
TT_LOG_I(TAG, "backlight %du", backlight_duty);
|
TT_LOG_I(TAG, "backlight %du", backlight_duty);
|
||||||
hal_display->setBacklightDuty(backlight_duty);
|
hal_display->setBacklightDuty(backlight_duty);
|
||||||
} else {
|
} else {
|
||||||
@ -52,27 +46,45 @@ private:
|
|||||||
|
|
||||||
if (hal_display->getGammaCurveCount() > 0) {
|
if (hal_display->getGammaCurveCount() > 0) {
|
||||||
uint8_t gamma_curve;
|
uint8_t gamma_curve;
|
||||||
if (app::display::getGammaCurve(gamma_curve)) {
|
if (display::getGammaCurve(gamma_curve)) {
|
||||||
hal_display->setGammaCurve(gamma_curve);
|
hal_display->setGammaCurve(gamma_curve);
|
||||||
TT_LOG_I(TAG, "gamma %du", gamma_curve);
|
TT_LOG_I(TAG, "gamma %du", gamma_curve);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (hal::usb::isUsbBootMode()) {
|
static bool setupUsbBootMode() {
|
||||||
TT_LOG_I(TAG, "Rebooting into mass storage device mode");
|
if (!hal::usb::isUsbBootMode()) {
|
||||||
hal::usb::resetUsbBootMode();
|
return false;
|
||||||
hal::usb::startMassStorageWithSdmmc();
|
}
|
||||||
} else {
|
|
||||||
|
TT_LOG_I(TAG, "Rebooting into mass storage device mode");
|
||||||
|
hal::usb::resetUsbBootMode();
|
||||||
|
hal::usb::startMassStorageWithSdmmc();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void waitForMinimalSplashDuration(TickType_t startTime) {
|
||||||
|
const auto end_time = kernel::getTicks();
|
||||||
|
const auto ticks_passed = end_time - startTime;
|
||||||
|
constexpr auto minimum_ticks = (CONFIG_TT_SPLASH_DURATION / portTICK_PERIOD_MS);
|
||||||
|
if (minimum_ticks > ticks_passed) {
|
||||||
|
kernel::delayTicks(minimum_ticks - ticks_passed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t bootThreadCallback() {
|
||||||
|
const auto start_time = kernel::getTicks();
|
||||||
|
|
||||||
|
kernel::publishSystemEvent(kernel::SystemEvent::BootSplash);
|
||||||
|
|
||||||
|
setupDisplay();
|
||||||
|
|
||||||
|
if (!setupUsbBootMode()) {
|
||||||
initFromBootApp();
|
initFromBootApp();
|
||||||
|
waitForMinimalSplashDuration(start_time);
|
||||||
TickType_t end_time = tt::kernel::getTicks();
|
service::loader::stopApp();
|
||||||
TickType_t ticks_passed = end_time - start_time;
|
|
||||||
TickType_t minimum_ticks = (CONFIG_TT_SPLASH_DURATION / portTICK_PERIOD_MS);
|
|
||||||
if (minimum_ticks > ticks_passed) {
|
|
||||||
kernel::delayTicks(minimum_ticks - ticks_passed);
|
|
||||||
}
|
|
||||||
|
|
||||||
tt::service::loader::stopApp();
|
|
||||||
startNextApp();
|
startNextApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,16 +93,15 @@ private:
|
|||||||
|
|
||||||
static void startNextApp() {
|
static void startNextApp() {
|
||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
esp_reset_reason_t reason = esp_reset_reason();
|
if (esp_reset_reason() == ESP_RST_PANIC) {
|
||||||
if (reason == ESP_RST_PANIC) {
|
crashdiagnostics::start();
|
||||||
app::crashdiagnostics::start();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto* config = tt::getConfiguration();
|
const auto* config = getConfiguration();
|
||||||
assert(!config->launcherAppId.empty());
|
assert(!config->launcherAppId.empty());
|
||||||
tt::service::loader::startApp(config->launcherAppId);
|
service::loader::startApp(config->launcherAppId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -99,9 +110,9 @@ public:
|
|||||||
auto* image = lv_image_create(parent);
|
auto* image = lv_image_create(parent);
|
||||||
lv_obj_set_size(image, LV_PCT(100), LV_PCT(100));
|
lv_obj_set_size(image, LV_PCT(100), LV_PCT(100));
|
||||||
|
|
||||||
auto paths = app.getPaths();
|
const auto paths = app.getPaths();
|
||||||
const char* logo = hal::usb::isUsbBootMode() ? "logo_usb.png" : "logo.png";
|
const char* logo = hal::usb::isUsbBootMode() ? "logo_usb.png" : "logo.png";
|
||||||
auto logo_path = paths->getSystemPathLvgl(logo);
|
const auto logo_path = paths->getSystemPathLvgl(logo);
|
||||||
TT_LOG_I(TAG, "%s", logo_path.c_str());
|
TT_LOG_I(TAG, "%s", logo_path.c_str());
|
||||||
lv_image_set_src(image, logo_path.c_str());
|
lv_image_set_src(image, logo_path.c_str());
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user