Some checks failed
ESP-IDF Build / build (esp32c6, release-v5.4) (push) Failing after 4m44s
ESP-IDF Build / build (esp32c6, release-v5.5) (push) Failing after 4m37s
ESP-IDF Build / build (esp32s3, release-v5.4) (push) Failing after 4m22s
ESP-IDF Build / build (esp32s3, release-v5.5) (push) Failing after 4m24s
Signed-off-by: Peter Siegmund <developer@mars3142.org>
80 lines
1.7 KiB
C
80 lines
1.7 KiB
C
#pragma once
|
|
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
typedef enum
|
|
{
|
|
MESSAGE_TYPE_SETTINGS,
|
|
MESSAGE_TYPE_BUTTON,
|
|
MESSAGE_TYPE_SIMULATION
|
|
} message_type_t;
|
|
|
|
typedef enum
|
|
{
|
|
BUTTON_EVENT_PRESS,
|
|
BUTTON_EVENT_RELEASE
|
|
} button_event_type_t;
|
|
|
|
typedef struct
|
|
{
|
|
button_event_type_t event_type;
|
|
uint8_t button_id;
|
|
} button_message_t;
|
|
|
|
typedef enum
|
|
{
|
|
SETTINGS_TYPE_BOOL,
|
|
SETTINGS_TYPE_INT,
|
|
SETTINGS_TYPE_FLOAT,
|
|
SETTINGS_TYPE_STRING
|
|
} settings_type_t;
|
|
|
|
typedef struct
|
|
{
|
|
settings_type_t type;
|
|
char key[32];
|
|
union {
|
|
bool bool_value;
|
|
int32_t int_value;
|
|
float float_value;
|
|
char string_value[64];
|
|
} value;
|
|
} settings_message_t;
|
|
|
|
typedef struct
|
|
{
|
|
char time[6];
|
|
uint8_t red;
|
|
uint8_t green;
|
|
uint8_t blue;
|
|
} simulation_message_t;
|
|
|
|
typedef struct
|
|
{
|
|
message_type_t type;
|
|
union {
|
|
settings_message_t settings;
|
|
button_message_t button;
|
|
simulation_message_t simulation;
|
|
} data;
|
|
} message_t;
|
|
|
|
// Observer Pattern: Listener-Typ und Registrierungsfunktionen
|
|
typedef void (*message_listener_t)(const message_t *msg);
|
|
void message_manager_register_listener(message_listener_t listener);
|
|
void message_manager_unregister_listener(message_listener_t listener);
|
|
void message_manager_init(void);
|
|
bool message_manager_post(const message_t *msg, TickType_t timeout);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|