mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-10-19 20:05:06 +00:00
Fix for LVGL file lock when LVGL is not running
This commit is contained in:
parent
700c332219
commit
f77bea59bc
@ -20,16 +20,19 @@ static bool initialized = false;
|
|||||||
|
|
||||||
void lvgl_lock(void) {
|
void lvgl_lock(void) {
|
||||||
if (!initialized) { return; }
|
if (!initialized) { return; }
|
||||||
|
if (!lvgl_is_running()) { return; }
|
||||||
lvgl_port_lock(portMAX_DELAY);
|
lvgl_port_lock(portMAX_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lvgl_try_lock(uint32_t timeoutTicks) {
|
bool lvgl_try_lock(uint32_t timeoutTicks) {
|
||||||
if (!initialized) { return false; }
|
if (!initialized) { return false; }
|
||||||
|
if (!lvgl_is_running()) { return false; }
|
||||||
// lvgl_port_lock expects milliseconds
|
// lvgl_port_lock expects milliseconds
|
||||||
return lvgl_port_lock(timeoutTicks * portTICK_PERIOD_MS);
|
return lvgl_port_lock(timeoutTicks * portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lvgl_unlock(void) {
|
void lvgl_unlock(void) {
|
||||||
|
if (!lvgl_is_running()) { return; }
|
||||||
if (!initialized) { return; }
|
if (!initialized) { return; }
|
||||||
lvgl_port_unlock();
|
lvgl_port_unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,14 +9,35 @@
|
|||||||
constexpr auto* TAG = "file_mutex_lvgl";
|
constexpr auto* TAG = "file_mutex_lvgl";
|
||||||
|
|
||||||
struct Device;
|
struct Device;
|
||||||
namespace tt {
|
|
||||||
|
|
||||||
static const FileMutex lvgl_mutex = {
|
namespace {
|
||||||
.lock = lvgl_lock,
|
|
||||||
.try_lock = lvgl_try_lock,
|
void wrapped_lvgl_lock() {
|
||||||
.unlock = lvgl_unlock,
|
if (!lvgl_is_running()) return;
|
||||||
|
lvgl_lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wrapped_lvgl_try_lock(uint32_t timeout) {
|
||||||
|
// Return lock success, so the file operation can continue when LVGL is not running
|
||||||
|
// lvgl_try_lock() fails to lock if LVGL is not running
|
||||||
|
if (!lvgl_is_running()) return true;
|
||||||
|
return lvgl_try_lock(timeout);
|
||||||
|
}
|
||||||
|
void wrapped_lvgl_unlock() {
|
||||||
|
if (!lvgl_is_running()) return;
|
||||||
|
lvgl_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
const FileMutex lvgl_mutex = {
|
||||||
|
.lock = wrapped_lvgl_lock,
|
||||||
|
.try_lock = wrapped_lvgl_try_lock,
|
||||||
|
.unlock = wrapped_lvgl_unlock,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace tt {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds file systems with a device (e.g. sd card) that is owned by a SPI controller.
|
* Finds file systems with a device (e.g. sd card) that is owned by a SPI controller.
|
||||||
* If the SPI controller has a display on the bus, we create an LVGL lock for the file system path.
|
* If the SPI controller has a display on the bus, we create an LVGL lock for the file system path.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user