
24-11-2015, 15:48
|
|
Parent Mentor
AKA: Andrew Chandler
 FRC #0031
Team Role: Mentor
|
|
Join Date: Dec 2013
Rookie Year: 2011
Location: Tulsa
Posts: 27
|
|
|
Re: Using encoder with talon SRX
I think I had found my problem - I am using the 2016 version of Robotbuilder I built from source (yay talon srx now works!) - I hadn't noticed when I threw the button in that it defaulted to while pressed not when pressed.
Quote:
Originally Posted by ozrien
If you are using RobotBuilder then you can to a "whenPressed" action...
https://wpilib.screenstepslive.com/s...e-to-a-command
If you are using command classes yourself there is a Button class you could wire into the scheduler.
If you are just writing straight java, I usually just copy/paste the following...
Code:
//instance variables
boolean [] btns = new boolean [] {false,false,false,false,false};
boolean [] last = new boolean [] {false,false,false,false,false};
Code:
//get latest
public void teleopPeriodic() {
btns[1] = _joy.getRawButton(1);
btns[2] = _joy.getRawButton(2);
btns[3] = _joy.getRawButton(3);
btns[4] = _joy.getRawButton(4);
Code:
if(!last[3] && btns[3]){
//btn3 just pressed, do something
}
Code:
// bottom of teleop save all btns into last
for(i=0;i<last.length;++i)
last[i] = btns[i];
|
|