summaryrefslogtreecommitdiff
path: root/robot/io.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-06-29 09:34:54 +0200
committerlonkaars <loek@pipeframe.xyz>2022-06-29 09:34:54 +0200
commit4d446fb2c1d14142304971095ee60668ba9c6bc5 (patch)
treed5e5670f17a2d8a89748645b0739ef95dd6bf4f4 /robot/io.c
parent0b50dfe730d87ff052ef08f0dd6df6071d50aef9 (diff)
[WIP] last touches for second assessment
Diffstat (limited to 'robot/io.c')
-rw-r--r--robot/io.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/robot/io.c b/robot/io.c
index 8add1e9..9977e2f 100644
--- a/robot/io.c
+++ b/robot/io.c
@@ -27,11 +27,13 @@ void w2_io_object_detection() {
if (front_distance <= W2_IO_DISTANCE_FAR_THRESHOLD) g_w2_io_object_detected = false;
if (w2_hypervisor_time_end(W2_TIMER_OBJECT_DETECTION) >= W2_IO_DISTANCE_TOO_CLOSE_TIMEOUT)
w2_errcatch_throw(W2_E_CRIT_OBSTACLE_STUCK);
-
- set_motors(0, 0);
}
}
+void w2_set_motors(int left, int right) {
+ set_motors(left * (1 - g_w2_io_object_detected), right * (1 - g_w2_io_object_detected));
+}
+
void w2_io_battery_logic() {
if (w2_hypervisor_time_end(W2_TIMER_BATTERY_MEASUREMENT) <= W2_BATTERY_MEAS_FREQ) return;
w2_hypervisor_time_start(W2_TIMER_BATTERY_MEASUREMENT);