From 6a58763ece0d6b9212b43a0807f7ad54d7a11bb4 Mon Sep 17 00:00:00 2001 From: Imbus Date: Sun, 24 Aug 2025 12:46:47 +0200 Subject: [PATCH] unions --- unions/unions.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 unions/unions.c diff --git a/unions/unions.c b/unions/unions.c new file mode 100644 index 0000000..9db9dc5 --- /dev/null +++ b/unions/unions.c @@ -0,0 +1,16 @@ +#include + +typedef enum { + CMD_SET_LEVEL = 1, + CMD_SET_LIGHTS = 2, + CMD_SET_DIST = 3, +} command_t; + +typedef struct Message { + uint8_t type; + union { + struct { uint8_t level; } set_level; + struct { uint8_t on; } set_lights; + struct { float distance; } set_distance; + } data; +} Message;