Skip to content

Commit f1becf3

Browse files
author
AJ Keller
authored
Merge pull request #61 from aj-ptw/dev-3.0.0
Dev 3.0.0
2 parents 8c9fc27 + d93670a commit f1becf3

6 files changed

Lines changed: 51 additions & 40 deletions

File tree

OpenBCI_32bit_Library.cpp

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -670,24 +670,15 @@ void OpenBCI_32bit_Library::setBoardMode(uint8_t newBoardMode) {
670670
curAccelMode = ACCEL_MODE_OFF;
671671
pinMode(11, INPUT);
672672
pinMode(12, INPUT);
673-
#ifdef USE_WIFI
674673
if (!wifi.present) pinMode(13, INPUT);
675-
#else
676-
pinMode(13, INPUT);
677-
#endif
678674
break;
679675
case BOARD_MODE_DIGITAL:
680676
curAccelMode = ACCEL_MODE_OFF;
681677
pinMode(11, INPUT);
682678
pinMode(12, INPUT);
683679
pinMode(17, INPUT);
684-
// #if USE_WIFI
685680
if (!wifi.present) pinMode(13, INPUT);
686681
if (!wifi.present) pinMode(18, INPUT);
687-
// #else
688-
// pinMode(13, INPUT);
689-
// pinMode(18, INPUT);
690-
// #endif
691682
break;
692683
case BOARD_MODE_DEBUG:
693684
curAccelMode = ACCEL_MODE_ON;
@@ -1050,14 +1041,14 @@ void OpenBCI_32bit_Library::sendChannelData() {
10501041
* Adds stop byte `OPENBCI_EOP_STND_ACCEL`. See `OpenBCI_32bit_Library_Definitions.h`
10511042
*/
10521043
void OpenBCI_32bit_Library::sendChannelData(PACKET_TYPE packetType) {
1053-
if (wifi.tx) {
1044+
if (wifi.present && wifi.tx) {
10541045
sendChannelDataWifi(packetType, false);
10551046
if (daisyPresent) sendChannelDataWifi(packetType, true);
1047+
} else {
1048+
// Send over bluetooth
1049+
if (iSerial0.tx || iSerial1.tx) sendChannelDataSerial(packetType);
10561050
}
10571051

1058-
// Send over bluetooth
1059-
if (iSerial0.tx || iSerial1.tx) sendChannelDataSerial(packetType);
1060-
10611052
if (packetType == PACKET_TYPE_ACCEL) LIS3DH_zeroAxisData();
10621053
if (packetType == PACKET_TYPE_RAW_AUX || packetType == PACKET_TYPE_RAW_AUX_TIME_SYNC) zeroAuxData();
10631054

@@ -1567,19 +1558,27 @@ void OpenBCI_32bit_Library::streamSafeSetAllChannelsToDefault(void) {
15671558
}
15681559
}
15691560

1561+
/**
1562+
* Return an array of gains in coded ADS form i.e. 0-6 where 6 is x24 and so on.
1563+
* @return [description]
1564+
*/
1565+
uint8_t *OpenBCI_32bit_Library::getGains(void) {
1566+
uint8_t gains[numChannels];
1567+
for (uint8_t i = 0; i < numChannels; i++) {
1568+
gains[i] = channelSettings[i][GAIN_SET];
1569+
}
1570+
return gains;
1571+
}
1572+
15701573
/**
15711574
* @description Call this to start the streaming data from the ADS1299
15721575
* @returns boolean if able to start streaming
15731576
*/
15741577
void OpenBCI_32bit_Library::streamStart(){ // needs daisy functionality
15751578

1576-
if (wifi.tx) {
1577-
uint8_t gains[numChannels];
1578-
for (uint8_t i = 0; i < numChannels; i++) {
1579-
gains[i] = channelSettings[i][GAIN_SET];
1580-
}
1579+
if (wifi.present && wifi.tx) {
15811580
// TODO: Remove this debug line
1582-
wifi.sendGains(numChannels, gains);
1581+
wifi.sendGains(numChannels, getGains());
15831582
}
15841583
streaming = true;
15851584
startADS();
@@ -2440,23 +2439,14 @@ void OpenBCI_32bit_Library::updateChannelData(){
24402439
case BOARD_MODE_ANALOG:
24412440
auxData[0] = analogRead(A5);
24422441
auxData[1] = analogRead(A6);
2443-
#ifdef USE_WIFI
24442442
if (!wifi.present) {
24452443
auxData[2] = analogRead(A7);
24462444
}
2447-
#else
2448-
auxData[2] = analogRead(A7);
2449-
#endif
24502445
break;
24512446
case BOARD_MODE_DIGITAL:
24522447
auxData[0] = digitalRead(11) << 8 | digitalRead(12);
2453-
#ifdef USE_WIFI
24542448
auxData[1] = (wifi.present ? 0 : digitalRead(13) << 8) | digitalRead(17);
24552449
auxData[2] = wifi.present ? 0 : digitalRead(18);
2456-
#else
2457-
auxData[1] = (digitalRead(13) << 8) | digitalRead(17);
2458-
auxData[2] = digitalRead(18);
2459-
#endif
24602450
break;
24612451
case BOARD_MODE_DEBUG:
24622452
case BOARD_MODE_DEFAULT:
@@ -2667,9 +2657,7 @@ void OpenBCI_32bit_Library::printlnSerial(const char *c) {
26672657
}
26682658

26692659
void OpenBCI_32bit_Library::write(uint8_t b) {
2670-
#ifdef USE_WIFI
26712660
wifi.storeByteBufTx(b);
2672-
#endif
26732661
writeSerial(b);
26742662
}
26752663

@@ -3181,16 +3169,16 @@ void OpenBCI_32bit_Library::printSuccess() {
31813169

31823170
void OpenBCI_32bit_Library::printAll(const char *arr) {
31833171
printSerial(arr);
3184-
// #ifdef USE_WIFI
3185-
wifi.sendStringMulti(arr);
3186-
// #endif
3172+
if (wifi.present && wifi.tx) {
3173+
wifi.sendStringMulti(arr);
3174+
}
31873175
}
31883176

31893177
void OpenBCI_32bit_Library::printlnAll(const char *arr) {
31903178
printlnSerial(arr);
3191-
// #ifdef USE_WIFI
3192-
wifi.sendStringLast(arr);
3193-
// #endif
3179+
if (wifi.present && wifi.tx) {
3180+
wifi.sendStringLast(arr);
3181+
}
31943182
}
31953183

31963184
/**

OpenBCI_32bit_Library.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class OpenBCI_32bit_Library {
103103
byte getDefaultChannelSettingForSetting(byte);
104104
char getDefaultChannelSettingForSettingAscii(byte);
105105
char getGainForAsciiChar(char);
106+
uint8_t * getGains(void);
106107
char getNumberForAsciiChar(char);
107108
const char* getSampleRate(void);
108109
char getTargetSSForConstrainedChannelNumber(byte);

changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@
4747
* Removed public `timeSynced` and private `sendTimeSyncUpPacket`
4848
* Setting internal test signal now, when not streaming, returns a success message, with EOT `$$$`
4949

50+
## Beta5
51+
52+
### New Features
53+
54+
* Send gains after connecting to Wifi shield
55+
56+
### Breaking Changes
57+
58+
* Don't send streaming data over bluetooth when wifi is present and attached
59+
5060
## Beta4
5161

5262
The overall goal was to clean the wifi code out of the library so it would not be needed when you are building a bare board.

examples/BoardWithWifi/BoardWithWifi.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,10 @@ void loop() {
4747
// Send to the board library
4848
board.processChar(newChar);
4949
}
50+
51+
if (!wifi.sentGains) {
52+
if(wifi.present && wifi.tx) {
53+
wifi.sendGains(board.numChannels, board.getGains());
54+
}
55+
}
5056
}

examples/DefaultBoard/DefaultBoard.ino

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ void loop() {
4848
}
4949
}
5050

51-
// Call to wifi loop
52-
wifi.loop();
53-
5451
// Check serial 0 for new data
5552
if (board.hasDataSerial0()) {
5653
// Read one char from the serial 0 port
@@ -74,6 +71,9 @@ void loop() {
7471
board.processChar(newChar);
7572
}
7673

74+
// Call to wifi loop
75+
wifi.loop();
76+
7777
if (wifi.hasData()) {
7878
// Read one char from the wifi shield
7979
char newChar = wifi.getChar();
@@ -84,4 +84,10 @@ void loop() {
8484
// Send to the board library
8585
board.processChar(newChar);
8686
}
87+
88+
if (!wifi.sentGains) {
89+
if(wifi.present && wifi.tx) {
90+
wifi.sendGains(board.numChannels, board.getGains());
91+
}
92+
}
8793
}

libraries.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=OpenBCI_32bit_Library
2-
version=3.0.0-beta4
2+
version=3.0.0
33
author=Joel Murphy <joel@openbci.com>, Conor Russomanno <conor@openbci.com>, Leif Percifield <lpercifield@gmail.com>, AJ Keller <pushtheworldllc@gmail.com>
44
maintainers=Joel Murphy <joel@openbci.com>, AJ Keller <pushtheworldllc@gmail.com>
55
sentence=The library for controlling OpenBCI 32bit boards. The Cyton is the main one.

0 commit comments

Comments
 (0)