Changes done in ECG and BT

Dependencies:   SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217

Fork of merged_code2_20sept_2017_4th_oct_2017 by nikita teggi

Committer:
nikitateggi
Date:
Sat Jul 15 05:39:45 2017 +0000
Revision:
31:0f67acfc6236
Parent:
22:ffa88619551d
Child:
36:00d96aa14658
new display code 15/07/17

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nidhinvarghese 14:f5c62d30c6fc 1 //-----------------------------------------------NEW BP code starts--------------------------------///
nikitateggi 3:9a06c2bed650 2
nikitateggi 3:9a06c2bed650 3
nidhinvarghese 8:adf2ba7e6412 4
nikitateggi 3:9a06c2bed650 5 #include "mbed.h"
nikitateggi 3:9a06c2bed650 6 #include "MAX30102.h" // BP ADD
nikitateggi 3:9a06c2bed650 7 #include <string.h>
nikitateggi 3:9a06c2bed650 8 #include <stdio.h>
nidhinvarghese 14:f5c62d30c6fc 9
nidhinvarghese 14:f5c62d30c6fc 10 #include <time.h>
nidhinvarghese 14:f5c62d30c6fc 11 //#include <iostream>
nikitateggi 3:9a06c2bed650 12 #include "ds3231.h"
nikitateggi 3:9a06c2bed650 13 #include "SDFileSystem.h"
nikitateggi 3:9a06c2bed650 14 #include "rtc.h"
nikitateggi 3:9a06c2bed650 15 #include "sdcard.h"
nikitateggi 3:9a06c2bed650 16 #include "ec_bp.h"
nikitateggi 3:9a06c2bed650 17 #include "bp.h"
nikitateggi 3:9a06c2bed650 18 #include "display_modules.h"
nikitateggi 3:9a06c2bed650 19
nikitateggi 3:9a06c2bed650 20
nikitateggi 3:9a06c2bed650 21
nidhinvarghese 14:f5c62d30c6fc 22 #include "struct.h"
nikitateggi 19:1650bbc923cc 23 //#include "test_type.h"
nidhinvarghese 8:adf2ba7e6412 24
nidhinvarghese 8:adf2ba7e6412 25 using namespace std;
nidhinvarghese 8:adf2ba7e6412 26
nidhinvarghese 14:f5c62d30c6fc 27 Serial bpr(USBTX,USBRX);
nidhinvarghese 8:adf2ba7e6412 28 DigitalIn INTR(PTC7);
nidhinvarghese 8:adf2ba7e6412 29
nidhinvarghese 8:adf2ba7e6412 30 Timer t;
nidhinvarghese 8:adf2ba7e6412 31
nidhinvarghese 14:f5c62d30c6fc 32
nidhinvarghese 8:adf2ba7e6412 33 //FILE *ecg;
nidhinvarghese 8:adf2ba7e6412 34 //FILE *ppg;
nidhinvarghese 8:adf2ba7e6412 35
nikitateggi 22:ffa88619551d 36 void bp(int32_t pid) {
nidhinvarghese 14:f5c62d30c6fc 37
nidhinvarghese 8:adf2ba7e6412 38 uint8_t uch_dummy;
nidhinvarghese 8:adf2ba7e6412 39 uint32_t ppgdata;
nikitateggi 20:7c64e6ecad76 40 uint8_t lead_reg=0;
nidhinvarghese 8:adf2ba7e6412 41 //int dummyconcat = 700000;
nidhinvarghese 8:adf2ba7e6412 42 int concatenate_value2 = 0;
nidhinvarghese 8:adf2ba7e6412 43 unsigned char chk = 1;
nidhinvarghese 8:adf2ba7e6412 44
nidhinvarghese 14:f5c62d30c6fc 45 uint32_t drum11[64];
nidhinvarghese 8:adf2ba7e6412 46 uint32_t drum21[64];
nidhinvarghese 14:f5c62d30c6fc 47
nidhinvarghese 14:f5c62d30c6fc 48
nidhinvarghese 14:f5c62d30c6fc 49 //Declaration of Master structure
nidhinvarghese 14:f5c62d30c6fc 50
nidhinvarghese 14:f5c62d30c6fc 51 BLEMsg_info *ptr_BLEMsg_info_bp, BLEMsg_info_bp; // A copy of master strcuture [ "BLEMsg_info" ] by name "BLEMsg_info_bp" is created
nidhinvarghese 14:f5c62d30c6fc 52 ptr_BLEMsg_info_bp = &BLEMsg_info_bp; // *ptr_BLEMsg_info_bp is the pointer to local copy;
nidhinvarghese 14:f5c62d30c6fc 53
nidhinvarghese 14:f5c62d30c6fc 54 // Declaration of Date Structure
nidhinvarghese 14:f5c62d30c6fc 55 DateTime_info *ptr_DateTime_info_bp, DateTime_info_bp; // A copy of Master Structure "DateTime_info" created,
nidhinvarghese 14:f5c62d30c6fc 56 ptr_DateTime_info_bp = &DateTime_info_bp; // Structure pointer points to that copy.
nidhinvarghese 14:f5c62d30c6fc 57
nidhinvarghese 14:f5c62d30c6fc 58
nidhinvarghese 14:f5c62d30c6fc 59 // RTC operations
nidhinvarghese 14:f5c62d30c6fc 60 time_t epoch_time_bp; //A copy of time_t by name epoch_time_bp is created
nidhinvarghese 14:f5c62d30c6fc 61 epoch_time_bp = rtc_read(); // time is got from get epoch function.
nidhinvarghese 14:f5c62d30c6fc 62
nidhinvarghese 14:f5c62d30c6fc 63 struct tm * ptr_time_info_bp, time_info_bp; // Sturucture copy of tm is created
nidhinvarghese 14:f5c62d30c6fc 64 ptr_time_info_bp = localtime(&epoch_time_bp); // Structure accepts the time in local format from "time_t" type.
nidhinvarghese 14:f5c62d30c6fc 65
nidhinvarghese 14:f5c62d30c6fc 66 //BELOW LINE IS TO CHECK Date and TIME
nidhinvarghese 14:f5c62d30c6fc 67 bpr.printf("Time is %d: %d: %d\n", (*ptr_time_info_bp).tm_hour, (*ptr_time_info_bp).tm_min, (*ptr_time_info_bp).tm_sec);
nidhinvarghese 14:f5c62d30c6fc 68 bpr.printf("Date is %d:%d:%d\n", (*ptr_time_info_bp).tm_mday, (*ptr_time_info_bp).tm_mon+1, (*ptr_time_info_bp).tm_year-100);
nidhinvarghese 14:f5c62d30c6fc 69
nidhinvarghese 14:f5c62d30c6fc 70 //Copying from one structure to the other using variables
nidhinvarghese 14:f5c62d30c6fc 71 DateTime_info_bp.hour = (uint8_t)(*ptr_time_info_bp).tm_hour;
nidhinvarghese 14:f5c62d30c6fc 72 DateTime_info_bp.mins = (uint8_t)(*ptr_time_info_bp).tm_min;
nidhinvarghese 14:f5c62d30c6fc 73 DateTime_info_bp.sec = (uint8_t)(*ptr_time_info_bp).tm_sec;
nidhinvarghese 14:f5c62d30c6fc 74
nidhinvarghese 14:f5c62d30c6fc 75 DateTime_info_bp.date = (uint8_t) (*ptr_time_info_bp).tm_mday;
nidhinvarghese 14:f5c62d30c6fc 76 DateTime_info_bp.month =(uint8_t)(*ptr_time_info_bp).tm_mon+1;
nidhinvarghese 14:f5c62d30c6fc 77 DateTime_info_bp.year = (uint8_t)(*ptr_time_info_bp).tm_year-100;
nidhinvarghese 14:f5c62d30c6fc 78
nidhinvarghese 14:f5c62d30c6fc 79 // Copying Time to Main structure
nidhinvarghese 14:f5c62d30c6fc 80 BLEMsg_info_bp.date_time.hour = DateTime_info_bp.hour;
nidhinvarghese 14:f5c62d30c6fc 81 BLEMsg_info_bp.date_time.mins = DateTime_info_bp.mins;
nidhinvarghese 14:f5c62d30c6fc 82 BLEMsg_info_bp.date_time.sec = DateTime_info_bp.sec;
nidhinvarghese 14:f5c62d30c6fc 83
nidhinvarghese 14:f5c62d30c6fc 84 BLEMsg_info_bp.date_time.date = DateTime_info_bp.date ;
nidhinvarghese 14:f5c62d30c6fc 85 BLEMsg_info_bp.date_time.month = DateTime_info_bp.month ;
nidhinvarghese 14:f5c62d30c6fc 86 BLEMsg_info_bp.date_time.year = DateTime_info_bp.year ;
nidhinvarghese 14:f5c62d30c6fc 87
nidhinvarghese 14:f5c62d30c6fc 88
nidhinvarghese 14:f5c62d30c6fc 89 //Checking if the structure has these values
nidhinvarghese 14:f5c62d30c6fc 90 bpr.printf("Time 2 is %d:%d:%d\n", DateTime_info_bp.hour, DateTime_info_bp.mins, DateTime_info_bp.sec);
nidhinvarghese 14:f5c62d30c6fc 91 bpr.printf("\t Date is %d:%d:%d\n",DateTime_info_bp.date, DateTime_info_bp.month, DateTime_info_bp.year);
nidhinvarghese 14:f5c62d30c6fc 92
nidhinvarghese 14:f5c62d30c6fc 93
nidhinvarghese 14:f5c62d30c6fc 94 //Loading values to of Test type
nidhinvarghese 14:f5c62d30c6fc 95 test_type_info test_type_info_bp; // copy of " test_type_info" created
nidhinvarghese 14:f5c62d30c6fc 96 test_type_info_bp = BP_Test; // Loaded value 00 to the test type
nidhinvarghese 14:f5c62d30c6fc 97
nidhinvarghese 14:f5c62d30c6fc 98 BLEMsg_info_bp.test_type = test_type_info_bp;
nidhinvarghese 14:f5c62d30c6fc 99 //Check if 00 is getting printed
nidhinvarghese 14:f5c62d30c6fc 100 bpr.printf("Test Type is : %d\n", test_type_info_bp);
nidhinvarghese 14:f5c62d30c6fc 101
nidhinvarghese 14:f5c62d30c6fc 102
nidhinvarghese 14:f5c62d30c6fc 103 // Loading values of Length , PID, DID, sampling frequency, number of samples, calculated data.
nidhinvarghese 14:f5c62d30c6fc 104 BLEMsg_info_bp.device_id = 01; // Device ID fixed
nidhinvarghese 14:f5c62d30c6fc 105 BLEMsg_info_bp.patient_id = (uint32_t)pid; // Patient ID
nidhinvarghese 14:f5c62d30c6fc 106 BLEMsg_info_bp.sampling_freq = 500; // sampling frrquency
nidhinvarghese 14:f5c62d30c6fc 107 BLEMsg_info_bp.length = 10774; //Total length of data in bytes 22 B+10752 B
nidhinvarghese 14:f5c62d30c6fc 108
nidhinvarghese 14:f5c62d30c6fc 109 /*
nidhinvarghese 14:f5c62d30c6fc 110 //Loading number of samples
nidhinvarghese 14:f5c62d30c6fc 111 NumSamples_info NumSamples_info_bp; //Copy of structure NumSamples_info
nidhinvarghese 14:f5c62d30c6fc 112 NumSamples_info_bp.num_ppg_sample = 1664; // PPG & ECG Sample number loaded in structure copy
nidhinvarghese 14:f5c62d30c6fc 113 NumSamples_info_bp.num_ecg_sample = 1024;
nidhinvarghese 14:f5c62d30c6fc 114 */
nidhinvarghese 14:f5c62d30c6fc 115
nidhinvarghese 14:f5c62d30c6fc 116 BLEMsg_info_bp.num_samples.num_sample_ppg_dummy = 1664 ;// PPG number of samples copied to master struct
nidhinvarghese 14:f5c62d30c6fc 117 BLEMsg_info_bp.num_samples.num_sample_ecg_OTtyp = 1024 ; // ECG number of samples copied to master struct
nidhinvarghese 14:f5c62d30c6fc 118
nidhinvarghese 14:f5c62d30c6fc 119
nidhinvarghese 14:f5c62d30c6fc 120
nidhinvarghese 14:f5c62d30c6fc 121
nidhinvarghese 8:adf2ba7e6412 122
nidhinvarghese 8:adf2ba7e6412 123 // Variables for file operations
nidhinvarghese 8:adf2ba7e6412 124 // uint32_t amax=0;
nidhinvarghese 8:adf2ba7e6412 125 //uint32_t bmax = 0;
nidhinvarghese 8:adf2ba7e6412 126 //uint32_t a;
nidhinvarghese 8:adf2ba7e6412 127 //uint32_t b;
nidhinvarghese 8:adf2ba7e6412 128
nidhinvarghese 8:adf2ba7e6412 129 //int aloc = 0;
nidhinvarghese 8:adf2ba7e6412 130 //int bloc = 0;
nidhinvarghese 8:adf2ba7e6412 131 //int samples = 0;
nidhinvarghese 8:adf2ba7e6412 132
nidhinvarghese 14:f5c62d30c6fc 133 bpr.baud(baud_rate);
nidhinvarghese 8:adf2ba7e6412 134
nidhinvarghese 8:adf2ba7e6412 135 freqset(); // setting the frequency
nidhinvarghese 8:adf2ba7e6412 136 setupfunc();
nikitateggi 20:7c64e6ecad76 137 lead_reg=ecgsetupfunc(); // lead contact // 14/06
nidhinvarghese 8:adf2ba7e6412 138
nidhinvarghese 8:adf2ba7e6412 139 maxim_max30102_reset(); // PPG reset
nidhinvarghese 8:adf2ba7e6412 140 wait_ms(20);
nidhinvarghese 8:adf2ba7e6412 141 maxim_max30102_init();
nidhinvarghese 8:adf2ba7e6412 142
nidhinvarghese 8:adf2ba7e6412 143 chk = 1;
nidhinvarghese 8:adf2ba7e6412 144
nidhinvarghese 8:adf2ba7e6412 145 wait(2);
nidhinvarghese 8:adf2ba7e6412 146 //bc.printf("BP start\n");
nidhinvarghese 8:adf2ba7e6412 147
nidhinvarghese 8:adf2ba7e6412 148 for(int i=0; i<500; i++)
nidhinvarghese 8:adf2ba7e6412 149 {
nidhinvarghese 8:adf2ba7e6412 150
nidhinvarghese 8:adf2ba7e6412 151 concatenate_value2= readvalue();
nidhinvarghese 8:adf2ba7e6412 152
nidhinvarghese 8:adf2ba7e6412 153 maxim_max30102_read_reg(0,&uch_dummy);
nidhinvarghese 8:adf2ba7e6412 154 while(INTR.read()==1);
nidhinvarghese 8:adf2ba7e6412 155 maxim_max30102_read_fifo(&ppgdata);
nidhinvarghese 8:adf2ba7e6412 156
nidhinvarghese 8:adf2ba7e6412 157 }
nikitateggi 20:7c64e6ecad76 158 // BP Finger detect Function Added Nidhin 16/6/17
nikitateggi 20:7c64e6ecad76 159 // START
nikitateggi 20:7c64e6ecad76 160 uint32_t un_max, un_min; // Declare two VARIABLE FOR MAX AND MIN
nikitateggi 20:7c64e6ecad76 161 un_max = 0;
nikitateggi 20:7c64e6ecad76 162 un_min = 0x3FFF;
nikitateggi 20:7c64e6ecad76 163
nikitateggi 20:7c64e6ecad76 164 for(int i=0; i<500; i++) // READS 500 SAMPLES TO SEE MAX AND MIN VAL DIFFERENCE
nikitateggi 20:7c64e6ecad76 165 {
nikitateggi 20:7c64e6ecad76 166 maxim_max30102_read_reg(0,&uch_dummy);
nikitateggi 20:7c64e6ecad76 167 while(INTR.read()==1);
nikitateggi 20:7c64e6ecad76 168 maxim_max30102_read_fifo(&ppgdata);
nikitateggi 21:7ef1b0b40841 169 bpr.printf("%d\n",ppgdata);
nikitateggi 20:7c64e6ecad76 170 if(un_min>ppgdata)
nikitateggi 20:7c64e6ecad76 171 un_min=ppgdata; //update signal min
nikitateggi 20:7c64e6ecad76 172 if(un_max<ppgdata)
nikitateggi 20:7c64e6ecad76 173 un_max=ppgdata;
nikitateggi 20:7c64e6ecad76 174
nikitateggi 20:7c64e6ecad76 175 }
nikitateggi 20:7c64e6ecad76 176
nikitateggi 21:7ef1b0b40841 177 bpr.printf("The max is %d\n", un_max); //
nikitateggi 21:7ef1b0b40841 178 bpr.printf("The min is %d\n", un_min);
nikitateggi 20:7c64e6ecad76 179 if (((un_max -un_min) > 300) && (lead_reg==0)) // Checking for threshold 300 Added Nidhin 16/6/17
nikitateggi 20:7c64e6ecad76 180
nikitateggi 20:7c64e6ecad76 181 { //Added Nidhin 16/6/17
nidhinvarghese 8:adf2ba7e6412 182
nidhinvarghese 14:f5c62d30c6fc 183 sd_open_BPfilee(pid);
nidhinvarghese 8:adf2ba7e6412 184 sd_open_BP_ECGfile(pid) ; // sd_open_BP_ECGfile(123) draft file for testing
nidhinvarghese 8:adf2ba7e6412 185 sd_open_BP_PPGfile(pid) ; // sd_open_BP_PPGfile(123) draft file for testing
nidhinvarghese 8:adf2ba7e6412 186
nidhinvarghese 8:adf2ba7e6412 187 FILE *ecg = NULL;
nidhinvarghese 8:adf2ba7e6412 188 FILE *ppg = NULL;
nidhinvarghese 14:f5c62d30c6fc 189 uint32_t *drum_ecg = NULL; // pointers to ecg buffer changed to uint32_t from int
nidhinvarghese 8:adf2ba7e6412 190 uint32_t *drum_ppg = NULL; // pointer to ppg buffer
nidhinvarghese 8:adf2ba7e6412 191
nidhinvarghese 8:adf2ba7e6412 192 drum_ecg = drum11;
nidhinvarghese 8:adf2ba7e6412 193 drum_ppg = drum21;
nidhinvarghese 8:adf2ba7e6412 194
nidhinvarghese 14:f5c62d30c6fc 195 for(int j =0 ; j<1; j++) // changed to 16 from 8 // Change by Nidhin 30/5/2017 Direct writing to SD card. no loop required
nidhinvarghese 8:adf2ba7e6412 196 {
nidhinvarghese 14:f5c62d30c6fc 197 for(int i=0; i<1024; i++)
nidhinvarghese 8:adf2ba7e6412 198 {
nidhinvarghese 8:adf2ba7e6412 199 concatenate_value2 = readvalue();
nidhinvarghese 14:f5c62d30c6fc 200 //drum11[i]=(uint32_t)concatenate_value2; //drum11[i]=concatenate_value2; drum11[i]=dummyconcat; typecasted to uint32_t
nidhinvarghese 14:f5c62d30c6fc 201 //Change by Nidhin 30/5/2017 Direct writing to SD card.
nidhinvarghese 15:208b146151ba 202 ecg = sd_BP_ecgwrite(&concatenate_value2);
nidhinvarghese 14:f5c62d30c6fc 203
nidhinvarghese 8:adf2ba7e6412 204 maxim_max30102_read_reg(0,&uch_dummy);
nidhinvarghese 8:adf2ba7e6412 205 while(INTR.read()==1);
nidhinvarghese 8:adf2ba7e6412 206 maxim_max30102_read_fifo(&ppgdata);
nidhinvarghese 14:f5c62d30c6fc 207 ppg = sd_BP_ppgwrite(&ppgdata); //Change by Nidhin 30/5/2017 Direct writing to SD card.
nidhinvarghese 14:f5c62d30c6fc 208 //drum21[i]=ppgdata; //Change by Nidhin 30/5/2017 Direct writing to SD card.
nidhinvarghese 8:adf2ba7e6412 209 }
nidhinvarghese 8:adf2ba7e6412 210
nidhinvarghese 14:f5c62d30c6fc 211 //ecg = sd_BP_ecgwrite(drum_ecg); // //Change by Nidhin 30/5/2017 Direct writing to SD card.
nidhinvarghese 14:f5c62d30c6fc 212 //ppg = sd_BP_ppgwrite(drum_ppg); // //Change by Nidhin 30/5/2017 Direct writing to SD card.
nidhinvarghese 8:adf2ba7e6412 213
nidhinvarghese 8:adf2ba7e6412 214
nidhinvarghese 8:adf2ba7e6412 215 }
nidhinvarghese 8:adf2ba7e6412 216
nidhinvarghese 14:f5c62d30c6fc 217 for(int j =0 ; j<1; j++) // changed to 16 from 8
nidhinvarghese 8:adf2ba7e6412 218 {
nidhinvarghese 14:f5c62d30c6fc 219 for(int i=0; i<640; i++)
nidhinvarghese 8:adf2ba7e6412 220 {
nidhinvarghese 8:adf2ba7e6412 221 maxim_max30102_read_reg(0,&uch_dummy);
nidhinvarghese 8:adf2ba7e6412 222 while(INTR.read()==1);
nidhinvarghese 8:adf2ba7e6412 223 maxim_max30102_read_fifo(&ppgdata);
nidhinvarghese 14:f5c62d30c6fc 224 //drum21[i]=ppgdata;
nidhinvarghese 14:f5c62d30c6fc 225 ppg = sd_BP_ppgwrite (&ppgdata); //Change by Nidhin 30/5/2017 Direct writing to SD card.
nidhinvarghese 8:adf2ba7e6412 226 }
nidhinvarghese 8:adf2ba7e6412 227
nidhinvarghese 14:f5c62d30c6fc 228
nidhinvarghese 8:adf2ba7e6412 229
nidhinvarghese 8:adf2ba7e6412 230 }
nidhinvarghese 8:adf2ba7e6412 231 fclose(ecg);
nidhinvarghese 8:adf2ba7e6412 232 fclose(ppg);
nidhinvarghese 8:adf2ba7e6412 233
nidhinvarghese 8:adf2ba7e6412 234 maxim_max30102_reset();
nidhinvarghese 8:adf2ba7e6412 235
nidhinvarghese 8:adf2ba7e6412 236 //-----Reading from file starts //
nidhinvarghese 8:adf2ba7e6412 237
nidhinvarghese 8:adf2ba7e6412 238 //std::ifstream ec1("/sd/123_BP_ECG.csv");
nidhinvarghese 8:adf2ba7e6412 239 //std::ifstream pp1("/sd/123_BP_PPG.csv");
nidhinvarghese 8:adf2ba7e6412 240
nidhinvarghese 8:adf2ba7e6412 241 int eloc = 0;
nidhinvarghese 8:adf2ba7e6412 242 int ploc = 0;
nidhinvarghese 8:adf2ba7e6412 243
nidhinvarghese 8:adf2ba7e6412 244
nidhinvarghese 8:adf2ba7e6412 245 eloc = sd_BP_ECGMAX(pid); // eloc = sd_BP_ECGMAX(123);
nidhinvarghese 8:adf2ba7e6412 246 ploc = sd_BP_PPGMAX(pid); // ploc = sd_BP_PPGMAX(123);
nidhinvarghese 8:adf2ba7e6412 247
nidhinvarghese 8:adf2ba7e6412 248 //bc.printf("The ECG max is at : %d", eloc);
nidhinvarghese 8:adf2ba7e6412 249 //bc.printf("The PPG Max is at : %d", ploc);
nidhinvarghese 8:adf2ba7e6412 250
nidhinvarghese 8:adf2ba7e6412 251 float PWV = 0;
nidhinvarghese 8:adf2ba7e6412 252 int d = 210000;
nidhinvarghese 8:adf2ba7e6412 253 int delta_t = 0;
nidhinvarghese 8:adf2ba7e6412 254 float SBP = 0;
nidhinvarghese 8:adf2ba7e6412 255 float DBP = 0;
nidhinvarghese 8:adf2ba7e6412 256
nidhinvarghese 8:adf2ba7e6412 257 delta_t = (2*(ploc - eloc));
nidhinvarghese 8:adf2ba7e6412 258 PWV = d/delta_t;
nidhinvarghese 8:adf2ba7e6412 259
nidhinvarghese 8:adf2ba7e6412 260 SBP = 0.0508955*PWV+62.559;
nidhinvarghese 8:adf2ba7e6412 261 DBP = (0.0494*PWV + 17.480)+10;
nidhinvarghese 8:adf2ba7e6412 262
nidhinvarghese 14:f5c62d30c6fc 263 /*
nidhinvarghese 14:f5c62d30c6fc 264 //Copying to Structure starts
nidhinvarghese 14:f5c62d30c6fc 265 CalData_info CalData_info_bp;
nidhinvarghese 14:f5c62d30c6fc 266 CalData_info_bp.cal_sbp = (uint16_t) SBP;
nidhinvarghese 14:f5c62d30c6fc 267 CalData_info_bp.cal_dbp = (uint16_t) DBP; NOT REQUIRED
nidhinvarghese 14:f5c62d30c6fc 268 */
nidhinvarghese 14:f5c62d30c6fc 269
nidhinvarghese 14:f5c62d30c6fc 270 BLEMsg_info_bp.cal_data.cal_sbp_dummy = (uint16_t) SBP;
nidhinvarghese 14:f5c62d30c6fc 271 BLEMsg_info_bp.cal_data.cal_dbp_OTtyp = (uint16_t) DBP;
nidhinvarghese 14:f5c62d30c6fc 272
nikitateggi 31:0f67acfc6236 273 if((SBP>190 || SBP<70) && (DBP>100 || DBP<40)) // checking for range below and above and then displaying error
nikitateggi 31:0f67acfc6236 274 {
nikitateggi 31:0f67acfc6236 275 screen_bp_error(); // checking for error out of range- nikita 10-7-17
nikitateggi 31:0f67acfc6236 276
nikitateggi 31:0f67acfc6236 277 }
nidhinvarghese 14:f5c62d30c6fc 278
nikitateggi 31:0f67acfc6236 279 else
nikitateggi 31:0f67acfc6236 280 {
nidhinvarghese 14:f5c62d30c6fc 281
nikitateggi 31:0f67acfc6236 282 create_single_BPfile(pid); // Copy ECG and PPG data to BP file
nikitateggi 31:0f67acfc6236 283 structure_file(ptr_BLEMsg_info_bp, pid); // Copy BP structure to main file
nikitateggi 31:0f67acfc6236 284 bpfile_mainfile(pid);
nikitateggi 31:0f67acfc6236 285
nikitateggi 31:0f67acfc6236 286 screen_bp1(SBP,DBP);
nikitateggi 31:0f67acfc6236 287 }
nikitateggi 20:7c64e6ecad76 288 } //Added Nidhin 16/6/17
nikitateggi 20:7c64e6ecad76 289
nikitateggi 20:7c64e6ecad76 290 else //Added Nidhin 16/6/17
nikitateggi 20:7c64e6ecad76 291 { //Added Nidhin 16/6/17
nikitateggi 20:7c64e6ecad76 292 // Add display sequence for Finger detect fail //Added Nidhin 16/6/17
nikitateggi 20:7c64e6ecad76 293 maxim_max30102_reset();
nikitateggi 20:7c64e6ecad76 294 bpr.printf("no finger detect\n");
nikitateggi 20:7c64e6ecad76 295 screen_ecg_lead_bp_fingerdetect();
nikitateggi 20:7c64e6ecad76 296 } //Added Nidhin 16/6/17
nikitateggi 20:7c64e6ecad76 297 screen_ecg_bp() ;
nidhinvarghese 14:f5c62d30c6fc 298 // Only for testing
nikitateggi 20:7c64e6ecad76 299 //} //Commented Nidhin 16/6/17
nikitateggi 20:7c64e6ecad76 300 }