Add Serial Console app and update other apps for new SDK (#10)
This commit is contained in:
committed by
GitHub
parent
d33e7a41df
commit
a42f018ddc
@@ -11,16 +11,16 @@
|
||||
constexpr char* TAG = "GPIO";
|
||||
|
||||
void Gpio::updatePinStates() {
|
||||
tt_mutex_lock(mutex, TT_MAX_TICKS);
|
||||
mutex.lock();
|
||||
// Update pin states
|
||||
for (int i = 0; i < pinStates.size(); ++i) {
|
||||
pinStates[i] = tt_hal_gpio_get_level(i);
|
||||
}
|
||||
tt_mutex_unlock(mutex);
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void Gpio::updatePinWidgets() {
|
||||
tt_lvgl_lock();
|
||||
tt_lvgl_lock(TT_MAX_TICKS);
|
||||
assert(pinStates.size() == pinWidgets.size());
|
||||
for (int j = 0; j < pinStates.size(); ++j) {
|
||||
int level = pinStates[j];
|
||||
@@ -56,11 +56,11 @@ void Gpio::onTimer(void* context) {
|
||||
}
|
||||
|
||||
void Gpio::startTask() {
|
||||
tt_mutex_lock(mutex, TT_MAX_TICKS);
|
||||
mutex.lock();
|
||||
assert(timer == nullptr);
|
||||
timer = tt_timer_alloc(TimerTypePeriodic, onTimer, this);
|
||||
tt_timer_start(timer, 100 / portTICK_PERIOD_MS);
|
||||
tt_mutex_unlock(mutex);
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void Gpio::stopTask() {
|
||||
@@ -81,14 +81,6 @@ static int getSquareSpacing(UiScale scale) {
|
||||
}
|
||||
}
|
||||
|
||||
void Gpio::onCreate(AppHandle app) {
|
||||
mutex = tt_mutex_alloc(MUTEX_TYPE_RECURSIVE);
|
||||
}
|
||||
|
||||
void Gpio::onDestroy(AppHandle app) {
|
||||
tt_mutex_free(mutex);
|
||||
}
|
||||
|
||||
void Gpio::onShow(AppHandle app, lv_obj_t* parent) {
|
||||
// auto ui_scale = hal::getConfiguration()->uiScale;
|
||||
|
||||
@@ -126,7 +118,7 @@ void Gpio::onShow(AppHandle app, lv_obj_t* parent) {
|
||||
auto* row_wrapper = createGpioRowWrapper(centering_wrapper);
|
||||
lv_obj_align(row_wrapper, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
tt_mutex_lock(mutex, TT_MAX_TICKS);
|
||||
mutex.lock();
|
||||
|
||||
auto pin_count = tt_hal_gpio_get_pin_count();
|
||||
pinStates.resize(pin_count);
|
||||
@@ -166,7 +158,7 @@ void Gpio::onShow(AppHandle app, lv_obj_t* parent) {
|
||||
}
|
||||
}
|
||||
|
||||
tt_mutex_unlock(mutex);
|
||||
mutex.unlock();
|
||||
|
||||
startTask();
|
||||
}
|
||||
@@ -174,8 +166,8 @@ void Gpio::onShow(AppHandle app, lv_obj_t* parent) {
|
||||
void Gpio::onHide(AppHandle app) {
|
||||
stopTask();
|
||||
|
||||
tt_mutex_lock(mutex, TT_MAX_TICKS);
|
||||
mutex.lock();
|
||||
pinWidgets.clear();
|
||||
pinStates.clear();
|
||||
tt_mutex_unlock(mutex);
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
#include <TactilityCpp/App.h>
|
||||
|
||||
#include <tt_app.h>
|
||||
#include <tt_mutex.h>
|
||||
#include <tt_timer.h>
|
||||
|
||||
#include <TactilityCpp/Mutex.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <vector>
|
||||
|
||||
@@ -14,15 +15,13 @@ class Gpio final : public App {
|
||||
std::vector<lv_obj_t*> pinWidgets;
|
||||
std::vector<bool> pinStates;
|
||||
TimerHandle timer;
|
||||
MutexHandle mutex;
|
||||
Mutex mutex = Mutex(MutexTypeRecursive);
|
||||
|
||||
static lv_obj_t* createGpioRowWrapper(lv_obj_t* parent);
|
||||
static void onTimer(void* parameter);
|
||||
|
||||
public:
|
||||
|
||||
void onCreate(AppHandle app) override;
|
||||
void onDestroy(AppHandle app) override;
|
||||
void onShow(AppHandle context, lv_obj_t* parent) override;
|
||||
void onHide(AppHandle context) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user