Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the creation and playback of OpenBCI GUI data files #1120

Merged
merged 8 commits into from
May 15, 2023
9 changes: 0 additions & 9 deletions OpenBCI_GUI/BatteryInfoCapableBoard.pde

This file was deleted.

104 changes: 1 addition & 103 deletions OpenBCI_GUI/BoardBrainFlowSynthetic.pde
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ import brainflow.*;

import org.apache.commons.lang3.tuple.Pair;

class BoardBrainFlowSynthetic extends BoardBrainFlow
implements AccelerometerCapableBoard, PPGCapableBoard, EDACapableBoard, BatteryInfoCapableBoard {
class BoardBrainFlowSynthetic extends BoardBrainFlow implements AccelerometerCapableBoard {
retiutut marked this conversation as resolved.
Show resolved Hide resolved

private int[] accelChannelsCache = null;
private int[] edaChannelsCache = null;
private int[] ppgChannelsCache = null;
private Integer batteryChannelCache = null;
private int numChannels = 0;
private volatile boolean[] activeChannels = null;

Expand Down Expand Up @@ -97,80 +93,12 @@ implements AccelerometerCapableBoard, PPGCapableBoard, EDACapableBoard, BatteryI
return accelChannelsCache;
}

@Override
public boolean isPPGActive() {
return true;
}

@Override
public void setPPGActive(boolean active) {
outputWarn("PPG is always active for BrainflowSyntheticBoard");
}

@Override
public int[] getPPGChannels() {
if(ppgChannelsCache == null) {
try {
ppgChannelsCache = BoardShim.get_ppg_channels(getBoardIdInt());

} catch (BrainFlowError e) {
e.printStackTrace();
}
}

return ppgChannelsCache;
}

@Override
public boolean isEDAActive() {
return true;
}

@Override
public void setEDAActive(boolean active) {
outputWarn("EDA is always active for BrainflowSyntheticBoard");
}

@Override
public int[] getEDAChannels() {
if (edaChannelsCache == null) {
try {
edaChannelsCache = BoardShim.get_eda_channels(getBoardIdInt());

} catch (BrainFlowError e) {
e.printStackTrace();
}
}

return edaChannelsCache;
}

@Override
public Integer getBatteryChannel() {
if (batteryChannelCache == null) {
try {
batteryChannelCache = BoardShim.get_battery_channel(getBoardIdInt());
} catch (BrainFlowError e) {
e.printStackTrace();

}
}

return batteryChannelCache;
}

@Override
protected void addChannelNamesInternal(String[] channelNames) {
for (int i=0; i<getEDAChannels().length; i++) {
channelNames[getEDAChannels()[i]] = "EDA Channel " + i;
}
for (int i=0; i<getPPGChannels().length; i++) {
channelNames[getPPGChannels()[i]] = "PPG Channel " + i;
}
for (int i=0; i<getAccelerometerChannels().length; i++) {
channelNames[getAccelerometerChannels()[i]] = "Accel Channel " + i;
}
channelNames[getBatteryChannel()] = "Battery Info Channel";
}

@Override
Expand All @@ -186,38 +114,8 @@ implements AccelerometerCapableBoard, PPGCapableBoard, EDACapableBoard, BatteryI
return getData(maxSamples);
}

@Override
public List<double[]> getDataWithPPG(int maxSamples) {
return getData(maxSamples);
}

@Override
public List<double[]> getDataWithEDA(int maxSamples) {
return getData(maxSamples);
}

@Override
public List<double[]> getDataWithBatteryInfo(int maxSamples) {
return getData(maxSamples);
}

@Override
public int getAccelSampleRate() {
return getSampleRate();
}

@Override
public int getPPGSampleRate() {
return getSampleRate();
}

@Override
public int getEDASampleRate() {
return getSampleRate();
}

@Override
public int getBatteryInfoSampleRate() {
return getSampleRate();
}
};
1 change: 1 addition & 0 deletions OpenBCI_GUI/CustomCp5Classes.pde
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class ButtonHelpText{
////////////////////////////////////////////////////////////////////////////////////
// MENULIST CLASS //
// Based on ControlP5 Processing Library example, written by Andreas Schlegel //
// WARNING: This class does not respond well to being resized -RW 5/5/23 //
////////////////////////////////////////////////////////////////////////////////////
public class MenuList extends controlP5.Controller {

Expand Down
Loading