-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
117 lines (97 loc) · 3.67 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#pragma config(Sensor, in8, PWR, sensorPotentiometer)
#pragma config(Sensor, dgtl1, S_WHEEL_L, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, S_WHEEL_R, sensorQuadEncoder)
#pragma config(Sensor, dgtl5, S_TOP_SONAR, sensorSONAR_mm)
#pragma config(Sensor, dgtl7, S_LOW_SONAR, sensorSONAR_cm)
#pragma config(Sensor, dgtl9, S_CATAPULT_LIM, sensorTouch)
#pragma config(Motor, port1, M_INTAKE, tmotorVex393HighSpeed_HBridge, openLoop)
#pragma config(Motor, port2, M_LIFT, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, M_CATAPULT, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, M_WHEEL_R1, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port5, M_WHEEL_R2, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port6, M_WHEEL_R3, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port7, M_WHEEL_L1, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port8, M_WHEEL_L2, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port9, M_WHEEL_L3, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port10, M_FLIPPER, tmotorVex393_HBridge, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*
MAIN.C
Primary file: Holds the entire competition sequence. You compile and flash THIS file.
Jeffrey Shen
*/
#pragma DebuggerWindows("debugStream") //Include when debugging (automatically enables debug window)
#pragma platform(VEX)
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(1200)
#include "Vex_Competition_Includes.c"
#include "main.h"
#include "parallax-library/bin/constants.h"
#include "auton.c"
#include "parallax-library/main.c"
#include "bat.c"
#include "arm.c"
void pre_auton(){
bStopTasksBetweenModes = false; //Make sure all tasks we create actually execute in user control
startTask(catapultTask, 9);
initialize();
CATAPULT_COMMAND = RESET;
}
task autonomous(){
stopTask(usercontrol);
autonProcedure();
}
/*
USER CONTROL
*/
task usercontrol(){
int V, H, X;
stopTask(autonomous);
startTask(catapultTask, 9);
if(MODE == RBT_SKILL){ //Disable slew for the drive during robot skills
// MOTOR_SLEW[1] = 255;
// MOTOR_SLEW[2] = 255;
// MOTOR_SLEW[3] = 255;
// MOTOR_SLEW[4] = 255;
// MOTOR_SLEW[5] = 255;
// MOTOR_SLEW[6] = 255;
}
while(true){
V = -vexRT[Ch3];
X = vexRT[Ch4];
H = vexRT[Ch1];
if(vexRT[Btn8U]) intakeUp();
else if(vexRT[Btn8D]) intakeDown();
else intakeStop();
if(vexRT[Btn7U] == 1) CATAPULT_COMMAND = RESET;
else if(vexRT[Btn8L] == 1) CATAPULT_COMMAND = UP;
else if(vexRT[Btn8R] == 1) CATAPULT_COMMAND = DOWN;
else if(CATAPULT_COMMAND != RESET) CATAPULT_COMMAND = STOP;
/*if(vexRT[Btn8R] == 1) CATAPULT_COMMAND = UP;
else if(vexRT[Btn8L] == 1) CATAPULT_COMMAND = DOWN;
else if(CATAPULT_COMMAND != HOLD && CATAPULT_COMMAND != RESET) CATAPULT_COMMAND = STOP;*/
if(getPrButton(BTN_7L)) {
//PlaySoundFile("highground.wav");
//autoC();
resetPrButton(BTN_7L);
}
if(vexRT[Btn6U]) moveLift(UP);
else if(vexRT[Btn6D]) moveLift(DOWN);
else if(LIFT_COMMAND == HOLD_UP) moveLift(20);
else moveLift(STOP);
if(vexRT[Btn5U]) moveFlipper(UP);
else if(vexRT[Btn5D]) moveFlipper(DOWN);
else if(FLIPPER_COMMAND == HOLD_UP) moveFlipper(40);
else if(FLIPPER_COMMAND == HOLD_DOWN) moveFlipper(-20);
else moveFlipper(STOP);
//Robot skills controls
if(MODE == RBT_SKILL){
move(V, H, X);
}
else{
move(V, H * 0.75, X);
}
userControlUpdate();
}
}