Util
controller​
The pros controller is defined globally in our library as master
.
- Prototype
- Example
void opcontrol() {
while (true) {
int l_stick = left_curve_function(master.get_analog(ANALOG_LEFT_Y));
int r_stick = left_curve_function(master.get_analog(ANALOG_RIGHT_Y));
chassis.set_tank(l_stick, r_stick);
pros::delay(ez::util::DELAY_TIME);
}
}
extern pros::Controller master();
print_to_screen()​
Prints to the LLEMU. This function handles text that's too long for a line by finding the last word and starting it on a new line, and takes \n
to set a new line.
text
input string
line
starting line
- Prototype
- Example
- Example 2
Returns:
hello, this is line 0
this is line 1
void initialize() {
ez::print_to_screen("hello, this is line 0\nthis is line 1");
}
void print_to_screen(std::string text, int line)
Returns:
01234567890123456789012345678901
hello
void initialize() {
std::string 32char = 01234567890123456789012345678901;
ez::print_to_screen(32char + "hello", 2);
}
print_ez_template()​
Prints our branding on your terimnal :D.
- Prototype
- Example
void initialize() {
print_ez_template();
}
void print_ez_template();
sgn()​
Returns the sign of the input. Returns 1 if positive, -1 if negative, and 0 if 0.
input
value to check the sign of
- Prototype
- Example
void opcontrol() {
while (true) {
printf("Sgn of Controller: %i \n", sgn(master.get_analog(ANALOG_LEFT_Y)));
pros::delay(ez::util::DELAY_TIME);
}
}
double sgn(double input);
clip_num()​
Checks if input
is within range of max
and min
. If it's out, this returns max
or min
respectively.
input
value to check if it's above/below max/min
max
biggest input can be
min
smallest input can be
- Prototype
- Example
void opcontrol() {
while (true) {
int joy = master.get_analog(ANALOG_LEFT_Y);
// When the joystick is between 100 and 127
// (or -100 and -127) this will print 100 (or -100).
printf("Clipped Controller: %i \n", clip_num(joy, 100, -100));
}
}
double clip_num(double input, double max, double min);
DELAY_TIME​
Standard delay time for loops in ms.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.tank();
pros::delay(ez::util::DELAY_TIME);
}
}
const int DELAY_TIME = 10;
IS_SD_CARD​
Boolean that checks if an SD card is installed. True if there is one, false if there isn't.
- Prototype
- Example
void initialize() {
if (!ez::util::IS_SD_CARD)
printf("No SD Card Found!\n");
}
const bool IS_SD_CARD = pros::usd::is_installed();