-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from pushtheworldllc/dev-time-sync
Dev time sync
- Loading branch information
Showing
5 changed files
with
95 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#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 aux data, this effects `::sendChannelData()` | ||
board.useAux = true; | ||
|
||
// Set pin to input A0-A5 can be digital input | ||
pinMode(17, INPUT); | ||
} | ||
|
||
void loop() { | ||
|
||
// The main dependency of this single threaded microcontroller is to | ||
// stream data from the ADS. | ||
if (board.streaming) { | ||
// Wait for the ADS to signal it's ready with new data | ||
while (board.waitForNewChannelData()) {} | ||
|
||
// Read from the ADS(s) and store data into | ||
board.updateChannelData(); | ||
|
||
// Read from the analog sensor and store auxiliary position 0 | ||
// take a reading from the ADC. Result range from 0 to 1023 | ||
board.auxData[0] = digitalRead(17); | ||
|
||
// Send standard packet with channel data and accel data | ||
// includes aux data because we set `useAux` in setup() | ||
if (board.timeSynced) { | ||
board.sendChannelDataWithTimeAndRawAux(); | ||
} else { | ||
// Send standard packet with channel data | ||
board.sendChannelDataWithRawAux(); | ||
} | ||
} | ||
|
||
// Check the serial port for new data | ||
if (board.isSerialAvailableForRead()) { | ||
// Read one char and process it | ||
board.processChar(board.readOneSerialChar()); | ||
} | ||
} |