diff --git a/src/main.cpp b/src/main.cpp index 99fd1bc71..2cc89c635 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,21 @@ #include "main.h" +/** + * A callback function for LLEMU's center button. + * + * When this callback is fired, it will toggle line 2 of the LCD text between + * "I was pressed!" and nothing. + */ +void on_center_button() { + static bool pressed = false; + pressed = !pressed; + if (pressed) { + pros::lcd::set_text(2, "I was pressed!"); + } else { + pros::lcd::clear_line(2); + } +} + /** * Runs initialization code. This occurs as soon as the program is started. * @@ -7,6 +23,10 @@ * to keep execution time for this mode under a few seconds. */ void initialize() { + pros::lcd::initialize(); + pros::lcd::set_text(1, "Hello PROS User!"); + + pros::lcd::register_btn1_cb(on_center_button); } /** @@ -14,8 +34,7 @@ void initialize() { * the VEX Competition Switch, following either autonomous or opcontrol. When * the robot is enabled, this task will exit. */ -void disabled() { -} +void disabled() {} /** * Runs after initialize(), and before autonomous when connected to the Field @@ -26,8 +45,7 @@ void disabled() { * This task will exit when the robot is enabled and autonomous or opcontrol * starts. */ -void competition_initialize() { -} +void competition_initialize() {} /** * Runs the user autonomous code. This function will be started in its own task @@ -40,8 +58,7 @@ void competition_initialize() { * will be stopped. Re-enabling the robot will restart the task, not re-start it * from where it left off. */ -void autonomous() { -} +void autonomous() {} /** * Runs the operator control code. This function will be started in its own task