Convert code to use Timer instead of Thread (#120)

This commit is contained in:
Ken Van Hoeylandt
2024-12-12 23:44:51 +01:00
committed by GitHub
parent 51c6aaa428
commit 34f99205ca
6 changed files with 57 additions and 85 deletions
+3 -2
View File
@@ -5,6 +5,7 @@
#include <Thread.h>
#include "lvgl.h"
#include "hal/i2c/I2c.h"
#include "Timer.h"
#include <memory>
namespace tt::app::i2cscanner {
@@ -20,7 +21,7 @@ enum ScanState {
struct Data {
// Core
Mutex mutex = Mutex(Mutex::TypeRecursive);
Thread* _Nullable scanThread = nullptr;
std::unique_ptr<Timer> scanTimer = nullptr;
// State
ScanState scanState;
i2c_port_t port = I2C_NUM_0;
@@ -31,6 +32,6 @@ struct Data {
lv_obj_t* scanListWidget = nullptr;
};
void onThreadFinished(std::shared_ptr<Data> data);
void onScanTimerFinished(std::shared_ptr<Data> data);
}