Hm, how do I work around this without making it into a total mess?
On Arduino it's easy, because Serial.read() always returns one character. But here, I could be getting anything...
Is there anything more graceful than
AzzyRF.prototype.onData = function(data) { for (var x=0; x < data.length; x++) { if (data.charAt(x)=="#" && this.datastring) { if (this.datastring) { this.Serial.print(this.datastring); this.datastring=""; } } else if (data.charAt(x)==">" && this.datastring) { //TODO } else if (data.charAt(x)=="\n" || data.charAt(x)=="\r"){ if (this.inString!="") { this.outputFormat(this.inString); this.inString=""; } } else { this.inString+=data.charAt(x); if (this.timeout > 0) { clearTimeout(this.timeout); } } } this.timeout=setTimeout(function() {this.outputFormat(this.inString);this.inString='';this.timeout=0;}.bind(this),1000); };
@DrAzzy started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hm, how do I work around this without making it into a total mess?
On Arduino it's easy, because Serial.read() always returns one character. But here, I could be getting anything...
Is there anything more graceful than