Tactility.py 3.0.0 and SDK updates for 0.7.0-dev (#19)
- Remove `Libraries/Str` - Replaced usage of `TactilityC` FreeRtos features with `TactilityFreeRtos` library - Update `tactility.py` - Removed redundant code from `TactilityCpp`
This commit is contained in:
committed by
GitHub
parent
3bc1e7a373
commit
b6c27b64d4
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <tt_lock.h>
|
||||
|
||||
class ScopedLock;
|
||||
|
||||
/** Represents a lock/mutex */
|
||||
class Lock {
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Lock() = default;
|
||||
|
||||
virtual bool lock(TickType timeout) const = 0;
|
||||
|
||||
bool lock() const { return lock(TT_MAX_TICKS); }
|
||||
|
||||
virtual bool unlock() const = 0;
|
||||
|
||||
ScopedLock asScopedLock() const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a lockable instance that is scoped to a specific lifecycle.
|
||||
* Once the ScopedLock is destroyed, unlock() is called automatically.
|
||||
*
|
||||
* In other words:
|
||||
* You have to lock() this object manually, but unlock() happens automatically on destruction.
|
||||
*/
|
||||
class ScopedLock final : public Lock {
|
||||
|
||||
const Lock& lockable;
|
||||
|
||||
public:
|
||||
|
||||
using Lock::lock;
|
||||
|
||||
explicit ScopedLock(const Lock& lockable) : lockable(lockable) {}
|
||||
|
||||
~ScopedLock() override {
|
||||
lockable.unlock(); // We don't care whether it succeeded or not
|
||||
}
|
||||
|
||||
bool lock(TickType timeout) const override {
|
||||
return lockable.lock(timeout);
|
||||
}
|
||||
|
||||
bool unlock() const override {
|
||||
return lockable.unlock();
|
||||
}
|
||||
};
|
||||
@@ -1,21 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <TactilityCpp/Lock.h>
|
||||
#include <Tactility/Lock.h>
|
||||
#include <tt_lvgl.h>
|
||||
|
||||
class LvglLock final : public Lock {
|
||||
class LvglLock final : public tt::Lock {
|
||||
|
||||
public:
|
||||
|
||||
bool lock(TickType timeout = TT_MAX_TICKS) const override {
|
||||
tt_lvgl_lock(timeout);
|
||||
return true;
|
||||
bool lock(TickType_t timeout = tt::kernel::MAX_TICKS) const override {
|
||||
return tt_lvgl_lock(timeout);
|
||||
}
|
||||
|
||||
|
||||
bool unlock() const override {
|
||||
void unlock() const override {
|
||||
tt_lvgl_unlock();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <tt_lock.h>
|
||||
#include <TactilityCpp/Lock.h>
|
||||
|
||||
class Mutex final : public Lock {
|
||||
|
||||
LockHandle handle;
|
||||
|
||||
public:
|
||||
|
||||
explicit Mutex(TtMutexType type) : handle(tt_lock_alloc_mutex(type)) {};
|
||||
|
||||
~Mutex() override {
|
||||
tt_lock_free(handle);
|
||||
}
|
||||
|
||||
bool lock(TickType timeout = TT_MAX_TICKS) const override {
|
||||
return tt_lock_acquire(handle, timeout);
|
||||
}
|
||||
|
||||
bool unlock() const override {
|
||||
return tt_lock_release(handle);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <tt_thread.h>
|
||||
|
||||
class Thread {
|
||||
ThreadHandle handle;
|
||||
public:
|
||||
|
||||
Thread() : handle(tt_thread_alloc()) {}
|
||||
|
||||
Thread(
|
||||
const char* name,
|
||||
uint32_t stackSize,
|
||||
ThreadCallback callback,
|
||||
void* _Nullable callbackContext
|
||||
) : handle(tt_thread_alloc_ext(name, stackSize, callback, callbackContext)) {}
|
||||
|
||||
~Thread() {
|
||||
tt_thread_free(handle);
|
||||
}
|
||||
|
||||
void start() const {
|
||||
tt_thread_start(handle);
|
||||
}
|
||||
|
||||
bool join(TickType timeout = TT_MAX_TICKS) const {
|
||||
return tt_thread_join(handle, timeout);
|
||||
}
|
||||
|
||||
void setName(const char* name) const {
|
||||
tt_thread_set_name(handle, name);
|
||||
}
|
||||
|
||||
void setStackSize(size_t stackSize) const {
|
||||
tt_thread_set_stack_size(handle, stackSize);
|
||||
}
|
||||
|
||||
void setAffinity(int affinity) const {
|
||||
tt_thread_set_affinity(handle, affinity);
|
||||
}
|
||||
|
||||
void setCallback(ThreadCallback callback, void* _Nullable callbackContext) const {
|
||||
tt_thread_set_callback(handle, callback, callbackContext);
|
||||
}
|
||||
|
||||
void setPriority(ThreadPriority priority) const {
|
||||
tt_thread_set_priority(handle, priority);
|
||||
}
|
||||
|
||||
void setStateCallback(ThreadStateCallback callback, void* _Nullable callbackContext) const {
|
||||
tt_thread_set_state_callback(handle, callback, callbackContext);
|
||||
}
|
||||
|
||||
ThreadState getState() const {
|
||||
return tt_thread_get_state(handle);
|
||||
}
|
||||
|
||||
ThreadId getId() const {
|
||||
return tt_thread_get_id(handle);
|
||||
}
|
||||
|
||||
int32_t getReturnCode() const {
|
||||
return tt_thread_get_return_code(handle);
|
||||
}
|
||||
};
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <tt_hal_uart.h>
|
||||
#include <Str.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
|
||||
class Uart {
|
||||
UartHandle handle;
|
||||
@@ -20,13 +22,13 @@ public:
|
||||
return std::make_unique<Uart>(handle);
|
||||
}
|
||||
|
||||
static std::vector<Str> getNames() {
|
||||
std::vector<Str> names;
|
||||
static std::vector<std::string> getNames() {
|
||||
std::vector<std::string> names;
|
||||
size_t count = tt_hal_uart_get_count();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
char buffer[64];
|
||||
if (tt_hal_uart_get_name(i, buffer, sizeof(buffer))) {
|
||||
names.push_back(Str(buffer));
|
||||
names.push_back(std::string(buffer));
|
||||
}
|
||||
}
|
||||
return names;
|
||||
@@ -44,15 +46,15 @@ public:
|
||||
return tt_hal_uart_stop(handle);
|
||||
}
|
||||
|
||||
size_t readBytes(char* buffer, size_t bufferSize, TickType timeout) const {
|
||||
size_t readBytes(char* buffer, size_t bufferSize, TickType_t timeout) const {
|
||||
return tt_hal_uart_read_bytes(handle, buffer, bufferSize, timeout);
|
||||
}
|
||||
|
||||
bool readByte(char* output, TickType timeout) const {
|
||||
bool readByte(char* output, TickType_t timeout) const {
|
||||
return tt_hal_uart_read_bytes(handle, output, 1, timeout);
|
||||
}
|
||||
|
||||
size_t writeBytes(const char* buffer, size_t bufferSize, TickType timeout) const {
|
||||
size_t writeBytes(const char* buffer, size_t bufferSize, TickType_t timeout) const {
|
||||
return tt_hal_uart_write_bytes(handle, buffer, bufferSize, timeout);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user