Merge develop into main (#304)
## New - Read property files with `PropertiesFile` - Support `boot.properties` so the user can specify the launcher app and an optional app to start after the launcher finishes. (see `BootProperties.cpp`) - Create registry for CPU affinity and update code to make use of it - `AppRegistration` and `ServiceRegistration` now also ensure that the `/data` directories always exist for all apps - `Notes` is now the default app for opening text files. `TextViewer` is removed entirely. Created `tt::app::notes::start(path)` function. - WiFi settings moved from NVS to properties file. - Specify `*.ap.properties` file on the SD card for automatic WiFi settings import on start-up. - Added `file::getLock(path)` and `file::withLock(path, function)` to do safe file operations on SD cards ## Improvements - Update TinyUSB to `1.7.6~1` - Improved `Boot.cpp` code. General code quality fixes and some restructuring to improve readability. - `tt::string` functionality improvements - Rename `AppRegistry` to `AppRegistration` - Rename `ServiceRegistry` to `ServiceRegistration` - Cleanup in `Notes.cpp` - `FileTest.cpp` fix for PC - Created `TestFile` helper class for tests, which automatically deletes files after the test. - Renamed `Partitions.h` to `MountPoints.h` - Created `std::string getMountPoints()` function for easy re-use - Other code quality improvements - `SdCardDevice`'s `getState()` and `isMounted()` now have a timeout argument ## Fixes - ELF loading now has a lock so to avoid a bug when 2 ELF apps are loaded in parallel
This commit is contained in:
committed by
GitHub
parent
fbaff8cbac
commit
ee5a5a7181
@@ -11,6 +11,8 @@
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <Tactility/BootProperties.h>
|
||||
#include <Tactility/CpuAffinity.h>
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "Tactility/app/crashdiagnostics/CrashDiagnostics.h"
|
||||
@@ -24,26 +26,25 @@
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
class BootApp : public App {
|
||||
|
||||
private:
|
||||
Thread thread = Thread(
|
||||
"boot",
|
||||
4096,
|
||||
[] { return bootThreadCallback(); },
|
||||
getCpuAffinityConfiguration().system
|
||||
);
|
||||
|
||||
Thread thread = Thread("boot", 4096, [this]() { return bootThreadCallback(); });
|
||||
|
||||
int32_t bootThreadCallback() {
|
||||
TickType_t start_time = kernel::getTicks();
|
||||
|
||||
kernel::publishSystemEvent(kernel::SystemEvent::BootSplash);
|
||||
|
||||
auto hal_display = getHalDisplay();
|
||||
static void setupDisplay() {
|
||||
const auto hal_display = getHalDisplay();
|
||||
assert(hal_display != nullptr);
|
||||
if (hal_display->supportsBacklightDuty()) {
|
||||
uint8_t backlight_duty = 200;
|
||||
app::display::getBacklightDuty(backlight_duty);
|
||||
display::getBacklightDuty(backlight_duty);
|
||||
TT_LOG_I(TAG, "backlight %du", backlight_duty);
|
||||
hal_display->setBacklightDuty(backlight_duty);
|
||||
} else {
|
||||
@@ -52,27 +53,45 @@ private:
|
||||
|
||||
if (hal_display->getGammaCurveCount() > 0) {
|
||||
uint8_t gamma_curve;
|
||||
if (app::display::getGammaCurve(gamma_curve)) {
|
||||
if (display::getGammaCurve(gamma_curve)) {
|
||||
hal_display->setGammaCurve(gamma_curve);
|
||||
TT_LOG_I(TAG, "gamma %du", gamma_curve);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hal::usb::isUsbBootMode()) {
|
||||
TT_LOG_I(TAG, "Rebooting into mass storage device mode");
|
||||
hal::usb::resetUsbBootMode();
|
||||
hal::usb::startMassStorageWithSdmmc();
|
||||
} else {
|
||||
static bool setupUsbBootMode() {
|
||||
if (!hal::usb::isUsbBootMode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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) {
|
||||
kernel::delayTicks(minimum_ticks - ticks_passed);
|
||||
}
|
||||
|
||||
tt::service::loader::stopApp();
|
||||
waitForMinimalSplashDuration(start_time);
|
||||
service::loader::stopApp();
|
||||
startNextApp();
|
||||
}
|
||||
|
||||
@@ -81,16 +100,20 @@ private:
|
||||
|
||||
static void startNextApp() {
|
||||
#ifdef ESP_PLATFORM
|
||||
esp_reset_reason_t reason = esp_reset_reason();
|
||||
if (reason == ESP_RST_PANIC) {
|
||||
app::crashdiagnostics::start();
|
||||
if (esp_reset_reason() == ESP_RST_PANIC) {
|
||||
crashdiagnostics::start();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
auto* config = tt::getConfiguration();
|
||||
assert(!config->launcherAppId.empty());
|
||||
tt::service::loader::startApp(config->launcherAppId);
|
||||
BootProperties boot_properties;
|
||||
if (!loadBootProperties(boot_properties) || boot_properties.launcherAppId.empty()) {
|
||||
TT_LOG_E(TAG, "Launcher not configured");
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
service::loader::startApp(boot_properties.launcherAppId);
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -99,9 +122,9 @@ public:
|
||||
auto* image = lv_image_create(parent);
|
||||
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";
|
||||
auto logo_path = paths->getSystemPathLvgl(logo);
|
||||
const auto logo_path = paths->getSystemPathLvgl(logo);
|
||||
TT_LOG_I(TAG, "%s", logo_path.c_str());
|
||||
lv_image_set_src(image, logo_path.c_str());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user