Comparar commits
2 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| cc839b3b32 | |||
| e2cd5d1dd7 |
@@ -1,3 +1,9 @@
|
||||
# 0.3.6
|
||||
|
||||
### New Features
|
||||
|
||||
* Simulator now has accelerometer data
|
||||
|
||||
# 0.3.5
|
||||
|
||||
### New Features
|
||||
|
||||
+29
-1
@@ -296,6 +296,10 @@ var sampleModule = {
|
||||
sinePhaseRad.fill(0);
|
||||
|
||||
var auxData = [0,0,0];
|
||||
var accelCounter = 0;
|
||||
// With 250Hz, every 10 samples, with 125Hz, every 5...
|
||||
var samplesPerAccelRate = Math.floor(sampleRateHz / 25); // best to make this an integer
|
||||
if (samplesPerAccelRate < 1) samplesPerAccelRate = 1;
|
||||
|
||||
// Init arrays to hold coefficients for each channel and init to 0
|
||||
// This gives the 1/f filter memory on each iteration
|
||||
@@ -352,7 +356,31 @@ var sampleModule = {
|
||||
} else {
|
||||
newSample.sampleNumber = previousSampleNumber + 1;
|
||||
}
|
||||
newSample.auxData = auxData;
|
||||
|
||||
/**
|
||||
* Sample rate of accelerometer is 25Hz... when the accelCounter hits the relative sample rate of the accel
|
||||
* we will output a new accel value. The approach will be to consider that Z should be about 1 and X and Y
|
||||
* should be somewhere around 0.
|
||||
*/
|
||||
if (accelCounter == samplesPerAccelRate) {
|
||||
// Initialize a new array
|
||||
var accelArray = [0,0,0];
|
||||
// Calculate X
|
||||
accelArray[0] = (Math.random() * 0.1 * (Math.random() > 0.5 ? -1 : 1));
|
||||
// Calculate Y
|
||||
accelArray[1] = (Math.random() * 0.1 * (Math.random() > 0.5 ? -1 : 1));
|
||||
// Calculate Z, this is around 1
|
||||
accelArray[2] = 1 - ((Math.random() * 0.4) * (Math.random() > 0.5 ? -1 : 1));
|
||||
// Store the newly calculated value
|
||||
newSample.auxData = accelArray;
|
||||
// Reset the counter
|
||||
accelCounter = 0;
|
||||
} else {
|
||||
// Increment counter
|
||||
accelCounter++;
|
||||
// Store the default value
|
||||
newSample.auxData = auxData;
|
||||
}
|
||||
|
||||
return newSample;
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openbci-sdk",
|
||||
"version": "0.3.5",
|
||||
"version": "0.3.6",
|
||||
"description": "The official Node.js SDK for the OpenBCI Biosensor Board.",
|
||||
"main": "openBCIBoard",
|
||||
"scripts": {
|
||||
|
||||
@@ -242,6 +242,23 @@ describe('openBCISample',function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should generate a sample with accel data every 25Hz',function() {
|
||||
var generateSample = openBCISample.randomSample(k.OBCINumberOfChannelsDefault, k.OBCISampleRate250);
|
||||
var newSample = generateSample(0);
|
||||
|
||||
var passed = false;
|
||||
// Should get one non-zero auxData array (on the 10th sample)
|
||||
for (var i = 0; i < 10; i++) {
|
||||
newSample = generateSample(newSample.sampleNumber);
|
||||
if (newSample.auxData[0] !== 0 || newSample.auxData[1] !== 0 || newSample.auxData[2] !== 0) {
|
||||
passed = true;
|
||||
newSample.auxData[0].should.be.approximately(0,0.1);
|
||||
newSample.auxData[1].should.be.approximately(0,0.1);
|
||||
newSample.auxData[2].should.be.approximately(1,0.4);
|
||||
}
|
||||
}
|
||||
assert(passed,"a sample with accel data was produced");
|
||||
});
|
||||
});
|
||||
describe('#impedanceCalculationForChannel', function() {
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário