Changes done in ECG and BT
Dependencies: SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217
Fork of merged_code2_20sept_2017_4th_oct_2017 by
bp.cpp@20:7c64e6ecad76, 2017-06-17 (annotated)
- Committer:
- nikitateggi
- Date:
- Sat Jun 17 09:36:18 2017 +0000
- Revision:
- 20:7c64e6ecad76
- Parent:
- 19:1650bbc923cc
- Child:
- 21:7ef1b0b40841
poc code with finger detect and leadoff
Who changed what in which revision?
User | Revision | Line number | New 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 | |
nidhinvarghese | 14:f5c62d30c6fc | 36 | void bp(int 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 | 20:7c64e6ecad76 | 169 | |
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 | 20:7c64e6ecad76 | 177 | if (((un_max -un_min) > 300) && (lead_reg==0)) // Checking for threshold 300 Added Nidhin 16/6/17 |
nikitateggi | 20:7c64e6ecad76 | 178 | |
nikitateggi | 20:7c64e6ecad76 | 179 | { //Added Nidhin 16/6/17 |
nidhinvarghese | 8:adf2ba7e6412 | 180 | |
nidhinvarghese | 14:f5c62d30c6fc | 181 | sd_open_BPfilee(pid); |
nidhinvarghese | 8:adf2ba7e6412 | 182 | sd_open_BP_ECGfile(pid) ; // sd_open_BP_ECGfile(123) draft file for testing |
nidhinvarghese | 8:adf2ba7e6412 | 183 | sd_open_BP_PPGfile(pid) ; // sd_open_BP_PPGfile(123) draft file for testing |
nidhinvarghese | 8:adf2ba7e6412 | 184 | |
nidhinvarghese | 8:adf2ba7e6412 | 185 | FILE *ecg = NULL; |
nidhinvarghese | 8:adf2ba7e6412 | 186 | FILE *ppg = NULL; |
nidhinvarghese | 14:f5c62d30c6fc | 187 | uint32_t *drum_ecg = NULL; // pointers to ecg buffer changed to uint32_t from int |
nidhinvarghese | 8:adf2ba7e6412 | 188 | uint32_t *drum_ppg = NULL; // pointer to ppg buffer |
nidhinvarghese | 8:adf2ba7e6412 | 189 | |
nidhinvarghese | 8:adf2ba7e6412 | 190 | drum_ecg = drum11; |
nidhinvarghese | 8:adf2ba7e6412 | 191 | drum_ppg = drum21; |
nidhinvarghese | 8:adf2ba7e6412 | 192 | |
nidhinvarghese | 14:f5c62d30c6fc | 193 | 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 | 194 | { |
nidhinvarghese | 14:f5c62d30c6fc | 195 | for(int i=0; i<1024; i++) |
nidhinvarghese | 8:adf2ba7e6412 | 196 | { |
nidhinvarghese | 8:adf2ba7e6412 | 197 | concatenate_value2 = readvalue(); |
nidhinvarghese | 14:f5c62d30c6fc | 198 | //drum11[i]=(uint32_t)concatenate_value2; //drum11[i]=concatenate_value2; drum11[i]=dummyconcat; typecasted to uint32_t |
nidhinvarghese | 14:f5c62d30c6fc | 199 | //Change by Nidhin 30/5/2017 Direct writing to SD card. |
nidhinvarghese | 15:208b146151ba | 200 | ecg = sd_BP_ecgwrite(&concatenate_value2); |
nidhinvarghese | 14:f5c62d30c6fc | 201 | |
nidhinvarghese | 8:adf2ba7e6412 | 202 | maxim_max30102_read_reg(0,&uch_dummy); |
nidhinvarghese | 8:adf2ba7e6412 | 203 | while(INTR.read()==1); |
nidhinvarghese | 8:adf2ba7e6412 | 204 | maxim_max30102_read_fifo(&ppgdata); |
nidhinvarghese | 14:f5c62d30c6fc | 205 | ppg = sd_BP_ppgwrite(&ppgdata); //Change by Nidhin 30/5/2017 Direct writing to SD card. |
nidhinvarghese | 14:f5c62d30c6fc | 206 | //drum21[i]=ppgdata; //Change by Nidhin 30/5/2017 Direct writing to SD card. |
nidhinvarghese | 8:adf2ba7e6412 | 207 | } |
nidhinvarghese | 8:adf2ba7e6412 | 208 | |
nidhinvarghese | 14:f5c62d30c6fc | 209 | //ecg = sd_BP_ecgwrite(drum_ecg); // //Change by Nidhin 30/5/2017 Direct writing to SD card. |
nidhinvarghese | 14:f5c62d30c6fc | 210 | //ppg = sd_BP_ppgwrite(drum_ppg); // //Change by Nidhin 30/5/2017 Direct writing to SD card. |
nidhinvarghese | 8:adf2ba7e6412 | 211 | |
nidhinvarghese | 8:adf2ba7e6412 | 212 | |
nidhinvarghese | 8:adf2ba7e6412 | 213 | } |
nidhinvarghese | 8:adf2ba7e6412 | 214 | |
nidhinvarghese | 14:f5c62d30c6fc | 215 | for(int j =0 ; j<1; j++) // changed to 16 from 8 |
nidhinvarghese | 8:adf2ba7e6412 | 216 | { |
nidhinvarghese | 14:f5c62d30c6fc | 217 | for(int i=0; i<640; i++) |
nidhinvarghese | 8:adf2ba7e6412 | 218 | { |
nidhinvarghese | 8:adf2ba7e6412 | 219 | maxim_max30102_read_reg(0,&uch_dummy); |
nidhinvarghese | 8:adf2ba7e6412 | 220 | while(INTR.read()==1); |
nidhinvarghese | 8:adf2ba7e6412 | 221 | maxim_max30102_read_fifo(&ppgdata); |
nidhinvarghese | 14:f5c62d30c6fc | 222 | //drum21[i]=ppgdata; |
nidhinvarghese | 14:f5c62d30c6fc | 223 | ppg = sd_BP_ppgwrite (&ppgdata); //Change by Nidhin 30/5/2017 Direct writing to SD card. |
nidhinvarghese | 8:adf2ba7e6412 | 224 | } |
nidhinvarghese | 8:adf2ba7e6412 | 225 | |
nidhinvarghese | 14:f5c62d30c6fc | 226 | |
nidhinvarghese | 8:adf2ba7e6412 | 227 | |
nidhinvarghese | 8:adf2ba7e6412 | 228 | } |
nidhinvarghese | 8:adf2ba7e6412 | 229 | fclose(ecg); |
nidhinvarghese | 8:adf2ba7e6412 | 230 | fclose(ppg); |
nidhinvarghese | 8:adf2ba7e6412 | 231 | |
nidhinvarghese | 8:adf2ba7e6412 | 232 | maxim_max30102_reset(); |
nidhinvarghese | 8:adf2ba7e6412 | 233 | |
nidhinvarghese | 8:adf2ba7e6412 | 234 | //-----Reading from file starts // |
nidhinvarghese | 8:adf2ba7e6412 | 235 | |
nidhinvarghese | 8:adf2ba7e6412 | 236 | //std::ifstream ec1("/sd/123_BP_ECG.csv"); |
nidhinvarghese | 8:adf2ba7e6412 | 237 | //std::ifstream pp1("/sd/123_BP_PPG.csv"); |
nidhinvarghese | 8:adf2ba7e6412 | 238 | |
nidhinvarghese | 8:adf2ba7e6412 | 239 | int eloc = 0; |
nidhinvarghese | 8:adf2ba7e6412 | 240 | int ploc = 0; |
nidhinvarghese | 8:adf2ba7e6412 | 241 | |
nidhinvarghese | 8:adf2ba7e6412 | 242 | |
nidhinvarghese | 8:adf2ba7e6412 | 243 | eloc = sd_BP_ECGMAX(pid); // eloc = sd_BP_ECGMAX(123); |
nidhinvarghese | 8:adf2ba7e6412 | 244 | ploc = sd_BP_PPGMAX(pid); // ploc = sd_BP_PPGMAX(123); |
nidhinvarghese | 8:adf2ba7e6412 | 245 | |
nidhinvarghese | 8:adf2ba7e6412 | 246 | //bc.printf("The ECG max is at : %d", eloc); |
nidhinvarghese | 8:adf2ba7e6412 | 247 | //bc.printf("The PPG Max is at : %d", ploc); |
nidhinvarghese | 8:adf2ba7e6412 | 248 | |
nidhinvarghese | 8:adf2ba7e6412 | 249 | float PWV = 0; |
nidhinvarghese | 8:adf2ba7e6412 | 250 | int d = 210000; |
nidhinvarghese | 8:adf2ba7e6412 | 251 | int delta_t = 0; |
nidhinvarghese | 8:adf2ba7e6412 | 252 | float SBP = 0; |
nidhinvarghese | 8:adf2ba7e6412 | 253 | float DBP = 0; |
nidhinvarghese | 8:adf2ba7e6412 | 254 | |
nidhinvarghese | 8:adf2ba7e6412 | 255 | delta_t = (2*(ploc - eloc)); |
nidhinvarghese | 8:adf2ba7e6412 | 256 | PWV = d/delta_t; |
nidhinvarghese | 8:adf2ba7e6412 | 257 | |
nidhinvarghese | 8:adf2ba7e6412 | 258 | SBP = 0.0508955*PWV+62.559; |
nidhinvarghese | 8:adf2ba7e6412 | 259 | DBP = (0.0494*PWV + 17.480)+10; |
nidhinvarghese | 8:adf2ba7e6412 | 260 | |
nidhinvarghese | 14:f5c62d30c6fc | 261 | /* |
nidhinvarghese | 14:f5c62d30c6fc | 262 | //Copying to Structure starts |
nidhinvarghese | 14:f5c62d30c6fc | 263 | CalData_info CalData_info_bp; |
nidhinvarghese | 14:f5c62d30c6fc | 264 | CalData_info_bp.cal_sbp = (uint16_t) SBP; |
nidhinvarghese | 14:f5c62d30c6fc | 265 | CalData_info_bp.cal_dbp = (uint16_t) DBP; NOT REQUIRED |
nidhinvarghese | 14:f5c62d30c6fc | 266 | */ |
nidhinvarghese | 14:f5c62d30c6fc | 267 | |
nidhinvarghese | 14:f5c62d30c6fc | 268 | BLEMsg_info_bp.cal_data.cal_sbp_dummy = (uint16_t) SBP; |
nidhinvarghese | 14:f5c62d30c6fc | 269 | BLEMsg_info_bp.cal_data.cal_dbp_OTtyp = (uint16_t) DBP; |
nidhinvarghese | 14:f5c62d30c6fc | 270 | |
nidhinvarghese | 14:f5c62d30c6fc | 271 | |
nidhinvarghese | 14:f5c62d30c6fc | 272 | |
nidhinvarghese | 14:f5c62d30c6fc | 273 | create_single_BPfile(pid); // Copy ECG and PPG data to BP file |
nidhinvarghese | 14:f5c62d30c6fc | 274 | structure_file(ptr_BLEMsg_info_bp, pid); // Copy BP structure to main file |
nidhinvarghese | 14:f5c62d30c6fc | 275 | bpfile_mainfile(pid); |
nidhinvarghese | 14:f5c62d30c6fc | 276 | |
nidhinvarghese | 8:adf2ba7e6412 | 277 | screen_bp1(SBP,DBP); |
nikitateggi | 20:7c64e6ecad76 | 278 | |
nikitateggi | 20:7c64e6ecad76 | 279 | } //Added Nidhin 16/6/17 |
nikitateggi | 20:7c64e6ecad76 | 280 | |
nikitateggi | 20:7c64e6ecad76 | 281 | else //Added Nidhin 16/6/17 |
nikitateggi | 20:7c64e6ecad76 | 282 | { //Added Nidhin 16/6/17 |
nikitateggi | 20:7c64e6ecad76 | 283 | // Add display sequence for Finger detect fail //Added Nidhin 16/6/17 |
nikitateggi | 20:7c64e6ecad76 | 284 | maxim_max30102_reset(); |
nikitateggi | 20:7c64e6ecad76 | 285 | bpr.printf("no finger detect\n"); |
nikitateggi | 20:7c64e6ecad76 | 286 | screen_ecg_lead_bp_fingerdetect(); |
nikitateggi | 20:7c64e6ecad76 | 287 | } //Added Nidhin 16/6/17 |
nikitateggi | 20:7c64e6ecad76 | 288 | screen_ecg_bp() ; |
nidhinvarghese | 14:f5c62d30c6fc | 289 | // Only for testing |
nikitateggi | 20:7c64e6ecad76 | 290 | //} //Commented Nidhin 16/6/17 |
nikitateggi | 20:7c64e6ecad76 | 291 | } |