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
@@ -223,8 +223,7 @@ private:
updatePowerStatusIcon();
}
static void onUpdate(std::shared_ptr<void> parameter) {
auto service = std::static_pointer_cast<StatusbarService>(parameter);
static void onUpdate(const std::shared_ptr<StatusbarService>& service) {
service->update();
}
@@ -242,11 +241,14 @@ public:
// TODO: Make thread-safe for LVGL
lvgl::statusbar_icon_set_visibility(wifi_icon_id, true);
auto service = findServiceById(manifest.id);
auto service = findServiceById<StatusbarService>(manifest.id);
assert(service);
onUpdate(service);
updateTimer = std::make_unique<Timer>(Timer::Type::Periodic, onUpdate, service);
updateTimer = std::make_unique<Timer>(Timer::Type::Periodic, [service]() {
onUpdate(service);
});
// We want to try and scan more often in case of startup or scan lock failure
updateTimer->start(1000);
}