BoneScript
attachInterrupt(pin, handler, mode, [callback])
Detect changes on a digital input line
Note: This function is still undergoing development and debug.
Arguments
- pin: the BeagleBone pin identifier
- handler:
- true: always call the callback upon interrupt event
- string: evaluated upon interrupt, passed an object with 'value' having the state of the input pin and will call callback if evaluates to true
- mode: RISING, FALLING or CHANGE
- callback: called when handler returns true or other events
Return value
callback(x)
- x.pin: pin that generated event
- x.output: result of handler function
- x.value: input state of the pin generating the interrupt
- x.attached: handler successfully attached
- x.configured: interrupt handler previously configured
Example
var b = require('bonescript'); var inputPin = 'P8_19'; b.pinMode(inputPin, b.INPUT); b.attachInterrupt(inputPin, true, b.CHANGE, interruptCallback); setTimeout(detach, 12000); function interruptCallback(x) { console.log(JSON.stringify(x)); } function detach() { b.detachInterrupt(inputPin); console.log('Interrupt detached'); }
Build and execute instructions
- Toggle the state of P8_19 within 12 seconds of starting script.
See also
Topics
Related functions
Examples
Last updated by blog.hangerhead.com on Fri Jun 21 2013 14:36:23 GMT-0000 (UTC).