-
Notifications
You must be signed in to change notification settings - Fork 0
/
systemtest.h
76 lines (67 loc) · 1.52 KB
/
systemtest.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef SYSTEM_H
#define SYSTEM_H
#include <stdint.h> /* Declarations of uint_32 and the like */
#include <pic32mx.h> /* Declarations of system-specific addresses etc */
#include "mipslab.h" /* Declatations for these labs */
#include <stdbool.h> // need this for bool
#include "motors.h"
#include "sensor.h"
#include "servo.h"
#include "utils.h"
bool motorTest(float sec) {
if(sec < 3) bothWheelsForward();
else if(sec < 6) bothWheelsStop();
else if(sec < 9) bothWheelsBackward();
else if(sec < 12){
rightWheelForward();
leftWheelStop();
}
else if(sec < 15){
rightWheelBackward();
leftWheelStop();
}
else if(sec < 18){
leftWheelForward();
rightWheelStop();
}
else if(sec < 21){
leftWheelBackward();
rightWheelStop();
}else{
bothWheelsStop();
return true;
}
return false;
}
void servoTest(float sec){
if(sec < 3) lookLeft();
else if(sec < 6) lookForward();
else if(sec < 9) lookRight();
else lookForward();
}
void timer3Test(float sec){
if((int)(sec)%3 == 0){
PORTESET = 0x1;
}else PORTECLR = 0x1;
}
void sensorTest(long tick){
long reply = readSensor();
PORTECLR=0x7;
if(reply<=5){
PORTESET = 0x1;
}
else if(reply<=10){
PORTESET = 0x2;
}
else if(reply<=15){
PORTESET = 0x4;
}
}
void systemTest(long tick){
float sec = tick/50000;
motorTest(sec);
servoTest(sec);
timer3Test(sec);
sensorTest(tick);
}
#endif