Refactor LVGL code into kernel module (#472)
* **New Features** * Added a standalone LVGL module and enabled LVGL support in the simulator for richer local UI testing. * **Refactor** * HAL and LVGL split into distinct modules; startup and device attach/detach flows reorganized for clearer lifecycle management. * Public APIs tightened with clearer nullability/documentation. * **Bug Fixes** * More consistent LVGL start/stop and device attach/detach behavior for improved stability.
This commit is contained in:
committed by
GitHub
parent
3fe1dc0312
commit
9f721e6655
@@ -1,39 +1,16 @@
|
||||
#include "Tactility/lvgl/LvglSync.h"
|
||||
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <tactility/lvgl_module.h>
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
static Mutex lockMutex;
|
||||
|
||||
static bool defaultLock(uint32_t timeoutMillis) {
|
||||
return lockMutex.lock(timeoutMillis);
|
||||
}
|
||||
|
||||
static void defaultUnlock() {
|
||||
lockMutex.unlock();
|
||||
}
|
||||
|
||||
static LvglLock lock_singleton = defaultLock;
|
||||
static LvglUnlock unlock_singleton = defaultUnlock;
|
||||
|
||||
void syncSet(LvglLock lock, LvglUnlock unlock) {
|
||||
auto old_lock = lock_singleton;
|
||||
auto old_unlock = unlock_singleton;
|
||||
|
||||
// Ensure the old lock is not engaged when changing locks
|
||||
old_lock((uint32_t)kernel::MAX_TICKS);
|
||||
lock_singleton = lock;
|
||||
unlock_singleton = unlock;
|
||||
old_unlock();
|
||||
}
|
||||
|
||||
bool lock(TickType_t timeout) {
|
||||
return lock_singleton(pdMS_TO_TICKS(timeout == 0 ? kernel::MAX_TICKS : timeout));
|
||||
return lvgl_try_lock_timed(timeout);
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
unlock_singleton();
|
||||
lvgl_unlock();
|
||||
}
|
||||
|
||||
class LvglSync : public Lock {
|
||||
@@ -41,11 +18,11 @@ public:
|
||||
~LvglSync() override = default;
|
||||
|
||||
bool lock(TickType_t timeoutTicks) const override {
|
||||
return lvgl::lock(timeoutTicks);
|
||||
return lvgl_try_lock_timed(timeoutTicks);
|
||||
}
|
||||
|
||||
void unlock() const override {
|
||||
lvgl::unlock();
|
||||
lvgl_unlock();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user