Comparing version 0.0.2 to 0.0.3
@@ -13,21 +13,9 @@ /* | ||
var self = this; | ||
self.pause = false; | ||
self.uart = null; | ||
self.timer = 200; //Wait for device to power up | ||
self.speaking = false; | ||
self.timer = 200; | ||
self.currentAction = 'idle'; | ||
self.baudrate = 9600; | ||
self.hardware = hardware; | ||
self.queue = new Queue(); | ||
EventEmitter.call(this); | ||
self.init(callback); | ||
return self; | ||
@@ -44,12 +32,15 @@ } | ||
self.uart = new self.hardware.UART(); | ||
var statusResponse = function(data){ | ||
var res = data.toString(); | ||
console.log(res); | ||
if(res.indexOf(':') !== -1){ | ||
self.uart.removeListener('data', statusResponse); | ||
if(callback) callback(); | ||
self.emit('ready'); | ||
self.setListener(); | ||
} | ||
}; | ||
setTimeout(function(){ | ||
self.uart.write('\n'); | ||
self.uart.once('data', function(data){ | ||
var res = data.toString(); | ||
if(res.match(/:/)){ | ||
if(callback) callback(); | ||
self.emit('ready'); | ||
self.setListener(); | ||
} | ||
}); | ||
self.uart.on('data', statusResponse); | ||
}, self.timer); | ||
@@ -62,6 +53,8 @@ }; | ||
var res = data.toString(); | ||
if(res.match(/:/)){ | ||
self.emit('done'); | ||
if(res.indexOf(':') !== -1){ | ||
self.emit('done', self.currentAction); | ||
self.speaking = false; | ||
self.queue.next(); | ||
}else if(res.match(/\?/)){ | ||
}else if(res.indexOf('?') !== -1){ | ||
self.speaking = false; | ||
self.emit('error'); | ||
@@ -73,10 +66,6 @@ self.queue.next(); | ||
emic2.prototype.destroy = function(callback){ | ||
this.uart.removeListener('data'); | ||
if(callback) callback(); | ||
}; | ||
emic2.prototype.speak = function (text) { | ||
var self = this; | ||
self.queue.place(function s(){ | ||
self.currentAction = 'speaking'; | ||
self.uart.write('S' + text + '\n'); | ||
@@ -90,2 +79,3 @@ }); | ||
self.queue.place(function(){ | ||
self.currentAction = 'setting language'; | ||
var l = 0; | ||
@@ -100,4 +90,5 @@ switch(lan){ | ||
} | ||
self.uart.write('L' + l + '\n'); | ||
self.uart.write('l' + l + '\n'); | ||
}); | ||
return this; | ||
}; | ||
@@ -108,4 +99,6 @@ | ||
self.queue.place(function(){ | ||
self.currentAction = 'setting volume'; | ||
self.uart.write('V' + vol + '\n'); | ||
}); | ||
return this; | ||
}; | ||
@@ -116,4 +109,6 @@ | ||
self.queue.place(function(){ | ||
self.currentAction = 'setting voice'; | ||
self.uart.write('N' + voice + '\n'); | ||
}); | ||
return this; | ||
}; | ||
@@ -124,8 +119,11 @@ | ||
self.queue.place(function(){ | ||
self.currentAction = 'setting rate'; | ||
self.uart.write('W' + rate + '\n'); | ||
}); | ||
return this; | ||
}; | ||
emic2.prototype.pause = function(){ | ||
self.uart.write('Z\n'); | ||
this.uart.write('Z\n'); | ||
return this; | ||
}; | ||
@@ -135,2 +133,3 @@ | ||
this.uart.write('X\n'); | ||
return this; | ||
}; | ||
@@ -141,4 +140,6 @@ | ||
self.queue.place(function(){ | ||
self.currentAction = 'resetting'; | ||
self.uart.write('R\n'); | ||
}) | ||
}); | ||
return this; | ||
}; | ||
@@ -145,0 +146,0 @@ |
{ | ||
"name": "emic2", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Node API for Emic2 module TTS", | ||
@@ -5,0 +5,0 @@ "main": "./lib/emic2.js", |
Sorry, the diff of this file is not supported yet
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
5684
4
125