// // Created by erki on 11/02/24. // #pragma once #include namespace clock_core { struct EventGroup { static constexpr EventBits_t WIFI_FAILED = BIT0; static constexpr EventBits_t WIFI_CONNECTED = BIT1; static constexpr EventBits_t SNTP_SYNCED = BIT2; static constexpr EventBits_t CLOCK_UPDATE = BIT3; static constexpr EventBits_t DISPLAY_UPDATE = BIT4; static constexpr EventBits_t ALL_EVENTS = WIFI_FAILED | WIFI_CONNECTED | SNTP_SYNCED | CLOCK_UPDATE | DISPLAY_UPDATE; EventGroupHandle_t rtos_event_group = nullptr; EventGroup() : rtos_event_group(xEventGroupCreate()) { } EventGroup(const EventGroup&) = delete; EventGroup(EventGroup&&) = delete; EventGroup& operator=(const EventGroup&) = delete; EventGroup& operator=(EventGroup&&) = delete; void setEvent(const EventBits_t& bits) { xEventGroupSetBits(rtos_event_group, bits); } EventBits_t waitForEvent() { return xEventGroupWaitBits(rtos_event_group, ALL_EVENTS, pdTRUE, pdFALSE, portMAX_DELAY); } }; }