View Single Post
  #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