47 linhas
1.1 KiB
Arduino
47 linhas
1.1 KiB
Arduino
#include <DSPI.h>
|
|
#include <EEPROM.h>
|
|
#include <OpenBCI_Wifi_Master_Definitions.h>
|
|
#include <OpenBCI_Wifi_Master.h>
|
|
#include <OpenBCI_32bit_Library.h>
|
|
#include <OpenBCI_32bit_Library_Definitions.h>
|
|
|
|
void setup() {
|
|
// Bring up the OpenBCI Board
|
|
board.begin();
|
|
// Bring up wifi with rx/tx both true
|
|
wifi.begin(true, true);
|
|
}
|
|
|
|
void loop() {
|
|
if (board.streaming) {
|
|
if (board.channelDataAvailable) {
|
|
// Read from the ADS(s), store data, set channelDataAvailable flag to false
|
|
board.updateChannelData();
|
|
// Send the channel data
|
|
board.sendChannelData();
|
|
}
|
|
}
|
|
|
|
// Check the serial ports for new data
|
|
if (board.hasDataSerial0()) board.processChar(board.getCharSerial0());
|
|
if (board.hasDataSerial1()) board.processChar(board.getCharSerial1());
|
|
board.loop();
|
|
|
|
// Call to wifi loop
|
|
wifi.loop();
|
|
|
|
if (wifi.hasData()) {
|
|
// Read one char from the wifi shield
|
|
char newChar = wifi.getChar();
|
|
|
|
// Send to the board library
|
|
board.processCharWifi(newChar);
|
|
}
|
|
|
|
if (!wifi.sentGains) {
|
|
if(wifi.present && wifi.tx) {
|
|
wifi.sendGains(board.numChannels, board.getGains());
|
|
}
|
|
}
|
|
}
|