aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/protocol.h53
1 files changed, 52 insertions, 1 deletions
diff --git a/shared/protocol.h b/shared/protocol.h
index 057f67d..b997ec6 100644
--- a/shared/protocol.h
+++ b/shared/protocol.h
@@ -1,5 +1,6 @@
#pragma once
+#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
@@ -48,6 +49,56 @@ typedef enum {
#pragma pack(push, 1)
+/** momentary button input struct */
+typedef struct {
+ bool pressed;
+} w2_s_i_push;
+
+/** qtr contrast sensor input struct */
+typedef struct {
+ uint16_t range;
+} w2_s_i_contrast;
+
+/** distance sensor input struct */
+typedef struct {
+ uint16_t detection;
+} w2_s_i_distance;
+
+/** battery input struct */
+typedef struct {
+ uint16_t charge_level;
+} w2_s_i_battery;
+
+/** motor output struct */
+typedef struct {
+ int speed;
+} w2_s_o_motor;
+
+/** underside led output struct */
+typedef struct {
+ bool on;
+} w2_s_o_led;
+
+/** lcd output struct */
+typedef struct {
+ char text[16];
+} w2_s_o_display;
+
+/** struct containing all i/o */
+typedef struct {
+ w2_s_i_push button[5];
+ w2_s_i_contrast qtr[5];
+ w2_s_i_distance front_distance;
+ w2_s_i_distance side_distance;
+ w2_s_i_battery battery;
+
+ w2_s_o_motor motor_left;
+ w2_s_o_motor motor_right;
+ w2_s_o_led led_red;
+ w2_s_o_led led_green;
+ w2_s_o_display lcd;
+} w2_s_io_all;
+
typedef struct {
uint8_t opcode;
uint8_t id;
@@ -134,7 +185,7 @@ typedef struct {
typedef struct {
uint8_t opcode;
- // TODO: sensor data
+ w2_s_io_all io;
} w2_s_cmd_sens_tx;
typedef struct {