Skip to content

Commit 14049ad

Browse files
committed
Add EMG Joystick Widget #1131
1 parent c6b44ae commit 14049ad

12 files changed

Lines changed: 912 additions & 1238 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Improvements
1212

13+
- Add EMG Joystick widget and EMG Settings UI from NeuroFly Project #1131
1314
- Update to BrainFlow 5.6.1
1415
- Add feature to connect to Ganglion using Native Bluetooth #1080
1516
- Refactor the creation and playback of OpenBCI GUI CSV files #1119

OpenBCI_GUI/DataProcessing.pde

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,9 @@ import ddf.minim.analysis.*; //for FFT
77
import brainflow.DataFilter;
88
import brainflow.FilterTypes;
99

10-
DataProcessing dataProcessing;
1110
String curTimestamp;
1211
HashMap<Integer,String> index_of_times;
1312

14-
// indexes
15-
final int DELTA = 0; // 1-4 Hz
16-
final int THETA = 1; // 4-8 Hz
17-
final int ALPHA = 2; // 8-13 Hz
18-
final int BETA = 3; // 13-30 Hz
19-
final int GAMMA = 4; // 30-55 Hz
20-
2113
float playback_speed_fac = 1.0f; //make 1.0 for real-time. larger for faster playback
2214

2315
//------------------------------------------------------------------------
@@ -101,6 +93,8 @@ class DataProcessing {
10193
float avgPowerInBins[][];
10294
float headWidePower[];
10395

96+
public EmgValues emgValues;
97+
10498
DataProcessing(int NCHAN, float sample_rate_Hz) {
10599
nchan = NCHAN;
106100
fs_Hz = sample_rate_Hz;
@@ -109,6 +103,8 @@ class DataProcessing {
109103
newDataToSend = false;
110104
avgPowerInBins = new float[nchan][processing_band_low_Hz.length];
111105
headWidePower = new float[processing_band_low_Hz.length];
106+
107+
emgValues = new EmgValues();
112108
}
113109

114110
//Process data on a channel-by-channel basis
@@ -281,9 +277,6 @@ class DataProcessing {
281277
headWidePower[i] = sum/nchan; // averaging power over all channels
282278
}
283279

284-
//delta in channel 2 ... avgPowerInBins[1][DELTA];
285-
//headwide beta ... headWidePower[BETA];
286-
287280
//find strongest channel
288281
int refChanInd = findMax(data_std_uV);
289282
//println("EEG_Processing: strongest chan (one referenced) = " + (refChanInd+1));
@@ -302,5 +295,8 @@ class DataProcessing {
302295
polarity[Ichan]=-1.0;
303296
}
304297
}
298+
299+
//Compute EMG values independent of widgets
300+
emgValues.process(dataProcessingFilteredBuffer);
305301
}
306302
}

OpenBCI_GUI/EmgSettingsEnums.pde

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
interface EmgSettingsEnum {
2+
public int getIndex();
3+
public String getString();
4+
}
5+
6+
public enum EmgSmoothing implements EmgSettingsEnum
7+
{
8+
ONE_HUNDREDTH_SECOND (0, "0.01 s", .01f),
9+
ONE_TENTH_SECOND (1, "0.1 s", .1f),
10+
FIFTEEN_HUNDREDTHS_SECOND (2, "0.15 s", .15f),
11+
QUARTER_SECOND (3, "0.25 s", .25f),
12+
HALF_SECOND (4, "0.5 s", .5f),
13+
THREE_QUARTERS_SECOND (5, "0.75 s", .75f),
14+
ONE_SECOND (6, "1.0 s", 1f),
15+
TWO_SECONDS (7, "2.0 s", 2f);
16+
17+
private int index;
18+
private String name;
19+
private float value;
20+
21+
EmgSmoothing(int index, String name, float value) {
22+
this.index = index;
23+
this.name = name;
24+
this.value = value;
25+
}
26+
27+
public int getIndex() {
28+
return index;
29+
}
30+
31+
public String getString() {
32+
return name;
33+
}
34+
35+
public float getValue() {
36+
return value;
37+
}
38+
}
39+
40+
public enum EmgUVLimit implements EmgSettingsEnum
41+
{
42+
FIFTY_UV (0, "50 uV", 50),
43+
ONE_HUNDRED_UV (1, "100 uV", 100),
44+
TWO_HUNDRED_UV (2, "200 uV", 200),
45+
FOUR_HUNDRED_UV (3, "400 uV", 400);
46+
47+
private int index;
48+
private String name;
49+
private int value;
50+
51+
EmgUVLimit(int index, String name, int value) {
52+
this.index = index;
53+
this.name = name;
54+
this.value = value;
55+
}
56+
57+
public int getIndex() {
58+
return index;
59+
}
60+
61+
public String getString() {
62+
return name;
63+
}
64+
65+
public int getValue() {
66+
return value;
67+
}
68+
}
69+
70+
public enum EmgCreepIncreasing implements EmgSettingsEnum
71+
{
72+
POINT_9 (0, "0.9", .9f),
73+
POINT_95 (1, "0.95", .95f),
74+
POINT_98 (2, "0.98", .98f),
75+
POINT_99 (3, "0.99", .99f),
76+
POINT_999 (4, "0.999", .999f),
77+
POINT_9999 (5, "0.9999", .9999f),
78+
POINT_99999 (6, "0.99999", .99999f);
79+
80+
private int index;
81+
private String name;
82+
private float value;
83+
84+
EmgCreepIncreasing(int index, String name, float value) {
85+
this.index = index;
86+
this.name = name;
87+
this.value = value;
88+
}
89+
90+
public int getIndex() {
91+
return index;
92+
}
93+
94+
public String getString() {
95+
return name;
96+
}
97+
98+
public float getValue() {
99+
return value;
100+
}
101+
}
102+
103+
public enum EmgCreepDecreasing implements EmgSettingsEnum
104+
{
105+
POINT_9 (0, "0.9", .9f),
106+
POINT_95 (1, "0.95", .95f),
107+
POINT_98 (2, "0.98", .98f),
108+
POINT_99 (3, "0.99", .99f),
109+
POINT_999 (4, "0.999", .999f),
110+
POINT_9999 (5, "0.9999", .9999f),
111+
POINT_99999 (6, "0.99999", .99999f);
112+
113+
private int index;
114+
private String name;
115+
private float value;
116+
117+
EmgCreepDecreasing(int index, String name, float value) {
118+
this.index = index;
119+
this.name = name;
120+
this.value = value;
121+
}
122+
123+
public int getIndex() {
124+
return index;
125+
}
126+
127+
public String getString() {
128+
return name;
129+
}
130+
131+
public float getValue() {
132+
return value;
133+
}
134+
}
135+
136+
public enum EmgMinimumDeltaUV implements EmgSettingsEnum
137+
{
138+
TWO_UV (0, "2 uV", 2),
139+
FOUR_UV (1, "4 uV", 4),
140+
SIX_UV (2, "6 uV", 6),
141+
EIGHT_UV (3, "8 uV", 8),
142+
TEN_UV (4, "10 uV", 10),
143+
TWENTY_UV (5, "20 uV", 20),
144+
FORTY_UV (6, "40 uV", 40),
145+
EIGHTY_UV (7, "80 uV", 80);
146+
147+
private int index;
148+
private String name;
149+
private int value;
150+
151+
EmgMinimumDeltaUV(int index, String name, int value) {
152+
this.index = index;
153+
this.name = name;
154+
this.value = value;
155+
}
156+
157+
public int getIndex() {
158+
return index;
159+
}
160+
161+
public String getString() {
162+
return name;
163+
}
164+
165+
public int getValue() {
166+
return value;
167+
}
168+
}
169+
170+
public enum EmgLowerThresholdMinimum implements EmgSettingsEnum
171+
{
172+
ZERO_UV (0, "0 uV", 0),
173+
TWO_UV (1, "2 uV", 2),
174+
FOUR_UV (2, "4 uV", 4),
175+
SIX_UV (3, "6 uV", 6),
176+
EIGHT_UV (4, "8 uV", 8),
177+
TEN_UV (5, "10 uV", 10),
178+
FIFTEEN_UV (6, "15 uV", 15),
179+
TWENTY_UV (7, "20 uV", 20),
180+
THIRTY_UV (8, "30 uV", 30),
181+
FORTY_UV (9, "40 uV", 40);
182+
183+
private int index;
184+
private String name;
185+
private int value;
186+
187+
EmgLowerThresholdMinimum(int index, String name, int value) {
188+
this.index = index;
189+
this.name = name;
190+
this.value = value;
191+
}
192+
193+
public int getIndex() {
194+
return index;
195+
}
196+
197+
public String getString() {
198+
return name;
199+
}
200+
201+
public int getValue() {
202+
return value;
203+
}
204+
}

0 commit comments

Comments
 (0)