From dfd387545ec2ce6a13d14822e078245a9d70a2fd Mon Sep 17 00:00:00 2001 From: Alex Brooke Date: Mon, 2 Sep 2019 20:11:28 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20adddefault=20LLEMU=20init=20?= =?UTF-8?q?code=20back=20to=20main.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 99fd1bc71..95aa9873e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,15 @@ #include "main.h" +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 +17,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 +28,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 +39,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 +52,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 From a5f40c0313b8dc4a1c4ff08653b13a16200d4472 Mon Sep 17 00:00:00 2001 From: Alex Brooke Date: Mon, 2 Sep 2019 20:46:22 -0400 Subject: [PATCH 2/2] add documentation comment for callback function --- src/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 95aa9873e..2cc89c635 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,11 @@ #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;