rework message manager

use of listener pattern instead of message queue

Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
2026-01-18 14:26:13 +01:00
parent 1fade06bdb
commit cdac9cbfb8
3 changed files with 50 additions and 7 deletions

View File

@@ -14,6 +14,7 @@
#include "ui/ScreenSaver.h"
#include "ui/SplashScreen.h"
#include "wifi_manager.h"
#include <cstring>
#include <driver/i2c.h>
#include <esp_diagnostics.h>
#include <esp_insights.h>
@@ -127,6 +128,15 @@ static void init_ui(void)
u8g2_SendBuffer(&u8g2);
}
static void on_message_received(const message_t *msg)
{
if (msg && msg->type == MESSAGE_TYPE_SETTINGS && msg->data.settings.type == SETTINGS_TYPE_BOOL &&
std::strcmp(msg->data.settings.key, "light_active") == 0)
{
start_simulation();
}
}
static void handle_button(uint8_t button)
{
m_inactivityTracker->reset();
@@ -240,6 +250,8 @@ void app_task(void *args)
wifi_manager_init();
message_manager_register_listener(on_message_received);
start_simulation();
auto oldTime = esp_timer_get_time();