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
+4 -4
View File
@@ -18,7 +18,7 @@ namespace tt::lvgl {
#define TAG "statusbar"
static void onUpdateTime(TT_UNUSED std::shared_ptr<void> context);
static void onUpdateTime();
struct StatusbarIcon {
std::string image;
@@ -30,7 +30,7 @@ struct StatusbarData {
Mutex mutex = Mutex(Mutex::Type::Recursive);
std::shared_ptr<PubSub> pubsub = std::make_shared<PubSub>();
StatusbarIcon icons[STATUSBAR_ICON_LIMIT] = {};
Timer* time_update_timer = new Timer(Timer::Type::Once, onUpdateTime, nullptr);
Timer* time_update_timer = new Timer(Timer::Type::Once, []() { onUpdateTime(); });
uint8_t time_hours = 0;
uint8_t time_minutes = 0;
bool time_set = false;
@@ -70,7 +70,7 @@ static TickType_t getNextUpdateTime() {
return pdMS_TO_TICKS(seconds_to_wait * 1000U);
}
static void onUpdateTime(TT_UNUSED std::shared_ptr<void> context) {
static void onUpdateTime() {
time_t now = ::time(nullptr);
struct tm* tm_struct = localtime(&now);
@@ -137,7 +137,7 @@ static void statusbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
if (!statusbar_data.time_update_timer->isRunning()) {
statusbar_data.time_update_timer->start(50 / portTICK_PERIOD_MS);
statusbar_data.systemEventSubscription = kernel::systemEventAddListener(
statusbar_data.systemEventSubscription = kernel::subscribeSystemEvent(
kernel::SystemEvent::Time,
onNetworkConnected
);