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:
rashmivenkataramaiah
Date:
Mon Sep 11 10:02:46 2017 +0000
Revision:
42:c81673b04b6a
Parent:
41:1141a75eacc4
Child:
43:85a7f399cb9d
PID tracking with getpid, store pid

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nikitateggi 19:1650bbc923cc 1 // changed the pid in all to int32_t;
nikitateggi 19:1650bbc923cc 2 //added bt
nikitateggi 19:1650bbc923cc 3
nikitateggi 0:c47fb0c1bbf6 4 #include "mbed.h"
nikitateggi 0:c47fb0c1bbf6 5 #include "display_modules.h"
nikitateggi 0:c47fb0c1bbf6 6 #include "touch_modules.h"
nikitateggi 1:8316c23ec6b9 7 #include "ecg_dec.h"
nikitateggi 1:8316c23ec6b9 8 #include "touch_modules.h"
nikitateggi 1:8316c23ec6b9 9 #include "glc.h"
nikitateggi 3:9a06c2bed650 10 #include "bp.h"
nikitateggi 1:8316c23ec6b9 11 #include "sdcard.h"
nikitateggi 4:6bd81bb1790d 12 #include "eeprom_pgm.h"
nikitateggi 19:1650bbc923cc 13 #include "struct.h"
nikitateggi 22:ffa88619551d 14 #include "battery.h"
rashmivenkataramaiah 41:1141a75eacc4 15 #include "main.h"
nikitateggi 24:d992ee8369f4 16
nikitateggi 0:c47fb0c1bbf6 17 Serial gc(USBTX, USBRX);
nikitateggi 0:c47fb0c1bbf6 18 DigitalIn q1(PTB11);
nikitateggi 29:7edc76b15e3d 19 DigitalIn q(PTC5);
nikitateggi 29:7edc76b15e3d 20 DigitalIn q3(PTC12);
rashmivenkataramaiah 42:c81673b04b6a 21 DigitalIn BT(PTA5);
rashmivenkataramaiah 42:c81673b04b6a 22 //bluetooth status pin
rashmivenkataramaiah 42:c81673b04b6a 23 uint8_t touch(uint8_t state); // touch state
rashmivenkataramaiah 42:c81673b04b6a 24 uint8_t display(uint8_t state1); // display state
rashmivenkataramaiah 42:c81673b04b6a 25 static uint8_t nstate=0;
rashmivenkataramaiah 42:c81673b04b6a 26 static uint8_t nstate1=0;
rashmivenkataramaiah 42:c81673b04b6a 27 static uint32_t current_test_pid=0;
rashmivenkataramaiah 42:c81673b04b6a 28 static uint32_t bt_file_sent_pid=0;
rashmivenkataramaiah 42:c81673b04b6a 29 uint32_t pid = 0; // patient ID
rashmivenkataramaiah 42:c81673b04b6a 30 bool file_created_status = false; //initialise file created to 0
rashmivenkataramaiah 42:c81673b04b6a 31 static uint32_t pid_btpid[2];
rashmivenkataramaiah 42:c81673b04b6a 32 uint32_t filepid_btpid[2] = {};
nikitateggi 0:c47fb0c1bbf6 33
rashmivenkataramaiah 41:1141a75eacc4 34 int main()
rashmivenkataramaiah 41:1141a75eacc4 35 {
rashmivenkataramaiah 41:1141a75eacc4 36 static uint8_t main_state=1;
rashmivenkataramaiah 41:1141a75eacc4 37 static uint8_t state_display = 0;
rashmivenkataramaiah 41:1141a75eacc4 38 static uint8_t state_touch = 1;
rashmivenkataramaiah 41:1141a75eacc4 39 static uint8_t state_t = 1; // state to transmit to bluetooth
rashmivenkataramaiah 41:1141a75eacc4 40 static uint8_t state_r = 0; // state to receive from bluetooth
rashmivenkataramaiah 41:1141a75eacc4 41 uint8_t battery_voltage_condition = 0;
avp2417 37:92fcbf22bf91 42
avp2417 37:92fcbf22bf91 43
rashmivenkataramaiah 41:1141a75eacc4 44 DisableTouch();
rashmivenkataramaiah 41:1141a75eacc4 45 gc.baud(115200);
rashmivenkataramaiah 41:1141a75eacc4 46 init_screen(); //initialize lcd
rashmivenkataramaiah 42:c81673b04b6a 47 //sd_read(pid_btpid); //read test pid and bt pid from sd card
rashmivenkataramaiah 42:c81673b04b6a 48 //pid = pid_btpid[0]; //copy test pid to pid variable
rashmivenkataramaiah 42:c81673b04b6a 49 pid = get_filepid();
rashmivenkataramaiah 41:1141a75eacc4 50 screen_main(); // display of main screen
avp2417 37:92fcbf22bf91 51
avp2417 37:92fcbf22bf91 52
nikitateggi 0:c47fb0c1bbf6 53 while(1)
nikitateggi 0:c47fb0c1bbf6 54 {
avp2417 37:92fcbf22bf91 55
avp2417 37:92fcbf22bf91 56 EnableTouch();
rashmivenkataramaiah 41:1141a75eacc4 57 switch(main_state) // main state machine
nikitateggi 19:1650bbc923cc 58 {
rashmivenkataramaiah 41:1141a75eacc4 59 case 1:
rashmivenkataramaiah 41:1141a75eacc4 60 state_display = touch(state_touch); // touch state
rashmivenkataramaiah 41:1141a75eacc4 61 if(state_display == 12)
rashmivenkataramaiah 41:1141a75eacc4 62 main_state = 3;
rashmivenkataramaiah 41:1141a75eacc4 63 else
rashmivenkataramaiah 41:1141a75eacc4 64 main_state = 2;
rashmivenkataramaiah 41:1141a75eacc4 65 break;
nikitateggi 19:1650bbc923cc 66
rashmivenkataramaiah 41:1141a75eacc4 67 case 2:
rashmivenkataramaiah 41:1141a75eacc4 68 state_touch = display(state_display); //display state
rashmivenkataramaiah 41:1141a75eacc4 69 main_state = 1;
nikitateggi 22:ffa88619551d 70 break;
nikitateggi 19:1650bbc923cc 71
nikitateggi 19:1650bbc923cc 72
rashmivenkataramaiah 41:1141a75eacc4 73 case 3:
rashmivenkataramaiah 41:1141a75eacc4 74 DisableTouch(); // bluetooth send
rashmivenkataramaiah 41:1141a75eacc4 75 if(BT==1)
rashmivenkataramaiah 41:1141a75eacc4 76 {
rashmivenkataramaiah 41:1141a75eacc4 77 BT_connection() ; // displaying connection on bluetooth
rashmivenkataramaiah 41:1141a75eacc4 78 state_r=bt_send(state_t);
rashmivenkataramaiah 41:1141a75eacc4 79 main_state=4;
rashmivenkataramaiah 41:1141a75eacc4 80 }
rashmivenkataramaiah 41:1141a75eacc4 81 else
rashmivenkataramaiah 41:1141a75eacc4 82 BT_no_connection();
rashmivenkataramaiah 41:1141a75eacc4 83
rashmivenkataramaiah 41:1141a75eacc4 84 break;
nikitateggi 19:1650bbc923cc 85
nikitateggi 39:69b09bd87502 86 case 4: DisableTouch();
rashmivenkataramaiah 41:1141a75eacc4 87 state_t=bt_receive(state_r); // bluetooth receive
nikitateggi 19:1650bbc923cc 88 main_state=3;
nikitateggi 19:1650bbc923cc 89 if(state_t ==0)
nikitateggi 19:1650bbc923cc 90 {
nikitateggi 31:0f67acfc6236 91 BT_finished();
nikitateggi 31:0f67acfc6236 92 screen_BT_return();
nikitateggi 19:1650bbc923cc 93 EnableTouch();
nikitateggi 19:1650bbc923cc 94 main_state=1;
rashmivenkataramaiah 41:1141a75eacc4 95 state_touch=12; // jumping to touch case 12
nikitateggi 19:1650bbc923cc 96 }
nikitateggi 19:1650bbc923cc 97 break;
avp2417 37:92fcbf22bf91 98 }
nikitateggi 19:1650bbc923cc 99
nikitateggi 19:1650bbc923cc 100 }
nikitateggi 22:ffa88619551d 101 }
nikitateggi 19:1650bbc923cc 102
nikitateggi 19:1650bbc923cc 103 uint8_t touch(uint8_t state)
nikitateggi 19:1650bbc923cc 104 {
nikitateggi 19:1650bbc923cc 105 static uint8_t state1=0;
rashmivenkataramaiah 41:1141a75eacc4 106 detect_touch(state); // determine the touch points
nikitateggi 1:8316c23ec6b9 107
rashmivenkataramaiah 41:1141a75eacc4 108 switch(state) // state for touch
nikitateggi 0:c47fb0c1bbf6 109 {
rashmivenkataramaiah 41:1141a75eacc4 110 case 1:
rashmivenkataramaiah 41:1141a75eacc4 111 state1=touch_main(); // determining the touch for main screen
nikitateggi 0:c47fb0c1bbf6 112 state=0;
nikitateggi 1:8316c23ec6b9 113 nstate1=state1;
rashmivenkataramaiah 41:1141a75eacc4 114 break;
nikitateggi 0:c47fb0c1bbf6 115
nikitateggi 0:c47fb0c1bbf6 116 case 2:
rashmivenkataramaiah 41:1141a75eacc4 117 state1=touch_main_1(); // determining the touch for SYSTEM CONFIGURATION screen
nikitateggi 0:c47fb0c1bbf6 118 state=0;
nikitateggi 3:9a06c2bed650 119 nstate1=state1;
nikitateggi 0:c47fb0c1bbf6 120 break;
nikitateggi 0:c47fb0c1bbf6 121
nikitateggi 0:c47fb0c1bbf6 122 case 3:
rashmivenkataramaiah 41:1141a75eacc4 123 state1=touch_main_2(); // determining the touch for TEST screen
nikitateggi 0:c47fb0c1bbf6 124 state=0;
nikitateggi 1:8316c23ec6b9 125 nstate1=state1;
nikitateggi 0:c47fb0c1bbf6 126 break;
nikitateggi 0:c47fb0c1bbf6 127
nikitateggi 0:c47fb0c1bbf6 128 case 4:
rashmivenkataramaiah 41:1141a75eacc4 129 state1=touch_glc(); // determining the touch for GLC screen
nikitateggi 1:8316c23ec6b9 130 state=0;
nikitateggi 1:8316c23ec6b9 131 nstate1=state1;
nikitateggi 1:8316c23ec6b9 132 break;
nikitateggi 1:8316c23ec6b9 133
nikitateggi 1:8316c23ec6b9 134 case 5:
rashmivenkataramaiah 41:1141a75eacc4 135 state1=touch_ecg(); // determining the touch for ECG screen
nikitateggi 1:8316c23ec6b9 136 state=0;
nikitateggi 3:9a06c2bed650 137 nstate1=state1;
nikitateggi 3:9a06c2bed650 138 break;
nikitateggi 4:6bd81bb1790d 139 case 6:
rashmivenkataramaiah 41:1141a75eacc4 140 state1=touch_ret(); // determining the touch for returning back to the main screen
nikitateggi 0:c47fb0c1bbf6 141 state=0;
nikitateggi 3:9a06c2bed650 142 nstate1=state1;
nikitateggi 1:8316c23ec6b9 143 break;
nikitateggi 1:8316c23ec6b9 144
nikitateggi 4:6bd81bb1790d 145 case 7:
rashmivenkataramaiah 41:1141a75eacc4 146 state1=touch_again_ecg(); // determining the touch when readings are taken more than once screen
nikitateggi 1:8316c23ec6b9 147 state=0;
nikitateggi 1:8316c23ec6b9 148 nstate1=state1;
nikitateggi 1:8316c23ec6b9 149 break;
nikitateggi 0:c47fb0c1bbf6 150
nikitateggi 3:9a06c2bed650 151 case 8:
rashmivenkataramaiah 41:1141a75eacc4 152 state1=touch_bp(); // determining the touch for BP screen
nikitateggi 3:9a06c2bed650 153 state=0;
nikitateggi 3:9a06c2bed650 154 nstate1=state1;
nikitateggi 3:9a06c2bed650 155 break;
nikitateggi 3:9a06c2bed650 156
rashmivenkataramaiah 41:1141a75eacc4 157 case 9:
rashmivenkataramaiah 41:1141a75eacc4 158 state1=touch_again_glc();
suhasini 5:a3ea7c82b7e1 159 state=0;
suhasini 5:a3ea7c82b7e1 160 nstate1=state1;
suhasini 5:a3ea7c82b7e1 161 break;
nikitateggi 3:9a06c2bed650 162
rashmivenkataramaiah 41:1141a75eacc4 163 case 10 :
rashmivenkataramaiah 41:1141a75eacc4 164 DisableTouch();
rashmivenkataramaiah 41:1141a75eacc4 165 wait_ms(300);
rashmivenkataramaiah 41:1141a75eacc4 166 EnableTouch();
rashmivenkataramaiah 41:1141a75eacc4 167 state=nstate;
rashmivenkataramaiah 41:1141a75eacc4 168 break;
suhasini 5:a3ea7c82b7e1 169
suhasini 5:a3ea7c82b7e1 170
rashmivenkataramaiah 41:1141a75eacc4 171 case 11:
rashmivenkataramaiah 41:1141a75eacc4 172 state1=touch_again_bp();
rashmivenkataramaiah 41:1141a75eacc4 173 state=0;
rashmivenkataramaiah 41:1141a75eacc4 174 nstate1=state1;
rashmivenkataramaiah 41:1141a75eacc4 175 break;
suhasini 5:a3ea7c82b7e1 176
rashmivenkataramaiah 41:1141a75eacc4 177 case 12:
rashmivenkataramaiah 41:1141a75eacc4 178 state1=BT_return();
rashmivenkataramaiah 41:1141a75eacc4 179 state=0;
rashmivenkataramaiah 41:1141a75eacc4 180 nstate1=state1;
rashmivenkataramaiah 41:1141a75eacc4 181 break;
suhasini 5:a3ea7c82b7e1 182
rashmivenkataramaiah 41:1141a75eacc4 183 default :
rashmivenkataramaiah 41:1141a75eacc4 184 DisableTouch();
rashmivenkataramaiah 41:1141a75eacc4 185 wait_ms(300);
rashmivenkataramaiah 41:1141a75eacc4 186 EnableTouch();
rashmivenkataramaiah 41:1141a75eacc4 187 state=nstate;
rashmivenkataramaiah 41:1141a75eacc4 188 break;
nikitateggi 1:8316c23ec6b9 189
nikitateggi 0:c47fb0c1bbf6 190 }
nikitateggi 0:c47fb0c1bbf6 191
rashmivenkataramaiah 41:1141a75eacc4 192 return state1;
rashmivenkataramaiah 41:1141a75eacc4 193 }
nikitateggi 0:c47fb0c1bbf6 194
nikitateggi 0:c47fb0c1bbf6 195
nikitateggi 19:1650bbc923cc 196 uint8_t display(uint8_t state1)
nikitateggi 19:1650bbc923cc 197 {
rashmivenkataramaiah 41:1141a75eacc4 198 static uint8_t state=0;
rashmivenkataramaiah 41:1141a75eacc4 199 static uint8_t ecg_flag=0; // ecg_flag to indicate the ecg test is already done for the same pid
rashmivenkataramaiah 41:1141a75eacc4 200 static uint8_t glc_flag=0; // glc_flag to indicate the glc test is already done for the same pid
rashmivenkataramaiah 41:1141a75eacc4 201 uint16_t heart_rate=0;
rashmivenkataramaiah 41:1141a75eacc4 202
rashmivenkataramaiah 41:1141a75eacc4 203
rashmivenkataramaiah 41:1141a75eacc4 204 switch(state1) // state for display screens
rashmivenkataramaiah 41:1141a75eacc4 205 {
nikitateggi 4:6bd81bb1790d 206
nikitateggi 1:8316c23ec6b9 207
rashmivenkataramaiah 41:1141a75eacc4 208 case 1:
rashmivenkataramaiah 41:1141a75eacc4 209 DisableTouch();
rashmivenkataramaiah 41:1141a75eacc4 210 screen_main(); // main screen
nikitateggi 1:8316c23ec6b9 211 state1=0;
nikitateggi 1:8316c23ec6b9 212 state=1;
nikitateggi 1:8316c23ec6b9 213 nstate=state;
rashmivenkataramaiah 41:1141a75eacc4 214 ecg_flag=0; // ecg, glc flag to determine whether the readings are taken more than once
nikitateggi 1:8316c23ec6b9 215 glc_flag=0;
rashmivenkataramaiah 41:1141a75eacc4 216 clear_filecreated_status();
rashmivenkataramaiah 42:c81673b04b6a 217 pid = get_filepid();
nikitateggi 3:9a06c2bed650 218 EnableTouch();
nikitateggi 1:8316c23ec6b9 219 break;
nikitateggi 1:8316c23ec6b9 220
rashmivenkataramaiah 41:1141a75eacc4 221 case 2:
rashmivenkataramaiah 41:1141a75eacc4 222 DisableTouch();
rashmivenkataramaiah 41:1141a75eacc4 223 screen_main_1(); // System configration screen
nikitateggi 0:c47fb0c1bbf6 224 state1=0;
nikitateggi 0:c47fb0c1bbf6 225 state=2;
nikitateggi 1:8316c23ec6b9 226 nstate=state;
nikitateggi 3:9a06c2bed650 227 EnableTouch();
nikitateggi 0:c47fb0c1bbf6 228 break;
nikitateggi 0:c47fb0c1bbf6 229
rashmivenkataramaiah 41:1141a75eacc4 230 case 3:
rashmivenkataramaiah 41:1141a75eacc4 231 DisableTouch();
rashmivenkataramaiah 42:c81673b04b6a 232 //sd_read(pid_btpid); //read pid from sd card
rashmivenkataramaiah 42:c81673b04b6a 233 //pid=pid_btpid[0]; //copy pid to a variable
nikitateggi 19:1650bbc923cc 234 gc.printf("pidinit=%d",pid);
rashmivenkataramaiah 41:1141a75eacc4 235 screen_main_2(pid);
rashmivenkataramaiah 41:1141a75eacc4 236 state1=0;
rashmivenkataramaiah 41:1141a75eacc4 237 state=3;
rashmivenkataramaiah 41:1141a75eacc4 238 nstate=state;
rashmivenkataramaiah 41:1141a75eacc4 239 EnableTouch();
rashmivenkataramaiah 41:1141a75eacc4 240 break;
nikitateggi 0:c47fb0c1bbf6 241
rashmivenkataramaiah 41:1141a75eacc4 242 case 4:
rashmivenkataramaiah 41:1141a75eacc4 243 DisableTouch();
rashmivenkataramaiah 41:1141a75eacc4 244 if (glc_flag==1) // glc_flag=1 when already the reading has been taken
rashmivenkataramaiah 41:1141a75eacc4 245 {
rashmivenkataramaiah 41:1141a75eacc4 246 screen_again();
rashmivenkataramaiah 41:1141a75eacc4 247 state1=0;
rashmivenkataramaiah 41:1141a75eacc4 248 state=9;
rashmivenkataramaiah 41:1141a75eacc4 249 nstate=state;
rashmivenkataramaiah 41:1141a75eacc4 250 }
rashmivenkataramaiah 41:1141a75eacc4 251 else
nikitateggi 19:1650bbc923cc 252 {
rashmivenkataramaiah 41:1141a75eacc4 253 screen_glc(); // glc screen
rashmivenkataramaiah 41:1141a75eacc4 254 state1=0;
rashmivenkataramaiah 41:1141a75eacc4 255 state=4;
rashmivenkataramaiah 41:1141a75eacc4 256 nstate=state;
rashmivenkataramaiah 41:1141a75eacc4 257 }
nikitateggi 3:9a06c2bed650 258 EnableTouch();
nikitateggi 3:9a06c2bed650 259
nikitateggi 0:c47fb0c1bbf6 260 break;
nikitateggi 1:8316c23ec6b9 261
nikitateggi 1:8316c23ec6b9 262
rashmivenkataramaiah 41:1141a75eacc4 263 case 5:
rashmivenkataramaiah 41:1141a75eacc4 264 DisableTouch();
rashmivenkataramaiah 41:1141a75eacc4 265 if (ecg_flag==1)
rashmivenkataramaiah 41:1141a75eacc4 266 {
rashmivenkataramaiah 41:1141a75eacc4 267 screen_again();
rashmivenkataramaiah 41:1141a75eacc4 268 state1=0;
rashmivenkataramaiah 41:1141a75eacc4 269 state=7;
nikitateggi 1:8316c23ec6b9 270 nstate=state;
rashmivenkataramaiah 41:1141a75eacc4 271 }
rashmivenkataramaiah 41:1141a75eacc4 272
rashmivenkataramaiah 41:1141a75eacc4 273 else
rashmivenkataramaiah 41:1141a75eacc4 274 {
rashmivenkataramaiah 41:1141a75eacc4 275 screen_ecg(); //ecg main screen
rashmivenkataramaiah 41:1141a75eacc4 276 state1=0;
rashmivenkataramaiah 41:1141a75eacc4 277 state=5;
nikitateggi 1:8316c23ec6b9 278 nstate=state;
rashmivenkataramaiah 41:1141a75eacc4 279 }
rashmivenkataramaiah 41:1141a75eacc4 280 EnableTouch();
nikitateggi 1:8316c23ec6b9 281 break;
nikitateggi 1:8316c23ec6b9 282
rashmivenkataramaiah 41:1141a75eacc4 283 case 6:
rashmivenkataramaiah 41:1141a75eacc4 284 DisableTouch();
rashmivenkataramaiah 41:1141a75eacc4 285 screen_bp(); // bp main screen
nikitateggi 3:9a06c2bed650 286 state1=0;
nikitateggi 3:9a06c2bed650 287 state=8;
rashmivenkataramaiah 41:1141a75eacc4 288 nstate=state;
rashmivenkataramaiah 41:1141a75eacc4 289 EnableTouch();
nikitateggi 3:9a06c2bed650 290 break;
nikitateggi 3:9a06c2bed650 291
rashmivenkataramaiah 41:1141a75eacc4 292 case 7:
rashmivenkataramaiah 41:1141a75eacc4 293 DisableTouch();
rashmivenkataramaiah 41:1141a75eacc4 294 glc(pid); // glc measurement
rashmivenkataramaiah 42:c81673b04b6a 295 if(get_filecreated_status() == false) //if file is in write mode
rashmivenkataramaiah 42:c81673b04b6a 296 {
rashmivenkataramaiah 42:c81673b04b6a 297 set_filecreated_status();
rashmivenkataramaiah 42:c81673b04b6a 298 increment_pid ();
rashmivenkataramaiah 42:c81673b04b6a 299 }
nikitateggi 1:8316c23ec6b9 300 glc_flag=1;
avp2417 35:43133f017ed4 301 wait(1);
nikitateggi 4:6bd81bb1790d 302 state1=0;
nikitateggi 4:6bd81bb1790d 303 screen_glc_2();
rashmivenkataramaiah 41:1141a75eacc4 304 state=6;
rashmivenkataramaiah 41:1141a75eacc4 305 eprom_write_8(30,0);
rashmivenkataramaiah 41:1141a75eacc4 306 nstate=state;
rashmivenkataramaiah 41:1141a75eacc4 307 EnableTouch();
nikitateggi 1:8316c23ec6b9 308 break;
nikitateggi 1:8316c23ec6b9 309
nikitateggi 3:9a06c2bed650 310 case 8: DisableTouch();
rashmivenkataramaiah 41:1141a75eacc4 311 ecg_countdown(); // countdown before ecg capture
rashmivenkataramaiah 41:1141a75eacc4 312 heart_rate=ecg(pid); // capturing ecg
nikitateggi 1:8316c23ec6b9 313 state1=0;
nikitateggi 20:7c64e6ecad76 314 if (heart_rate==0)
nikitateggi 20:7c64e6ecad76 315 {
avp2417 34:8f6b0dc124e8 316
nikitateggi 20:7c64e6ecad76 317 screen_ecg_lead();
nikitateggi 20:7c64e6ecad76 318 }
rashmivenkataramaiah 41:1141a75eacc4 319 else if(heart_rate==1) // if heart rate goes above or below range display error // 10/7/17 nikita
nikitateggi 31:0f67acfc6236 320 {
nikitateggi 31:0f67acfc6236 321 screen_ecg_error();
nikitateggi 31:0f67acfc6236 322
nikitateggi 31:0f67acfc6236 323 }
avp2417 34:8f6b0dc124e8 324 else
avp2417 34:8f6b0dc124e8 325 {
avp2417 34:8f6b0dc124e8 326
nikitateggi 20:7c64e6ecad76 327 screen_ecg_2(heart_rate);
nikitateggi 20:7c64e6ecad76 328 ecg_flag=1;
rashmivenkataramaiah 42:c81673b04b6a 329 }
rashmivenkataramaiah 42:c81673b04b6a 330 if(get_filecreated_status() == false) //if file is in write mode
rashmivenkataramaiah 42:c81673b04b6a 331 {
rashmivenkataramaiah 42:c81673b04b6a 332 set_filecreated_status();
rashmivenkataramaiah 42:c81673b04b6a 333 increment_pid ();
rashmivenkataramaiah 42:c81673b04b6a 334 }
rashmivenkataramaiah 42:c81673b04b6a 335
nikitateggi 1:8316c23ec6b9 336 state=6;
nikitateggi 24:d992ee8369f4 337 eprom_write_8(30,1);
nikitateggi 20:7c64e6ecad76 338 nstate=state;
nikitateggi 20:7c64e6ecad76 339 screen_ecg_bp();
nikitateggi 4:6bd81bb1790d 340 EnableTouch();
nikitateggi 1:8316c23ec6b9 341 break;
rashmivenkataramaiah 41:1141a75eacc4 342
nikitateggi 19:1650bbc923cc 343 case 9:
nikitateggi 3:9a06c2bed650 344 DisableTouch();
rashmivenkataramaiah 41:1141a75eacc4 345 screen_bp2(); // bp main screen
rashmivenkataramaiah 41:1141a75eacc4 346 bp_countdown(); // countdown for bp
rashmivenkataramaiah 41:1141a75eacc4 347 bp(pid); // measuring bp earlier bp() changed to bp(pid) 28/4/2017
rashmivenkataramaiah 42:c81673b04b6a 348 if(get_filecreated_status() == false) //if file is in write mode
rashmivenkataramaiah 42:c81673b04b6a 349 {
rashmivenkataramaiah 42:c81673b04b6a 350 set_filecreated_status();
rashmivenkataramaiah 42:c81673b04b6a 351 increment_pid ();
rashmivenkataramaiah 42:c81673b04b6a 352 }
nikitateggi 3:9a06c2bed650 353 state1=0;
nikitateggi 3:9a06c2bed650 354 state=6;
nikitateggi 24:d992ee8369f4 355 eprom_write_8(30,2);
nikitateggi 3:9a06c2bed650 356 nstate=state;
nikitateggi 3:9a06c2bed650 357 EnableTouch();
nikitateggi 3:9a06c2bed650 358 break;
nikitateggi 31:0f67acfc6236 359
nikitateggi 31:0f67acfc6236 360
nikitateggi 31:0f67acfc6236 361 case 10 : DisableTouch();
nikitateggi 31:0f67acfc6236 362 wait_ms(300);
nikitateggi 31:0f67acfc6236 363 EnableTouch();
nikitateggi 31:0f67acfc6236 364 state=nstate;
nikitateggi 31:0f67acfc6236 365 break;
nikitateggi 31:0f67acfc6236 366
rashmivenkataramaiah 41:1141a75eacc4 367 case 11 :
rashmivenkataramaiah 41:1141a75eacc4 368 DisableTouch();
rashmivenkataramaiah 42:c81673b04b6a 369 //sd_read(pid_btpid); //read pid from sd card
rashmivenkataramaiah 42:c81673b04b6a 370 //current_test_pid=pid_btpid[0];
rashmivenkataramaiah 42:c81673b04b6a 371 //bt_file_sent_pid=pid_btpid[1];
rashmivenkataramaiah 42:c81673b04b6a 372 //screen_patient_info(current_test_pid, bt_file_sent_pid);
rashmivenkataramaiah 42:c81673b04b6a 373 screen_patient_info(get_filepid(), get_btpid());
rashmivenkataramaiah 41:1141a75eacc4 374 state1=0;
rashmivenkataramaiah 41:1141a75eacc4 375 state=12;
rashmivenkataramaiah 41:1141a75eacc4 376 EnableTouch();
rashmivenkataramaiah 41:1141a75eacc4 377 break;
nikitateggi 31:0f67acfc6236 378
nikitateggi 31:0f67acfc6236 379
nikitateggi 1:8316c23ec6b9 380 default :
nikitateggi 3:9a06c2bed650 381
nikitateggi 1:8316c23ec6b9 382 state1=nstate1;
nikitateggi 1:8316c23ec6b9 383 break;
nikitateggi 1:8316c23ec6b9 384
nikitateggi 0:c47fb0c1bbf6 385
nikitateggi 0:c47fb0c1bbf6 386 }
nikitateggi 0:c47fb0c1bbf6 387
nikitateggi 0:c47fb0c1bbf6 388
nikitateggi 0:c47fb0c1bbf6 389
rashmivenkataramaiah 41:1141a75eacc4 390 return state;
nikitateggi 0:c47fb0c1bbf6 391
rashmivenkataramaiah 41:1141a75eacc4 392 }
rashmivenkataramaiah 41:1141a75eacc4 393
rashmivenkataramaiah 41:1141a75eacc4 394
rashmivenkataramaiah 41:1141a75eacc4 395 bool get_filecreated_status(void) //function to get file created status
rashmivenkataramaiah 41:1141a75eacc4 396 {
rashmivenkataramaiah 41:1141a75eacc4 397 return file_created_status;
rashmivenkataramaiah 41:1141a75eacc4 398 }
rashmivenkataramaiah 41:1141a75eacc4 399
rashmivenkataramaiah 41:1141a75eacc4 400 void set_filecreated_status(void) //function to set file created status
rashmivenkataramaiah 41:1141a75eacc4 401 {
rashmivenkataramaiah 42:c81673b04b6a 402 file_created_status = true;
rashmivenkataramaiah 41:1141a75eacc4 403 }
rashmivenkataramaiah 41:1141a75eacc4 404
rashmivenkataramaiah 41:1141a75eacc4 405
rashmivenkataramaiah 41:1141a75eacc4 406 void clear_filecreated_status(void) //function to clear file created status
rashmivenkataramaiah 41:1141a75eacc4 407 {
rashmivenkataramaiah 42:c81673b04b6a 408 file_created_status = false;
rashmivenkataramaiah 42:c81673b04b6a 409 }
rashmivenkataramaiah 42:c81673b04b6a 410
rashmivenkataramaiah 42:c81673b04b6a 411 void increment_pid (void) //increment pid if a test is completed
rashmivenkataramaiah 42:c81673b04b6a 412 {
rashmivenkataramaiah 42:c81673b04b6a 413 uint32_t filepid_btpid[2] = {};
rashmivenkataramaiah 42:c81673b04b6a 414
rashmivenkataramaiah 42:c81673b04b6a 415 //set_filecreated_status(); //set it to make it append mode
rashmivenkataramaiah 42:c81673b04b6a 416 sd_read(filepid_btpid); //read pid from sd card
rashmivenkataramaiah 42:c81673b04b6a 417 filepid_btpid[0] = filepid_btpid[0] + 1; //increment it by 1
rashmivenkataramaiah 42:c81673b04b6a 418 sd_write(filepid_btpid); //write it back to sd card
rashmivenkataramaiah 42:c81673b04b6a 419
rashmivenkataramaiah 42:c81673b04b6a 420 }
rashmivenkataramaiah 42:c81673b04b6a 421
rashmivenkataramaiah 42:c81673b04b6a 422 uint32_t get_filepid(void)
rashmivenkataramaiah 42:c81673b04b6a 423 {
rashmivenkataramaiah 42:c81673b04b6a 424 //uint32_t filepid_btpid[2] = {};
rashmivenkataramaiah 42:c81673b04b6a 425 uint32_t filepid = 0;
rashmivenkataramaiah 42:c81673b04b6a 426
rashmivenkataramaiah 42:c81673b04b6a 427 sd_read(filepid_btpid); //read pid from sd card
rashmivenkataramaiah 42:c81673b04b6a 428 filepid= filepid_btpid[0];
rashmivenkataramaiah 42:c81673b04b6a 429 return filepid;
rashmivenkataramaiah 42:c81673b04b6a 430
rashmivenkataramaiah 42:c81673b04b6a 431 }
rashmivenkataramaiah 42:c81673b04b6a 432
rashmivenkataramaiah 42:c81673b04b6a 433 void store_filepid(uint32_t pid)
rashmivenkataramaiah 42:c81673b04b6a 434 {
rashmivenkataramaiah 42:c81673b04b6a 435 //uint32_t filepid_btpid[2] = {};
rashmivenkataramaiah 42:c81673b04b6a 436 sd_read(filepid_btpid); //read pid from sd card
rashmivenkataramaiah 42:c81673b04b6a 437 filepid_btpid[0] = pid;
rashmivenkataramaiah 42:c81673b04b6a 438 sd_write(filepid_btpid); //write it back to sd card
rashmivenkataramaiah 42:c81673b04b6a 439
rashmivenkataramaiah 42:c81673b04b6a 440 }
rashmivenkataramaiah 42:c81673b04b6a 441
rashmivenkataramaiah 42:c81673b04b6a 442 uint32_t get_btpid(void)
rashmivenkataramaiah 42:c81673b04b6a 443 {
rashmivenkataramaiah 42:c81673b04b6a 444 //uint32_t filepid_btpid[2] = {};
rashmivenkataramaiah 42:c81673b04b6a 445 uint32_t btpid = 0;
rashmivenkataramaiah 42:c81673b04b6a 446
rashmivenkataramaiah 42:c81673b04b6a 447 sd_read(filepid_btpid); //read pid from sd card
rashmivenkataramaiah 42:c81673b04b6a 448 btpid= filepid_btpid[1];
rashmivenkataramaiah 42:c81673b04b6a 449 return btpid;
rashmivenkataramaiah 42:c81673b04b6a 450
rashmivenkataramaiah 42:c81673b04b6a 451 }
rashmivenkataramaiah 42:c81673b04b6a 452
rashmivenkataramaiah 42:c81673b04b6a 453 void store_btpid(uint32_t bt_pid)
rashmivenkataramaiah 42:c81673b04b6a 454 {
rashmivenkataramaiah 42:c81673b04b6a 455 //uint32_t filepid_btpid[2] = {};
rashmivenkataramaiah 42:c81673b04b6a 456
rashmivenkataramaiah 42:c81673b04b6a 457 sd_read(filepid_btpid); //read pid from sd card
rashmivenkataramaiah 42:c81673b04b6a 458 filepid_btpid[1] = bt_pid;
rashmivenkataramaiah 42:c81673b04b6a 459 sd_write(filepid_btpid); //write it back to sd card
rashmivenkataramaiah 42:c81673b04b6a 460
rashmivenkataramaiah 42:c81673b04b6a 461 }
rashmivenkataramaiah 42:c81673b04b6a 462