Skip to content

Commit eae1ab2

Browse files
authored
Merge pull request #1120 from OpenBCI/refactor-playback-classes
Refactor the creation and playback of OpenBCI GUI data files
2 parents 91d0820 + a83527f commit eae1ab2

20 files changed

Lines changed: 441 additions & 457 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Improvements
1010
- Update to BrainFlow 5.6.1
1111
- Add feature to connect to Ganglion using Native Bluetooth #1080
12+
- Refactor the creation and playback of OpenBCI GUI CSV files #1119
1213

1314

1415
# v5.1.0

OpenBCI_GUI/BatteryInfoCapableBoard.pde

Lines changed: 0 additions & 9 deletions
This file was deleted.

OpenBCI_GUI/BoardBrainFlowSynthetic.pde

Lines changed: 1 addition & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ import brainflow.*;
22

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

5-
class BoardBrainFlowSynthetic extends BoardBrainFlow
6-
implements AccelerometerCapableBoard, PPGCapableBoard, EDACapableBoard, BatteryInfoCapableBoard {
5+
class BoardBrainFlowSynthetic extends BoardBrainFlow implements AccelerometerCapableBoard {
76

87
private int[] accelChannelsCache = null;
9-
private int[] edaChannelsCache = null;
10-
private int[] ppgChannelsCache = null;
11-
private Integer batteryChannelCache = null;
128
private int numChannels = 0;
139
private volatile boolean[] activeChannels = null;
1410

@@ -97,80 +93,12 @@ implements AccelerometerCapableBoard, PPGCapableBoard, EDACapableBoard, BatteryI
9793
return accelChannelsCache;
9894
}
9995

100-
@Override
101-
public boolean isPPGActive() {
102-
return true;
103-
}
104-
105-
@Override
106-
public void setPPGActive(boolean active) {
107-
outputWarn("PPG is always active for BrainflowSyntheticBoard");
108-
}
109-
110-
@Override
111-
public int[] getPPGChannels() {
112-
if(ppgChannelsCache == null) {
113-
try {
114-
ppgChannelsCache = BoardShim.get_ppg_channels(getBoardIdInt());
115-
116-
} catch (BrainFlowError e) {
117-
e.printStackTrace();
118-
}
119-
}
120-
121-
return ppgChannelsCache;
122-
}
123-
124-
@Override
125-
public boolean isEDAActive() {
126-
return true;
127-
}
128-
129-
@Override
130-
public void setEDAActive(boolean active) {
131-
outputWarn("EDA is always active for BrainflowSyntheticBoard");
132-
}
133-
134-
@Override
135-
public int[] getEDAChannels() {
136-
if (edaChannelsCache == null) {
137-
try {
138-
edaChannelsCache = BoardShim.get_eda_channels(getBoardIdInt());
139-
140-
} catch (BrainFlowError e) {
141-
e.printStackTrace();
142-
}
143-
}
144-
145-
return edaChannelsCache;
146-
}
147-
148-
@Override
149-
public Integer getBatteryChannel() {
150-
if (batteryChannelCache == null) {
151-
try {
152-
batteryChannelCache = BoardShim.get_battery_channel(getBoardIdInt());
153-
} catch (BrainFlowError e) {
154-
e.printStackTrace();
155-
156-
}
157-
}
158-
159-
return batteryChannelCache;
160-
}
16196

16297
@Override
16398
protected void addChannelNamesInternal(String[] channelNames) {
164-
for (int i=0; i<getEDAChannels().length; i++) {
165-
channelNames[getEDAChannels()[i]] = "EDA Channel " + i;
166-
}
167-
for (int i=0; i<getPPGChannels().length; i++) {
168-
channelNames[getPPGChannels()[i]] = "PPG Channel " + i;
169-
}
17099
for (int i=0; i<getAccelerometerChannels().length; i++) {
171100
channelNames[getAccelerometerChannels()[i]] = "Accel Channel " + i;
172101
}
173-
channelNames[getBatteryChannel()] = "Battery Info Channel";
174102
}
175103

176104
@Override
@@ -186,38 +114,8 @@ implements AccelerometerCapableBoard, PPGCapableBoard, EDACapableBoard, BatteryI
186114
return getData(maxSamples);
187115
}
188116

189-
@Override
190-
public List<double[]> getDataWithPPG(int maxSamples) {
191-
return getData(maxSamples);
192-
}
193-
194-
@Override
195-
public List<double[]> getDataWithEDA(int maxSamples) {
196-
return getData(maxSamples);
197-
}
198-
199-
@Override
200-
public List<double[]> getDataWithBatteryInfo(int maxSamples) {
201-
return getData(maxSamples);
202-
}
203-
204117
@Override
205118
public int getAccelSampleRate() {
206119
return getSampleRate();
207120
}
208-
209-
@Override
210-
public int getPPGSampleRate() {
211-
return getSampleRate();
212-
}
213-
214-
@Override
215-
public int getEDASampleRate() {
216-
return getSampleRate();
217-
}
218-
219-
@Override
220-
public int getBatteryInfoSampleRate() {
221-
return getSampleRate();
222-
}
223121
};

OpenBCI_GUI/CustomCp5Classes.pde

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class ButtonHelpText{
130130
////////////////////////////////////////////////////////////////////////////////////
131131
// MENULIST CLASS //
132132
// Based on ControlP5 Processing Library example, written by Andreas Schlegel //
133+
// WARNING: This class does not respond well to being resized -RW 5/5/23 //
133134
////////////////////////////////////////////////////////////////////////////////////
134135
public class MenuList extends controlP5.Controller {
135136

0 commit comments

Comments
 (0)