Various improvements (#461)

* **New Features**
  * Time and delay utilities added (ticks, ms, µs); SD card now uses an expansion-header CS pin; HTTP downloads warn when run on the GUI task and yield to avoid blocking.

* **Bug Fixes / Reliability**
  * Many hard-crash paths converted to guarded checks to reduce abrupt termination and improve stability.

* **Tests**
  * Unit tests added to validate time and delay accuracy.

* **Chores**
  * License header and build/macro updates.
This commit is contained in:
Ken Van Hoeylandt
2026-01-27 08:04:21 +01:00
committed by GitHub
parent 619b5aa53b
commit e6abd496f9
95 changed files with 433 additions and 284 deletions
@@ -95,7 +95,7 @@ public:
void onShow(AppContext& app, lv_obj_t* parent) override {
auto parameters = app.getParameters();
tt_check(parameters != nullptr, "Parameters missing");
check(parameters != nullptr, "Parameters missing");
std::string title = getTitleParameter(app.getParameters());
lv_obj_t* toolbar = lvgl::toolbar_create(parent, title);
@@ -4,9 +4,9 @@
#include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/Check.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/TactilityCore.h>
#include <lvgl.h>
#include <format>
@@ -27,7 +27,7 @@ class AppDetailsApp : public App {
std::shared_ptr<AppManifest> manifest;
static void onPressUninstall(TT_UNUSED lv_event_t* event) {
static void onPressUninstall(lv_event_t* event) {
auto* self = static_cast<AppDetailsApp*>(lv_event_get_user_data(event));
std::vector<std::string> choices = {
"Yes",
@@ -40,7 +40,7 @@ public:
void onCreate(AppContext& app) override {
const auto parameters = app.getParameters();
tt_check(parameters != nullptr, "Parameters missing");
check(parameters != nullptr, "Parameters missing");
auto app_id = parameters->getString("appId");
manifest = findAppManifestById(app_id);
assert(manifest != nullptr);
@@ -86,7 +86,7 @@ public:
}
}
void onResult(TT_UNUSED AppContext& appContext, TT_UNUSED LaunchId launchId, TT_UNUSED Result result, std::unique_ptr<Bundle> bundle) override {
void onResult(AppContext& appContext, LaunchId launchId, Result result, std::unique_ptr<Bundle> bundle) override {
if (result != Result::Ok || bundle == nullptr) {
return;
}
+1 -1
View File
@@ -157,7 +157,7 @@ class AppHubApp final : public App {
public:
void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) override {
void onShow(AppContext& app, lv_obj_t* parent) override {
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
@@ -186,7 +186,7 @@ public:
}
}
void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) override {
void onShow(AppContext& app, lv_obj_t* parent) override {
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
+1 -1
View File
@@ -24,7 +24,7 @@ class AppListApp final : public App {
public:
void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) override {
void onShow(AppContext& app, lv_obj_t* parent) override {
auto* toolbar = lvgl::toolbar_create(parent, app);
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
@@ -25,7 +25,7 @@ class AppSettingsApp final : public App {
public:
void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) override {
void onShow(AppContext& app, lv_obj_t* parent) override {
auto* toolbar = lvgl::toolbar_create(parent, "Installed Apps");
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
+1 -1
View File
@@ -170,7 +170,7 @@ public:
thread.join();
}
void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) override {
void onShow(AppContext& app, lv_obj_t* parent) override {
lvgl::obj_set_style_bg_blacken(parent);
lv_obj_set_style_border_width(parent, 0, LV_STATE_DEFAULT);
lv_obj_set_style_radius(parent, 0, LV_STATE_DEFAULT);
@@ -17,7 +17,7 @@ static const auto LOGGER = Logger("CrashDiagnostics");
extern const AppManifest manifest;
void onContinuePressed(TT_UNUSED lv_event_t* event) {
void onContinuePressed(lv_event_t* event) {
stop(manifest.appId);
launcher::start();
}
+1 -1
View File
@@ -236,7 +236,7 @@ public:
}
}
void onHide(TT_UNUSED AppContext& app) override {
void onHide(AppContext& app) override {
if (displaySettingsUpdated) {
// Dispatch it, so file IO doesn't block the UI
const settings::display::DisplaySettings settings_to_save = displaySettings;
+1 -1
View File
@@ -27,7 +27,7 @@ public:
view->init(appContext, parent);
}
void onResult(AppContext& appContext, TT_UNUSED LaunchId launchId, Result result, std::unique_ptr<Bundle> bundle) override {
void onResult(AppContext& appContext, LaunchId launchId, Result result, std::unique_ptr<Bundle> bundle) override {
view->onResult(launchId, result, std::move(bundle));
}
};
+4 -3
View File
@@ -1,12 +1,13 @@
#include <Tactility/app/files/View.h>
#include <Tactility/app/files/SupportedFiles.h>
#include <Tactility/file/File.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/app/imageviewer/ImageViewer.h>
#include <Tactility/app/inputdialog/InputDialog.h>
#include <Tactility/app/notes/Notes.h>
#include <Tactility/app/ElfApp.h>
#include <Tactility/Check.h>
#include <Tactility/file/File.h>
#include <Tactility/kernel/Platform.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
@@ -58,7 +59,7 @@ static void onDeletePressedCallback(lv_event_t* event) {
view->onDeletePressed();
}
static void onNavigateUpPressedCallback(TT_UNUSED lv_event_t* event) {
static void onNavigateUpPressedCallback(lv_event_t* event) {
auto* view = static_cast<View*>(lv_event_get_user_data(event));
view->onNavigateUpPressed();
}
@@ -179,7 +180,7 @@ void View::onDirEntryLongPressed(int32_t index) {
}
void View::createDirEntryWidget(lv_obj_t* list, dirent& dir_entry) {
tt_check(list);
check(list);
const char* symbol;
if (dir_entry.d_type == file::TT_DT_DIR || dir_entry.d_type == file::TT_DT_CHR) {
symbol = LV_SYMBOL_DIRECTORY;
+3 -2
View File
@@ -1,6 +1,7 @@
#include <Tactility/app/fileselection/View.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/Check.h>
#include <Tactility/file/File.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
@@ -30,7 +31,7 @@ static void onDirEntryPressedCallback(lv_event_t* event) {
view->onDirEntryPressed(index);
}
static void onNavigateUpPressedCallback(TT_UNUSED lv_event_t* event) {
static void onNavigateUpPressedCallback(lv_event_t* event) {
auto* view = static_cast<View*>(lv_event_get_user_data(event));
view->onNavigateUpPressed();
}
@@ -126,7 +127,7 @@ void View::onPathTextChanged(lv_event_t* event) {
}
void View::createDirEntryWidget(lv_obj_t* list, dirent& dir_entry) {
tt_check(list);
check(list);
const char* symbol;
if (dir_entry.d_type == file::TT_DT_DIR || dir_entry.d_type == file::TT_DT_CHR) {
symbol = LV_SYMBOL_DIRECTORY;
@@ -318,7 +318,7 @@ class GpsSettingsApp final : public App {
}
}
void onGpsToggled(TT_UNUSED lv_event_t* event) {
void onGpsToggled(lv_event_t* event) {
bool wants_on = lv_obj_has_state(switchWidget, LV_STATE_CHECKED);
auto state = service->getState();
bool is_on = (state == service::gps::State::On) || (state == service::gps::State::OnPending);
@@ -325,7 +325,7 @@ void I2cScannerApp::selectBus(int32_t selected) {
updateViews();
}
void I2cScannerApp::onPressScan(TT_UNUSED lv_event_t* event) {
void I2cScannerApp::onPressScan(lv_event_t* event) {
if (scanState == ScanStateScanning) {
stopScanning();
} else {
@@ -45,7 +45,7 @@ class ImageViewerApp final : public App {
lv_obj_align_to(file_label, wrapper, LV_ALIGN_BOTTOM_LEFT, 0, 0);
std::shared_ptr<const Bundle> bundle = app.getParameters();
tt_check(bundle != nullptr, "Parameters not set");
check(bundle != nullptr, "Parameters not set");
std::string file_argument;
if (bundle->optString(IMAGE_VIEWER_FILE_ARGUMENT, file_argument)) {
std::string prefixed_path = lvgl::PATH_PREFIX + file_argument;
@@ -79,7 +79,7 @@ public:
void onShow(AppContext& app, lv_obj_t* parent) override {
auto parameters = app.getParameters();
tt_check(parameters != nullptr, "Parameters missing");
check(parameters != nullptr, "Parameters missing");
std::string title = getTitleParameter(app.getParameters());
auto* toolbar = lvgl::toolbar_create(parent, title);
@@ -170,7 +170,7 @@ public:
}
}
void onHide(TT_UNUSED AppContext& app) override {
void onHide(AppContext& app) override {
if (updated) {
const auto copy = kbSettings;
getMainDispatcher().dispatch([copy]{ settings::keyboard::save(copy); });
+3 -3
View File
@@ -76,7 +76,7 @@ class LauncherApp final : public App {
return show_power_button;
}
static void onAppPressed(TT_UNUSED lv_event_t* e) {
static void onAppPressed(lv_event_t* e) {
auto* appId = static_cast<const char*>(lv_event_get_user_data(e));
start(appId);
}
@@ -90,7 +90,7 @@ class LauncherApp final : public App {
public:
void onCreate(TT_UNUSED AppContext& app) override {
void onCreate(AppContext& app) override {
settings::BootSettings boot_properties;
if (settings::loadBootSettings(boot_properties) && !boot_properties.autoStartAppId.empty()) {
LOGGER.info("Starting {}", boot_properties.autoStartAppId);
@@ -98,7 +98,7 @@ public:
}
}
void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) override {
void onShow(AppContext& app, lv_obj_t* parent) override {
auto* buttons_wrapper = lv_obj_create(parent);
auto ui_scale = hal::getConfiguration()->uiScale;
@@ -149,7 +149,7 @@ public:
lv_obj_add_event_cb(languageDropdown, onLanguageSet, LV_EVENT_VALUE_CHANGED, this);
}
void onHide(TT_UNUSED AppContext& app) override {
void onHide(AppContext& app) override {
if (settingsUpdated && regionTextArea) {
settings::SystemSettings sysSettings;
if (settings::loadSystemSettings(sysSettings)) {
+1 -1
View File
@@ -183,7 +183,7 @@ public:
update_timer.start();
}
void onHide(TT_UNUSED AppContext& app) override {
void onHide(AppContext& app) override {
update_timer.stop();
}
};
@@ -58,14 +58,14 @@ std::shared_ptr<ScreenshotApp> _Nullable optApp() {
}
}
static void onStartPressedCallback(TT_UNUSED lv_event_t* event) {
static void onStartPressedCallback(lv_event_t* event) {
auto app = optApp();
if (app != nullptr) {
app->onStartPressed();
}
}
static void onModeSetCallback(TT_UNUSED lv_event_t* event) {
static void onModeSetCallback(lv_event_t* event) {
auto app = optApp();
if (app != nullptr) {
app->onModeSet();
@@ -80,7 +80,7 @@ public:
lv_obj_set_flex_grow(list, 1);
auto parameters = app.getParameters();
tt_check(parameters != nullptr, "Parameters missing");
check(parameters != nullptr, "Parameters missing");
std::string items_concatenated;
if (parameters->optString(PARAMETER_BUNDLE_KEY_ITEMS, items_concatenated)) {
std::vector<std::string> items = string::split(items_concatenated, PARAMETER_ITEM_CONCATENATION_TOKEN);
+1 -1
View File
@@ -16,7 +16,7 @@ static void onAppPressed(lv_event_t* e) {
}
static void createWidget(const std::shared_ptr<AppManifest>& manifest, void* parent) {
tt_check(parent);
check(parent);
auto* list = (lv_obj_t*)parent;
const void* icon = !manifest->appIcon.empty() ? manifest->appIcon.c_str() : TT_ASSETS_APP_ICON_FALLBACK;
auto* btn = lv_list_add_button(list, icon, manifest->appName.c_str());
@@ -692,7 +692,7 @@ class SystemInfoApp final : public App {
tasksTimer.start(); // Tasks/CPU: every 15s
}
void onHide(TT_UNUSED AppContext& app) override {
void onHide(AppContext& app) override {
memoryTimer.stop();
tasksTimer.stop();
}
@@ -134,7 +134,7 @@ public:
lv_label_set_text(timeZoneLabel, timeZoneName.c_str());
}
void onResult(AppContext& app, TT_UNUSED LaunchId launchId, Result result, std::unique_ptr<Bundle> bundle) override {
void onResult(AppContext& app, LaunchId launchId, Result result, std::unique_ptr<Bundle> bundle) override {
if (result == Result::Ok && bundle != nullptr) {
const auto name = timezone::getResultName(*bundle);
const auto code = timezone::getResultCode(*bundle);
+2 -2
View File
@@ -73,12 +73,12 @@ class TimeZoneApp final : public App {
lv_obj_t* listWidget = nullptr;
lv_obj_t* filterTextareaWidget = nullptr;
static void onTextareaValueChangedCallback(TT_UNUSED lv_event_t* e) {
static void onTextareaValueChangedCallback(lv_event_t* e) {
auto* app = (TimeZoneApp*)lv_event_get_user_data(e);
app->onTextareaValueChanged(e);
}
void onTextareaValueChanged(TT_UNUSED lv_event_t* e) {
void onTextareaValueChanged(lv_event_t* e) {
if (mutex.lock(100 / portTICK_PERIOD_MS)) {
if (updateTimer->isRunning()) {
updateTimer->stop();
@@ -197,7 +197,7 @@ public:
}
}
void onHide(TT_UNUSED AppContext& app) override {
void onHide(AppContext& app) override {
if (updated) {
const auto copy = tbSettings;
getMainDispatcher().dispatch([copy]{ settings::trackball::save(copy); });
@@ -11,12 +11,12 @@
namespace tt::app::usbsettings {
static void onRebootMassStorageSdmmc(TT_UNUSED lv_event_t* event) {
static void onRebootMassStorageSdmmc(lv_event_t* event) {
hal::usb::rebootIntoMassStorageSdmmc();
}
// Flash reboot handler
static void onRebootMassStorageFlash(TT_UNUSED lv_event_t* event) {
static void onRebootMassStorageFlash(lv_event_t* event) {
hal::usb::rebootIntoMassStorageFlash();
}
@@ -183,7 +183,7 @@ class WebServerSettingsApp final : public App {
}
public:
void onCreate(TT_UNUSED AppContext& app) override {
void onCreate(AppContext& app) override {
wsSettings = settings::webserver::loadOrGetDefault();
originalSettings = wsSettings;
}
@@ -353,7 +353,7 @@ public:
"AP mode uses the password configured above.");
}
void onHide(TT_UNUSED AppContext& app) override {
void onHide(AppContext& app) override {
if (updated) {
// Read values from text areas
if (textAreaApPassword) {
@@ -6,6 +6,7 @@
#include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/Check.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/Style.h>
@@ -34,7 +35,7 @@ class WifiApSettings : public App {
std::string ssid;
PubSub<service::wifi::WifiEvent>::SubscriptionHandle wifiSubscription = nullptr;
static void onPressForget(TT_UNUSED lv_event_t* event) {
static void onPressForget(lv_event_t* event) {
std::vector<std::string> choices = {
"Yes",
"No"
@@ -61,7 +62,7 @@ class WifiApSettings : public App {
static void onPressConnect(lv_event_t* event) {
auto app = getCurrentAppContext();
auto parameters = app->getParameters();
tt_check(parameters != nullptr, "Parameters missing");
check(parameters != nullptr, "Parameters missing");
std::string ssid = parameters->getString("ssid");
service::wifi::settings::WifiApSettings settings;
@@ -124,7 +125,7 @@ public:
void onCreate(AppContext& app) override {
const auto parameters = app.getParameters();
tt_check(parameters != nullptr, "Parameters missing");
check(parameters != nullptr, "Parameters missing");
ssid = parameters->getString("ssid");
}
@@ -209,7 +210,7 @@ public:
viewEnabled = false;
}
void onResult(TT_UNUSED AppContext& appContext, TT_UNUSED LaunchId launchId, TT_UNUSED Result result, std::unique_ptr<Bundle> bundle) override {
void onResult(AppContext& appContext, LaunchId launchId, Result result, std::unique_ptr<Bundle> bundle) override {
if (result != Result::Ok || bundle == nullptr) {
return;
}
@@ -220,7 +221,7 @@ public:
}
auto parameters = appContext.getParameters();
tt_check(parameters != nullptr, "Parameters missing");
check(parameters != nullptr, "Parameters missing");
std::string ssid = parameters->getString("ssid");
if (!service::wifi::settings::remove(ssid.c_str())) {
+1 -1
View File
@@ -21,7 +21,7 @@ void View::resetErrors() {
lv_obj_add_flag(connection_error, LV_OBJ_FLAG_HIDDEN);
}
static void onConnect(TT_UNUSED lv_event_t* event) {
static void onConnect(lv_event_t* event) {
auto wifi = std::static_pointer_cast<WifiConnect>(getCurrentApp());
auto& view = wifi->getView();
@@ -15,7 +15,7 @@ constexpr auto* WIFI_CONNECT_PARAM_PASSWORD = "password"; // String
extern const AppManifest manifest;
static void onConnect(const service::wifi::settings::WifiApSettings& ap_settings, bool remember, TT_UNUSED void* parameter) {
static void onConnect(const service::wifi::settings::WifiApSettings& ap_settings, bool remember, void* parameter) {
auto* wifi = static_cast<WifiConnect*>(parameter);
wifi->getState().setApSettings(ap_settings);
wifi->getState().setConnecting(true);
@@ -88,7 +88,7 @@ void WifiConnect::onShow(AppContext& app, lv_obj_t* parent) {
unlock();
}
void WifiConnect::onHide(TT_UNUSED AppContext& app) {
void WifiConnect::onHide(AppContext& app) {
// No need to lock view, as this is called from within Gui's LVGL context
lock();
viewEnabled = false;
@@ -131,7 +131,7 @@ void WifiManage::onShow(AppContext& app, lv_obj_t* parent) {
}
}
void WifiManage::onHide(TT_UNUSED AppContext& app) {
void WifiManage::onHide(AppContext& app) {
lock();
service::wifi::getPubsub()->unsubscribe(wifiSubscription);
wifiSubscription = nullptr;