43 linhas
1.0 KiB
Arduino
43 linhas
1.0 KiB
Arduino
#include <DSPI.h>
|
|
#include <OpenBCI_32bit_Library.h>
|
|
#include <OpenBCI_32Bit_Library_Definitions.h>
|
|
|
|
void setup() {
|
|
// Bring up the OpenBCI Board
|
|
board.begin();
|
|
|
|
// Notify the board we want to use accel data
|
|
board.useAccel(true);
|
|
}
|
|
|
|
void loop() {
|
|
// The main dependency of this single threaded microcontroller is to
|
|
// stream data from the ADS.
|
|
if (board.streaming) {
|
|
if (board.channelDataAvailable) {
|
|
// Read from the ADS(s), store data, set channelDataAvailable flag to false
|
|
board.updateChannelData();
|
|
|
|
// Check to see if accel has new data
|
|
if(board.accelHasNewData()){
|
|
// Get new accel data
|
|
board.accelUpdateAxisData();
|
|
}
|
|
|
|
// Send standard packet with channel data
|
|
board.sendChannelData();
|
|
}
|
|
}
|
|
|
|
// Check the serial port for new data
|
|
if (board.hasDataSerial0()) {
|
|
// Read one char and process it
|
|
board.processChar(board.getCharSerial0());
|
|
}
|
|
|
|
// Used to abort multi part messages
|
|
if (board.isProcessingMultibyteMsg()) {
|
|
board.tryMultiAbort();
|
|
}
|
|
}
|