Guest User

Untitled

a guest
Jan 16th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. @Override
  2. public void teleopPeriodic() {
  3.  
  4. // Set buttonCurr
  5.  
  6. // Check if a press JUST started
  7. // If so, reset timer
  8.  
  9.  
  10. // Check if button is pressed
  11. // If so, check if we need to reset timer (over 1 second)
  12.  
  13. // If not, pulse
  14.  
  15.  
  16. currButton = controller.getRawButtonPressed(1);
  17.  
  18. // Change this to use currButton (only to make it more readable, that's all)
  19. if (controller.getRawButton(1)) {
  20. // You can just say !prevButton instead of prevButton == false
  21. if (prevButton == false) {
  22. timer.start();
  23. // Don't set this here, instead just set prevButton = currButton at the very end of the method
  24. prevButton = true;
  25. }
  26.  
  27. // Break out the pulseOn and timer.hasPassed checks into separate if statements, not connected
  28.  
  29. // if time.hasPassed()
  30. // reset timer
  31. // Toggle pulseOn value
  32.  
  33.  
  34. // if pulseOn
  35. // set motor output to 0
  36.  
  37. // Set talon to motor output
  38.  
  39. // Then you shouldn't need anything below here:
  40.  
  41. // if (pulseOn) {
  42. // motorOutput = 0;
  43. // if (timer.hasPeriodPassed(1)) {
  44. // pulseOn = false;
  45. // }
  46. // } else {
  47. // motorOutput = 1;
  48. // if (timer.hasPeriodPassed(1)) {
  49. // pulseOn = true;
  50. // }
  51. //
  52. // }
  53. // talon.set(ControlMode.PercentOutput, motorOutput);
  54. // System.out.println(timer.get());
  55. // if (timer.hasPeriodPassed(1)) {
  56. // timer.reset();
  57. // }
  58.  
  59.  
  60. }
  61. // if (controller.getRawButtonReleased(1)) {
  62. // prevButton = false;
  63. // }
  64.  
  65. }
Add Comment
Please, Sign In to add comment