Skip to content

Commit

Permalink
Merge pull request #89 from aj-ptw/spi-wifi-fix
Browse files Browse the repository at this point in the history
FIX: Add delay after multipacket spi messages for WiFi
  • Loading branch information
AJ Keller authored Mar 16, 2018
2 parents a59623e + b1690db commit a38ffd8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
19 changes: 13 additions & 6 deletions OpenBCI_32bit_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ boolean OpenBCI_32bit_Library::processChar(char character) {
sendEOT();
break;
case OPENBCI_GET_VERSION:
printAll("v3.1.0");
printAll("v3.1.1");
sendEOT();
break;
default:
Expand Down Expand Up @@ -711,7 +711,7 @@ void OpenBCI_32bit_Library::boardReset(void) {
printAll("On Daisy ADS1299 Device ID: 0x"); printlnHex(ADS_getDeviceID(ON_DAISY));
}
printAll("LIS3DH Device ID: 0x"); printlnHex(LIS3DH_getDeviceID());
printlnAll("Firmware: v3.1.0");
printlnAll("Firmware: v3.1.1");
sendEOT();
delay(5);
wifi.reset();
Expand Down Expand Up @@ -880,7 +880,9 @@ void OpenBCI_32bit_Library::processIncomingSampleRate(char c) {
sendEOT();
} else if (wifi.present && wifi.tx) {
wifi.sendStringMulti("Success: Sample rate is ");
delay(1);
wifi.sendStringMulti(getSampleRate());
delay(1);
wifi.sendStringLast("Hz");
}
} else {
Expand All @@ -889,7 +891,7 @@ void OpenBCI_32bit_Library::processIncomingSampleRate(char c) {
printAll("sample value out of bounds");
sendEOT();
} else if (wifi.present && wifi.tx) {
wifi.sendStringMulti("Failure: sample value");
wifi.sendStringMulti("Failure: sample value"); delay(1);
wifi.sendStringLast(" out of bounds");
}
}
Expand All @@ -899,7 +901,7 @@ void OpenBCI_32bit_Library::processIncomingSampleRate(char c) {
printAll("invalid sample value");
sendEOT();
} else if (wifi.present && wifi.tx) {
wifi.sendStringLast("Failure: invalid sample value");
wifi.sendStringLast("Failure: invalid sample value"); delay(1);
}
}
endMultiCharCmdTimer();
Expand Down Expand Up @@ -1014,7 +1016,7 @@ void OpenBCI_32bit_Library::processIncomingChannelSettings(char character) {
sendEOT();
} else if (wifi.present && wifi.tx) {
char buf[3];
wifi.sendStringMulti("Success: Channel set for ");
wifi.sendStringMulti("Success: Channel set for "); delay(1);
wifi.sendStringLast(itoa(currentChannelSetting + 1, buf, 10));
}

Expand Down Expand Up @@ -1120,7 +1122,7 @@ void OpenBCI_32bit_Library::processIncomingLeadOffSettings(char character) {
sendEOT();
} else if (wifi.present && wifi.tx) {
char buf[3];
wifi.sendStringMulti("Success: Lead off set for ");
wifi.sendStringMulti("Success: Lead off set for "); delay(1);
wifi.sendStringLast(itoa(currentChannelSetting + 1, buf, 10));
}

Expand Down Expand Up @@ -3528,28 +3530,33 @@ void OpenBCI_32bit_Library::printAll(char c) {
printSerial(c);
if (wifi.present && wifi.tx) {
wifi.sendStringMulti(c);
delay(1);
}
}

void OpenBCI_32bit_Library::printAll(const char *arr) {
printSerial(arr);
if (wifi.present && wifi.tx) {
wifi.sendStringMulti(arr);
delay(1);
}
}

void OpenBCI_32bit_Library::printlnAll(const char *arr) {
printlnSerial(arr);
if (wifi.present && wifi.tx) {
wifi.sendStringMulti(arr);
delay(1);
wifi.sendStringMulti("\n");
delay(1);
}
}

void OpenBCI_32bit_Library::printlnAll(void) {
printlnSerial();
if (wifi.present && wifi.tx) {
wifi.sendStringMulti("\n");
delay(1);
}
}

Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v3.1.1

### Bug Fixes

* Adding a delay after sending multipacket spi messages improves reliability! Some messages like sample rate got chopped up :rocket:

# v3.1.0

### New Features
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=OpenBCI_32bit_Library
version=3.1.0
version=3.1.1
author=Joel Murphy <[email protected]>, Conor Russomanno <[email protected]>, Leif Percifield <[email protected]>, AJ Keller <[email protected]>
maintainer=Joel Murphy <[email protected]>, AJ Keller <[email protected]>
sentence=The library for controlling OpenBCI Cyton (32bit) boards. The Cyton is the main one.
Expand Down

0 comments on commit a38ffd8

Please sign in to comment.