@@ -147,7 +147,6 @@ boolean OpenBCI_32bit_Library::isProcessingMultibyteMsg(void) {
147
147
* @return {boolean} - `true` if the command was recognized, `false` if not
148
148
*/
149
149
boolean OpenBCI_32bit_Library::processChar (char character) {
150
- // Serial0.print("pC: "); Serial0.print(character); Serial0.print(" 0x"); Serial0.println(character, HEX);
151
150
if (curBoardMode == BOARD_MODE_DEBUG) {
152
151
Serial1.print (" pC: " ); Serial1.println (character);
153
152
}
@@ -331,14 +330,19 @@ boolean OpenBCI_32bit_Library::processChar(char character) {
331
330
if (curAccelMode == ACCEL_MODE_ON){
332
331
enable_accel (RATE_25HZ);
333
332
} // fire up the accelerometer if you want it
334
- // Serial0.println("streamStart - pc");
333
+ if (wifi.present && wifi.tx ) {
334
+ wifi.sendStringLast (" Stream started" );
335
+ }
335
336
streamStart (); // turn on the fire hose
336
337
break ;
337
338
case OPENBCI_STREAM_STOP: // stop streaming data
338
339
if (curAccelMode == ACCEL_MODE_ON){
339
340
disable_accel ();
340
341
} // shut down the accelerometer if you're using it
341
342
streamStop ();
343
+ if (wifi.present && wifi.tx ) {
344
+ wifi.sendStringLast (" Stream stopped" );
345
+ }
342
346
break ;
343
347
344
348
// INITIALIZE AND VERIFY
@@ -355,8 +359,8 @@ boolean OpenBCI_32bit_Library::processChar(char character) {
355
359
// TIME SYNC
356
360
case OPENBCI_TIME_SET:
357
361
// Set flag to send time packet
358
- if (!streaming && iSerial0. tx ) {
359
- Serial0. print (" Time stamp ON" );
362
+ if (!streaming) {
363
+ printAll (" Time stamp ON" );
360
364
sendEOT ();
361
365
}
362
366
curTimeSyncMode = TIME_SYNC_MODE_ON;
@@ -366,7 +370,7 @@ boolean OpenBCI_32bit_Library::processChar(char character) {
366
370
case OPENBCI_TIME_STOP:
367
371
// Stop the Sync
368
372
if (!streaming) {
369
- Serial0. print (" Time stamp OFF" );
373
+ printAll (" Time stamp OFF" );
370
374
sendEOT ();
371
375
}
372
376
curTimeSyncMode = TIME_SYNC_MODE_OFF;
@@ -589,13 +593,13 @@ void OpenBCI_32bit_Library::boardReset(void) {
589
593
initialize (); // initalizes accelerometer and on-board ADS and on-daisy ADS if present
590
594
delay (500 );
591
595
configureLeadOffDetection (LOFF_MAG_6NA, LOFF_FREQ_31p2HZ);
592
- Serial0. println (" OpenBCI V3 8-16 channel" );
593
- Serial0. print (" On Board ADS1299 Device ID: 0x" ); Serial0. println (ADS_getDeviceID (ON_BOARD),HEX );
596
+ printlnAll (" OpenBCI V3 8-16 channel" );
597
+ printAll (" On Board ADS1299 Device ID: 0x" ); printlnHex (ADS_getDeviceID (ON_BOARD));
594
598
if (daisyPresent){ // library will set this in initialize() if daisy present and functional
595
- Serial0. print (" On Daisy ADS1299 Device ID: 0x" ); Serial0. println (ADS_getDeviceID (ON_DAISY),HEX );
599
+ printAll (" On Daisy ADS1299 Device ID: 0x" ); printlnHex (ADS_getDeviceID (ON_DAISY));
596
600
}
597
- Serial0. print (" LIS3DH Device ID: 0x" ); Serial0. println (LIS3DH_getDeviceID (),HEX );
598
- Serial0. println (" Firmware: v3.0.0" );
601
+ printAll (" LIS3DH Device ID: 0x" ); printlnHex (LIS3DH_getDeviceID ());
602
+ printlnAll (" Firmware: v3.0.0" );
599
603
sendEOT ();
600
604
delay (5 );
601
605
wifi.reset ();
@@ -1019,13 +1023,13 @@ void OpenBCI_32bit_Library::setSerialInfo(SerialInfo si, boolean rx, boolean tx,
1019
1023
1020
1024
void OpenBCI_32bit_Library::printAllRegisters (){
1021
1025
if (!isRunning){
1022
- Serial0. println (" \n Board ADS Registers" );
1026
+ printlnAll (" \n Board ADS Registers" );
1023
1027
printADSregisters (BOARD_ADS);
1024
1028
if (daisyPresent){
1025
- Serial0. println (" \n Daisy ADS Registers" );
1029
+ printlnAll (" \n Daisy ADS Registers" );
1026
1030
printADSregisters (DAISY_ADS);
1027
1031
}
1028
- Serial0. println (" \n LIS3DH Registers" );
1032
+ printlnAll (" \n LIS3DH Registers" );
1029
1033
LIS3DH_readAllRegs ();
1030
1034
sendEOT ();
1031
1035
}
@@ -1606,7 +1610,7 @@ void OpenBCI_32bit_Library::streamStop(){
1606
1610
boolean OpenBCI_32bit_Library::smellDaisy (void ){ // check if daisy present
1607
1611
boolean isDaisy = false ;
1608
1612
byte setting = RREG (ID_REG,DAISY_ADS); // try to read the daisy product ID
1609
- if (verbosity){Serial0. print (" Daisy ID 0x" ); Serial0. println (setting,HEX ); sendEOT ();}
1613
+ if (verbosity){printAll (" Daisy ID 0x" ); printlnHex (setting); sendEOT ();}
1610
1614
if (setting == ADS_ID) {isDaisy = true ;} // should read as 0x3E
1611
1615
return isDaisy;
1612
1616
}
@@ -2736,17 +2740,17 @@ void OpenBCI_32bit_Library::printADSregisters(int targetSS)
2736
2740
{
2737
2741
boolean prevverbosityState = verbosity;
2738
2742
verbosity = true ; // set up for verbosity output
2739
- RREGS (0x00 ,0x0C ,targetSS); // read out the first registers
2743
+ RREGS (0x00 , 0x0C , targetSS); // read out the first registers
2740
2744
delay (10 ); // stall to let all that data get read by the PC
2741
- RREGS (0x0D ,0x17 -0x0D ,targetSS); // read out the rest
2745
+ RREGS (0x0D , 0x17 -0x0D , targetSS); // read out the rest
2742
2746
verbosity = prevverbosityState;
2743
2747
}
2744
2748
2745
2749
byte OpenBCI_32bit_Library::ADS_getDeviceID (int targetSS) { // simple hello world com check
2746
2750
byte data = RREG (ID_REG,targetSS);
2747
2751
if (verbosity){ // verbosity otuput
2748
- Serial0. print (" On Board ADS ID " );
2749
- printHex (data); Serial0. println ();
2752
+ printAll (" On Board ADS ID " );
2753
+ printHex (data); printlnAll ();
2750
2754
sendEOT ();
2751
2755
}
2752
2756
return data;
@@ -2852,15 +2856,16 @@ byte OpenBCI_32bit_Library::RREG(byte _address,int targetSS) { // reads ONE
2852
2856
if (verbosity){ // verbosity output
2853
2857
printRegisterName (_address);
2854
2858
printHex (_address);
2855
- Serial0. print (" , " );
2859
+ printAll (" , " );
2856
2860
printHex (regData[_address]);
2857
- Serial0. print (" , " );
2861
+ printAll (" , " );
2858
2862
for (byte j = 0 ; j<8 ; j++){
2859
- Serial0.print (bitRead (regData[_address], 7 -j));
2860
- if (j!=7 ) Serial0.print (" , " );
2863
+ char buf[3 ];
2864
+ printAll (itoa (bitRead (regData[_address], 7 -j), buf, DEC));
2865
+ if (j!=7 ) printAll (" , " );
2861
2866
}
2862
2867
2863
- Serial0. println ();
2868
+ printlnAll ();
2864
2869
}
2865
2870
return regData[_address]; // return requested register value
2866
2871
}
@@ -2881,14 +2886,15 @@ void OpenBCI_32bit_Library::RREGS(byte _address, byte _numRegistersMinusOne, int
2881
2886
for (int i = 0 ; i<= _numRegistersMinusOne; i++){
2882
2887
printRegisterName (_address + i);
2883
2888
printHex (_address + i);
2884
- Serial0. print (" , " );
2889
+ printAll (" , " );
2885
2890
printHex (regData[_address + i]);
2886
- Serial0. print (" , " );
2891
+ printAll (" , " );
2887
2892
for (int j = 0 ; j<8 ; j++){
2888
- Serial0.print (bitRead (regData[_address + i], 7 -j));
2889
- if (j!=7 ) Serial0.print (" , " );
2893
+ char buf[3 ];
2894
+ printAll (itoa (bitRead (regData[_address + i], 7 -j), buf, DEC));
2895
+ if (j!=7 ) printAll (" , " );
2890
2896
}
2891
- Serial0. println ();
2897
+ printlnAll ();
2892
2898
delay (30 );
2893
2899
}
2894
2900
}
@@ -2903,9 +2909,9 @@ void OpenBCI_32bit_Library::WREG(byte _address, byte _value, int target_SS) { //
2903
2909
csHigh (target_SS); // close SPI
2904
2910
regData[_address] = _value; // update the mirror array
2905
2911
if (verbosity){ // verbosity output
2906
- Serial0. print (" Register " );
2912
+ printAll (" Register " );
2907
2913
printHex (_address);
2908
- Serial0. println (" modified." );
2914
+ printlnAll (" modified." );
2909
2915
sendEOT ();
2910
2916
}
2911
2917
}
@@ -2920,10 +2926,10 @@ void OpenBCI_32bit_Library::WREGS(byte _address, byte _numRegistersMinusOne, int
2920
2926
}
2921
2927
csHigh (targetSS);
2922
2928
if (verbosity){
2923
- Serial0. print (" Registers " );
2924
- printHex (_address); Serial0. print (" to " );
2929
+ printAll (" Registers " );
2930
+ printHex (_address); printAll (" to " );
2925
2931
printHex (_address + _numRegistersMinusOne);
2926
- Serial0. println (" modified" );
2932
+ printlnAll (" modified" );
2927
2933
sendEOT ();
2928
2934
}
2929
2935
}
@@ -3066,25 +3072,25 @@ void OpenBCI_32bit_Library::LIS3DH_readAllRegs(){
3066
3072
3067
3073
for (int i = STATUS_REG_AUX; i <= WHO_AM_I; i++){
3068
3074
inByte = LIS3DH_read (i);
3069
- Serial0. print ( " 0x0 " );Serial0. print (i,HEX );
3070
- Serial0. print ( " \t " );Serial0. println (inByte,HEX );
3075
+ printAll ( " 0x " ); printHex (i );
3076
+ printAll ( " " ); printlnHex (inByte);
3071
3077
delay (20 );
3072
3078
}
3073
- Serial0. println ();
3079
+ printlnAll ();
3074
3080
3075
3081
for (int i = TMP_CFG_REG; i <= INT1_DURATION; i++){
3076
3082
inByte = LIS3DH_read (i);
3077
3083
// printRegisterName(i);
3078
- Serial0. print (" 0x" );Serial0. print (i,HEX );
3079
- Serial0. print ( " \t " );Serial0. println (inByte,HEX );
3084
+ printAll (" 0x" ); printHex (i );
3085
+ printAll ( " " ); printlnHex (inByte);
3080
3086
delay (20 );
3081
3087
}
3082
- Serial0. println ();
3088
+ printlnAll ();
3083
3089
3084
3090
for (int i = CLICK_CFG; i <= TIME_WINDOW; i++){
3085
3091
inByte = LIS3DH_read (i);
3086
- Serial0. print (" 0x" );Serial0. print (i,HEX );
3087
- Serial0. print ( " \t " );Serial0. println (inByte,HEX );
3092
+ printAll (" 0x" ); printHex (i );
3093
+ printAll ( " " ); printlnHex (inByte);
3088
3094
delay (20 );
3089
3095
}
3090
3096
@@ -3154,9 +3160,15 @@ void OpenBCI_32bit_Library::printRegisterName(byte _address) {
3154
3160
3155
3161
// Used for printing HEX in verbosity feedback mode
3156
3162
void OpenBCI_32bit_Library::printHex (byte _data){
3157
- Serial0.print (" 0x" );
3158
- if (_data < 0x10 ) Serial0.print (" 0" );
3159
- Serial0.print (_data, HEX);
3163
+ if (_data < 0x10 ) printAll (" 0" );
3164
+ char buf[4 ];
3165
+ // Serial.print(_data);
3166
+ printAll (itoa (_data, buf, HEX));
3167
+ }
3168
+
3169
+ void OpenBCI_32bit_Library::printlnHex (byte _data){
3170
+ printHex (_data);
3171
+ printlnAll ();
3160
3172
}
3161
3173
3162
3174
void OpenBCI_32bit_Library::printFailure () {
@@ -3167,6 +3179,13 @@ void OpenBCI_32bit_Library::printSuccess() {
3167
3179
printAll (" Success: " );
3168
3180
}
3169
3181
3182
+ void OpenBCI_32bit_Library::printAll (char c) {
3183
+ printSerial (c);
3184
+ if (wifi.present && wifi.tx ) {
3185
+ wifi.sendStringMulti (c);
3186
+ }
3187
+ }
3188
+
3170
3189
void OpenBCI_32bit_Library::printAll (const char *arr) {
3171
3190
printSerial (arr);
3172
3191
if (wifi.present && wifi.tx ) {
@@ -3177,7 +3196,15 @@ void OpenBCI_32bit_Library::printAll(const char *arr) {
3177
3196
void OpenBCI_32bit_Library::printlnAll (const char *arr) {
3178
3197
printlnSerial (arr);
3179
3198
if (wifi.present && wifi.tx ) {
3180
- wifi.sendStringLast (arr);
3199
+ wifi.sendStringMulti (arr);
3200
+ wifi.sendStringMulti (" \n " );
3201
+ }
3202
+ }
3203
+
3204
+ void OpenBCI_32bit_Library::printlnAll (void ) {
3205
+ printlnSerial ();
3206
+ if (wifi.present && wifi.tx ) {
3207
+ wifi.sendStringMulti (" \n " );
3181
3208
}
3182
3209
}
3183
3210
@@ -3235,10 +3262,10 @@ char OpenBCI_32bit_Library::getChannelCommandForAsciiChar(char asciiChar) {
3235
3262
char OpenBCI_32bit_Library::getYesOrNoForAsciiChar (char asciiChar) {
3236
3263
switch (asciiChar) {
3237
3264
case ' 1' :
3238
- return ACTIVATE;
3265
+ return ACTIVATE;
3239
3266
case ' 0' :
3240
3267
default :
3241
- return DEACTIVATE;
3268
+ return DEACTIVATE;
3242
3269
}
3243
3270
}
3244
3271
0 commit comments