Skip to content

Commit f9fda74

Browse files
Added new HealthyPi v3 GUI
1 parent 5eac914 commit f9fda74

File tree

6 files changed

+860
-0
lines changed

6 files changed

+860
-0
lines changed

gui/healthypi3_gui/BPM.pde

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//////////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// Desktop GUI for controlling the HealthyPi HAT [ Patient Monitoring System]
4+
//
5+
// Copyright (c) 2016 ProtoCentral
6+
//
7+
// This software is licensed under the MIT License(http://opensource.org/licenses/MIT).
8+
//
9+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
10+
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
11+
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
12+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14+
//
15+
// Requires g4p_control graphing library for processing. Built on V4.1
16+
// Downloaded from Processing IDE Sketch->Import Library->Add Library->G4P Install
17+
//
18+
/////////////////////////////////////////////////////////////////////////////////////////
19+
20+
class BPM
21+
{
22+
23+
float min, max; // Stores Minimum and Maximum Value
24+
double threshold; // Stores the threshold
25+
float minimizedVolt[] = new float[pSize]; // Stores the absoulte values in the buffer
26+
int beats = 0, bpm = 0; // Variables to store the no.of peaks and bpm
27+
28+
////////////////////////////////////////////////////////////////////////////////////////////
29+
// - Heart Value is calculated by:
30+
// * Setting a threshold value which is between the minimum and maximum value
31+
// * Calculating no.of peaks crossing, the threshold value.
32+
// * Calculate the Heart rate with the no.of peaks achieved with the no.of seconds
33+
//
34+
////////////////////////////////////////////////////////////////////////////////////////////
35+
36+
void bpmCalc(float[] recVoltage)
37+
{
38+
39+
int j = 0, n = 0, cntr = 0;
40+
41+
// Making the array into absolute (positive values only)
42+
43+
for (int i=0; i<pSize; i++)
44+
{
45+
recVoltage[i] = (float)Math.abs(recVoltage[i]);
46+
}
47+
48+
j = 0;
49+
for (int i = 0; i < pSize; i++)
50+
{
51+
minimizedVolt[j++] = recVoltage[i];
52+
}
53+
54+
// Calculating the minimum and maximum value
55+
56+
min = min(minimizedVolt);
57+
max = max(minimizedVolt);
58+
59+
if ((int)min == (int)max)
60+
{
61+
lblHR.setText("Heart Rate: 0 bpm");
62+
} else
63+
{
64+
threshold = min+max; // Calculating the threshold value
65+
threshold = (threshold) * 0.400;
66+
67+
if (threshold != 0)
68+
{
69+
while (n < pSize) // scan through ECG samples
70+
{
71+
if (minimizedVolt[n] > threshold) // ECG threshold crossed
72+
{
73+
beats++;
74+
n = n+30; // skipping the some samples to avoid repeatation
75+
} else
76+
n++;
77+
}
78+
bpm = (beats*60)/8;
79+
80+
lblHR.setText("Heart Rate:" + bpm+" bpm");
81+
beats = 0;
82+
} else
83+
{
84+
lblHR.setText("Heart Rate:0 bpm");
85+
86+
}
87+
}
88+
}
89+
};

gui/healthypi3_gui/RPM.pde

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//////////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// Desktop GUI for controlling the HealthyPi HAT [ Patient Monitoring System]
4+
//
5+
// Copyright (c) 2016 ProtoCentral
6+
//
7+
// This software is licensed under the MIT License(http://opensource.org/licenses/MIT).
8+
//
9+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
10+
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
11+
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
12+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14+
//
15+
// Requires g4p_control graphing library for processing. Built on V4.1
16+
// Downloaded from Processing IDE Sketch->Import Library->Add Library->G4P Install
17+
//
18+
/////////////////////////////////////////////////////////////////////////////////////////
19+
20+
class RPM
21+
{
22+
float min, max; // Stores Minimum and Maximum Value
23+
double threshold; // Stores the threshold
24+
float minimizedVolt[] = new float[pSize]; // Stores the absoulte values in the buffer
25+
int peaks = 0, rpm1 = 0; // Variables to store the no.of peaks and bpm
26+
27+
////////////////////////////////////////////////////////////////////////////////////////////
28+
// - Respiration Rate is calculated by:
29+
// * Setting a threshold value which is between the minimum and maximum value
30+
// * Calculating no.of peaks crossing, the threshold value.
31+
//
32+
////////////////////////////////////////////////////////////////////////////////////////////
33+
34+
void rpmCalc(float[] recVoltage)
35+
{
36+
int j = 0, n = 0, cntr = 0;
37+
// Making the array into absolute (positive values only)
38+
for (int i=0; i<pSize; i++)
39+
{
40+
minimizedVolt[i] = (float)Math.abs(recVoltage[i]);
41+
}
42+
min = min(minimizedVolt);
43+
max = max(minimizedVolt);
44+
45+
threshold = min+max; // Calculating the threshold value
46+
threshold = (threshold) * 0.400;
47+
48+
if (threshold != 0)
49+
{
50+
while (n < pSize) // scan through ECG samples
51+
{
52+
if (recVoltage[n] > threshold) // ECG threshold crossed
53+
{
54+
peaks++;
55+
n = n+30; // skipping the some samples to avoid repeatation
56+
} else
57+
n++;
58+
}
59+
lblRR.setText("Respiration: " + peaks+ " bpm");
60+
peaks = 0;
61+
} else
62+
{
63+
lblRR.setText("Respiration: 0 bpm");
64+
}
65+
}
66+
};

gui/healthypi3_gui/SpO2_cal.pde

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
//////////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// Desktop GUI for controlling the HealthyPi HAT [ Patient Monitoring System]
4+
//
5+
// Copyright (c) 2016 ProtoCentral
6+
//
7+
// This software is licensed under the MIT License(http://opensource.org/licenses/MIT).
8+
//
9+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
10+
// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
11+
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
12+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14+
//
15+
// Requires g4p_control graphing library for processing. Built on V4.1
16+
// Downloaded from Processing IDE Sketch->Import Library->Add Library->G4P Install
17+
//
18+
/////////////////////////////////////////////////////////////////////////////////////////
19+
20+
public class SPO2_cal
21+
{
22+
float Vdc = 0;
23+
float Vac = 0;
24+
float spo2_cal_array[] = new float[pSize];
25+
26+
float SPO2 = 0;
27+
28+
///////////////////////////////////////////////////////////////////////////
29+
//
30+
// To Calulate the Spo2 value any one of the following Emprical Formal are used:
31+
// 1. float SpO2 = 10.0002*(value)-52.887*(value) + 26.817*(value) + 98.293;
32+
// 2. float SpO2 =((0.81-0.18*(value))/(0.73+0.11*(value)));
33+
// 3. float SpO2=110-25*(value);
34+
// In this Program, the 3rd formulae is used
35+
//
36+
//////////////////////////////////////////////////////////////////////////
37+
38+
public void rawDataArray(float ir_array[], float red_array[], double ir_avg, double red_avg)
39+
{
40+
float RedAC = s.SPO2_Value(red_array);
41+
float IrAC = s.SPO2_Value(ir_array);
42+
float value = (RedAC/abs((float)red_avg))/(IrAC/abs((float)ir_avg));
43+
float SpO2=110-25*(value);
44+
SpO2 = (int)(SpO2 * 100);
45+
SpO2 = Math.round(SpO2/100);
46+
lblSPO2.setText("SpO2: "+ (SpO2+10)+" %");
47+
}
48+
49+
////////////////////////////////////////////////////////////////////////////////////////////
50+
// SPo2 Value is calculated by:
51+
// * Calculate the square of the spo2 values and store it in the buffer
52+
// * Sum of the values in the squared buffer is calculated.
53+
// * This sum is sent to the main function
54+
//
55+
////////////////////////////////////////////////////////////////////////////////////////////
56+
57+
public float SPO2_Value(float spo2_array[])
58+
{
59+
SPO2 = 0;
60+
int k = 0;
61+
for (int i = 50; i < spo2_array.length; i++)
62+
{
63+
spo2_cal_array[k++] = spo2_array[i] * spo2_array[i];
64+
}
65+
SPO2 = sum(spo2_cal_array, k);
66+
return (SPO2);
67+
}
68+
69+
public float sum(float array[], int len)
70+
{
71+
float spo2 = 0;
72+
for (int p = 0; p < len; p++)
73+
{
74+
spo2 = spo2 + array[p];
75+
}
76+
Vac = (float)Math.sqrt(spo2/len);
77+
return Vac;
78+
}
79+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mode=Java
2+
mode.id=processing.mode.java.JavaMode
7.13 KB
Loading

0 commit comments

Comments
 (0)