Skip to content

Commit

Permalink
added all four buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwolf3140 committed Jan 2, 2025
1 parent fb60d43 commit 48a5dcd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
14 changes: 13 additions & 1 deletion include/EZ-Template/drive/drive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,8 +1253,16 @@ class Drive {
* sets the button to lower PID tuner
* \param increase
* sets the button to increase PID tuner
* \param pageLeft
sets the PID screen left
* \param pageRight
sets the PID screen right
* \param pageUP
switched between kp, ki, kd, and start i
* \param pageDown
switched between kp, ki, kd, and start i
*/
void pid_tuner_button_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase);
void pid_tuner_button_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase, pros::controller_digital_e_t pageLeft, pros::controller_digital_e_t pageRight, pros::controller_digital_e_t pageUp, pros::controller_digital_e_t pageDown);

/////
//
Expand Down Expand Up @@ -3554,6 +3562,10 @@ class Drive {

pros::controller_digital_e_t pid_tuner_increase; //is this place good?
pros::controller_digital_e_t pid_tuner_decrease;
pros::controller_digital_e_t pid_tuner_pageLeft;
pros::controller_digital_e_t pid_tuner_pageRight;
pros::controller_digital_e_t pid_tuner_pageUp;
pros::controller_digital_e_t pid_tuner_pageDown;

/**
* Private wait until for drive
Expand Down
20 changes: 15 additions & 5 deletions src/EZ-Template/drive/pid_tuner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,21 @@ double Drive::pid_tuner_increment_start_i_get() { return start_i_increment; }

/*pros::controller_digital_e_t pid_tuner_increase;
pros::controller_digital_e_t pid_tuner_decrease;*/
void Drive::pid_tuner_button_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase) {
/*void Drive::pid_tuner_button_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase) {
pid_tuner_increase = increase;
pid_tuner_decrease = decrease;
}*/

void Drive::pid_tuner_button_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase, pros::controller_digital_e_t pageLeft, pros::controller_digital_e_t pageRight, pros::controller_digital_e_t pageUp, pros::controller_digital_e_t pageDown){
pid_tuner_increase = increase;
pid_tuner_decrease = decrease;
pid_tuner_pageLeft = pageLeft;
pid_tuner_pageRight = pageRight;
pid_tuner_pageUp = pageUp;
pid_tuner_pageDown = pageDown;
}


// Iterate
void Drive::pid_tuner_iterate() {
if (!pid_tuner_on) return; // Exit if it's disabled
Expand All @@ -183,25 +193,25 @@ void Drive::pid_tuner_iterate() {
}

// Up / Down for Rows
if (master.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_RIGHT)) {
if (master.get_digital_new_press(pid_tuner_pageRight)) {
column++;
if (column > used_pid_tuner_pids->size() - 1)
column = 0;
pid_tuner_print();
} else if (master.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_LEFT)) {
} else if (master.get_digital_new_press(pid_tuner_pageLeft)) {
column--;
if (column < 0)
column = used_pid_tuner_pids->size() - 1;
pid_tuner_print();
}

// Left / Right for Columns
if (master.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_DOWN)) {
if (master.get_digital_new_press(pid_tuner_pageDown)) {
row++;
if (row > 3)
row = 0;
pid_tuner_print();
} else if (master.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_UP)) {
} else if (master.get_digital_new_press(pid_tuner_pageUp)) {
row--;
if (row < 0)
row = 3;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void initialize() {
// - ignore this if you aren't using a vertical tracker
// chassis.odom_tracker_left_set(&vert_tracker);

chassis.pid_tuner_button_set(pros::E_CONTROLLER_DIGITAL_Y, pros::E_CONTROLLER_DIGITAL_A); // Sets the buttons used for PID Tuning.
chassis.pid_tuner_button_set(pros::E_CONTROLLER_DIGITAL_Y, pros::E_CONTROLLER_DIGITAL_A, pros::E_CONTROLLER_DIGITAL_LEFT, pros::E_CONTROLLER_DIGITAL_RIGHT, pros::E_CONTROLLER_DIGITAL_UP, pros::E_CONTROLLER_DIGITAL_DOWN); // Sets the buttons used for PID Tuning.

// Configure your chassis controls
chassis.opcontrol_curve_buttons_toggle(true); // Enables modifying the controller curve with buttons on the joysticks
Expand Down

0 comments on commit 48a5dcd

Please sign in to comment.