Autonomous Selector
initialize()
Initializes the autonomous selector. If an SD card is plugged in, the current page will set to what's on the SD card.
- Prototype
- Example
void initialize() {
ez::as::initialize();
}
void initialize();
limit_switch_lcd_initialize()
Sets external buttons to increase/decrease the current autonomous page.
The library never takes ownership of the pointers you pass in and will never delete them, but it keeps using them after this call returns, so the switches must stay alive for the whole program. Make them global, not locals inside initialize(). Passing nullptr for both disables the limit switches.
right_limit a button to go forward a page
left_limit a button to go backwards a page
- Prototype
- Example
pros::adi::DigitalIn increase('A');
pros::adi::DigitalIn decrease('B');
void initialize() {
ez::as::initialize();
ez::as::limit_switch_lcd_initialize(&increase, &decrease);
// . . .
}
void limit_switch_lcd_initialize(pros::adi::DigitalIn* right_limit, pros::adi::DigitalIn* left_limit = nullptr);
shutdown()
Wrapper for pros::lcd::shutdown() found here.
- Prototype
- Example
void initialize() {
ez::as::initialize();
// Do something
ez::as::shutdown();
}
void shutdown();
autons_add();
Appends autonomous routines to the autonomous selector's list. Calling this more than once keeps the routines you've already added, and the selector goes back to the first page. Uses ez::screen_print() to display to the brain.
autons accepts an object of a string and a function
- Prototype
- Example
void auto1() {
// Do something
}
void auto2() {
// Do something
}
void auto3() {
// Do something
}
void initialize() {
ez::as::auton_selector.autons_add({
ez::Auton("Autonomous 1\nDoes Something", auto1),
ez::Auton("Autonomous 2\nDoes Something Else", auto2),
ez::Auton("Autonomous 3\nDoes Something More", auto3),
});
}
void autons_add(std::vector<Auton> autons);
selected_auton_print();
Prints the current autonomous mode to the screen.
- Prototype
- Example
void initialize() {
ez::as::auton_selector.selected_auton_print();
}
void selected_auton_print();
page_down()
Decreases the page number. Best used with the lcd callback functions.
- Prototype
- Example
void initialize() {
pros::lcd::register_btn0_cb(ez::as::page_down);
pros::lcd::register_btn2_cb(ez::as::page_up);
}
void page_down();
page_up()
Increases the page number. Best used with the lcd callback functions
- Prototype
- Example
Example
void initialize() {
pros::lcd::register_btn2_cb(ez::as::page_up);
}
void page_up();
selected_auton_call()
Runs the current autonomous that's selected. If the selector is on a blank page instead of an autonomous, it runs the last autonomous page you were on.
- Prototype
- Example
void autonomous() {
chassis.drive_imu_reset();
chassis.drive_sensor_reset();
chassis.drive_brake_set(MOTOR_BRAKE_HOLD);
ez::as::auton_selector.selected_auton_call();
}
void selected_auton_call();
enabled()
Returns true if the auton selector is enabled and false if it isn't.
- Prototype
- Example
void initialize() {
printf("Enabled? %i\n", ez::as::enabled()); // Returns false
ez::as::initialize();
printf("Enabled? %i\n", ez::as::enabled()); // Returns true
}
bool enabled();
page_blank_is_on()
Checks if this blank page is open. If this page doesn't exist, this will create it.
page blank page index
- Prototype
- Example
bool page_blank_is_on(int page);
void opcontrol() {
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print("Hello World!", 1);
ez::screen_print(std::to_string(3.1415) + " <- is pie!", 2);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
page_blank_remove_all()
Removes all blank pages.
- Prototype
- Example
void page_blank_remove_all();
void opcontrol() {
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print("Hello World!", 1);
ez::screen_print(std::to_string(3.1415) + " <- is pie!", 2);
}
if (master.get_digital_new_press(DIGITAL_L1)) {
ez::as::page_blank_remove_all();
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
The next page_blank_is_on() call creates its page again, so stop calling it once you have removed the pages (for example, only call it while pros::competition::is_connected() is false, as the Blank Pages tutorial does).