Go to Post Do not interrupt, do not defend yourself - just listen. After they are done, be sure to thank them for their honest feedback, and close the books. Arguing or defending is not how to accept feedback. - DonRotolo [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

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-11-2015, 15:25
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 521
ozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant future
Re: Using encoder with talon SRX

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
  #2   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
Reply


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 10:16.

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