Skip to content

Commit

Permalink
Update robot.c
Browse files Browse the repository at this point in the history
  • Loading branch information
alkaza authored Nov 27, 2017
1 parent 96eda7c commit 43c6758
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/lib/robot.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <wiringPi.h>
#include "robot.h"

/* Min speed */
int min_speed = 60;
/* Track current flag */
volatile int turningR = 0;
volatile int turningL = 0;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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)
{
Expand Down

0 comments on commit 43c6758

Please sign in to comment.