Skip to content

Commit b370b87

Browse files
committed
Merge branch 'master' into development
2 parents 95f8554 + 37fa9a4 commit b370b87

8 files changed

Lines changed: 135 additions & 42 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ libDataHandler.so
2626
libGanglionLib.so
2727
libGanglionScan.so
2828
libunicorn.so
29+
OpenBCI_GUI/out/

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
- Add channel labels for Cyton Digital Channels in GUI CSV files and also label unused channels #1108
77
- Process all data in the background when widgets are closed and sending over Networking stream #1094
88

9+
# v5.2.2
10+
11+
### Improvements
12+
- Update Ganglion decompression to support Ganglion firmware v3 and v2 #1173 Awesome work! @philippitts
13+
914
# v5.2.1
1015

1116
### Improvements

GuiUnitTests/PacketLossTrackerGanglion_UnitTests.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import org.junit.Before;
66

77
public static class PacketLossTrackerGanglionBLE_UnitTests{
88

9-
PacketLossTrackerGanglionBLE packetLossTracker;
9+
PacketLossTrackerGanglionBLE2 packetLossTracker;
1010
FakeTimeProvider fakeTimeProvider;
1111

1212
@Before
1313
public void setUp() {
1414
int sampleIndexChannel = 0;
1515
int timestampChannel = 1;
1616
fakeTimeProvider = currentApplet.new FakeTimeProvider();
17-
packetLossTracker = currentApplet.new PacketLossTrackerGanglionBLE(
17+
packetLossTracker = currentApplet.new PacketLossTrackerGanglionBLE2(
1818
sampleIndexChannel, timestampChannel, fakeTimeProvider);
1919
packetLossTracker.silent = true;
2020
}

OpenBCI_GUI/BoardBrainflow.pde

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,13 @@ abstract class BoardBrainFlow extends Board {
105105
time_last_datapoint = -1.0;
106106
}
107107
catch (BrainFlowError e) {
108-
println("ERROR: Exception when stoppping stream");
108+
outputError("ERROR: Exception when stopping stream. Please restart the Board and Session.");
109109
e.printStackTrace();
110-
streaming = true;
110+
//If no data was received in X seconds, there is a serious problem with communications. Go ahead and stop trying to collect data.
111+
//Prevents feedback loop of errors.
112+
if (data_popup_displayed) {
113+
streaming = false;
114+
}
111115
}
112116

113117
if (eegDataSource != DATASOURCE_PLAYBACKFILE && eegDataSource != DATASOURCE_STREAMING) {

OpenBCI_GUI/BoardGanglion.pde

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@ class BoardGanglionNative extends BoardGanglion {
22

33
private PacketLossTrackerGanglionBLE packetLossTrackerGanglionNative;
44
private String boardName;
5+
private int firmwareVersion = 0;
56

67
public BoardGanglionNative() {
78
super();
89
}
910

10-
public BoardGanglionNative(String name) {
11+
public BoardGanglionNative(String name, boolean showUpgradePopup) {
1112
super();
1213
this.boardName = name;
14+
15+
if (name.indexOf("Ganglion 1.3") != -1) {
16+
this.firmwareVersion = 3;
17+
output("Detected Ganglion firmware version 3");
18+
}
19+
else {
20+
this.firmwareVersion = 2;
21+
output("Detected Ganglion firmware version 2");
22+
if (showUpgradePopup) {
23+
PopupMessage msg = new PopupMessage("Warning", "Ganglion firmware version 2 detected. Please update to version 3 for better performance. \n\nhttps://docs.openbci.com/Ganglion/GanglionProgram");
24+
}
25+
}
1326
}
1427

1528
@Override
@@ -37,24 +50,43 @@ class BoardGanglionNative extends BoardGanglion {
3750

3851
@Override
3952
protected PacketLossTracker setupPacketLossTracker() {
40-
packetLossTrackerGanglionNative = new PacketLossTrackerGanglionBLE(getSampleIndexChannel(), getTimestampChannel());
53+
if (firmwareVersion == 2) {
54+
packetLossTrackerGanglionNative = new PacketLossTrackerGanglionBLE2(getSampleIndexChannel(), getTimestampChannel());
55+
}
56+
else if (firmwareVersion == 3) {
57+
packetLossTrackerGanglionNative = new PacketLossTrackerGanglionBLE3(getSampleIndexChannel(), getTimestampChannel());
58+
}
59+
4160
packetLossTrackerGanglionNative.setAccelerometerActive(isAccelerometerActive());
4261
return packetLossTrackerGanglionNative;
4362
}
4463
};
4564

4665
class BoardGanglionBLE extends BoardGanglion {
4766

67+
private int firmwareVersion = 0;
4868
private PacketLossTrackerGanglionBLE packetLossTrackerGanglionBLE;
4969

5070
public BoardGanglionBLE() {
5171
super();
5272
}
5373

54-
public BoardGanglionBLE(String serialPort, String macAddress) {
74+
public BoardGanglionBLE(String deviceName, String serialPort, String macAddress, boolean showUpgradePopup) {
5575
super();
5676
this.serialPort = serialPort;
5777
this.macAddress = macAddress;
78+
79+
if (deviceName.indexOf("Ganglion 1.3") != -1) {
80+
this.firmwareVersion = 3;
81+
output("Detected Ganglion firmware version 3");
82+
}
83+
else {
84+
this.firmwareVersion = 2;
85+
if (showUpgradePopup) {
86+
PopupMessage msg = new PopupMessage("Warning", "Ganglion firmware version 2 detected. Please update to version 3 for better performance. \n\nhttps://docs.openbci.com/Ganglion/GanglionProgram");
87+
}
88+
output("Detected Ganglion firmware version 2");
89+
}
5890
}
5991

6092
@Override
@@ -75,7 +107,13 @@ class BoardGanglionBLE extends BoardGanglion {
75107

76108
@Override
77109
protected PacketLossTracker setupPacketLossTracker() {
78-
packetLossTrackerGanglionBLE = new PacketLossTrackerGanglionBLE(getSampleIndexChannel(), getTimestampChannel());
110+
if (firmwareVersion == 2) {
111+
packetLossTrackerGanglionBLE = new PacketLossTrackerGanglionBLE2(getSampleIndexChannel(), getTimestampChannel());
112+
}
113+
else if (firmwareVersion == 3) {
114+
packetLossTrackerGanglionBLE = new PacketLossTrackerGanglionBLE3(getSampleIndexChannel(), getTimestampChannel());
115+
}
116+
79117
packetLossTrackerGanglionBLE.setAccelerometerActive(isAccelerometerActive());
80118
return packetLossTrackerGanglionBLE;
81119
}
@@ -141,6 +179,7 @@ abstract class BoardGanglion extends BoardBrainFlow implements AccelerometerCapa
141179
protected String serialPort = "";
142180
protected String macAddress = "";
143181
protected String ipAddress = "";
182+
144183
private boolean isCheckingImpedance = false;
145184
private boolean isGettingAccel = false;
146185

OpenBCI_GUI/GuiSettings.pde

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ enum ExpertModeEnum implements GuiSettingsEnum {
3434
public class GuiSettingsValues {
3535
public ExpertModeEnum expertMode = ExpertModeEnum.OFF;
3636
public boolean showCytonSmoothingPopup = true;
37+
public boolean showGanglionUpgradePopup = true;
3738

3839
public GuiSettingsValues() {
3940
}
@@ -43,7 +44,7 @@ class GuiSettings {
4344

4445
private GuiSettingsValues values;
4546
private String filename;
46-
private List<String> valueKeys = Arrays.asList("expertMode", "showCytonSmoothingPopup");
47+
private List<String> valueKeys = Arrays.asList("expertMode", "showCytonSmoothingPopup", "showGanglionUpgradePopup");
4748

4849
GuiSettings(String settingsDirectory) {
4950

@@ -164,7 +165,16 @@ class GuiSettings {
164165
saveToFile();
165166
}
166167

168+
public void setShowGanglionUpgradePopup(boolean b) {
169+
values.showGanglionUpgradePopup = b;
170+
saveToFile();
171+
}
172+
167173
public boolean getShowCytonSmoothingPopup() {
168174
return values.showCytonSmoothingPopup;
169175
}
176+
177+
public boolean getShowGanglionUpgradePopup() {
178+
return values.showGanglionUpgradePopup;
179+
}
170180
}

OpenBCI_GUI/OpenBCI_GUI.pde

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -607,19 +607,26 @@ void initSystem() {
607607
}
608608
break;
609609
case DATASOURCE_GANGLION:
610+
boolean showUpgradePopup = false;
611+
if (guiSettings.getShowGanglionUpgradePopup())
612+
{
613+
showUpgradePopup = true;
614+
guiSettings.setShowGanglionUpgradePopup(false);
615+
}
616+
610617
if (selectedProtocol == BoardProtocol.WIFI) {
611618
currentBoard = new BoardGanglionWifi(wifi_ipAddress, selectedSamplingRate);
612619
} else if (selectedProtocol == BoardProtocol.BLED112) {
613620
String ganglionName = (String)(controlPanel.bleBox.bleList.getItem(controlPanel.bleBox.bleList.activeItem).get("headline"));
614621
String ganglionPort = (String)(controlPanel.bleBox.bleList.getItem(controlPanel.bleBox.bleList.activeItem).get("subline"));
615622
String ganglionMac = controlPanel.bleBox.bleMACAddrMap.get(ganglionName);
616623
println("MAC address for Ganglion is " + ganglionMac);
617-
currentBoard = new BoardGanglionBLE(ganglionPort, ganglionMac);
624+
currentBoard = new BoardGanglionBLE(ganglionName, ganglionPort, ganglionMac, showUpgradePopup);
618625
} else if (selectedProtocol == BoardProtocol.NATIVE_BLE) {
619626
String ganglionName = (String)(controlPanel.bleBox.bleList.getItem(controlPanel.bleBox.bleList.activeItem).get("headline"));
620627
String ganglionMac = controlPanel.bleBox.bleMACAddrMap.get(ganglionName);
621-
println("MAC address for Ganglion is " + ganglionName);
622-
currentBoard = new BoardGanglionNative(ganglionName);
628+
println("MAC address for Ganglion is " + ganglionMac);
629+
currentBoard = new BoardGanglionNative(ganglionName, showUpgradePopup);
623630
}
624631
break;
625632
case DATASOURCE_STREAMING:
@@ -642,7 +649,7 @@ void initSystem() {
642649
println("OpenBCI_GUI: Configuring Cyton Channel Count...");
643650
if (currentBoard instanceof BoardCytonSerial) {
644651
Pair<Boolean, String> res = ((BoardBrainFlow)currentBoard).sendCommand("c");
645-
//println(res.getKey().booleanValue(), res.getValue());
652+
//println(res.getKey().booleanValue(), res.getValue());guiSettings
646653
if (res.getValue().startsWith("daisy removed")) {
647654
println("OpenBCI_GUI: Daisy is physically attached, using Cyton 8 Channels instead.");
648655
}

OpenBCI_GUI/PacketLossTracker.pde

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,6 @@ class PacketLossTrackerCytonSerialDaisy extends PacketLossTracker {
211211
}
212212
}
213213

214-
// with accel: sample index range 0-100, all sample indexes are duplicated except for zero.
215-
// eg 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, ... , 99, 99, 100, 100, 0, 1, 1, 2, 2, 3, 3, ...
216-
// without acceL: sample 0, then 101-200
217214
class PacketLossTrackerGanglionBLE extends PacketLossTracker {
218215

219216
ArrayList<Integer> sampleIndexArrayAccel = new ArrayList<Integer>();
@@ -225,32 +222,6 @@ class PacketLossTrackerGanglionBLE extends PacketLossTracker {
225222

226223
PacketLossTrackerGanglionBLE(int _sampleIndexChannel, int _timestampChannel, TTQTimeProvider _timeProvider) {
227224
super(_sampleIndexChannel, _timestampChannel, _timeProvider);
228-
229-
{
230-
// add indices to array of indices
231-
// With accel: 0-100, all sample indexes are duplicated except for zero
232-
sampleIndexArrayAccel.add(0);
233-
int firstIndex = 1;
234-
int lastIndex = 100;
235-
for (int i = firstIndex; i <= lastIndex; i++) {
236-
sampleIndexArrayAccel.add(i);
237-
sampleIndexArrayAccel.add(i);
238-
}
239-
}
240-
241-
{
242-
// add indices to array of indices
243-
// Without accel: 0, then 101 to 200, all sample indexes are duplicated except for zero
244-
sampleIndexArrayNoAccel.add(0);
245-
int firstIndex = 101;
246-
int lastIndex = 200;
247-
for (int i = firstIndex; i <= lastIndex; i++) {
248-
sampleIndexArrayNoAccel.add(i);
249-
sampleIndexArrayNoAccel.add(i);
250-
}
251-
}
252-
253-
setAccelerometerActive(true);
254225
}
255226

256227
public void setAccelerometerActive(boolean active) {
@@ -264,4 +235,60 @@ class PacketLossTrackerGanglionBLE extends PacketLossTracker {
264235

265236
reset();
266237
}
238+
}
239+
240+
// With acceleration: sample index range 0-100, all sample indexes are duplicated except for zero.
241+
// E.g. 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, ... , 99, 99, 100, 100, 0, 1, 1, 2, 2, 3, 3, ...
242+
// Without acceleration: sample 0, then 101-200
243+
class PacketLossTrackerGanglionBLE2 extends PacketLossTrackerGanglionBLE {
244+
PacketLossTrackerGanglionBLE2(int _sampleIndexChannel, int _timestampChannel) {
245+
this(_sampleIndexChannel, _timestampChannel, new RealTimeProvider());
246+
}
247+
248+
PacketLossTrackerGanglionBLE2(int _sampleIndexChannel, int _timestampChannel, TTQTimeProvider _timeProvider) {
249+
super(_sampleIndexChannel, _timestampChannel, _timeProvider);
250+
251+
// Add indices to array of indices
252+
// With acceleration: 0-100, all sample indexes are duplicated except for zero
253+
sampleIndexArrayAccel.add(0);
254+
for (int i = 1; i <= 100; i++) {
255+
sampleIndexArrayAccel.add(i);
256+
sampleIndexArrayAccel.add(i);
257+
}
258+
259+
// Add indices to array of indices
260+
// Without acceleration: 0, then 101 to 200, all sample indexes are duplicated except for zero
261+
sampleIndexArrayNoAccel.add(0);
262+
for (int i = 101; i <= 200; i++) {
263+
sampleIndexArrayNoAccel.add(i);
264+
sampleIndexArrayNoAccel.add(i);
265+
}
266+
267+
setAccelerometerActive(true);
268+
}
269+
}
270+
271+
// With acceleration: sample index range 0-100, all sample indexes are duplicated (including zero).
272+
// E.g. 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, ... , 99, 99, 100, 100, 0, 0, 1, 1, 2, 2, 3, 3, ...
273+
// Without acceleration: 101-200
274+
class PacketLossTrackerGanglionBLE3 extends PacketLossTrackerGanglionBLE {
275+
PacketLossTrackerGanglionBLE3(int _sampleIndexChannel, int _timestampChannel) {
276+
this(_sampleIndexChannel, _timestampChannel, new RealTimeProvider());
277+
}
278+
279+
PacketLossTrackerGanglionBLE3(int _sampleIndexChannel, int _timestampChannel, TTQTimeProvider _timeProvider) {
280+
super(_sampleIndexChannel, _timestampChannel, _timeProvider);
281+
282+
for (int i = 0; i < 100; i++) {
283+
sampleIndexArrayAccel.add(i);
284+
sampleIndexArrayAccel.add(i);
285+
}
286+
287+
for (int i = 100; i < 200; i++) {
288+
sampleIndexArrayNoAccel.add(i);
289+
sampleIndexArrayNoAccel.add(i);
290+
}
291+
292+
setAccelerometerActive(true);
293+
}
267294
}

0 commit comments

Comments
 (0)