#Infrared
Driver for the ir-attx4 Tessel infrared module. The hardware documentation for this module can be found here.
If you run into any issues you can ask for support on the IR Module Forums.
###Installation
npm install ir-attx4
###Example
var tessel = require('tessel');
var infraredlib = require('ir-attx4');
var infrared = infraredlib.use(tessel.port['A']);
infrared.on('ready', function() {
if (!err) {
console.log("Connected to IR!");
setInterval(function() {
var powerBuffer = new Buffer([0, 178, 255, 168, 0, 12, 255, 246, 0, 13, 255, 225, 0, 13, 255, 224, 0, 12, 255, 246, 0, 12, 255, 246, 0, 13, 255, 247, 0, 13, 255, 247, 0, 13, 255, 224, 0, 12, 255, 224, 0, 13, 255, 247, 0, 13, 255, 224, 0, 12, 255, 246, 0, 12, 255, 246, 0, 12, 255, 246, 0, 12, 255, 246, 0, 13, 255, 247, 0, 13, 255, 224, 0, 12, 255, 224, 0, 13, 255, 225, 0, 13, 255, 224, 0, 12, 255, 246, 0, 12, 255, 246, 0, 13, 255, 247, 0, 13, 255, 247, 0, 13, 255, 246, 0, 12, 255, 246, 0, 12, 255, 246, 0, 12, 255, 246, 0, 12, 255, 224, 0, 13, 255, 224, 0, 12, 255, 224, 0, 12, 255, 224, 0, 12]);
infrared.sendRawSignal(38, powerBuffer, function(err) {
if (err) {
console.log("Unable to send signal: ", err);
} else {
console.log("Signal sent!");
}
});
}, 3000);
} else {
console.log(err);
}
});
infrared.on('data', function(data) {
console.log("Received RX Data: ", data);
});
###Methods
# infrared.sendRawSignal( frequency, signalDurations, callback )
The primary method for sending data. The first argument is a frequency of signal in Hz, typically 38 but can range from 36 to 40. The second argument is a buffer of unsigned 16 bit integers representing the number of microseconds the transmission should be on. The max length of the signal durations is 100 durations.
# infrared.setListening( set, callback )
Determines whether the module is listening for incoming signals. Will automatically be set and unset depending on listeners for the data event.
###Events
# infrared.on( 'data', callback(data) )
Emitted when an infrared signal is detected.
# infrared.on( 'error', callback(err) )
Emitted when there is an error communicating with the module.
# infrared.on( 'ready', callback() )
Emitted upon first successful communication between the Tessel and the module.
###License
Released under the MIT and Apache 2.0 licenses.