unions
This commit is contained in:
parent
2c4fe1994f
commit
6a58763ece
1 changed files with 16 additions and 0 deletions
16
unions/unions.c
Normal file
16
unions/unions.c
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
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;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue