forked from tessel/ir-attx4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
.DS_Store | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var tessel = require('tessel'); | ||
|
||
var portname1 = process.argv[2] || 'A'; | ||
var infrared1 = require('../index').use(tessel.port[portname1]); | ||
|
||
var portname2 = process.argv[3] || 'B'; | ||
var infrared2 = require('../index').use(tessel.port[portname2]); | ||
|
||
console.log('1..2') | ||
|
||
// Receive on IR 1 | ||
infrared1.on('data', function (data) { | ||
console.log('# received RX Data:', data); | ||
console.log('ok'); | ||
process.exit(0); | ||
}); | ||
|
||
// Send on IR 2 | ||
var sendack = false; | ||
infrared2.on('ready', function(err) { | ||
if (err) { return console.error(err); } | ||
|
||
setImmediate(function sendSignal () { | ||
// Make a buffer off on/off durations (each duration is 16 bits) | ||
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 | ||
]); | ||
|
||
// Send the signal at 38 kHz | ||
infrared2.sendRawSignal(38, powerBuffer, function (err) { | ||
if (err) { return console.log("Unable to send signal: ", err); } | ||
|
||
console.log('# signal sent!'); | ||
!sendack && console.log('ok'); | ||
sendack = true; | ||
setImmediate(sendSignal); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env node | ||
|
||
require('shelljs/global'); | ||
|
||
var port1 = process.env.IR_PORT1 || 'A'; | ||
var port2 = process.env.IR_PORT2 || 'B'; | ||
var cmd = './node_modules/.bin/tap -e "tessel run {} ' + port1 + ' ' + port2 + '" test/*.js'; | ||
|
||
// execute | ||
cd(__dirname) | ||
process.exit(exec(cmd).code); |