Skip to content

Commit beb4d94

Browse files
committed
Merge pull request #19 from pushtheworldllc/dev
Made simulator more like board. Made simulator sample rate be 250Hz. …
2 parents c6f05d8 + 610a75f commit beb4d94

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

openBCIBoard.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ function OpenBCIFactory() {
162162
*/
163163
OpenBCIBoard.prototype.streamStart = function() {
164164
this.streaming = true;
165+
this._reset();
165166
return this.write(k.OBCIStreamStart);
166167
};
167168

@@ -175,7 +176,6 @@ function OpenBCIFactory() {
175176
*/
176177
OpenBCIBoard.prototype.streamStop = function() {
177178
this.streaming = false;
178-
this._reset();
179179
return this.write(k.OBCIStreamStop);
180180
};
181181

@@ -472,6 +472,8 @@ function OpenBCIFactory() {
472472
reject('Simulator Already Running');
473473
} else {
474474
// start simulating
475+
this.connected = true;
476+
this.streaming = true;
475477
this.isSimulating = true;
476478
// generateSample is a func that takes the previous sample number
477479
var generateSample = openBCISample.randomSample(this.numberOfChannels(),this.sampleRate());
@@ -485,7 +487,7 @@ function OpenBCIFactory() {
485487
this.emit('sample',newSample);
486488
oldSample = newSample;
487489
resolve();
488-
}, 20);
490+
}, 4);
489491

490492
}
491493

@@ -503,6 +505,8 @@ function OpenBCIFactory() {
503505
if(this.isSimulating) {
504506
// stop simulating
505507
this.isSimulating = false;
508+
this.connected = false;
509+
this.streaming = false;
506510
if(this.simulator) {
507511
clearInterval(this.simulator);
508512
}

openBCISample.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ module.exports = {
173173

174174
}
175175
}
176-
newSample.sampleNumber = previousSampleNumber + 1;
176+
if (previousSampleNumber == 255) {
177+
newSample.sampleNumber = 0;
178+
} else {
179+
newSample.sampleNumber = previousSampleNumber + 1;
180+
}
177181
newSample.auxData = auxData;
178182

179183
return newSample;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openbci-sdk",
3-
"version": "0.1.7",
3+
"version": "0.1.8",
44
"description": "A fully NodeJS based API for the OpenBCI board connecting to the hardware directly over serial",
55
"main": "openBCIBoard",
66
"scripts": {

0 commit comments

Comments
 (0)