From 43c67581c0003db459e5a0f3547e40d753d003a4 Mon Sep 17 00:00:00 2001 From: Alena Kazakova Date: Tue, 28 Nov 2017 00:10:13 +0900 Subject: [PATCH] Update robot.c --- src/lib/robot.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lib/robot.c b/src/lib/robot.c index fc0642a..0a661c7 100644 --- a/src/lib/robot.c +++ b/src/lib/robot.c @@ -5,6 +5,8 @@ #include #include "robot.h" +/* Min speed */ +int min_speed = 60; /* Track current flag */ volatile int turningR = 0; volatile int turningL = 0; @@ -65,19 +67,12 @@ float calc_dist(void) return dist; } -/* Motor state control normal */ -void move(char dir, int speedA, int speedB) -{ - setSpeed(speedA, speedB); - setDir(dir); -} - /* Motor state control with gradual deceleration */ void move_slow(char dir, int speedA, int speedB) { if (dir == prev_dir) { prev_dir = dir; - if ((curr_speedA > MINSPEED) && (curr_speedB > MINSPEED)){ + if ((curr_speedA > min_speed) && (curr_speedB > min_speed)){ curr_speedA-=1; curr_speedB-=1; } @@ -92,6 +87,12 @@ void move_slow(char dir, int speedA, int speedB) } } +/* Set min speed */ +void set_min_speed(int speed) +{ + min_speed = speed; +} + /* Initialize ultrasonic sensor */ void ultraInit(void) {