aboutsummaryrefslogtreecommitdiff
path: root/zumo/protocol.h
diff options
context:
space:
mode:
authorUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2023-05-25 21:07:27 +0200
committerUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2023-05-25 21:07:27 +0200
commitfbe109a12420033c3421733072d36a875e154f64 (patch)
tree3f0efe7cee27c2389d057f411261fd037fccbb2b /zumo/protocol.h
parent76df689d48df0b5056769b9c8ca968ac4a0eb261 (diff)
parent6daf8036c1342899196b2f7830ae5a18f0918d07 (diff)
Merge branch 'master' of https://github.com/unavailabledev/avans-dui
Diffstat (limited to 'zumo/protocol.h')
-rw-r--r--zumo/protocol.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/zumo/protocol.h b/zumo/protocol.h
new file mode 100644
index 0000000..662a5ce
--- /dev/null
+++ b/zumo/protocol.h
@@ -0,0 +1,35 @@
+#pragma once
+
+typedef enum {
+ DUI_CMD_NULL,
+ DUI_CMD_SIGN,
+ DUI_CMD_SPEED,
+ DUI_CMD_STEER,
+} dui_e_cmd;
+
+typedef enum {
+ DUI_SIGN_NONE, /** @brief no sign */
+ DUI_SIGN_STOP, /** @brief stop (set speed to 0) */
+ DUI_SIGN_LEFT, /** @brief turn left (set steer to -1) */
+ DUI_SIGN_RIGHT, /** @brief turn right (set steer to +1) */
+ DUI_SIGN_SPEED_LIMIT_LOW, /** @brief slow down (speed limit 0.5) */
+ DUI_SIGN_SPEED_LIMIT_HIGH, /** @brief full speed (speed limit 1.0) */
+ DUI_SIGN_LIGHT_STOP, /** @brief traffic light red (set speed to 0) */
+ DUI_SIGN_LIGHT_FLOOR_IT, /** @brief traffic light orange (set speed to 2 temporarily) */
+ DUI_SIGN_LIGHT_GO, /** @brief traffic light green (keep current speed) */
+} dui_e_sign;
+
+typedef struct {
+ float steer; /** @brief steer value (-1 is left, +1 is right) */
+ float speed; /** @brief speed (0-15) */
+ dui_e_sign current_sign; /** @brief last seen sign */
+ float speed_mod; /** @brief global speed multiplier */
+} dui_state_t;
+
+/** @brief non blocking read byte */
+unsigned char uart_read();
+/** @brief read and apply cmd to state */
+void handle_cmd(unsigned char cmd, dui_state_t *state);
+/** @brief apply state to motors */
+void apply_state(dui_state_t* state);
+