Skip to content

Commit

Permalink
FIX: Lead off command setting for v2 firmware and later
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ Keller committed Aug 27, 2017
1 parent 2def7ed commit 64a1c6a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.0.4

### Bug Fixes

* Fixed lead off command sending for v2 firmware and later.

# 1.0.3

### Bug Fixes
Expand Down
39 changes: 22 additions & 17 deletions openBCICyton.js
Original file line number Diff line number Diff line change
Expand Up @@ -1169,20 +1169,6 @@ Cyton.prototype.softReset = function () {
return this.write(k.OBCIMiscSoftReset);
};

/**
* @description To get the specified channelSettings register data from printRegisterSettings call
* @param channelNumber - a number
* @returns {Promise.<T>|*}
* @author AJ Keller (@pushtheworldllc)
*/
// TODO: REDO THIS FUNCTION
Cyton.prototype.getSettingsForChannel = function (channelNumber) {
return k.channelSettingsKeyForChannel(channelNumber).then((newSearchingBuffer) => {
// this.searchingBuf = newSearchingBuffer
return this.printRegisterSettings();
});
};

/**
* @description Syncs the internal channel settings object with a cyton, this will take about
* over a second because there are delays between the register reads in the firmware.
Expand Down Expand Up @@ -1335,7 +1321,14 @@ Cyton.prototype.impedanceTestContinuousStart = function () {
for (let i = 0; i < this.numberOfChannels(); i++) {
chain = chain
.then(() => k.getImpedanceSetter(i + 1, false, true))
.then((commandsArray) => this.write(commandsArray));
.then((commandsArray) => {
if (this.usingAtLeastVersionTwoFirmware()) {
const buf = Buffer.from(commandsArray.join(''));
return this._writeAndDrain(buf);
} else {
return this.write(commandsArray);
}
});
}
chain.then(resolve, reject);
});
Expand All @@ -1358,7 +1351,14 @@ Cyton.prototype.impedanceTestContinuousStop = function () {
for (let i = 0; i < this.numberOfChannels(); i++) {
chain = chain
.then(() => k.getImpedanceSetter(i + 1, false, false))
.then((commandsArray) => this.write(commandsArray));
.then((commandsArray) => {
if (this.usingAtLeastVersionTwoFirmware()) {
const buf = Buffer.from(commandsArray.join(''));
return this._writeAndDrain(buf);
} else {
return this.write(commandsArray);
}
});
}
chain.then(resolve, reject);
});
Expand Down Expand Up @@ -1567,7 +1567,12 @@ Cyton.prototype._impedanceTestSetChannel = function (channelNumber, pInput, nInp
if (this.options.verbose) console.log('pInput: ' + pInput + ' nInput: ' + nInput);
// Get impedance settings to send the board
k.getImpedanceSetter(channelNumber, pInput, nInput).then((commandsArray) => {
return this.write(commandsArray);
if (this.usingAtLeastVersionTwoFirmware()) {
const buf = Buffer.from(commandsArray.join(''));
return this._writeAndDrain(buf);
} else {
return this.write(commandsArray);
}
}).then(() => {
/**
* If either pInput or nInput are true then we should start calculating impedance. Setting
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openbci-cyton",
"version": "1.0.3",
"version": "1.0.4",
"description": "The official Node.js SDK for the OpenBCI Cyton with Dongle.",
"main": "openBCICyton.js",
"scripts": {
Expand All @@ -19,7 +19,7 @@
"buffer-equal": "^1.0.0",
"lodash": "^4.17.4",
"mathjs": "^3.14.2",
"openbci-utilities": "^0.2.1",
"openbci-utilities": "^0.2.2",
"safe-buffer": "^5.1.1",
"serialport": "4.0.7",
"sntp": "^2.0.2"
Expand All @@ -33,6 +33,11 @@
"chai-as-promised": "^7.1.1",
"codecov": "^2.1.0",
"dirty-chai": "^2.0.1",
"eslint-config-semistandard": "^11.0.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.3.0",
"eslint-plugin-standard": "^3.0.1",
"istanbul": "^0.4.4",
"mocha": "^3.4.2",
"sandboxed-module": "^2.0.3",
Expand Down

0 comments on commit 64a1c6a

Please sign in to comment.