Various improvements (#264)

- Replace C function pointers with C++ `std::function` in `Thread`, `Timer` and `DispatcherThread`
- Rename `SystemEvent`-related functions
- WiFi: fix auto-connect when WiFi disconnects from bad signal
- WiFi: fix auto-connect when WiFi fails to auto-connect
- WiFi: implement disconnect() when tapping connected WiFi ap in WiFi management app
This commit is contained in:
Ken Van Hoeylandt
2025-03-30 21:59:31 +02:00
committed by GitHub
parent d72852a6e2
commit 3f1bfee3f5
37 changed files with 239 additions and 322 deletions
@@ -113,16 +113,6 @@ private:
return 0;
}
static int32_t viewThreadMainStatic(void* parameter) {
auto* view = (ConsoleView*)parameter;
return view->viewThreadMain();
}
static int32_t uartThreadMainStatic(void* parameter) {
auto* view = (ConsoleView*)parameter;
return view->uartThreadMain();
}
static void onSendClickedCallback(lv_event_t* event) {
auto* view = (ConsoleView*)lv_event_get_user_data(event);
view->onSendClicked();
@@ -177,8 +167,9 @@ public:
uartThread = std::make_unique<Thread>(
"SerConsUart",
4096,
uartThreadMainStatic,
this
[this]() {
return this->uartThreadMain();
}
);
uartThread->setPriority(tt::Thread::Priority::High);
uartThread->start();
@@ -226,8 +217,9 @@ public:
viewThread = std::make_unique<Thread>(
"SerConsView",
4096,
viewThreadMainStatic,
this
[this]() {
return this->viewThreadMain();
}
);
viewThread->setPriority(THREAD_PRIORITY_RENDER);
viewThread->start();
@@ -57,7 +57,6 @@ private:
GpsModel model = GpsModel::Unknown;
State state = State::Off;
static int32_t threadMainStatic(void* parameter);
int32_t threadMain();
bool isThreadInterrupted() const;
@@ -29,10 +29,10 @@ typedef uint32_t SystemEventSubscription;
typedef std::function<void(SystemEvent)> OnSystemEvent;
void systemEventPublish(SystemEvent event);
void publishSystemEvent(SystemEvent event);
SystemEventSubscription systemEventAddListener(SystemEvent event, OnSystemEvent handler);
SystemEventSubscription subscribeSystemEvent(SystemEvent event, OnSystemEvent handler);
void systemEventRemoveListener(SystemEventSubscription subscription);
void unsubscribeSystemEvent(SystemEventSubscription subscription);
}