Go to Post The 2008 team is not the 2007 team and won't be the 2009 team. Every year is a new year and a new opportunity for growth and development as a FIRST team. It's very cool. - JaneYoung [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #21   Spotlight this post!  
Unread 24-11-2015, 15:48
riftware riftware is offline
Parent Mentor
AKA: Andrew Chandler
FRC #0031
Team Role: Mentor
 
Join Date: Dec 2013
Rookie Year: 2011
Location: Tulsa
Posts: 27
riftware is an unknown quantity at this point
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 View Post
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];
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:52.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi