Skip to content

Commit f239723

Browse files
author
AJ Keller
authored
Merge pull request #9 from aj-ptw/master
v0.1.1
2 parents 392cb14 + 12697be commit f239723

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

Diff for: changelog.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.1.1
2+
3+
### Bug Fixes
4+
5+
* Send counts did not work for daisy.
6+
17
# 0.1.0
28

39
### New Functions

Diff for: openBCIUtilities.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,13 @@ function floatTo2ByteBuffer (float) {
14681468
function makeDaisySampleObject (lowerSampleObject, upperSampleObject) {
14691469
var daisySampleObject = {};
14701470

1471-
daisySampleObject['channelData'] = lowerSampleObject.channelData.concat(upperSampleObject.channelData);
1471+
if (lowerSampleObject.hasOwnProperty('channelData')) {
1472+
daisySampleObject['channelData'] = lowerSampleObject.channelData.concat(upperSampleObject.channelData);
1473+
}
1474+
1475+
if (lowerSampleObject.hasOwnProperty('channelDataCounts')) {
1476+
daisySampleObject['channelDataCounts'] = lowerSampleObject.channelDataCounts.concat(upperSampleObject.channelDataCounts);
1477+
}
14721478

14731479
daisySampleObject['sampleNumber'] = Math.floor(upperSampleObject.sampleNumber / 2);
14741480

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openbci-utilities",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "The official utility package of Node.js SDK for the OpenBCI Biosensor Boards.",
55
"main": "index.js",
66
"scripts": {

Diff for: test/openBCIUtilities-test.js

+26
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ describe('openBCIUtilities', function () {
917917
});
918918
describe('#makeDaisySampleObject', function () {
919919
let lowerSampleObject, upperSampleObject, daisySampleObject;
920+
let lowerSampleObjectNoScale, upperSampleObjectNoScale, daisySampleObjectNoScale;
920921
before(() => {
921922
// Make the lower sample (channels 1-8)
922923
lowerSampleObject = openBCIUtilities.newSample(1);
@@ -931,38 +932,63 @@ describe('openBCIUtilities', function () {
931932
upperSampleObject.timestamp = 8;
932933

933934
daisySampleObject = openBCIUtilities.makeDaisySampleObject(lowerSampleObject, upperSampleObject);
935+
936+
lowerSampleObjectNoScale = openBCIUtilities.newSample(1);
937+
lowerSampleObjectNoScale.channelDataCounts = [1, 2, 3, 4, 5, 6, 7, 8];
938+
lowerSampleObjectNoScale.auxData = [0, 1, 2];
939+
lowerSampleObjectNoScale.timestamp = 4;
940+
lowerSampleObjectNoScale.accelData = [0.5, -0.5, 1];
941+
// Make the upper sample (channels 9-16)
942+
upperSampleObjectNoScale = openBCIUtilities.newSample(2);
943+
upperSampleObjectNoScale.channelDataCounts = [9, 10, 11, 12, 13, 14, 15, 16];
944+
upperSampleObjectNoScale.auxData = [3, 4, 5];
945+
upperSampleObjectNoScale.timestamp = 8;
946+
947+
// Call the function under test
948+
daisySampleObjectNoScale = openBCIUtilities.makeDaisySampleObject(lowerSampleObjectNoScale, upperSampleObjectNoScale);
934949
});
935950
it('should make a channelData array 16 elements long', function () {
936951
expect(daisySampleObject.channelData).to.have.length(k.OBCINumberOfChannelsDaisy);
952+
expect(daisySampleObjectNoScale.channelDataCounts).to.have.length(k.OBCINumberOfChannelsDaisy);
937953
});
938954
it('should make a channelData array with lower array in front of upper array', function () {
939955
for (let i = 0; i < 16; i++) {
940956
expect(daisySampleObject.channelData[i]).to.equal(i + 1);
957+
expect(daisySampleObjectNoScale.channelDataCounts[i]).to.equal(i + 1);
941958
}
942959
});
943960
it('should make the sample number equal to the second packet divided by two', function () {
944961
expect(daisySampleObject.sampleNumber).to.equal(upperSampleObject.sampleNumber / 2);
962+
expect(daisySampleObjectNoScale.sampleNumber).to.equal(upperSampleObjectNoScale.sampleNumber / 2);
945963
});
946964
it('should put the aux packets in an object', function () {
947965
expect(daisySampleObject.auxData).to.have.property('lower');
948966
expect(daisySampleObject.auxData).to.have.property('upper');
967+
expect(daisySampleObjectNoScale.auxData).to.have.property('lower');
968+
expect(daisySampleObjectNoScale.auxData).to.have.property('upper');
949969
});
950970
it('should put the aux packets in an object in the right order', function () {
951971
for (let i = 0; i < 3; i++) {
952972
expect(daisySampleObject.auxData['lower'][i]).to.equal(i);
953973
expect(daisySampleObject.auxData['upper'][i]).to.equal(i + 3);
974+
expect(daisySampleObjectNoScale.auxData['lower'][i]).to.equal(i);
975+
expect(daisySampleObjectNoScale.auxData['upper'][i]).to.equal(i + 3);
954976
}
955977
});
956978
it('should average the two timestamps together', function () {
957979
let expectedAverage = (upperSampleObject.timestamp + lowerSampleObject.timestamp) / 2;
958980
expect(daisySampleObject.timestamp).to.equal(expectedAverage);
981+
expect(daisySampleObjectNoScale.timestamp).to.equal(expectedAverage);
959982
});
960983
it('should place the old timestamps in an object', function () {
961984
expect(daisySampleObject._timestamps.lower).to.equal(lowerSampleObject.timestamp);
962985
expect(daisySampleObject._timestamps.upper).to.equal(upperSampleObject.timestamp);
986+
expect(daisySampleObjectNoScale._timestamps.lower).to.equal(lowerSampleObjectNoScale.timestamp);
987+
expect(daisySampleObjectNoScale._timestamps.upper).to.equal(upperSampleObjectNoScale.timestamp);
963988
});
964989
it('should store an accelerometer value if present', function () {
965990
expect(daisySampleObject).to.have.property('accelData');
991+
expect(daisySampleObjectNoScale).to.have.property('accelData');
966992
});
967993
});
968994

0 commit comments

Comments
 (0)