summaryrefslogtreecommitdiff
path: root/robot/io.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-06-26 16:21:07 +0200
committerlonkaars <loek@pipeframe.xyz>2022-06-26 16:21:07 +0200
commit6b7b02596522b0db476dd64bb69e0e3825ce790d (patch)
treed2a648d45abc1db0138ff35edbbc05ec352c520d /robot/io.c
parent6c3d73d260a4254013e48b7f992c8c4fd87f5689 (diff)
added error beeps and fix mode history IOB error
Diffstat (limited to 'robot/io.c')
-rw-r--r--robot/io.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/robot/io.c b/robot/io.c
index 42c3a4b..91a62b2 100644
--- a/robot/io.c
+++ b/robot/io.c
@@ -17,21 +17,13 @@ void w2_io_object_detection() {
if (!g_w2_io_object_detected && front_distance >= W2_IO_DISTANCE_CLOSE_THRESHOLD) {
g_w2_io_object_detected = true;
w2_hypervisor_time_start(W2_TIMER_OBJECT_DETECTION);
- lcd_goto_xy(0, 0);
- print("detected");
+ w2_errcatch_throw(W2_E_WARN_OBSTACLE_DETECTED);
}
if (g_w2_io_object_detected) {
- if (front_distance <= W2_IO_DISTANCE_FAR_THRESHOLD) {
- g_w2_io_object_detected = false;
- lcd_goto_xy(0, 0);
- print(" ");
- }
- if (w2_hypervisor_time_end(W2_TIMER_OBJECT_DETECTION) >= W2_IO_DISTANCE_TOO_CLOSE_TIMEOUT) {
+ 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);
- lcd_goto_xy(0, 0);
- print("unavoid ");
- }
set_motors(0, 0);
}