-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
103 lines (84 loc) · 1.99 KB
/
main.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef LIB_MAIN_C
#define LIB_MAIN_C
/*
MAIN.C
Implements and combines other library files
*** Include this file ***
*/
#include "bin/constants.h"
#include "bin/functions.c"
#include "../config.c" //You write this file
#ifndef DEBUG
#define DEBUG 0
#endif
#include "bin/sensors.c"
#include "bin/remote.c"
#include "bin/slew.c"
#include "bin/lcd.c"
#include "bin/move.c"
void initialize(){
bStopTasksBetweenModes = false;
clearTimer(T1);
sensorReset();
#if USE_PR_BUTTON == 1
#if DEBUG == 1 || DEBUG_REMOTE == 1
writeDebugStreamLine("Setting up remote buttons");
#endif
setUpButtons();
#if DEBUG == 1 || DEBUG_REMOTE == 1
writeDebugStreamLine("Successfully set up remote buttons");
#endif
#endif
#if USE_SLEW == 1
#if DEBUG == 1 || DEBUG_SLEW == 1
writeDebugStreamLine("Slew task is enabled");
#endif
startTask(MotorSlewRateTask);
#else
#if DEBUG == 1 || DEBUG_SLEW == 1
writeDebugStreamLine("Slew task is disabled");
#endif
startTask(MotorsTask);
#endif
#if USE_MOVE == 1
startTask(moveTask);
#endif
#if USE_LCD == 1
lcdSelection();
#endif
preAutonProcedure();
}
void autonProcedure(){
stopTask(usercontrol);
clearTimer(T1);
#if USE_LCD == 1
if (MODE == AUTO_A) autoA();
else if (MODE == AUTO_B) autoB();
else if (MODE == AUTO_C) autoC();
else if (MODE == PRG_SKILL) prgSkills();
lcdMessage();
#endif
}
void userControlUpdate(){
#if USE_LCD == 1
lcdMessage();
#endif
#if USE_PR_BUTTON == 1
updatePrbStatus();
#endif
#ifdef BAILOUT_BUTTON
if(vexRT[BAILOUT_BUTTON] == 1){
#if DEBUG == 1 || DEBUG_REMOTE == 1
writeDebugStreamLine("Bailout button pressed");
#endif
for(int i = 0; i < 10; i++) motor[i] = 0;
BAILOUT = 1;
bailOut();
}
else
BAILOUT = 0;
#endif
userControlProcedure();
wait1Msec(10);
}
#endif