-
Notifications
You must be signed in to change notification settings - Fork 0
/
thinking_functions.c
60 lines (53 loc) · 1.69 KB
/
thinking_functions.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "../functions/thinking_functions.h"
#include <trig.h>
#define unsigned int Speed = 333;//in metre per 10 seconds (10*(m/s))
#define unsigned char Laser_distance = 18;//this is a guess
unsigned int Dist_to_TCY(unsigned int dist)
{
return((2500000*dist)/Speed);
}
unsigned int TCY_dist_Dist(unsigned int tcy)
{
return((Speed*tcy)/2500000);
}
void Travel_for_Distance(unsigned int dist)
{
While(ReadTimer0() >= (Dist_to_TCY(dist));
}
unsigned char Mirrored_Sensors (unsigned char input_binary)
{
unsigned char return_binary;
if();
}
void Think_Turn_Angle(void) //problems: doesnt identify corners but needs to start with 0b0011x or 0bx1100
//depends on being pretty striaght
//for turns of larger then 90 deg it cant be seeing 0b0111x or 0bx1110
{
unsigned int distance_traveled;
unsigned char turn_angle;
while(1)
{
if (SeeLine.b.Center == 0)//start when SeeLine.b.Center turns off
{
WriteTimer0(0); //clear the timer
while((SeeLine.b.CntRight || SeeLine.b.CntLeft) == 1);//dont change during this time
distance_travled = TCY_to_Dist(ReadTimer0());
turn_angel=atan(distance_traveld/Laser_distance);
//reverse
Travel_for_Distance(distance_traveled);
//need function for turn for paticular angle
return(void);
}
if ((SeeLine.b.CntRight && SeeLine.b.CntLeft) == 0)//start when SeeLine.b.Center turns off
{
WriteTimer0(0); //clear the timer
while(SeeLine.b.Center == 1);//dont change during this time
distance_travled = TCY_to_Dist(ReadTimer0());
turn_angel=atan(Laser_distance/distance_traveled);
//reverse
Travel_for_Distance(distance_traveled);
Turn_for_Angle(turn_angle);//need function for turn for paticular angle
return(void);
}
}
}