You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: openBCIUtilities.js
+41-12Lines changed: 41 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -383,6 +383,7 @@ let utilitiesModule = {
383
383
}
384
384
},
385
385
newSample,
386
+
newSampleNoScale,
386
387
/**
387
388
* @description Create a configurable function to return samples for a simulator. This implements 1/f filtering injection to create more brain like data.
388
389
* @param numberOfChannels {Number} - The number of channels in the sample... either 8 or 16
@@ -1049,8 +1050,8 @@ function transformRawDataPacketToSample (o) {
1049
1050
*/
1050
1051
functionconvertGanglionArrayToBuffer(arr,data){
1051
1052
for(leti=0;i<k.OBCINumberOfChannelsGanglion;i++){
1052
-
letthreeByteBuffer=floatTo3ByteBuffer(arr[i]);
1053
-
threeByteBuffer.copy(data,(i*3));
1053
+
data.writeInt16BE(arr[i]>>8,(i*3));
1054
+
data.writeInt8(arr[i]&255,(i*3)+2);
1054
1055
}
1055
1056
}
1056
1057
@@ -1656,6 +1657,26 @@ function newSample (sampleNumber) {
1656
1657
};
1657
1658
}
1658
1659
1660
+
functionnewSampleNoScale(sampleNumber){
1661
+
if(sampleNumber||sampleNumber===0){
1662
+
if(sampleNumber>255){
1663
+
sampleNumber=255;
1664
+
}
1665
+
}else{
1666
+
sampleNumber=0;
1667
+
}
1668
+
return{
1669
+
startByte: k.OBCIByteStart,
1670
+
sampleNumber: sampleNumber,
1671
+
channelDataCounts: [],
1672
+
accelDataCounts: [],
1673
+
auxData: null,
1674
+
stopByte: k.OBCIByteStop,
1675
+
boardTime: 0,
1676
+
timestamp: 0
1677
+
};
1678
+
}
1679
+
1659
1680
/**
1660
1681
* @description Convert float number into three byte buffer. This is the opposite of .interpret24bitAsInt32()
1661
1682
* @param float - The number you want to convert
@@ -1718,34 +1739,42 @@ function makeDaisySampleObject (lowerSampleObject, upperSampleObject) {
expect(bufferEqual(rawDataPacket.slice(2,2+k.OBCIPacketSizeBLERaw),bleRawBuf),`expected ${bleRawBuf.toString('hex')} but got ${rawDataPacket.slice(2,2+k.OBCIPacketSizeBLERaw).toString('hex')}`).to.be.true();
54
+
expect(bufferEqual(rawDataPacket.slice(2,2+k.OBCIPacketSizeBLERaw),data),`expected ${data.toString('hex')} but got ${rawDataPacket.slice(2,2+k.OBCIPacketSizeBLERaw).toString('hex')}`).to.be.true();
0 commit comments