Alex Borisevich / Mbed 2 deprecated OpenBCI

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 #define USE_PRINTF (1)
00004 
00005 DigitalOut led_blue(PB_5);
00006 
00007 
00008 //#include <DSPI.h>
00009 #include "OpenBCI_32bit_Library.h"
00010 #include "Definitions.h"
00011 
00012 void setup() {
00013   // Bring up the OpenBCI Board
00014   board.begin();
00015 }
00016 
00017 void loop() {
00018 
00019   if (board.streaming) {
00020     if (board.channelDataAvailable) {
00021       // Read from the ADS(s), store data, set channelDataAvailable flag to false
00022       board.updateChannelData();
00023 
00024       if (board.timeSynced) {
00025         // Send time synced packet with channel data, current board time, and an accel reading
00026         //  X axis is sent on sampleCounter % 10 == 7
00027         //  Y axis is sent on sampleCounter % 10 == 8
00028         //  Z axis is sent on sampleCounter % 10 == 9
00029         board.sendChannelDataWithTimeAndAccel();
00030       } else {
00031         // Send standard packet with channel data
00032         board.sendChannelDataWithAccel();
00033       }
00034       /*
00035       if (board.timeSynced) {
00036         board.sendChannelDataWithTimeAndRawAux();
00037       } else {
00038         // Send standard packet with channel data
00039         board.sendChannelDataWithRawAux();
00040       }
00041       */
00042     }
00043   }
00044   // Check the serial port for new data
00045   if (board.hasDataSerial0()) {
00046     // Read one char and process it
00047     board.processChar(board.getCharSerial0());
00048   }
00049 }
00050 
00051 
00052 
00053 int main() 
00054 {  
00055   setup();
00056 
00057   while (1) loop();
00058 }
00059