-
Notifications
You must be signed in to change notification settings - Fork 0
Utility Functions
Jeffrey Shen edited this page Aug 18, 2017
·
1 revision
This library ships with a set of utility functions to do common tasks: MIN
, MAX
, SIGN
, BOUND
, and isTimedOut
.
-
MIN(X, Y)
returns the lower of the two parameters. The parameters can be any data type that is a number. For example:
int x = MIN(-10, 15); //x will be set to -10
-
MAX(X, Y)
returns the higher of the two parameters. The parameters can be any data type that is a number. For example:
int x = MAX(-5, -1); //x will be set to -1
-
int SIGN(int x)
returns the sign of the integer parameter (so -1 or 1). For example:
int x = SIGN(34); //x will be set to 1
-
int BOUND(int a, int amin, int amax)
will make sure thata
is betweenamin
andamax
. So, ifa
is less thanamin
,amin
will be returned. For example:
BOUND(-100, -10, 10); //Will return -10
BOUND(5, -10, 10); //Will return 5
BOUND(100, -10, 10); //Will return 10
-
int isTimedOut(int tstop)
is used to implement time out logic. If the current time has passedtstop
, the method will return 1, but otherwise it will return 0. It's generally a good practice to implement time outs in any loops you create. For example:
int tnow = time1[T1]; //The initial time (in milliseconds)
while(true){
if(isTimedOut(tnow + 3000)) break; //Timeout after 3 seconds
wait1Msec(10);
}
Beginner Features:
Intermediate Features:
Advanced Features:
Controlling the LCD
Using Autonomous Modes
Custom Pre Auton Procedure
Using Autonomous Modes in User Control
More Remote Functionality
Configuring Bailout Button
Custom User Control Procedure
PID Control
Drive Train Control