tessel-morse
Advanced tools
Comparing version 0.0.1 to 0.1.0
61
index.js
@@ -16,32 +16,7 @@ var tessel = require('tessel'); | ||
var q = async.queue(function(c, callback) { | ||
var onDuration; | ||
var offDuration; | ||
if (c === WORD_DELIMITER) { | ||
onDuration = 0; | ||
offDuration = 7; | ||
} else if (c === '.') { | ||
onDuration = 1; | ||
offDuration = 1; | ||
} else if (c === '-') { | ||
onDuration = 3; | ||
offDuration = 1; | ||
} else if (c === ' ') { | ||
onDuration = 0; | ||
offDuration = 3; | ||
} | ||
if (onDuration > 0) { | ||
ledOn(); | ||
} | ||
setTimeout(function() { | ||
ledOff(); | ||
setTimeout(function() { | ||
callback(); | ||
}, offDuration * DOT_DURATION); | ||
}, onDuration * DOT_DURATION); | ||
}, 1); | ||
function morse_blink(str, options) { | ||
options = options || {}; | ||
options.on = options.on || ledOn; | ||
options.off = options.off || ledOff; | ||
if (typeof options.duration === 'number' && !isNaN(options.duration)) { | ||
@@ -53,2 +28,31 @@ DOT_DURATION = options.duration; | ||
} | ||
var q = async.queue(function(c, callback) { | ||
var onDuration; | ||
var offDuration; | ||
if (c === WORD_DELIMITER) { | ||
onDuration = 0; | ||
offDuration = 7; | ||
} else if (c === '.') { | ||
onDuration = 1; | ||
offDuration = 1; | ||
} else if (c === '-') { | ||
onDuration = 3; | ||
offDuration = 1; | ||
} else if (c === ' ') { | ||
onDuration = 0; | ||
offDuration = 3; | ||
} | ||
if (onDuration > 0) { | ||
options.on(); | ||
} | ||
setTimeout(function() { | ||
options.off(); | ||
setTimeout(function() { | ||
callback(); | ||
}, offDuration * DOT_DURATION); | ||
}, onDuration * DOT_DURATION); | ||
}, 1); | ||
var morseStr = morse.encode(str.split(' ')).join(WORD_DELIMITER); | ||
@@ -59,2 +63,3 @@ var arr = morseStr.split(''); | ||
} | ||
return morse.encode(str); | ||
@@ -61,0 +66,0 @@ } |
{ | ||
"name": "tessel-morse", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Communicate in Morse code using your Tessel", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,2 +13,4 @@ # tessel-morse | ||
Run the following script on your tessel: | ||
``` js | ||
@@ -20,2 +22,6 @@ var morseBlink = require('tessel-morse'); | ||
Look at your Tessel! It should be blinking :) | ||
[See it in action here.](http://www.gfycat.com/OilyPeskyBandicoot) | ||
## Options | ||
@@ -22,0 +28,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4345
5
60
58