Merge develop into main (#313)

- Add app path get() functions to `TactilityC`
- Improved `Dispatcher` and `DispatcherThread`
- Improved `PubSub` (type safety)
- Created test for `DispatcherThread` and `PubSub`
- Save properties files on app exit (various apps) by posting it to the main dispatcher (fixes UI hanging briefly on app exit)
- Fixed bug with `SystemSettings` being read from the wrong file path.
- `loadPropertiesFile()` now uses `file::readLines()` instead of doing that manually
- Increased timer task stack size (required due to issues when reading a properties file for the very first time)
- General cleanup
- Created `EstimatedPower` driver that uses an ADC pin to measure voltage and estimate the battery charge that is left.
- Cleanup of T-Deck board (updated to new style)
This commit is contained in:
Ken Van Hoeylandt
2025-09-01 23:07:00 +02:00
committed by GitHub
parent 5cc5b50694
commit 0f8380e8fe
96 changed files with 766 additions and 682 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ class BootApp : public App {
Thread thread = Thread(
"boot",
4096,
5120,
[] { return bootThreadCallback(); },
getCpuAffinityConfiguration().system
);
@@ -1,17 +1,19 @@
#ifdef ESP_PLATFORM
#include <Tactility/Tactility.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/development/DevelopmentService.h>
#include <Tactility/service/development/DevelopmentSettings.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h>
#include <Tactility/Timer.h>
#include <cstring>
#include <lvgl.h>
#include <Tactility/service/development/DevelopmentSettings.h>
namespace tt::app::development {
@@ -51,7 +53,10 @@ class DevelopmentApp final : public App {
bool is_on = lv_obj_has_state(widget, LV_STATE_CHECKED);
bool is_changed = is_on != service::development::shouldEnableOnBoot();
if (is_changed) {
service::development::setEnableOnBoot(is_on);
// Dispatch it, so file IO doesn't block the UI
getMainDispatcher().dispatch([is_on] {
service::development::setEnableOnBoot(is_on);
});
}
}
}
+7 -2
View File
@@ -1,8 +1,9 @@
#include <Tactility/Tactility.h>
#include <Tactility/settings/DisplaySettings.h>
#include <Tactility/Assets.h>
#include <Tactility/hal/display/DisplayDevice.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Tactility.h>
#include <lvgl.h>
@@ -139,7 +140,11 @@ public:
void onHide(TT_UNUSED AppContext& app) override {
if (displaySettingsUpdated) {
settings::display::save(displaySettings);
// Dispatch it, so file IO doesn't block the UI
const settings::display::DisplaySettings settings_to_save = displaySettings;
getMainDispatcher().dispatch([settings_to_save] {
settings::display::save(settings_to_save);
});
}
}
};
@@ -1,12 +1,13 @@
#include "Tactility/TactilityHeadless.h"
#include "Tactility/Timer.h"
#include "Tactility/app/AppManifest.h"
#include "Tactility/app/alertdialog/AlertDialog.h"
#include "Tactility/lvgl/LvglSync.h"
#include "Tactility/lvgl/Toolbar.h"
#include "Tactility/service/gps/GpsUtil.h"
#include "Tactility/service/loader/Loader.h"
#include <Tactility/Tactility.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/gps/GpsService.h>
#include <Tactility/service/gps/GpsState.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/Timer.h>
#include <cstring>
#include <format>
@@ -34,14 +35,9 @@ class GpsSettingsApp final : public App {
lv_obj_t* gpsConfigWrapper = nullptr;
lv_obj_t* addGpsWrapper = nullptr;
bool hasSetInfo = false;
PubSub::SubscriptionHandle serviceStateSubscription = nullptr;
PubSub<service::gps::State>::SubscriptionHandle serviceStateSubscription = nullptr;
std::shared_ptr<service::gps::GpsService> service;
static void onServiceStateChangedCallback(const void* data, void* context) {
auto* app = (GpsSettingsApp*)context;
app->onServiceStateChanged();
}
void onServiceStateChanged() {
auto lock = lvgl::getSyncLock()->asScopedLock();
if (lock.lock(100 / portTICK_PERIOD_MS)) {
@@ -313,7 +309,9 @@ public:
lv_obj_set_style_pad_all(infoContainerWidget, 0, 0);
hasSetInfo = false;
serviceStateSubscription = service->getStatePubsub()->subscribe(onServiceStateChangedCallback, this);
serviceStateSubscription = service->getStatePubsub()->subscribe([this](auto) {
onServiceStateChanged();
});
gpsConfigWrapper = lv_obj_create(main_wrapper);
lv_obj_set_size(gpsConfigWrapper, LV_PCT(100), LV_SIZE_CONTENT);
@@ -1,19 +1,18 @@
#include "Tactility/TactilityConfig.h"
#include <Tactility/Tactility.h>
#include <Tactility/TactilityConfig.h>
#include <Tactility/Timer.h>
#include <Tactility/kernel/Kernel.h>
#if TT_FEATURE_SCREENSHOT_ENABLED
#include "Tactility/app/App.h"
#include "Tactility/app/AppManifest.h"
#include "Tactility/lvgl/LvglSync.h"
#include "Tactility/lvgl/Toolbar.h"
#include "Tactility/service/screenshot/Screenshot.h"
#include <Tactility/app/App.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/screenshot/Screenshot.h>
#include <Tactility/TactilityHeadless.h>
#define TAG "screenshot"
constexpr auto* TAG = "Screenshot";
namespace tt::app::screenshot {
+1 -3
View File
@@ -1,6 +1,4 @@
#include "Tactility/app/wificonnect/State.h"
#include <cstring>
#include <Tactility/app/wificonnect/State.h>
namespace tt::app::wificonnect {
+8 -9
View File
@@ -1,19 +1,18 @@
#include "Tactility/app/wificonnect/View.h"
#include "Tactility/app/wificonnect/WifiConnect.h"
#include "Tactility/lvgl/Toolbar.h"
#include "Tactility/lvgl/Spinner.h"
#include <Tactility/TactilityCore.h>
#include <lvgl.h>
#include <cstring>
#include <Tactility/app/wificonnect/View.h>
#include <Tactility/app/wificonnect/WifiConnect.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/Spinner.h>
#include <Tactility/service/wifi/WifiApSettings.h>
#include <Tactility/service/wifi/WifiGlobals.h>
#include <lvgl.h>
#include <cstring>
namespace tt::app::wificonnect {
#define TAG "wifi_connect"
constexpr auto* TAG = "WifiConnect";
void View::resetErrors() {
lv_obj_add_flag(password_error, LV_OBJ_FLAG_HIDDEN);
@@ -1,41 +1,18 @@
#include "Tactility/app/wificonnect/WifiConnect.h"
#include <Tactility/app/wificonnect/WifiConnect.h>
#include "Tactility/app/AppContext.h"
#include "Tactility/service/loader/Loader.h"
#include "Tactility/service/wifi/Wifi.h"
#include "Tactility/lvgl/LvglSync.h"
#include <Tactility/app/AppContext.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h>
#include <Tactility/lvgl/LvglSync.h>
namespace tt::app::wificonnect {
#define TAG "wifi_connect"
#define WIFI_CONNECT_PARAM_SSID "ssid" // String
#define WIFI_CONNECT_PARAM_PASSWORD "password" // String
constexpr auto* TAG = "WifiConnect";
constexpr auto* WIFI_CONNECT_PARAM_SSID = "ssid"; // String
constexpr auto* WIFI_CONNECT_PARAM_PASSWORD = "password"; // String
extern const AppManifest manifest;
static void eventCallback(const void* message, void* context) {
auto* event = static_cast<const service::wifi::Event*>(message);
auto* wifi = static_cast<WifiConnect*>(context);
State& state = wifi->getState();
switch (event->type) {
case service::wifi::EventType::ConnectionFailed:
if (state.isConnecting()) {
state.setConnecting(false);
state.setConnectionError(true);
wifi->requestViewUpdate();
}
break;
case service::wifi::EventType::ConnectionSuccess:
if (wifi->getState().isConnecting()) {
state.setConnecting(false);
service::loader::stopApp();
}
break;
default:
break;
}
wifi->requestViewUpdate();
}
static void onConnect(const service::wifi::settings::WifiApSettings& ap_settings, bool remember, TT_UNUSED void* parameter) {
auto* wifi = static_cast<WifiConnect*>(parameter);
wifi->getState().setApSettings(ap_settings);
@@ -43,8 +20,33 @@ static void onConnect(const service::wifi::settings::WifiApSettings& ap_settings
service::wifi::connect(ap_settings, remember);
}
void WifiConnect::onWifiEvent(service::wifi::WifiEvent event) {
State& state = getState();
switch (event) {
case service::wifi::WifiEvent::ConnectionFailed:
if (state.isConnecting()) {
state.setConnecting(false);
state.setConnectionError(true);
requestViewUpdate();
}
break;
case service::wifi::WifiEvent::ConnectionSuccess:
if (getState().isConnecting()) {
state.setConnecting(false);
service::loader::stopApp();
}
break;
default:
break;
}
requestViewUpdate();
}
WifiConnect::WifiConnect() {
wifiSubscription = service::wifi::getPubsub()->subscribe(&eventCallback, this);
wifiSubscription = service::wifi::getPubsub()->subscribe([this](auto event) {
onWifiEvent(event);
});
bindings = (Bindings) {
.onConnectSsid = onConnect,
.onConnectSsidContext = this,
+1 -1
View File
@@ -1,4 +1,4 @@
#include "Tactility/app/wifimanage/WifiManagePrivate.h"
#include <Tactility/app/wifimanage/WifiManagePrivate.h>
namespace tt::app::wifimanage {
+12 -7
View File
@@ -1,9 +1,11 @@
#include "Tactility/app/wifimanage/View.h"
#include "Tactility/app/wifimanage/WifiManagePrivate.h"
#include <Tactility/app/wifimanage/View.h>
#include "Tactility/lvgl/Style.h"
#include "Tactility/lvgl/Toolbar.h"
#include "Tactility/lvgl/Spinner.h"
#include <Tactility/Tactility.h>
#include <Tactility/app/wifimanage/WifiManagePrivate.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/Spinner.h>
#include <Tactility/Log.h>
#include <Tactility/service/wifi/Wifi.h>
@@ -15,7 +17,7 @@
namespace tt::app::wifimanage {
#define TAG "wifi_main_view"
constexpr auto* TAG = "WifiManageView";
std::shared_ptr<WifiManage> _Nullable optWifiManage();
@@ -49,7 +51,10 @@ static void on_enable_on_boot_switch_changed(lv_event_t* event) {
auto* enable_switch = static_cast<lv_obj_t*>(lv_event_get_target(event));
if (code == LV_EVENT_VALUE_CHANGED) {
bool is_on = lv_obj_has_state(enable_switch, LV_STATE_CHECKED);
service::wifi::settings::setEnableOnBoot(is_on);
// Dispatch it, so file IO doesn't block the UI
getMainDispatcher().dispatch([is_on] {
service::wifi::settings::setEnableOnBoot(is_on);
});
}
}
+19 -20
View File
@@ -1,16 +1,15 @@
#include "Tactility/app/wifimanage/WifiManagePrivate.h"
#include "Tactility/app/wifimanage/View.h"
#include <Tactility/app/wifimanage/WifiManagePrivate.h>
#include <Tactility/app/wifimanage/View.h>
#include "Tactility/app/AppContext.h"
#include "Tactility/app/wifiapsettings/WifiApSettings.h"
#include "Tactility/service/loader/Loader.h"
#include "Tactility/service/wifi/WifiSettings.h"
#include "Tactility/lvgl/LvglSync.h"
#include "Tactility/app/wificonnect/WifiConnect.h"
#include <Tactility/app/AppContext.h>
#include <Tactility/app/wifiapsettings/WifiApSettings.h>
#include <Tactility/app/wificonnect/WifiConnect.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/loader/Loader.h>
namespace tt::app::wifimanage {
#define TAG "wifi_manage"
constexpr auto TAG = "WifiManage";
extern const AppManifest manifest;
@@ -72,20 +71,18 @@ void WifiManage::requestViewUpdate() {
unlock();
}
static void wifiManageEventCallback(const void* message, void* context) {
auto* event = (service::wifi::Event*)message;
auto* wifi = (WifiManage*)context;
void WifiManage::onWifiEvent(service::wifi::WifiEvent event) {
auto radio_state = service::wifi::getRadioState();
TT_LOG_I(TAG, "Update with state %s", service::wifi::radioStateToString(radio_state));
wifi->getState().setRadioState(radio_state);
switch (event->type) {
using enum tt::service::wifi::EventType;
getState().setRadioState(radio_state);
switch (event) {
using enum service::wifi::WifiEvent;
case ScanStarted:
wifi->getState().setScanning(true);
getState().setScanning(true);
break;
case ScanFinished:
wifi->getState().setScanning(false);
wifi->getState().updateApRecords();
getState().setScanning(false);
getState().updateApRecords();
break;
case RadioStateOn:
if (!service::wifi::isScanning()) {
@@ -96,11 +93,13 @@ static void wifiManageEventCallback(const void* message, void* context) {
break;
}
wifi->requestViewUpdate();
requestViewUpdate();
}
void WifiManage::onShow(AppContext& app, lv_obj_t* parent) {
wifiSubscription = service::wifi::getPubsub()->subscribe(&wifiManageEventCallback, this);
wifiSubscription = service::wifi::getPubsub()->subscribe([this](auto event) {
onWifiEvent(event);
});
// State update (it has its own locking)
state.setRadioState(service::wifi::getRadioState());