MCPcopy Index your code
hub / github.com/processing/processing / enableInterrupt

Method enableInterrupt

java/libraries/io/src/processing/io/GPIO.java:273–301  ·  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

271 * @see disableInterrupt
272 */
273 protected static void enableInterrupt(int pin, int mode) {
274 checkValidPin(pin);
275
276 String out;
277 if (mode == NONE) {
278 out = "none";
279 } else if (mode == CHANGE) {
280 out = "both";
281 } else if (mode == FALLING) {
282 out = "falling";
283 } else if (mode == RISING) {
284 out = "rising";
285 } else {
286 throw new IllegalArgumentException("Unknown mode");
287 }
288
289 if (NativeInterface.isSimulated()) {
290 return;
291 }
292
293 String fn = String.format("/sys/class/gpio/gpio%d/edge", pin);
294 int ret = NativeInterface.writeFile(fn, out);
295 if (ret < 0) {
296 if (ret == -2) { // ENOENT
297 System.err.println("Make sure your called pinMode on the input pin");
298 }
299 throw new RuntimeException(NativeInterface.getError(ret));
300 }
301 }
302
303
304 /**

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