Skip to content

Commit d93670a

Browse files
author
AJ Keller
committed
Send gains after connecting to wifi shield
1 parent 1645d6a commit d93670a

5 files changed

Lines changed: 40 additions & 13 deletions

File tree

OpenBCI_32bit_Library.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,11 +1044,11 @@ void OpenBCI_32bit_Library::sendChannelData(PACKET_TYPE packetType) {
10441044
if (wifi.present && wifi.tx) {
10451045
sendChannelDataWifi(packetType, false);
10461046
if (daisyPresent) sendChannelDataWifi(packetType, true);
1047+
} else {
1048+
// Send over bluetooth
1049+
if (iSerial0.tx || iSerial1.tx) sendChannelDataSerial(packetType);
10471050
}
10481051

1049-
// Send over bluetooth
1050-
if (iSerial0.tx || iSerial1.tx) sendChannelDataSerial(packetType);
1051-
10521052
if (packetType == PACKET_TYPE_ACCEL) LIS3DH_zeroAxisData();
10531053
if (packetType == PACKET_TYPE_RAW_AUX || packetType == PACKET_TYPE_RAW_AUX_TIME_SYNC) zeroAuxData();
10541054

@@ -1558,19 +1558,27 @@ void OpenBCI_32bit_Library::streamSafeSetAllChannelsToDefault(void) {
15581558
}
15591559
}
15601560

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+
15611573
/**
15621574
* @description Call this to start the streaming data from the ADS1299
15631575
* @returns boolean if able to start streaming
15641576
*/
15651577
void OpenBCI_32bit_Library::streamStart(){ // needs daisy functionality
15661578

15671579
if (wifi.present && wifi.tx) {
1568-
uint8_t gains[numChannels];
1569-
for (uint8_t i = 0; i < numChannels; i++) {
1570-
gains[i] = channelSettings[i][GAIN_SET];
1571-
}
15721580
// TODO: Remove this debug line
1573-
wifi.sendGains(numChannels, gains);
1581+
wifi.sendGains(numChannels, getGains());
15741582
}
15751583
streaming = true;
15761584
startADS();

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: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,15 @@
4747
* Removed public `timeSynced` and private `sendTimeSyncUpPacket`
4848
* Setting internal test signal now, when not streaming, returns a success message, with EOT `$$$`
4949

50-
## rc1
50+
## Beta5
5151

52-
The first release candidate for Cyton
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
5359

5460
## Beta4
5561

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
}

0 commit comments

Comments
 (0)