From b24e9def9781fb609503067681026f36cede62cf Mon Sep 17 00:00:00 2001 From: AJ Keller Date: Tue, 18 Jul 2017 12:22:09 -0400 Subject: [PATCH] Add new function for board type given number of channels --- .travis.yml | 3 +-- changelog.md | 6 ++++++ openBCIConstants.js | 13 +++++++++++++ package.json | 4 ++-- test/openBCIConstants-test.js | 14 ++++++++++++++ 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0a2cdea..9a82940 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,5 +7,4 @@ node_js: install: - npm install --all script: - - npm run test-lint - - npm run test-cov + - npm run test diff --git a/changelog.md b/changelog.md index da62a0a..fe62fd5 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +# 0.0.10 + +### New Function + +* Add `boardTypeForNumberOfChannels()` to Constants + # 0.0.9 ### New Features diff --git a/openBCIConstants.js b/openBCIConstants.js index d202d02..553360f 100644 --- a/openBCIConstants.js +++ b/openBCIConstants.js @@ -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, diff --git a/package.json b/package.json index dd6a3e3..69d42e2 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/test/openBCIConstants-test.js b/test/openBCIConstants-test.js index 2a5c88e..77910e9 100644 --- a/test/openBCIConstants-test.js +++ b/test/openBCIConstants-test.js @@ -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 () {