Arquivos
OpenBCI_32bit_Library/examples/BoardWithWifi/BoardWithWifi.ino
T

62 linhas
1.4 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();
}
}
// Used to abort multi part messages
if (board.isProcessingMultibyteMsg()) {
board.tryMultiAbort();
}
// Call to wifi loop
wifi.loop();
// Check serial 0 for new data
if (board.hasDataSerial0()) {
// Read one char from the serial 0 port
char newChar = board.getCharSerial0();
// Send to the sd library for processing
sdProcessChar(newChar);
// Send to the board library
board.processChar(newChar);
}
if (wifi.hasData()) {
// Read one char from the wifi shield
char newChar = wifi.getChar();
// Send to the sd library for processing
sdProcessChar(newChar);
// Send to the board library
board.processChar(newChar);
}
if (!wifi.sentGains) {
if(wifi.present && wifi.tx) {
wifi.sendGains(board.numChannels, board.getGains());
}
}
}