Go to Post I need someone to kick me out...unfortunately that would have to be me... - Mark McLeod [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 10-02-2015, 20:42
ericalbers ericalbers is offline
Registered User
no team
 
Join Date: Feb 2015
Location: earth
Posts: 4
ericalbers is an unknown quantity at this point
How do you get interrupt when digital input is set

Is there code showing how to get a interrupt when say a limit switch is hit?

I see the
public abstract class InterruptHandlerFunction<T>

is there example code of how to implement this for the requestInterrupts off DigitalInputs?
I'm having trouble with how to define the polymorphism of the function properly.

Thanks
Reply With Quote
  #2   Spotlight this post!  
Unread 10-02-2015, 20:52
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: How do you get interrupt when digital input is set

This is how I used interrupt handlers in a gyro driver. The really wierd part about it is that the interruptFired() method is package private, so any class that uses it needs to be in the edu.wpi.first.wpilibj package. I think this was an oversight on the part of the authors of WPILib.

Code:
DigitalInput interrupt = new DigitalInput(0);

// Register an interrupt handler
interrupt.requestInterrupts(new InterruptHandlerFunction<Object>() {

     @Override
     public void interruptFired(int interruptAssertedMask, Object param) {
          // Do stuff
     }
});
// Listen for a falling edge
interrupt.setUpSourceEdge(false, true);
// Enable digital interrupt pin
interrupt.enableInterrupts();
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #3   Spotlight this post!  
Unread 10-02-2015, 20:55
ericalbers ericalbers is offline
Registered User
no team
 
Join Date: Feb 2015
Location: earth
Posts: 4
ericalbers is an unknown quantity at this point
Re: How do you get interrupt when digital input is set

Thanks, actually the private part is what was reallly killing me, I just could not get the thing to be happy I had the same code...

testinput =new DigitalInput(0);


testinput.requestInterrupts(new InterruptHandlerFunction<Object>()
{

@Override
public void interruptFired(int interruptAssertedMask, Object param)
{

}
});

I just couldn't get it to like the interruptFired no matter how I set it up...the base class having an error explains it though
Thanks
Reply With Quote
  #4   Spotlight this post!  
Unread 11-02-2015, 17:06
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: How do you get interrupt when digital input is set

Quote:
Originally Posted by ericalbers View Post
Is there code showing how to get a interrupt when say a limit switch is hit?
How much code do you plan to put into the interrupt routine?


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: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