-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨Field Control State Getter #608
Changes from 3 commits
b704ad1
e8fae37
9356cfe
9865033
fb2687a
779e186
4bcd4d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ | |
#define COMPETITION_DISABLED (1 << 0) | ||
#define COMPETITION_AUTONOMOUS (1 << 1) | ||
#define COMPETITION_CONNECTED (1 << 2) | ||
#define COMPETITION_SYSTEM (1 << 3) | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
|
@@ -130,6 +131,17 @@ uint8_t competition_get_status(void); | |
*/ | ||
#define competition_is_autonomous() ((competition_get_status() & COMPETITION_AUTONOMOUS) != 0) | ||
|
||
/** | ||
* \return True if the V5 Brain is connected to VEXnet Field Controller, false otherwise. | ||
*/ | ||
#define competition_is_field_control() ((competition_get_status() & COMPETITION_SYSTEM) != 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto on the macro thing... maybe these could be functions? |
||
|
||
/** | ||
* \return True if the V5 Brain is connected to VEXnet Competition Switch, false otherwise. | ||
*/ | ||
#define competition_is_competition_switch() ((competition_get_status() & COMPETITION_SYSTEM) == 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should come up with a better naming scheme for these, I know it's a legacy thing but man competition_is_competition is kind of repetitive. |
||
|
||
|
||
///@} | ||
|
||
/// \name V5 Controller | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,25 @@ 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() { | ||
while (1) { | ||
if (pros::competition::is_field_control()) { | ||
printf("[Auton] testing is_field_control(): true\n"); | ||
} | ||
else { | ||
printf("[Auton] testing is_field_control(): false\n"); | ||
} | ||
|
||
if (pros::competition::is_competition_switch()) { | ||
printf("[Auton] testing is_competition_switch(): true\n"); | ||
} | ||
else { | ||
printf("[Auton] testing is_competition_switch(): false\n"); | ||
} | ||
|
||
pros::delay(1000); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. be sure to remove this before merge. |
||
|
||
/** | ||
* Runs the operator control code. This function will be started in its own task | ||
|
@@ -79,8 +97,10 @@ void opcontrol() { | |
pros::MotorGroup right_mg({-4,5,-6}); // Creates a motor group with forwards port 4 and reversed ports 4 & 6 | ||
|
||
while (true) { | ||
|
||
pros::lcd::print(0, "%d %d %d", (pros::lcd::read_buttons() & LCD_BTN_LEFT) >> 2, | ||
(pros::lcd::read_buttons() & LCD_BTN_CENTER) >> 1, | ||
|
||
(pros::lcd::read_buttons() & LCD_BTN_RIGHT) >> 0); // Prints status of the emulated screen LCDs | ||
|
||
// Arcade control scheme | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4.0.2 | ||
4.0.5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. forgot the newline... somebody did somewhere earlier as well. Please add it back |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we're making breaking changes anyways, do we want to switch this into an enum instead? If it's a readability thing with bits we could also just add a comment or support both enums and the old macros.