LvglSync removed (#591)

Replaced all usages with lvgl-module functions.
This commit is contained in:
Ken Van Hoeylandt 2026-07-26 23:56:07 +02:00 committed by GitHub
parent 03a6285328
commit 3354924359
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
35 changed files with 262 additions and 390 deletions

View File

@ -1,13 +1,12 @@
#include <tactility/module.h>
#include <tactility/error.h>
#include <tactility/log.h>
#include <lvgl/lvgl.h>
#include <Tactility/SystemEvents.h>
#include <Tactility/LogMessages.h>
#include <Tactility/kernel/Kernel.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/settings/TrackballSettings.h>
#include <lilygo/drivers/trackball.h>

View File

@ -4,6 +4,9 @@
#include <stdint.h>
#include <stdbool.h>
// Official LVGL library header
#include <lvgl.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -1,24 +0,0 @@
#pragma once
#include <Tactility/Lock.h>
#include <memory>
namespace tt::lvgl {
constexpr TickType_t defaultLockTime = 500 / portTICK_PERIOD_MS;
/**
* LVGL locking function
* @param[in] timeout as ticks
* @warning when passing zero, we wait forever, as this is the default behaviour for esp_lvgl_port, and we want it to remain consistent
* @deprecated Use lvgl_lock() or lvgl_try_lock() from lvgl-module instead.
*/
bool lock(TickType_t timeout = portMAX_DELAY) __attribute__((deprecated("Use lvgl_lock() from lvgl-module")));
/** @deprecated Use lvgl_unlock() from lvgl-module instead. */
void unlock() __attribute__((deprecated("Use lvgl_unlock() from lvgl-module")));
std::shared_ptr<Lock> getSyncLock() __attribute__((deprecated("Use lvgl locking functions from lvgl-module")));
} // namespace

View File

@ -3,7 +3,6 @@
#include <Tactility/MessageQueue.h>
#include <Tactility/PubSub.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/service/Service.h>
#include <Tactility/service/loader/Loader.h>
@ -11,7 +10,6 @@
#include <tactility/concurrent/dispatcher.h>
#include <cstdio>
#include <lvgl.h>
namespace tt::service::gui {

View File

@ -1,18 +1,18 @@
#include "Tactility/lvgl/LvglSync.h"
#include <Tactility/app/App.h>
#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 <lvgl/widgets/toolbar.h>
#include <lvgl.h>
#include <format>
#include <Tactility/StringUtils.h>
#include <Tactility/file/File.h>
#include <tactility/check.h>
#include <lvgl/lvgl.h>
#include <lvgl/widgets/toolbar.h>
#include <format>
namespace tt::app::appdetails {
extern const AppManifest manifest;

View File

@ -1,20 +1,21 @@
#include <Tactility/Paths.h>
#include <Tactility/app/apphub/AppHub.h>
#include <Tactility/app/apphub/AppHubEntry.h>
#include <Tactility/app/apphubdetails/AppHubDetailsApp.h>
#include <Tactility/file/File.h>
#include <Tactility/lvgl/LvglSync.h>
#include <lvgl/widgets/spinner.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/network/Http.h>
#include <Tactility/Paths.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h>
#include <tactility/log.h>
#include <lvgl/icons/shared.h>
#include <lvgl/lvgl.h>
#include <lvgl/widgets/spinner.h>
#include <algorithm>
#include <format>
#include <lvgl.h>
#include <tactility/log.h>
namespace tt::app::apphub {
@ -58,20 +59,16 @@ class AppHubApp final : public App {
void onRefreshSuccess() {
LOG_I(TAG, "Request success");
auto lockable = lvgl::getSyncLock();
auto lock = lockable->asScopedLock();
lock.lock();
lvgl_lock();
showApps();
lvgl_unlock();
}
void onRefreshError(const char* error) {
LOG_E(TAG, "Request failed: %s", error);
auto lockable = lvgl::getSyncLock();
auto lock = lockable->asScopedLock();
lock.lock();
lvgl_lock();
showRefreshFailedError("Cannot reach server");
lvgl_unlock();
}
static void createAppWidget(const std::shared_ptr<AppManifest>& manifest, lv_obj_t* list) {

View File

@ -1,17 +1,18 @@
#include <Tactility/Paths.h>
#include <Tactility/StringUtils.h>
#include <Tactility/app/AppRegistration.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/app/apphub/AppHub.h>
#include <Tactility/app/apphub/AppHubEntry.h>
#include <Tactility/app/AppRegistration.h>
#include <Tactility/file/File.h>
#include <Tactility/lvgl/LvglSync.h>
#include <lvgl/widgets/toolbar.h>
#include <Tactility/network/Http.h>
#include <Tactility/Paths.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/StringUtils.h>
#include <lvgl.h>
#include <lvgl/lvgl.h>
#include <lvgl/widgets/toolbar.h>
#include <tactility/log.h>
#include <format>
namespace tt::app::apphubdetails {
@ -87,15 +88,15 @@ class AppHubDetailsApp final : public App {
void uninstallApp() {
LOG_I(TAG, "Uninstall");
lvgl::getSyncLock()->lock();
lvgl_lock();
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
lvgl::getSyncLock()->unlock();
lvgl_unlock();
uninstall(entry.appId);
lvgl::getSyncLock()->lock();
lvgl_lock();
updateViews();
lvgl::getSyncLock()->unlock();
lvgl_unlock();
}
void doInstall() {
@ -115,9 +116,9 @@ class AppHubDetailsApp final : public App {
LOG_I(TAG, "Deleted temporary file %s", temp_file_path.c_str());
}
lvgl::getSyncLock()->lock();
lvgl_lock();
updateViews();
lvgl::getSyncLock()->unlock();
lvgl_unlock();
},
[temp_file_path](const char* errorMessage) {
LOG_E(TAG, "Download failed: %s", errorMessage);
@ -133,9 +134,9 @@ class AppHubDetailsApp final : public App {
void installApp() {
LOG_I(TAG, "Install");
lvgl::getSyncLock()->lock();
lvgl_lock();
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
lvgl::getSyncLock()->unlock();
lvgl_unlock();
doInstall();
}
@ -143,9 +144,9 @@ class AppHubDetailsApp final : public App {
void updateApp() {
LOG_I(TAG, "Update");
lvgl::getSyncLock()->lock();
lvgl_lock();
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
lvgl::getSyncLock()->unlock();
lvgl_unlock();
LOG_I(TAG, "Removing previous version");
uninstall(entry.appId);

View File

@ -1,16 +1,12 @@
#include <Tactility/Tactility.h>
#include <lvgl/icons/shared.h>
#include <Tactility/PubSub.h>
#include <Tactility/app/App.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/audio/Audio.h>
#include <lvgl/widgets/sliderbox.h>
#include <lvgl.h>
#include <lvgl/icons/shared.h>
#include <lvgl/lvgl.h>
#include <lvgl/widgets/sliderbox.h>
namespace tt::app::audiosettings {
@ -161,10 +157,9 @@ public:
refresh();
audioSubscription = service::audio::getPubsub()->subscribe([this](auto) {
if (lvgl::lock(lvgl::defaultLockTime)) {
refresh();
lvgl::unlock();
}
lvgl_lock();
refresh();
lvgl_unlock();
});
}

View File

@ -1,11 +1,11 @@
#include <lvgl/lvgl.h>
#include <Tactility/app/btmanage/BtManagePrivate.h>
#include <Tactility/app/btmanage/View.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Tactility.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/lvgl/LvglSync.h>
#include <lvgl/icons/shared.h>
#include <tactility/log.h>
@ -79,12 +79,9 @@ void BtManage::unlock() {
void BtManage::requestViewUpdate() {
lock();
if (isViewEnabled) {
if (lvgl::lock(1000)) {
view.update();
lvgl::unlock();
} else {
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
lvgl_lock();
view.update();
lvgl_unlock();
}
unlock();
}

View File

@ -1,23 +1,21 @@
#include <Tactility/app/btpeersettings/BtPeerSettings.h>
#include "tactility/device.h"
#include <lvgl/lvgl.h>
#include <lvgl/widgets/toolbar.h>
#include <Tactility/LogMessages.h>
#include <Tactility/app/App.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/bluetooth/Bluetooth.h>
#include <Tactility/bluetooth/BluetoothPairedDevice.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Style.h>
#include <lvgl/widgets/toolbar.h>
#include <tactility/check.h>
#include <tactility/device.h>
#include <tactility/drivers/bluetooth.h>
#include <tactility/log.h>
#include <lvgl.h>
namespace tt::app::btpeersettings {
constexpr auto* TAG = "BtPeerSettings";
@ -84,12 +82,9 @@ class BtPeerSettings : public App {
void requestViewUpdate() const {
if (viewEnabled) {
if (lvgl::lock(1000)) {
updateViews();
lvgl::unlock();
} else {
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
lvgl_lock();
updateViews();
lvgl_unlock();
}
}

View File

@ -6,15 +6,16 @@
#include <Tactility/app/chat/ChatAppPrivate.h>
#include <Tactility/app/chat/ChatProtocol.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/lvgl/LvglSync.h>
#include <tactility/log.h>
#include <lvgl/icons/shared.h>
#include <lvgl/lvgl.h>
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <tactility/log.h>
#include <vector>
namespace tt::app::chat {
@ -83,12 +84,9 @@ void ChatApp::onReceive(const esp_now_recv_info_t* receiveInfo, const uint8_t* d
state.addMessage(msg);
{
auto lockable = lvgl::getSyncLock();
auto lock = lockable->asScopedLock();
lock.lock();
view.displayMessage(msg);
}
lvgl_lock();
view.displayMessage(msg);
lvgl_unlock();
}
void ChatApp::sendMessage(const std::string& text) {
@ -115,12 +113,9 @@ void ChatApp::sendMessage(const std::string& text) {
state.addMessage(msg);
{
auto lockable = lvgl::getSyncLock();
auto lock = lockable->asScopedLock();
lock.lock();
view.displayMessage(msg);
}
lvgl_lock();
view.displayMessage(msg);
lvgl_unlock();
}
void ChatApp::applySettings(const std::string& nickname, const std::string& keyHex) {
@ -173,12 +168,9 @@ void ChatApp::switchChannel(const std::string& chatChannel) {
settings.chatChannel = trimmedChannel;
saveSettings(settings);
{
auto lockable = lvgl::getSyncLock();
auto lock = lockable->asScopedLock();
lock.lock();
view.refreshMessageList();
}
lvgl_lock();
view.refreshMessageList();
lvgl_unlock();
}
extern const AppManifest manifest = {

View File

@ -3,7 +3,6 @@
#include <Tactility/Tactility.h>
#include <Tactility/Timer.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>
@ -11,12 +10,12 @@
#include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h>
#include <lvgl/icons/shared.h>
#include <lvgl/lvgl.h>
#include <tactility/log.h>
#include <lvgl/icons/shared.h>
#include <lvgl/lvgl.h>
#include <cstring>
#include <lvgl.h>
namespace tt::app::development {

View File

@ -1,6 +1,5 @@
#include <Tactility/app/files/SupportedFiles.h>
#include <Tactility/app/files/View.h>
#include <Tactility/Platform.h>
#include <Tactility/StringUtils.h>
#include <Tactility/Tactility.h>
@ -9,14 +8,15 @@
#include <Tactility/app/inputdialog/InputDialog.h>
#include <Tactility/app/notes/Notes.h>
#include <Tactility/file/File.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <tactility/check.h>
#include <tactility/check.h>
#include <tactility/device.h>
#include <tactility/drivers/usb_host_msc.h>
#include <tactility/log.h>
#include <lvgl/lvgl.h>
#include <cctype>
#include <cstdio>
#include <cstring>
@ -450,9 +450,7 @@ void View::onEjectPressed() {
void View::update(size_t start_index) {
const bool is_root = (state->getCurrentPath() == "/");
auto sync_lockable = lvgl::getSyncLock();
auto scoped_lockable = sync_lockable->asScopedLock();
if (!scoped_lockable.lock(lvgl::defaultLockTime)) {
if (!lvgl_try_lock(500 / portTICK_PERIOD_MS)) {
LOG_E(TAG, "Mutex acquisition timeout (%s)", "lvgl");
return;
}
@ -516,6 +514,8 @@ void View::update(size_t start_index) {
} else {
lv_obj_add_flag(lv_obj_get_parent(paste_button), LV_OBJ_FLAG_HIDDEN);
}
lvgl_unlock();
}
void View::init(const AppContext& appContext, lv_obj_t* parent) {
@ -551,18 +551,16 @@ void View::init(const AppContext& appContext, lv_obj_t* parent) {
}
void View::onDirEntryListScrollBegin() {
auto sync_lockable = lvgl::getSyncLock();
auto scoped_lockable = sync_lockable->asScopedLock();
if (scoped_lockable.lock(lvgl::defaultLockTime)) {
if (lvgl_try_lock(500 / portTICK_PERIOD_MS)) {
lv_obj_add_flag(action_list, LV_OBJ_FLAG_HIDDEN);
lvgl_unlock();
}
}
void View::onNavigate() {
auto sync_lockable = lvgl::getSyncLock();
auto scoped_lockable = sync_lockable->asScopedLock();
if (scoped_lockable.lock(lvgl::defaultLockTime)) {
if (lvgl_try_lock(500 / portTICK_PERIOD_MS)) {
lv_obj_add_flag(action_list, LV_OBJ_FLAG_HIDDEN);
lvgl_unlock();
}
}

View File

@ -1,16 +1,16 @@
#include <Tactility/app/fileselection/View.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Platform.h>
#include <Tactility/StringUtils.h>
#include <Tactility/Tactility.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/file/File.h>
#include <Tactility/Platform.h>
#include <Tactility/lvgl/LvglSync.h>
#include <lvgl/widgets/toolbar.h>
#include <tactility/check.h>
#include <tactility/log.h>
#include <lvgl/lvgl.h>
#include <lvgl/widgets/toolbar.h>
#include <cstring>
#include <unistd.h>
@ -155,26 +155,27 @@ void View::onNavigateUpPressed() {
}
void View::update() {
auto sync_lockable = lvgl::getSyncLock();
auto scoped_lockable = sync_lockable->asScopedLock();
if (scoped_lockable.lock(lvgl::defaultLockTime)) {
lv_obj_clean(dir_entry_list);
state->withEntries([this](const std::vector<dirent>& entries) {
for (auto entry : entries) {
LOG_D(TAG, "Entry: %s %d", entry.d_name, (int)entry.d_type);
createDirEntryWidget(dir_entry_list, entry);
}
});
if (state->getCurrentPath() == "/") {
lv_obj_add_flag(navigate_up_button, LV_OBJ_FLAG_HIDDEN);
} else {
lv_obj_remove_flag(navigate_up_button, LV_OBJ_FLAG_HIDDEN);
}
} else {
if (!lvgl_try_lock(500 / portTICK_PERIOD_MS)) {
LOG_E(TAG, "Mutex acquisition timeout (%s)", "lvgl");
return;
}
lv_obj_clean(dir_entry_list);
state->withEntries([this](const std::vector<dirent>& entries) {
for (auto entry : entries) {
LOG_D(TAG, "Entry: %s %d", entry.d_name, (int)entry.d_type);
createDirEntryWidget(dir_entry_list, entry);
}
});
if (state->getCurrentPath() == "/") {
lv_obj_add_flag(navigate_up_button, LV_OBJ_FLAG_HIDDEN);
} else {
lv_obj_remove_flag(navigate_up_button, LV_OBJ_FLAG_HIDDEN);
}
lvgl_unlock();
}
void View::init(lv_obj_t* parent, Mode mode) {

View File

@ -1,20 +1,20 @@
#include <Tactility/app/i2cscanner/I2cScannerPrivate.h>
#include <Tactility/app/i2cscanner/I2cHelpers.h>
#include <Tactility/app/i2cscanner/I2cScannerPrivate.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Preferences.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/Timer.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <tactility/drivers/i2c_controller.h>
#include <tactility/log.h>
#include <format>
#include <lvgl/lvgl.h>
#include <lvgl/icons/shared.h>
#include <tactility/log.h>
namespace tt::app::i2cscanner {
@ -367,12 +367,9 @@ void I2cScannerApp::updateViews() {
}
void I2cScannerApp::updateViewsSafely() {
if (lvgl::lock(200 / portTICK_PERIOD_MS)) {
updateViews();
lvgl::unlock();
} else {
LOG_W(TAG, "Mutex acquisition timeout (%s)", "updateViewsSafely");
}
lvgl_lock();
updateViews();
lvgl_unlock();
}
void I2cScannerApp::onScanTimerFinished() {

View File

@ -1,10 +1,9 @@
#include "lvgl/lvgl.h"
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/fileselection/FileSelection.h>
#include <Tactility/file/FileLock.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/Assets.h>
#include <Tactility/file/File.h>
#include <lvgl/icons/shared.h>
@ -42,16 +41,16 @@ class NotesApp final : public App {
break;
case 1: // Save
if (!filePath.empty()) {
lvgl::getSyncLock()->lock();
lvgl_lock();
saveBuffer = lv_textarea_get_text(uiNoteText);
lvgl::getSyncLock()->unlock();
lvgl_unlock();
saveFile(filePath);
}
break;
case 2: // Save as...
lvgl::getSyncLock()->lock();
lvgl_lock();
saveBuffer = lv_textarea_get_text(uiNoteText);
lvgl::getSyncLock()->unlock();
lvgl_unlock();
saveFileLaunchId = fileselection::startForExistingOrNewFile();
LOG_I(TAG, "launched with id %u", saveFileLaunchId);
break;
@ -87,13 +86,12 @@ class NotesApp final : public App {
file::getLock(path)->withLock([this, path] {
auto data = file::readString(path);
if (data != nullptr) {
auto lockable = lvgl::getSyncLock();
auto lock = lockable->asScopedLock();
lock.lock();
lv_textarea_set_text(uiNoteText, reinterpret_cast<const char*>(data.get()));
lv_label_set_text(uiCurrentFileName, path.c_str());
filePath = path;
LOG_I(TAG, "Loaded from %s", path.c_str());
lvgl_lock();
lv_textarea_set_text(uiNoteText, reinterpret_cast<const char*>(data.get()));
lv_label_set_text(uiCurrentFileName, path.c_str());
lvgl_unlock();
filePath = path;
LOG_I(TAG, "Loaded from %s", path.c_str());
}
});
}

View File

@ -1,16 +1,14 @@
#include <Tactility/app/AppContext.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/Timer.h>
#include <lvgl/icons/shared.h>
#include <tactility/device.h>
#include <tactility/drivers/power_supply.h>
#include <lvgl.h>
#include <lvgl/lvgl.h>
#include <lvgl/icons/shared.h>
#include <vector>
@ -136,7 +134,7 @@ class PowerApp : public App {
return;
}
lvgl::lock(kernel::millisToTicks(1000));
lvgl_lock();
for (auto& entry : entries) {
if (entry.enableSwitch != nullptr) {
@ -155,7 +153,7 @@ class PowerApp : public App {
}
}
lvgl::unlock();
lvgl_unlock();
}
public:

View File

@ -7,16 +7,16 @@
#include <Tactility/app/App.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/lvgl/Lvgl.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/screenshot/Screenshot.h>
#include <Tactility/Paths.h>
#include <Tactility/Timer.h>
#include <lvgl/icons/shared.h>
#include <tactility/log.h>
#include <lvgl/lvgl.h>
#include <lvgl/icons/shared.h>
namespace tt::app::screenshot {
constexpr auto* TAG = "Screenshot";
@ -87,10 +87,9 @@ ScreenshotApp::~ScreenshotApp() {
}
void ScreenshotApp::onTimerTick() {
auto lockable = lvgl::getSyncLock();
auto lock = lockable->asScopedLock();
if (lock.lock(lvgl::defaultLockTime)) {
if (lvgl_try_lock(500 / portTICK_PERIOD_MS)) {
updateScreenshotMode();
lvgl_unlock();
}
}

View File

@ -4,12 +4,10 @@
#include <Tactility/app/App.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/setup/Setup.h>
#include <Tactility/Preferences.h>
#include <Tactility/StringUtils.h>
#include <Tactility/app/timezone/TimeZone.h>
#include <Tactility/app/wifimanage/WifiManage.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/wifi/Wifi.h>
#include <lvgl.h>

View File

@ -1,14 +1,12 @@
#include <Tactility/TactilityConfig.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Tactility.h>
#include <Tactility/Timer.h>
#include <Tactility/Paths.h>
#include <algorithm>
#include <cstring>
#include <format>
#include <lvgl.h>
#include <utility>
#include <lvgl/icons/shared.h>
@ -247,20 +245,18 @@ class SystemInfoApp final : public App {
Timer memoryTimer = Timer(Timer::Type::Periodic, kernel::millisToTicks(10000), [] {
auto app = optApp();
if (app) {
auto lockable = lvgl::getSyncLock();
auto lock = lockable->asScopedLock();
lock.lock();
lvgl_lock();
app->updateMemory();
lvgl_unlock();
}
});
Timer tasksTimer = Timer(Timer::Type::Periodic, kernel::millisToTicks(15000), [] {
auto app = optApp();
if (app) {
auto lockable = lvgl::getSyncLock();
auto lock = lockable->asScopedLock();
lock.lock();
lvgl_lock();
app->updateTasks();
lvgl_unlock();
}
});

View File

@ -1,20 +1,16 @@
#include <lvgl/lvgl.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/timezone/TimeZone.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/settings/SystemSettings.h>
#include <Tactility/settings/Time.h>
#include <lvgl.h>
#include <lvgl/icons/shared.h>
#include <tactility/log.h>
#include <lvgl/lvgl.h>
#include <lvgl/icons/shared.h>
namespace tt::app::timedatesettings {
constexpr auto* TAG = "TimeDate";

View File

@ -1,21 +1,20 @@
#include <lvgl/icons/shared.h>
#include <lvgl/fonts.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/timezone/TimeZone.h>
#include <Tactility/LogMessages.h>
#include <Tactility/MountPoints.h>
#include <Tactility/StringUtils.h>
#include <Tactility/Timer.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/settings/Time.h>
#include <tactility/log.h>
#include <lvgl.h>
#include <lvgl/lvgl.h>
#include <lvgl/icons/shared.h>
#include <lvgl/fonts.h>
#include <memory>
namespace tt::app::timezone {
@ -166,16 +165,16 @@ class TimeZoneApp final : public App {
}
void updateList() {
if (lvgl::lock(200 / portTICK_PERIOD_MS)) {
if (lvgl_try_lock(200 / portTICK_PERIOD_MS)) {
std::string filter = string::lowercase(std::string(lv_textarea_get_text(filterTextareaWidget)));
lvgl::unlock();
lvgl_unlock();
readTimeZones(filter);
} else {
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "TimeZone LVGL");
return;
}
if (lvgl::lock(200 / portTICK_PERIOD_MS)) {
if (lvgl_try_lock(200 / portTICK_PERIOD_MS)) {
if (mutex.lock(100 / portTICK_PERIOD_MS)) {
lv_obj_clean(listWidget);
@ -188,7 +187,7 @@ class TimeZoneApp final : public App {
mutex.unlock();
}
lvgl::unlock();
lvgl_unlock();
} else {
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "TimeZone LVGL");
}

View File

@ -2,22 +2,17 @@
#include <Tactility/Tactility.h>
#include <Tactility/settings/WebServerSettings.h>
#include <Tactility/service/wifi/Wifi.h>
#include <Tactility/service/wifi/WifiApSettings.h>
#include <Tactility/service/webserver/AssetVersion.h>
#include <Tactility/service/webserver/WebServerService.h>
#include <Tactility/Assets.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/webserver/WebServerService.h>
#include <Tactility/service/wifi/Wifi.h>
#include <tactility/log.h>
#include <lvgl/icons/shared.h>
#include <lvgl.h>
#include <tactility/log.h>
#include <lvgl/lvgl.h>
#include <esp_netif.h>
#include <esp_wifi.h>
#include <freertos/FreeRTOS.h>
#include <freertos/timers.h>
namespace tt::app::webserversettings {
@ -47,10 +42,9 @@ class WebServerSettingsApp final : public App {
app->wsSettings.wifiMode = static_cast<settings::webserver::WiFiMode>(index);
app->updated = true;
app->wifiSettingsChanged = true;
if (lvgl::lock(100)) {
app->updateUrlDisplay();
lvgl::unlock();
}
lvgl_lock();
app->updateUrlDisplay();
lvgl_unlock();
});
}
@ -60,10 +54,9 @@ class WebServerSettingsApp final : public App {
getMainDispatcher().dispatch([app, enabled] {
app->wsSettings.webServerEnabled = enabled;
app->updated = true;
if (lvgl::lock(100)) {
app->updateUrlDisplay();
lvgl::unlock();
}
lvgl_lock();
app->updateUrlDisplay();
lvgl_unlock();
// Apply immediately instead of waiting for app exit
const auto copy = app->wsSettings;

View File

@ -1,20 +1,17 @@
#include "Tactility/lvgl/LvglSync.h"
#include <Tactility/LogMessages.h>
#include <Tactility/app/App.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/lvgl/Style.h>
#include <lvgl/widgets/toolbar.h>
#include <Tactility/service/wifi/Wifi.h>
#include <Tactility/service/wifi/WifiApSettings.h>
#include <lvgl/lvgl.h>
#include <lvgl/widgets/toolbar.h>
#include <tactility/check.h>
#include <tactility/log.h>
#include <lvgl.h>
namespace tt::app::wifiapsettings {
constexpr auto* TAG = "WifiApSettings";
@ -88,12 +85,9 @@ class WifiApSettings : public App {
void requestViewUpdate() const {
if (viewEnabled) {
if (lvgl::lock(1000)) {
updateViews();
lvgl::unlock();
} else {
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
lvgl_lock();
updateViews();
lvgl_unlock();
}
}

View File

@ -1,12 +1,10 @@
#include <Tactility/app/wificonnect/WifiConnect.h>
#include <Tactility/LogMessages.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h>
#include <tactility/log.h>
#include <lvgl/lvgl.h>
namespace tt::app::wificonnect {
@ -68,12 +66,9 @@ void WifiConnect::unlock() {
void WifiConnect::requestViewUpdate() {
lock();
if (viewEnabled) {
if (lvgl::lock(1000)) {
view.update();
lvgl::unlock();
} else {
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
lvgl_lock();
view.update();
lvgl_unlock();
}
unlock();
}

View File

@ -1,16 +1,16 @@
#include <Tactility/app/wifimanage/WifiManagePrivate.h>
#include <Tactility/app/wifimanage/View.h>
#include <Tactility/app/wifimanage/WifiManagePrivate.h>
#include <Tactility/LogMessages.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>
#include <lvgl/icons/shared.h>
#include <tactility/log.h>
#include <lvgl/icons/shared.h>
#include <lvgl/lvgl.h>
namespace tt::app::wifimanage {
constexpr auto* TAG = "WifiManage";
@ -65,12 +65,9 @@ void WifiManage::unlock() {
void WifiManage::requestViewUpdate() {
lock();
if (isViewEnabled) {
if (lvgl::lock(1000)) {
view.update();
lvgl::unlock();
} else {
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
lvgl_lock();
view.update();
lvgl_unlock();
}
unlock();
}

View File

@ -11,7 +11,8 @@
#include <Tactility/Assets.h>
#include <Tactility/Tactility.h>
#include <Tactility/lvgl/Keyboard.h>
#include <Tactility/lvgl/LvglSync.h>
#include <tactility/log.h>
#include <host/ble_gap.h>
#include <host/ble_gatt.h>
@ -20,8 +21,8 @@
#include <esp_timer.h>
#include <freertos/FreeRTOS.h>
#include <freertos/queue.h>
#include <lvgl.h>
#include <tactility/log.h>
#include <lvgl/lvgl.h>
#include <algorithm>
#include <array>
@ -226,7 +227,7 @@ static void hidHostHandleMouseReport(const uint8_t* data, uint16_t len) {
if (hid_host_ctx && hid_host_ctx->mouseIndev == nullptr) {
getMainDispatcher().dispatch([] {
if (!hid_host_ctx || hid_host_ctx->mouseIndev != nullptr) return;
if (!tt::lvgl::lock(1000)) { LOG_W(TAG, "LVGL lock failed for mouse indev"); return; }
if (!lvgl_try_lock(1000)) { LOG_W(TAG, "LVGL lock failed for mouse indev"); return; }
auto* ms = lv_indev_create();
lv_indev_set_type(ms, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(ms, hidHostMouseReadCb);
@ -237,7 +238,7 @@ static void hidHostHandleMouseReport(const uint8_t* data, uint16_t len) {
lv_indev_set_cursor(ms, cur);
hid_host_ctx->mouseIndev = ms;
hid_host_ctx->mouseCursor = cur;
tt::lvgl::unlock();
lvgl_unlock();
LOG_I(TAG, "Mouse indev registered");
});
}
@ -468,13 +469,13 @@ static void hidHostSubscribeNext(HidHostCtx& ctx) {
}
getMainDispatcher().dispatch([] {
if (!hid_host_ctx || hid_host_ctx->kbIndev != nullptr) return;
if (!tt::lvgl::lock(1000)) { LOG_W(TAG, "LVGL lock failed for kb indev"); return; }
if (!lvgl_try_lock(1000)) { LOG_W(TAG, "LVGL lock failed for kb indev"); return; }
auto* kb = lv_indev_create();
lv_indev_set_type(kb, LV_INDEV_TYPE_KEYPAD);
lv_indev_set_read_cb(kb, hidHostKeyboardReadCb);
hid_host_ctx->kbIndev = kb;
tt::lvgl::hardware_keyboard_set_indev(kb);
tt::lvgl::unlock();
lvgl::hardware_keyboard_set_indev(kb);
lvgl_unlock();
LOG_I(TAG, "Keyboard indev registered");
});
@ -694,18 +695,18 @@ static int hidHostGapCb(struct ble_gap_event* event, void* /*arg*/) {
}
getMainDispatcher().dispatch([saved_kb, saved_mouse, saved_cursor, saved_queue] {
if (!tt::lvgl::lock(1000)) {
if (!lvgl_try_lock(1000)) {
LOG_W(TAG, "Failed to acquire LVGL lock for indev cleanup");
if (saved_queue) vQueueDelete(saved_queue);
return;
}
if (saved_kb) {
tt::lvgl::hardware_keyboard_set_indev(nullptr);
lvgl::hardware_keyboard_set_indev(nullptr);
lv_indev_delete(saved_kb);
}
if (saved_mouse) lv_indev_delete(saved_mouse);
if (saved_cursor) lv_obj_delete(saved_cursor);
tt::lvgl::unlock();
lvgl_unlock();
if (saved_queue) vQueueDelete(saved_queue);
});
break;

View File

@ -1,35 +0,0 @@
#include "Tactility/lvgl/LvglSync.h"
#include <Tactility/Mutex.h>
#include <lvgl/lvgl.h>
namespace tt::lvgl {
bool lock(TickType_t timeout) {
return lvgl_try_lock(timeout);
}
void unlock() {
lvgl_unlock();
}
class LvglSync : public Lock {
public:
~LvglSync() override = default;
bool lock(TickType_t timeoutTicks) const override {
return lvgl_try_lock(timeoutTicks);
}
void unlock() const override {
lvgl_unlock();
}
};
static std::shared_ptr<Lock> lvglSync = std::make_shared<LvglSync>();
std::shared_ptr<Lock> getSyncLock() {
return lvglSync;
}
} // namespace

View File

@ -5,17 +5,16 @@
#include <Tactility/RecursiveMutex.h>
#include <Tactility/Tactility.h>
#include <Tactility/Timer.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Statusbar.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/settings/Time.h>
#include <lvgl/fonts.h>
#include <lvgl/lvgl.h>
#include <tactility/check.h>
#include <tactility/log.h>
#include <lvgl.h>
#include <lvgl/fonts.h>
#include <lvgl/lvgl.h>
#include <memory>
namespace tt::lvgl {
@ -106,10 +105,10 @@ static lv_obj_class_t statusbar_class = {
static void statusbar_pubsub_event(Statusbar* statusbar) {
LOG_D(TAG, "Update event");
if (lock(defaultLockTime)) {
if (lvgl_try_lock(500 / portTICK_PERIOD_MS)) {
update_main(statusbar);
lv_obj_invalidate(&statusbar->obj);
unlock();
lvgl_unlock();
} else {
LOG_W(TAG, "Mutex acquisition timeout (%s)", "Statusbar");
}

View File

@ -2,10 +2,8 @@
#ifdef ESP_PLATFORM
#include <atomic>
#include <Tactility/Assets.h>
#include <Tactility/lvgl/Keyboard.h>
#include <Tactility/lvgl/LvglSync.h>
#include <tactility/device.h>
#include <tactility/drivers/usb_host_hid.h>
@ -16,7 +14,9 @@
#include <freertos/task.h>
#include <freertos/semphr.h>
#include <lvgl.h>
#include <lvgl/lvgl.h>
#include <atomic>
namespace tt::lvgl {
@ -148,33 +148,31 @@ static void usbHidInputTask(void* arg) {
auto* ctx = static_cast<UsbHidInputCtx*>(arg);
LOG_I(TAG, "started");
// TODO: Implement time-out
while (!lv_is_initialized()) {
vTaskDelay(pdMS_TO_TICKS(100));
}
if (lock()) {
ctx->mouse_cursor = lv_image_create(lv_layer_sys());
lv_obj_remove_flag(ctx->mouse_cursor, LV_OBJ_FLAG_CLICKABLE);
lv_image_set_src(ctx->mouse_cursor, TT_ASSETS_UI_CURSOR);
lv_obj_add_flag(ctx->mouse_cursor, LV_OBJ_FLAG_HIDDEN);
lvgl_lock();
ctx->mouse_indev = lv_indev_create();
lv_indev_set_type(ctx->mouse_indev, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(ctx->mouse_indev, mouse_read_cb);
lv_indev_set_user_data(ctx->mouse_indev, ctx);
lv_indev_set_cursor(ctx->mouse_indev, ctx->mouse_cursor);
ctx->mouse_cursor = lv_image_create(lv_layer_sys());
lv_obj_remove_flag(ctx->mouse_cursor, LV_OBJ_FLAG_CLICKABLE);
lv_image_set_src(ctx->mouse_cursor, TT_ASSETS_UI_CURSOR);
lv_obj_add_flag(ctx->mouse_cursor, LV_OBJ_FLAG_HIDDEN);
ctx->kb_indev = lv_indev_create();
lv_indev_set_type(ctx->kb_indev, LV_INDEV_TYPE_KEYPAD);
lv_indev_set_read_cb(ctx->kb_indev, keyboard_read_cb);
lv_indev_set_user_data(ctx->kb_indev, ctx);
lv_indev_set_group(ctx->kb_indev, lv_group_get_default());
ctx->mouse_indev = lv_indev_create();
lv_indev_set_type(ctx->mouse_indev, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(ctx->mouse_indev, mouse_read_cb);
lv_indev_set_user_data(ctx->mouse_indev, ctx);
lv_indev_set_cursor(ctx->mouse_indev, ctx->mouse_cursor);
unlock();
LOG_I(TAG, "LVGL input devices registered");
} else {
LOG_W(TAG, "could not acquire LVGL lock for indev registration");
}
ctx->kb_indev = lv_indev_create();
lv_indev_set_type(ctx->kb_indev, LV_INDEV_TYPE_KEYPAD);
lv_indev_set_read_cb(ctx->kb_indev, keyboard_read_cb);
lv_indev_set_user_data(ctx->kb_indev, ctx);
lv_indev_set_group(ctx->kb_indev, lv_group_get_default());
lvgl_unlock();
// Drain the HID event queue and route events to the appropriate destinations
while (ctx->running) {
@ -228,29 +226,29 @@ static void usbHidInputTask(void* arg) {
break;
}
case USB_HID_EVENT_KEYBOARD_CONNECTED:
if (ctx->kb_indev && lock(pdMS_TO_TICKS(200))) {
if (ctx->kb_indev && lvgl_try_lock(pdMS_TO_TICKS(200))) {
hardware_keyboard_set_indev(ctx->kb_indev);
unlock();
lvgl_unlock();
}
break;
case USB_HID_EVENT_KEYBOARD_DISCONNECTED:
if (lock(pdMS_TO_TICKS(200))) {
if (lvgl_try_lock(pdMS_TO_TICKS(200))) {
hardware_keyboard_set_indev(nullptr);
unlock();
lvgl_unlock();
}
break;
case USB_HID_EVENT_MOUSE_CONNECTED:
ctx->mouse_connected = true;
if (ctx->mouse_cursor && lock(pdMS_TO_TICKS(200))) {
if (ctx->mouse_cursor && lvgl_try_lock(pdMS_TO_TICKS(200))) {
lv_obj_remove_flag(ctx->mouse_cursor, LV_OBJ_FLAG_HIDDEN);
unlock();
lvgl_unlock();
}
break;
case USB_HID_EVENT_MOUSE_DISCONNECTED:
ctx->mouse_connected = false;
if (ctx->mouse_cursor && lock(pdMS_TO_TICKS(200))) {
if (ctx->mouse_cursor && lvgl_try_lock(pdMS_TO_TICKS(200))) {
lv_obj_add_flag(ctx->mouse_cursor, LV_OBJ_FLAG_HIDDEN);
unlock();
lvgl_unlock();
}
break;
default:
@ -258,16 +256,15 @@ static void usbHidInputTask(void* arg) {
}
}
if (lock()) {
if (ctx->mouse_indev) { lv_indev_delete(ctx->mouse_indev); ctx->mouse_indev = nullptr; }
if (ctx->mouse_cursor) { lv_obj_delete(ctx->mouse_cursor); ctx->mouse_cursor = nullptr; }
if (ctx->kb_indev) {
hardware_keyboard_set_indev(nullptr);
lv_indev_delete(ctx->kb_indev);
ctx->kb_indev = nullptr;
}
unlock();
lvgl_lock();
if (ctx->mouse_indev) { lv_indev_delete(ctx->mouse_indev); ctx->mouse_indev = nullptr; }
if (ctx->mouse_cursor) { lv_obj_delete(ctx->mouse_cursor); ctx->mouse_cursor = nullptr; }
if (ctx->kb_indev) {
hardware_keyboard_set_indev(nullptr);
lv_indev_delete(ctx->kb_indev);
ctx->kb_indev = nullptr;
}
lvgl_unlock();
LOG_I(TAG, "stopped");
xSemaphoreGive(ctx->task_done);
@ -334,7 +331,7 @@ void stopUsbHidInput() {
vTaskDelete(ctx->task);
// Task was killed before it could clean up LVGL objects; do it here to
// prevent mouse_read_cb / keyboard_read_cb from running with a freed ctx.
if (lock(pdMS_TO_TICKS(200))) {
if (lvgl_try_lock(pdMS_TO_TICKS(200))) {
if (ctx->mouse_indev) { lv_indev_delete(ctx->mouse_indev); ctx->mouse_indev = nullptr; }
if (ctx->mouse_cursor) { lv_obj_delete(ctx->mouse_cursor); ctx->mouse_cursor = nullptr; }
if (ctx->kb_indev) {
@ -342,7 +339,7 @@ void stopUsbHidInput() {
lv_indev_delete(ctx->kb_indev);
ctx->kb_indev = nullptr;
}
unlock();
lvgl_unlock();
}
}
ctx->task = nullptr;

View File

@ -1,19 +1,18 @@
#include <Tactility/service/gui/GuiService.h>
#include <cstring>
#include <Tactility/LogMessages.h>
#include <Tactility/Tactility.h>
#include <Tactility/app/AppInstance.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Statusbar.h>
#include <Tactility/lvgl/UsbHidInput.h>
#include <Tactility/service/ServiceRegistration.h>
#include <Tactility/service/loader/Loader.h>
#include <tactility/log.h>
#include <lvgl/lvgl.h>
#include <cstring>
namespace tt::service::gui {
extern const ServiceManifest manifest;

View File

@ -1,11 +1,12 @@
#include "Tactility/lvgl/Keyboard.h"
#include "Tactility/lvgl/LvglSync.h"
#include "Tactility/service/gui/GuiService.h"
#include <tactility/check.h>
#include <Tactility/lvgl/Keyboard.h>
#include <Tactility/service/gui/GuiService.h>
#include <Tactility/TactilityConfig.h>
#include <Tactility/service/espnow/EspNowService.h>
#include <tactility/check.h>
#include <lvgl/lvgl.h>
namespace tt::service::gui {
static void show_keyboard(lv_event_t* event) {
@ -53,7 +54,7 @@ void GuiService::keyboardAddTextArea(lv_obj_t* textarea) {
lock();
if (isStarted) {
check(lvgl::lock(0), "lvgl should already be locked before calling this method");
check(lvgl_try_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);
@ -66,7 +67,7 @@ void GuiService::keyboardAddTextArea(lv_obj_t* textarea) {
lvgl::software_keyboard_activate(keyboardGroup);
}
lvgl::unlock();
lvgl_unlock();
}
unlock();

View File

@ -5,16 +5,17 @@
#include <Tactility/LogMessages.h>
#include <Tactility/CpuAffinity.h>
#include <Tactility/TactilityCore.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/service/screenshot/ScreenshotTask.h>
#include <tactility/log.h>
#include <lvgl/lvgl.h>
#include <lv_screenshot.h>
#include <format>
#include <tactility/log.h>
namespace tt::service::screenshot {
constexpr auto* TAG = "ScreenshotTask";
@ -50,13 +51,13 @@ void ScreenshotTask::setFinished() {
}
static void makeScreenshot(const std::string& filename) {
if (lvgl::lock(50 / portTICK_PERIOD_MS)) {
if (lvgl_try_lock(50 / portTICK_PERIOD_MS)) {
if (lv_screenshot_create(lv_scr_act(), LV_100ASK_SCREENSHOT_SV_PNG, filename.c_str())) {
LOG_I(TAG, "Screenshot saved to %s", filename.c_str());
} else {
LOG_E(TAG, "Screenshot not saved to %s", filename.c_str());
}
lvgl::unlock();
lvgl_unlock();
} else {
LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}

View File

@ -3,11 +3,11 @@
#include <Tactility/Mutex.h>
#include <Tactility/Timer.h>
#include <Tactility/bluetooth/Bluetooth.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/ServiceContext.h>
#include <Tactility/service/ServicePaths.h>
#include <Tactility/service/ServiceRegistration.h>
#include <Tactility/service/wifi/Wifi.h>
#include <tactility/check.h>
#include <tactility/device.h>
#include <tactility/drivers/bluetooth.h>
@ -18,7 +18,6 @@
#include <tactility/drivers/usb_host_midi.h>
#include <tactility/drivers/usb_host_msc.h>
#include <tactility/filesystem/file_system.h>
#include <tactility/log.h>
#include <lvgl/icons/statusbar.h>

View File

@ -1,8 +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>
#include <Tactility/settings/WebServerSettings.h>
#include <Tactility/MountPoints.h>
@ -10,28 +8,29 @@
#include <Tactility/lvgl/Statusbar.h>
#include <Tactility/Mutex.h>
#include <tactility/check.h>
#include <Tactility/TactilityConfig.h>
#include <Tactility/app/AppRegistration.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/App.h>
#include <Tactility/service/wifi/Wifi.h>
#include <esp_wifi_default.h>
#include <Tactility/network/HttpdReq.h>
#include <Tactility/network/Url.h>
#include <Tactility/Paths.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Lvgl.h>
#include <Tactility/StringUtils.h>
#include <ranges>
#include <tactility/filesystem/file_system.h>
#include <tactility/log.h>
#include <lvgl/lvgl.h>
#include <lvgl/icons/statusbar.h>
#if TT_FEATURE_SCREENSHOT_ENABLED
#include <lv_screenshot.h>
#endif
#include <lvgl/icons/statusbar.h>
#include <atomic>
#include <cctype>
#include <cerrno>
@ -42,16 +41,16 @@
#include <esp_netif.h>
#include <esp_system.h>
#include <esp_vfs_fat.h>
#include <esp_wifi_default.h>
#include <esp_wifi.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <iomanip>
#include <lwip/ip4_addr.h>
#include <mbedtls/base64.h>
#include <ranges>
#include <sstream>
#include <tactility/log.h>
namespace tt::service::webserver {
constexpr auto* TAG = "WebServerService";
@ -1477,9 +1476,9 @@ esp_err_t WebServerService::handleApiScreenshot(httpd_req_t* request) {
std::string lvgl_screenshot_path = lvgl::PATH_PREFIX + screenshot_path;
// Capture screenshot using LVGL
if (lvgl::lock(pdMS_TO_TICKS(100))) {
if (lvgl_try_lock(pdMS_TO_TICKS(100))) {
bool success = lv_screenshot_create(lv_scr_act(), LV_100ASK_SCREENSHOT_SV_PNG, lvgl_screenshot_path.c_str());
lvgl::unlock();
lvgl_unlock();
if (!success) {
LOG_E(TAG, "lv_screenshot_create failed for path: %s", lvgl_screenshot_path.c_str());