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:
committed by
GitHub
parent
619b5aa53b
commit
e6abd496f9
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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); });
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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())) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/hal/Device.h>
|
||||
#include <Tactility/hal/gps/GpsInit.h>
|
||||
@@ -68,20 +69,19 @@ void init(const Configuration& configuration) {
|
||||
kernel::publishSystemEvent(kernel::SystemEvent::BootInitHalBegin);
|
||||
|
||||
kernel::publishSystemEvent(kernel::SystemEvent::BootInitI2cBegin);
|
||||
tt_check(i2c::init(configuration.i2c), "I2C init failed");
|
||||
check(i2c::init(configuration.i2c), "I2C init failed");
|
||||
kernel::publishSystemEvent(kernel::SystemEvent::BootInitI2cEnd);
|
||||
|
||||
kernel::publishSystemEvent(kernel::SystemEvent::BootInitSpiBegin);
|
||||
tt_check(spi::init(configuration.spi), "SPI init failed");
|
||||
check(spi::init(configuration.spi), "SPI init failed");
|
||||
kernel::publishSystemEvent(kernel::SystemEvent::BootInitSpiEnd);
|
||||
|
||||
kernel::publishSystemEvent(kernel::SystemEvent::BootInitUartBegin);
|
||||
tt_check(uart::init(configuration.uart), "UART init failed");
|
||||
check(uart::init(configuration.uart), "UART init failed");
|
||||
kernel::publishSystemEvent(kernel::SystemEvent::BootInitUartEnd);
|
||||
|
||||
if (configuration.initBoot != nullptr) {
|
||||
LOGGER.info("Init boot");
|
||||
tt_check(configuration.initBoot(), "Init boot failed");
|
||||
check(configuration.initBoot(), "Init boot failed");
|
||||
}
|
||||
|
||||
registerDevices(configuration);
|
||||
|
||||
@@ -139,7 +139,7 @@ GpsResponse getACKCas(uart::Uart& uart, uint8_t class_id, uint8_t msg_id, uint32
|
||||
bool init(uart::Uart& uart, GpsModel type) {
|
||||
switch (type) {
|
||||
case GpsModel::Unknown:
|
||||
tt_crash();
|
||||
check(false);
|
||||
case GpsModel::AG3335:
|
||||
case GpsModel::AG3352:
|
||||
return initAg33xx(uart);
|
||||
|
||||
@@ -202,7 +202,7 @@ bool masterWrite(i2c_port_t port, uint8_t address, const uint8_t* data, uint16_t
|
||||
}
|
||||
|
||||
bool masterWriteRegister(i2c_port_t port, uint8_t address, uint8_t reg, const uint8_t* data, uint16_t dataSize, TickType_t timeout) {
|
||||
tt_check(reg != 0);
|
||||
check(reg != 0);
|
||||
|
||||
auto lock = getLock(port).asScopedLock();
|
||||
if (!lock.lock(timeout)) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
|
||||
#include <Tactility/CoreDefines.h>
|
||||
#include <list>
|
||||
|
||||
namespace tt::kernel {
|
||||
@@ -53,7 +54,7 @@ static const char* getEventName(SystemEvent event) {
|
||||
return TT_STRINGIFY(Time);
|
||||
}
|
||||
|
||||
tt_crash(); // Missing case above
|
||||
check(false); // Missing case above
|
||||
}
|
||||
|
||||
void publishSystemEvent(SystemEvent event) {
|
||||
@@ -83,7 +84,7 @@ SystemEventSubscription subscribeSystemEvent(SystemEvent event, OnSystemEvent ha
|
||||
mutex.unlock();
|
||||
return id;
|
||||
} else {
|
||||
tt_crash();
|
||||
check(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ static void anim_rotation_callback(void* var, int32_t v) {
|
||||
lv_obj_set_style_transform_rotation(object, v, 0);
|
||||
}
|
||||
|
||||
static void spinner_constructor(TT_UNUSED const lv_obj_class_t* object_class, lv_obj_t* object) {
|
||||
static void spinner_constructor(const lv_obj_class_t* object_class, lv_obj_t* object) {
|
||||
lv_obj_remove_flag(object, LV_OBJ_FLAG_CLICKABLE);
|
||||
|
||||
lv_anim_t a;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
|
||||
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
@@ -10,7 +11,6 @@
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/settings/Time.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
@@ -116,7 +116,7 @@ static void statusbar_pubsub_event(Statusbar* statusbar) {
|
||||
}
|
||||
}
|
||||
|
||||
static void onTimeChanged(TT_UNUSED kernel::SystemEvent event) {
|
||||
static void onTimeChanged(kernel::SystemEvent event) {
|
||||
if (statusbar_data.mutex.lock()) {
|
||||
statusbar_data.time_update_timer->reset(5);
|
||||
statusbar_data.mutex.unlock();
|
||||
@@ -142,7 +142,7 @@ static void statusbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
|
||||
}
|
||||
}
|
||||
|
||||
static void statusbar_destructor(TT_UNUSED const lv_obj_class_t* class_p, lv_obj_t* obj) {
|
||||
static void statusbar_destructor(const lv_obj_class_t* class_p, lv_obj_t* obj) {
|
||||
auto* statusbar = (Statusbar*)obj;
|
||||
statusbar_data.pubsub->unsubscribe(statusbar->pubsub_subscription);
|
||||
}
|
||||
@@ -215,7 +215,7 @@ static void update_main(Statusbar* statusbar) {
|
||||
}
|
||||
}
|
||||
|
||||
static void statusbar_event(TT_UNUSED const lv_obj_class_t* class_p, lv_event_t* event) {
|
||||
static void statusbar_event(const lv_obj_class_t* class_p, lv_event_t* event) {
|
||||
// Call the ancestor's event handler
|
||||
lv_result_t result = lv_obj_event_base(&statusbar_class, event);
|
||||
if (result != LV_RES_OK) {
|
||||
@@ -258,7 +258,7 @@ void statusbar_icon_remove(int8_t id) {
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("id {}: remove", id);
|
||||
}
|
||||
tt_check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
|
||||
check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
|
||||
statusbar_data.mutex.lock();
|
||||
StatusbarIcon* icon = &statusbar_data.icons[id];
|
||||
icon->claimed = false;
|
||||
@@ -276,10 +276,10 @@ void statusbar_icon_set_image(int8_t id, const std::string& image) {
|
||||
LOGGER.debug("id {}: set image {}", id, image);
|
||||
}
|
||||
}
|
||||
tt_check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
|
||||
check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
|
||||
statusbar_data.mutex.lock();
|
||||
StatusbarIcon* icon = &statusbar_data.icons[id];
|
||||
tt_check(icon->claimed);
|
||||
check(icon->claimed);
|
||||
icon->image = image;
|
||||
statusbar_data.mutex.unlock();
|
||||
statusbar_data.pubsub->publish(nullptr);
|
||||
@@ -289,10 +289,10 @@ void statusbar_icon_set_visibility(int8_t id, bool visible) {
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("id {}: set visibility {}", id, visible);
|
||||
}
|
||||
tt_check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
|
||||
check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
|
||||
statusbar_data.mutex.lock();
|
||||
StatusbarIcon* icon = &statusbar_data.icons[id];
|
||||
tt_check(icon->claimed);
|
||||
check(icon->claimed);
|
||||
icon->visible = visible;
|
||||
statusbar_data.mutex.unlock();
|
||||
statusbar_data.pubsub->publish(nullptr);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/lvgl/Spinner.h>
|
||||
|
||||
@@ -63,7 +64,7 @@ static const lv_obj_class_t toolbar_class = {
|
||||
.theme_inheritable = false
|
||||
};
|
||||
|
||||
static void stop_app(TT_UNUSED lv_event_t* event) {
|
||||
static void stop_app(lv_event_t* event) {
|
||||
app::stop();
|
||||
}
|
||||
|
||||
@@ -166,7 +167,7 @@ void toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callb
|
||||
|
||||
lv_obj_t* toolbar_add_button_action(lv_obj_t* obj, const char* imageOrButton, bool isImage, lv_event_cb_t callback, void* user_data) {
|
||||
auto* toolbar = reinterpret_cast<Toolbar*>(obj);
|
||||
tt_check(toolbar->action_count < TOOLBAR_ACTION_LIMIT, "max actions reached");
|
||||
check(toolbar->action_count < TOOLBAR_ACTION_LIMIT, "max actions reached");
|
||||
toolbar->action_count++;
|
||||
|
||||
auto ui_scale = hal::getConfiguration()->uiScale;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/network/Http.h>
|
||||
|
||||
#include "Tactility/service/gui/GuiService.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include <Tactility/network/EspHttpClient.h>
|
||||
#include <esp_http_client.h>
|
||||
@@ -19,7 +21,8 @@ void download(
|
||||
const std::function<void()>& onSuccess,
|
||||
const std::function<void(const char* errorMessage)>& onError
|
||||
) {
|
||||
LOGGER.info("Downloading {} to {}", url, downloadFilePath);
|
||||
service::gui::warnIfRunningOnGuiTask("HTTP");
|
||||
LOGGER.info("Downloading from {} to {}", url, downloadFilePath);
|
||||
#ifdef ESP_PLATFORM
|
||||
getMainDispatcher().dispatch([url, certFilePath, downloadFilePath, onSuccess, onError] {
|
||||
LOGGER.info("Loading certificate");
|
||||
@@ -90,6 +93,7 @@ void download(
|
||||
onError("Failed to write all bytes");
|
||||
return;
|
||||
}
|
||||
taskYIELD();
|
||||
}
|
||||
fclose(file);
|
||||
LOGGER.info("Downloaded {} to {}", url, downloadFilePath);
|
||||
|
||||
@@ -59,7 +59,7 @@ class DisplayIdleService final : public Service {
|
||||
}
|
||||
|
||||
public:
|
||||
bool onStart(TT_UNUSED ServiceContext& service) override {
|
||||
bool onStart(ServiceContext& service) override {
|
||||
// Load settings once at startup and cache them
|
||||
// This eliminates file I/O from timer callback (prevents watchdog timeout)
|
||||
cachedDisplaySettings = settings::display::loadOrGetDefault();
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void onStop(TT_UNUSED ServiceContext& service) override {
|
||||
void onStop(ServiceContext& service) override {
|
||||
if (timer) {
|
||||
timer->stop();
|
||||
timer = nullptr;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <Tactility/service/gui/GuiService.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <Tactility/app/AppInstance.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
@@ -15,6 +17,15 @@ extern const ServiceManifest manifest;
|
||||
static const auto LOGGER = Logger("GuiService");
|
||||
using namespace loader;
|
||||
|
||||
constexpr auto* GUI_TASK_NAME = "gui";
|
||||
|
||||
void warnIfRunningOnGuiTask(const char* context) {
|
||||
const char* task_name = pcTaskGetName(nullptr);
|
||||
if (strcmp(GUI_TASK_NAME, task_name) == 0) {
|
||||
LOGGER.warn("{} shouldn't run on the GUI task", context);
|
||||
}
|
||||
}
|
||||
|
||||
// region AppManifest
|
||||
|
||||
void GuiService::onLoaderEvent(LoaderService::Event event) {
|
||||
@@ -114,7 +125,7 @@ void GuiService::redraw() {
|
||||
unlock();
|
||||
}
|
||||
|
||||
bool GuiService::onStart(TT_UNUSED ServiceContext& service) {
|
||||
bool GuiService::onStart(ServiceContext& service) {
|
||||
auto* screen_root = lv_screen_active();
|
||||
if (screen_root == nullptr) {
|
||||
LOGGER.error("No display found");
|
||||
@@ -122,11 +133,13 @@ bool GuiService::onStart(TT_UNUSED ServiceContext& service) {
|
||||
}
|
||||
|
||||
thread = new Thread(
|
||||
"gui",
|
||||
GUI_TASK_NAME,
|
||||
4096, // Last known minimum was 2800 for launching desktop
|
||||
[]() { return guiMain(); }
|
||||
);
|
||||
|
||||
thread->setPriority(THREAD_PRIORITY_SERVICE);
|
||||
|
||||
const auto loader = findLoaderService();
|
||||
assert(loader != nullptr);
|
||||
loader_pubsub_subscription = loader->getPubsub()->subscribe([this](auto event) {
|
||||
@@ -169,7 +182,7 @@ bool GuiService::onStart(TT_UNUSED ServiceContext& service) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void GuiService::onStop(TT_UNUSED ServiceContext& service) {
|
||||
void GuiService::onStop(ServiceContext& service) {
|
||||
lock();
|
||||
|
||||
const auto loader = findLoaderService();
|
||||
@@ -186,7 +199,7 @@ void GuiService::onStop(TT_UNUSED ServiceContext& service) {
|
||||
|
||||
unlock();
|
||||
|
||||
tt_check(lvgl::lock(1000 / portTICK_PERIOD_MS));
|
||||
check(lvgl::lock(1000 / portTICK_PERIOD_MS));
|
||||
lv_group_delete(keyboardGroup);
|
||||
lvgl::unlock();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ static void show_keyboard(lv_event_t* event) {
|
||||
}
|
||||
}
|
||||
|
||||
static void hide_keyboard(TT_UNUSED lv_event_t* event) {
|
||||
static void hide_keyboard(lv_event_t* event) {
|
||||
auto service = findService();
|
||||
if (service != nullptr) {
|
||||
service->softwareKeyboardHide();
|
||||
@@ -53,7 +53,7 @@ void GuiService::keyboardAddTextArea(lv_obj_t* textarea) {
|
||||
lock();
|
||||
|
||||
if (isStarted) {
|
||||
tt_check(lvgl::lock(0), "lvgl should already be locked before calling this method");
|
||||
check(lvgl::lock(0), "lvgl should already be locked before calling this method");
|
||||
|
||||
if (softwareKeyboardIsEnabled()) {
|
||||
lv_obj_add_event_cb(textarea, show_keyboard, LV_EVENT_FOCUSED, nullptr);
|
||||
|
||||
@@ -58,7 +58,7 @@ class KeyboardIdleService final : public Service {
|
||||
}
|
||||
|
||||
public:
|
||||
bool onStart(TT_UNUSED ServiceContext& service) override {
|
||||
bool onStart(ServiceContext& service) override {
|
||||
// Load settings once at startup and cache them
|
||||
// This eliminates file I/O from timer callback (prevents watchdog timeout)
|
||||
cachedKeyboardSettings = settings::keyboard::loadOrGetDefault();
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void onStop(TT_UNUSED ServiceContext& service) override {
|
||||
void onStop(ServiceContext& service) override {
|
||||
if (timer) {
|
||||
timer->stop();
|
||||
timer = nullptr;
|
||||
|
||||
@@ -245,7 +245,7 @@ void LoaderService::transitionAppToState(const std::shared_ptr<app::AppInstance>
|
||||
switch (state) {
|
||||
using enum app::State;
|
||||
case Initial:
|
||||
tt_crash(LOG_MESSAGE_ILLEGAL_STATE);
|
||||
check(false, LOG_MESSAGE_ILLEGAL_STATE);
|
||||
case Created:
|
||||
assert(app->getState() == app::State::Initial);
|
||||
app->getApp()->onCreate(*app);
|
||||
|
||||
@@ -107,7 +107,7 @@ void ScreenshotTask::taskStart() {
|
||||
return;
|
||||
}
|
||||
|
||||
tt_check(thread == nullptr);
|
||||
check(thread == nullptr);
|
||||
thread = new Thread(
|
||||
"screenshot",
|
||||
8192,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Tactility/lvgl/Statusbar.h>
|
||||
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/hal/power/PowerDevice.h>
|
||||
#include <Tactility/hal/sdcard/SdCardDevice.h>
|
||||
#include <Tactility/Logger.h>
|
||||
@@ -71,7 +72,7 @@ static const char* getWifiStatusIcon(wifi::RadioState state, bool secure) {
|
||||
rssi = wifi::getRssi();
|
||||
return getWifiStatusIconForRssi(rssi);
|
||||
default:
|
||||
tt_crash("not implemented");
|
||||
check(false, "not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ static const char* getSdCardStatusIcon(hal::sdcard::SdCardDevice::State state) {
|
||||
case Timeout:
|
||||
return STATUSBAR_ICON_SDCARD_ALERT;
|
||||
default:
|
||||
tt_crash("Unhandled SdCard state");
|
||||
check(false, "Unhandled SdCard state");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/service/webserver/WebServerService.h>
|
||||
#include <Tactility/service/webserver/AssetVersion.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
@@ -93,7 +94,7 @@ static void publish_event(WebServerService* webserver, WebServerEvent event) {
|
||||
std::shared_ptr<PubSub<WebServerEvent>> getPubsub() {
|
||||
WebServerService* webserver = g_webServerInstance.load();
|
||||
if (webserver == nullptr) {
|
||||
tt_crash("Service not running");
|
||||
check(false, "Service not running");
|
||||
}
|
||||
|
||||
return webserver->getPubsub();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/CoreDefines.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
|
||||
@@ -22,7 +23,7 @@ const char* radioStateToString(RadioState state) {
|
||||
case Off:
|
||||
return TT_STRINGIFY(Off);
|
||||
}
|
||||
tt_crash("not implemented");
|
||||
check(false, "not implemented");
|
||||
}
|
||||
|
||||
extern const ServiceManifest manifest;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/EventGroup.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/LogMessages.h>
|
||||
@@ -140,7 +141,7 @@ static std::shared_ptr<Wifi> wifi_singleton;
|
||||
std::shared_ptr<PubSub<WifiEvent>> getPubsub() {
|
||||
auto wifi = wifi_singleton;
|
||||
if (wifi == nullptr) {
|
||||
tt_crash("Service not running");
|
||||
check(false, "Service not running");
|
||||
}
|
||||
|
||||
return wifi->pubsub;
|
||||
@@ -472,7 +473,7 @@ static void dispatchAutoConnect(std::shared_ptr<Wifi> wifi) {
|
||||
}
|
||||
}
|
||||
|
||||
static void eventHandler(TT_UNUSED void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) {
|
||||
static void eventHandler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) {
|
||||
auto wifi = wifi_singleton;
|
||||
if (wifi == nullptr) {
|
||||
LOGGER.error("eventHandler: no wifi instance");
|
||||
|
||||
@@ -76,7 +76,7 @@ void setScanRecords(uint16_t records) {
|
||||
}
|
||||
|
||||
std::vector<ApRecord> getScanResults() {
|
||||
tt_check(wifi);
|
||||
check(wifi);
|
||||
|
||||
std::vector<ApRecord> records;
|
||||
records.push_back((ApRecord) {
|
||||
@@ -145,14 +145,14 @@ class WifiService final : public Service {
|
||||
|
||||
public:
|
||||
|
||||
bool onStart(TT_UNUSED ServiceContext& service) override {
|
||||
tt_check(wifi == nullptr);
|
||||
bool onStart(ServiceContext& service) override {
|
||||
check(wifi == nullptr);
|
||||
wifi = new Wifi();
|
||||
return true;
|
||||
}
|
||||
|
||||
void onStop(TT_UNUSED ServiceContext& service) override {
|
||||
tt_check(wifi != nullptr);
|
||||
void onStop(ServiceContext& service) override {
|
||||
check(wifi != nullptr);
|
||||
delete wifi;
|
||||
wifi = nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user