Skip to content
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

Clean joystick code in user_input.cpp #31

Closed
ssejrog opened this issue Dec 29, 2021 · 0 comments
Closed

Clean joystick code in user_input.cpp #31

ssejrog opened this issue Dec 29, 2021 · 0 comments

Comments

@ssejrog
Copy link
Member

ssejrog commented Dec 29, 2021

The code below is repeated in arcade_flipped, arcade_standard, and tank.

  // Threshold if joysticks don't come back to perfect 0
  if (abs(l_stick) > JOYSTICK_THRESHOLD || abs(r_stick) > JOYSTICK_THRESHOLD) {
    set_tank(r_stick + l_stick, r_stick - l_stick);
    reset_drive_sensor();
  }
  // When joys are released, run active brake (P) on drive
  else {
    set_tank((0 - left_sensor()) * active_brake_kp, (0 - right_sensor()) * active_brake_kp);
  }

Also, there's no reason to reset the drive sensors in opcontrol unless active brake is being used. if (active_brake_kp != 0) should be in front of reset_drive_sensor().

ssejrog added a commit that referenced this issue Dec 29, 2021
@ssejrog ssejrog closed this as completed Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant