-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutonomous.c
95 lines (80 loc) · 2.99 KB
/
Autonomous.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
#pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Sensor, S4, ultrasonic, sensorSONAR)
#pragma config(Motor, mtr_S1_C2_1, mRight2, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_2, mRight1, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_1, mLeft1, tmotorTetrix, openLoop, reversed)
#pragma config(Motor, mtr_S1_C1_2, mLeft2, tmotorTetrix, openLoop, reversed)
#pragma config(Servo, srvo_S1_C3_3, tubeHook1, tServoStandard)
#pragma config(Servo, srvo_S1_C3_4, tubeHook2, tServoStandard)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "AutoPrograms.h"
#define WAIT_FOR_START
int AUTO_PROGRAM = 0;
void optionScreen() {
nxtDisplayTextLine(0, "NXT: %.2f V", ((float)nAvgBatteryLevel)/1000.0);
if(externalBatteryAvg > 0) nxtDisplayTextLine(1, "EXT: %.2f V", ((float)externalBatteryAvg)/1000.0);
else nxtDisplayTextLine(1, "EXT: OFF");
if(nAvgBatteryLevel < NXT_LOW_BAT) nxtDisplayTextLine(2, "***NXT LOW***");
if(externalBatteryAvg < EXT_LOW_BAT) nxtDisplayTextLine(2, "*** EXT LOW***");
if(nAvgBatteryLevel < NXT_LOW_BAT && externalBatteryAvg < EXT_LOW_BAT) nxtDisplayTextLine(2, "***NXT EXT LOW***");
while(nNxtButtonPressed != BTN_CENTER) {
if(AUTO_PROGRAM == 0)
{
nxtDisplayBigTextLine(4, "Knock");
nxtDisplayBigTextLine(6, "Balls");
}
else if(AUTO_PROGRAM == 1)
{
nxtDisplayBigTextLine(4, "DriveOff");
nxtDisplayBigTextLine(6, "Ramp");
}
else if(AUTO_PROGRAM == 2)
{
nxtDisplayBigTextLine(4, "Drag");
nxtDisplayBigTextLine(6, "Goal");
}
else if(AUTO_PROGRAM == 3)
{
nxtDisplayBigTextLine(4, "BallsW/");
nxtDisplayBigTextLine(6, "Delay");
}
if(nNxtButtonPressed == BTN_LEFT || nNxtButtonPressed == BTN_RIGHT) {
PlaySound(soundShortBlip);
if(nNxtButtonPressed == BTN_LEFT) AUTO_PROGRAM--;
if(nNxtButtonPressed == BTN_RIGHT) AUTO_PROGRAM ++;
if(AUTO_PROGRAM > 3) AUTO_PROGRAM = 0;
if(AUTO_PROGRAM < 0) AUTO_PROGRAM = 3;
while(nNxtButtonPressed == BTN_LEFT || nNxtButtonPressed == BTN_RIGHT) wait1Msec(5);
}
} PlaySound(soundBlip); while(nNxtButtonPressed == BTN_CENTER) wait1Msec(5);
nxtDisplayTextLine(7, "*** LOCKED ***");
#ifdef WAIT_FOR_START
waitForStart();
#endif
switch(AUTO_PROGRAM)
{
case 0:
knockDownBalls();
break;
case 1:
driveOffRamp();
break;
case 2:
dragGoal();
break;
case 3:
knockDownBallsWithDelay();
}
}
task main() {
//--------------------------------------------------------
//Setup stuff goes here
//--------------------------------------------------------
//StartTask(monitorFeedback);
retractHooks();
//--------------------------------------------------------
//Main sequence goes here
//--------------------------------------------------------
optionScreen();
}