Skip to content

Add new function for board type given number of channels #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ node_js:
install:
- npm install --all
script:
- npm run test-lint
- npm run test-cov
- npm run test
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.0.10

### New Function

* Add `boardTypeForNumberOfChannels()` to Constants

# 0.0.9

### New Features
Expand Down
13 changes: 13 additions & 0 deletions openBCIConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,19 @@ const constantsModule = {
return obciNumberOfChannelsDefault;
}
},
boardTypeForNumberOfChannels: (numberOfChannels) => {
switch (numberOfChannels) {
case obciNumberOfChannelsDaisy:
return obciBoardDaisy;
case obciNumberOfChannelsGanglion:
return obciBoardGanglion;
case 0:
return obciBoardNone;
case obciNumberOfChannelsDefault:
default:
return obciBoardCyton;
}
},
/** Possible Sample Rates */
OBCISampleRate1000: obciSampleRate1000,
OBCISampleRate125: obciSampleRate125,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "openbci-utilities",
"version": "0.0.9",
"version": "0.0.10",
"description": "The official utility package of Node.js SDK for the OpenBCI Biosensor Boards.",
"main": "index.js",
"scripts": {
"test": "mocha test",
"test": "npm run test-lint && npm run test-cov",
"test-lint": "semistandard | snazzy",
"test-cov": "istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec && codecov"
},
Expand Down
14 changes: 14 additions & 0 deletions test/openBCIConstants-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,20 @@ describe('OpenBCIConstants', function () {
expect(k.numberOfChannelsForBoardType(k.OBCIBoardNone)).to.equal(0);
});
});
describe('boardTypeForNumberOfChannels', function () {
it('should get daisy board right for num chan', function () {
expect(k.boardTypeForNumberOfChannels(16)).to.equal(k.OBCIBoardDaisy);
});
it('should get cyton board right for num chan', function () {
expect(k.boardTypeForNumberOfChannels(8)).to.equal(k.OBCIBoardCyton);
});
it('should get ganglion right for num chan', function () {
expect(k.boardTypeForNumberOfChannels(4)).to.equal(k.OBCIBoardGanglion);
});
it('should get none right for num chan', function () {
expect(k.boardTypeForNumberOfChannels(0)).to.equal(k.OBCIBoardNone);
});
});
describe('#getChannelSetter', function () {
// 'channel 1, power on, gain 24, inputType normal, bias include, srb2 connect, srb1 dissconnect'
describe('channel input selection works', function () {
Expand Down