Skip to content

Commit 1d6d62d

Browse files
committed
Refactor PulseSensor widget and process data in the background if instantiated
1 parent a4db084 commit 1d6d62d

3 files changed

Lines changed: 163 additions & 189 deletions

File tree

OpenBCI_GUI/DataProcessing.pde

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,5 +304,8 @@ class DataProcessing {
304304
w_focus.updateFocusWidgetData();
305305
w_bandPower.updateBandPowerWidgetData();
306306
w_emgJoystick.updateEmgJoystickWidgetData();
307+
if (w_pulsesensor != null) {
308+
w_pulsesensor.updatePulseSensorWidgetData();
309+
}
307310
}
308311
}

OpenBCI_GUI/W_Networking.pde

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ class Stream extends Thread {
19441944

19451945
msg.clearArguments();
19461946
msg.setAddrPattern(baseOscAddress + "/pulse/bpm");
1947-
msg.add(w_pulsesensor.BPM);
1947+
msg.add(w_pulsesensor.getBPM());
19481948
try {
19491949
this.osc.send(msg, this.oscNetAddress);
19501950
} catch (Exception e) {
@@ -1953,7 +1953,7 @@ class Stream extends Thread {
19531953

19541954
msg.clearArguments();
19551955
msg.setAddrPattern(baseOscAddress + "/pulse/ibi");
1956-
msg.add(w_pulsesensor.IBI);
1956+
msg.add(w_pulsesensor.getIBI());
19571957
try {
19581958
this.osc.send(msg, this.oscNetAddress);
19591959
} catch (Exception e) {
@@ -1963,9 +1963,9 @@ class Stream extends Thread {
19631963
} else if (this.protocol.equals("UDP")) {
19641964

19651965
StringBuilder output = new StringBuilder("{\"type\":\"pulse\",\"data\":[");
1966-
output.append(str(w_pulsesensor.BPM));
1966+
output.append(str(w_pulsesensor.getBPM()));
19671967
output.append(",");
1968-
output.append(str(w_pulsesensor.IBI));
1968+
output.append(str(w_pulsesensor.getIBI()));
19691969
output.append("]}\r\n");
19701970
try {
19711971
this.udp.send(output.toString(), this.ip, this.port);
@@ -1976,17 +1976,17 @@ class Stream extends Thread {
19761976
} else if (this.protocol.equals("LSL")) {
19771977

19781978
float[] _dataToSend = new float[2];
1979-
_dataToSend[0] = w_pulsesensor.BPM;
1980-
_dataToSend[1] = w_pulsesensor.IBI;
1979+
_dataToSend[0] = w_pulsesensor.getBPM();
1980+
_dataToSend[1] = w_pulsesensor.getIBI();
19811981
// From LSLLink Library: The time stamps of other samples are automatically
19821982
// derived based on the sampling rate of the stream.
19831983
outlet_data.push_chunk(_dataToSend);
19841984

19851985
} else if (this.protocol.equals("Serial")) {
19861986

19871987
serialMessage = ""; // clear message
1988-
serialMessage += w_pulsesensor.BPM + ",";
1989-
serialMessage += w_pulsesensor.IBI;
1988+
serialMessage += w_pulsesensor.getBPM() + ",";
1989+
serialMessage += w_pulsesensor.getIBI();
19901990
try {
19911991
this.serial_networking.write(serialMessage);
19921992
} catch (Exception e) {

0 commit comments

Comments
 (0)