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