Merge pull request #109 from conorrussomanno/development

OpenBCI GUI v2.0.0
Esse commit está contido em:
Conor Russomanno
2017-01-10 16:07:19 -05:00
commit de GitHub
7 arquivos alterados com 63 adições e 5 exclusões
+32
Ver Arquivo
@@ -16,6 +16,9 @@
// Global Functions
//------------------------------------------------------------------------
boolean werePacketsDroppedGang = false;
int numPacketsDroppedGang = 0;
void clientEvent(Client someClient) {
// print("Server Says: ");
@@ -316,7 +319,15 @@ class OpenBCI_Ganglion {
if ((dataPacket.sampleIndex - prevSampleIndex) != 1) {
if(dataPacket.sampleIndex != 0){ // if we rolled over, don't count as error
bleErrorCounter++;
werePacketsDroppedGang = true; //set this true to activate packet duplication in serialEvent
if(dataPacket.sampleIndex < prevSampleIndex){ //handle the situation in which the index jumps from 250s past 255, and back to 0
numPacketsDroppedGang = (dataPacket.sampleIndex+200) - prevSampleIndex; //calculate how many times the last received packet should be duplicated...
} else {
numPacketsDroppedGang = dataPacket.sampleIndex - prevSampleIndex; //calculate how many times the last received packet should be duplicated...
}
println("OpenBCI_Ganglion: apparent sampleIndex jump from Serial data: " + prevSampleIndex + " to " + dataPacket.sampleIndex + ". Keeping packet. (" + bleErrorCounter + ")");
println("numPacketsDropped = " + numPacketsDropped);
}
}
prevSampleIndex = dataPacket.sampleIndex;
@@ -335,7 +346,28 @@ class OpenBCI_Ganglion {
getRawValues(dataPacket);
// println(binary(dataPacket.values[0], 24) + '\n' + binary(dataPacket.rawValues[0][0], 8) + binary(dataPacket.rawValues[0][1], 8) + binary(dataPacket.rawValues[0][2], 8) + '\n'); //<>//
curDataPacketInd = (curDataPacketInd+1) % dataPacketBuff.length; // This is also used to let the rest of the code that it may be time to do something
ganglion.copyDataPacketTo(dataPacketBuff[curDataPacketInd]); // Resets isNewDataPacketAvailable to false
// KILL SPIKES!!!
if(werePacketsDroppedGang){
// println("Packets Dropped ... doing some stuff...");
for(int i = numPacketsDroppedGang; i > 0; i--){
int tempDataPacketInd = curDataPacketInd - i; //
if(tempDataPacketInd >= 0 && tempDataPacketInd < dataPacketBuff.length){
// println("i = " + i);
ganglion.copyDataPacketTo(dataPacketBuff[tempDataPacketInd]);
} else {
ganglion.copyDataPacketTo(dataPacketBuff[tempDataPacketInd+200]);
}
//put the last stored packet in # of packets dropped after that packet
}
//reset werePacketsDropped & numPacketsDropped
werePacketsDroppedGang = false;
numPacketsDroppedGang = 0;
}
switch (outputDataSource) {
case OUTPUT_SOURCE_ODF:
fileoutput_odf.writeRawData_dataPacket(dataPacketBuff[curDataPacketInd], ganglion.get_scale_fac_uVolts_per_count(), get_scale_fac_accel_G_per_count());
+30
Ver Arquivo
@@ -38,6 +38,10 @@ int channelDeactivateCounter = 0; //used for re-deactivating channels after swit
boolean threadLock = false;
//these variables are used for "Kill Spikes" ... duplicating the last received data packet if packets were droppeds
boolean werePacketsDropped = false;
int numPacketsDropped = 0;
//everything below is now deprecated...
// final String[] command_activate_leadoffP_channel = {"!", "@", "#", "$", "%", "^", "&", "*"}; //shift + 1-8
@@ -74,8 +78,26 @@ void serialEvent(Serial port){
if (openBCI.get_isNewDataPacketAvailable()) {
//copy packet into buffer of data packets
curDataPacketInd = (curDataPacketInd+1) % dataPacketBuff.length; //this is also used to let the rest of the code that it may be time to do something
openBCI.copyDataPacketTo(dataPacketBuff[curDataPacketInd]); //resets isNewDataPacketAvailable to false
// KILL SPIKES!!!
if(werePacketsDropped){
for(int i = numPacketsDropped; i > 0; i--){
int tempDataPacketInd = curDataPacketInd - i; //
if(tempDataPacketInd >= 0 && tempDataPacketInd < dataPacketBuff.length){
openBCI.copyDataPacketTo(dataPacketBuff[tempDataPacketInd]);
} else {
openBCI.copyDataPacketTo(dataPacketBuff[tempDataPacketInd+255]);
}
//put the last stored packet in # of packets dropped after that packet
}
//reset werePacketsDropped & numPacketsDropped
werePacketsDropped = false;
numPacketsDropped = 0;
}
//If networking enabled --> send data every sample if 8 channels or every other sample if 16 channels
if (networkType !=0) {
if (nchan==8) {
@@ -792,6 +814,14 @@ class OpenBCI_ADS1299 {
if ((rawReceivedDataPacket.sampleIndex-prevSampleIndex) != 1) {
if (rawReceivedDataPacket.sampleIndex != 0) { // if we rolled over, don't count as error
serialErrorCounter++;
werePacketsDropped = true; //set this true to activate packet duplication in serialEvent
if(rawReceivedDataPacket.sampleIndex < prevSampleIndex){ //handle the situation in which the index jumps from 250s past 255, and back to 0
numPacketsDropped = (rawReceivedDataPacket.sampleIndex+255) - prevSampleIndex; //calculate how many times the last received packet should be duplicated...
} else {
numPacketsDropped = rawReceivedDataPacket.sampleIndex - prevSampleIndex; //calculate how many times the last received packet should be duplicated...
}
println("OpenBCI_ADS1299: apparent sampleIndex jump from Serial data: " + prevSampleIndex + " to " + rawReceivedDataPacket.sampleIndex + ". Keeping packet. (" + serialErrorCounter + ")");
if (outputDataSource == OUTPUT_SOURCE_BDF) {
int fakePacketsToWrite = (rawReceivedDataPacket.sampleIndex - prevSampleIndex) - 1;
+1 -1
Ver Arquivo
@@ -966,7 +966,7 @@ void introAnimation() {
textLeading(24);
fill(31, 69, 110, transparency);
textAlign(CENTER, CENTER);
text("OpenBCI GUI v2.0\nJanuary 2017", width/2, height/2 + width/9);
text("OpenBCI GUI v2.0.0\nJanuary 2017", width/2, height/2 + width/9);
}
//exit intro animation at t2
Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 168 KiB

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 167 KiB

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 165 KiB

-4
Ver Arquivo
@@ -46,11 +46,7 @@ void setupWidgets(PApplet _this, ArrayList<Widget> w){
w_accelerometer = new W_accelerometer(_this);
w_accelerometer.setTitle("Accelerometer");
addWidget(w_accelerometer, w);
<<<<<<< HEAD
=======
//
>>>>>>> e9b30d1441fde495039667b13c4215370dea102e
// w_networking = new W_networking(_this);
// w_networking.setTitle("Networking");
// addWidget(w_networking, w);