MCPcopy Index your code
hub / github.com/benfry/processing4 / enableInterrupt

Method enableInterrupt

java/libraries/io/src/processing/io/GPIO.java:301–329  ·  view source on GitHub ↗

Enables an interrupt for an input pin @param pin GPIO pin @param mode what to wait for: GPIO.CHANGE, GPIO.FALLING or GPIO.RISING @see waitForInterrupt @see disableInterrupt

(int pin, int mode)

Source from the content-addressed store, hash-verified

299 * @see disableInterrupt
300 */
301 protected static void enableInterrupt(int pin, int mode) {
302 checkValidPin(pin);
303
304 String out;
305 if (mode == NONE) {
306 out = "none";
307 } else if (mode == CHANGE) {
308 out = "both";
309 } else if (mode == FALLING) {
310 out = "falling";
311 } else if (mode == RISING) {
312 out = "rising";
313 } else {
314 throw new IllegalArgumentException("Unknown mode");
315 }
316
317 if (NativeInterface.isSimulated()) {
318 return;
319 }
320
321 String fn = String.format("/sys/class/gpio/gpio%d/edge", pin);
322 int ret = NativeInterface.writeFile(fn, out);
323 if (ret < 0) {
324 if (ret == -2) { // ENOENT
325 System.err.println("Make sure your called pinMode on the input pin");
326 }
327 throw new RuntimeException(NativeInterface.getError(ret));
328 }
329 }
330
331
332 /**

Callers 3

attachInterruptMethod · 0.95
disableInterruptMethod · 0.95
waitForMethod · 0.95

Calls 6

checkValidPinMethod · 0.95
isSimulatedMethod · 0.95
writeFileMethod · 0.95
getErrorMethod · 0.95
formatMethod · 0.65
printlnMethod · 0.45

Tested by

no test coverage detected