Changes done in ECG and BT
Dependencies: SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217
Fork of merged_code2_20sept_2017_4th_oct_2017 by
main.cpp@37:92fcbf22bf91, 2017-07-29 (annotated)
- Committer:
- avp2417
- Date:
- Sat Jul 29 12:12:28 2017 +0000
- Revision:
- 37:92fcbf22bf91
- Parent:
- 35:43133f017ed4
- Child:
- 39:69b09bd87502
Modification carried out by Nikita related to display screen timeout + Battery monitoring.
Who changed what in which revision?
User | Revision | Line number | New 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" |
nikitateggi | 24:d992ee8369f4 | 15 | |
nikitateggi | 0:c47fb0c1bbf6 | 16 | Serial gc(USBTX, USBRX); |
nikitateggi | 0:c47fb0c1bbf6 | 17 | DigitalIn q1(PTB11); |
nikitateggi | 29:7edc76b15e3d | 18 | DigitalIn q(PTC5); |
nikitateggi | 29:7edc76b15e3d | 19 | DigitalIn q3(PTC12); |
nikitateggi | 19:1650bbc923cc | 20 | DigitalIn BT(PTA5); //bluetooth status pin |
nikitateggi | 31:0f67acfc6236 | 21 | static uint32_t current_test_pid=0; |
nikitateggi | 31:0f67acfc6236 | 22 | static uint32_t bt_file_sent_pid=0; |
nikitateggi | 19:1650bbc923cc | 23 | uint8_t touch(uint8_t state); // touch state |
nikitateggi | 19:1650bbc923cc | 24 | uint8_t display(uint8_t state1); // display state |
nikitateggi | 22:ffa88619551d | 25 | int32_t pid=0; // patient ID |
nikitateggi | 19:1650bbc923cc | 26 | static uint8_t nstate=0; |
nikitateggi | 19:1650bbc923cc | 27 | static uint8_t nstate1=0; |
nikitateggi | 19:1650bbc923cc | 28 | static uint8_t flag=0; //flag to indicate not to update pid as it is already done |
nikitateggi | 19:1650bbc923cc | 29 | static uint8_t ecg_flag=0; // ecg_flag to indicate the ecg test is already done for the same pid |
nikitateggi | 19:1650bbc923cc | 30 | static uint8_t glc_flag=0; // glc_flag to indicate the glc test is already done for the same pid |
nikitateggi | 19:1650bbc923cc | 31 | uint8_t state_r=0; // state to receive from bluetooth |
nikitateggi | 19:1650bbc923cc | 32 | uint8_t state_t=1; // state to transmit to bluetooth |
nikitateggi | 22:ffa88619551d | 33 | uint16_t heart_rate=0; |
nikitateggi | 0:c47fb0c1bbf6 | 34 | |
nikitateggi | 0:c47fb0c1bbf6 | 35 | |
nikitateggi | 0:c47fb0c1bbf6 | 36 | int main(){ |
nikitateggi | 19:1650bbc923cc | 37 | static uint8_t main_state=1; |
nikitateggi | 19:1650bbc923cc | 38 | static uint8_t state_display=0; |
nikitateggi | 19:1650bbc923cc | 39 | static uint8_t state_touch=1; |
nikitateggi | 19:1650bbc923cc | 40 | static uint8_t state_t=1; |
nikitateggi | 19:1650bbc923cc | 41 | static uint8_t state_r=0; |
avp2417 | 37:92fcbf22bf91 | 42 | uint8_t battery_voltage_condition=0; |
avp2417 | 37:92fcbf22bf91 | 43 | |
avp2417 | 37:92fcbf22bf91 | 44 | |
avp2417 | 37:92fcbf22bf91 | 45 | DisableTouch(); |
avp2417 | 37:92fcbf22bf91 | 46 | gc.baud(115200); |
avp2417 | 37:92fcbf22bf91 | 47 | init_screen(); //initialize lcd |
avp2417 | 37:92fcbf22bf91 | 48 | screen_main(); // display of main screen |
avp2417 | 37:92fcbf22bf91 | 49 | |
avp2417 | 37:92fcbf22bf91 | 50 | |
nikitateggi | 0:c47fb0c1bbf6 | 51 | while(1) |
nikitateggi | 0:c47fb0c1bbf6 | 52 | { |
avp2417 | 37:92fcbf22bf91 | 53 | DisableTouch(); |
avp2417 | 37:92fcbf22bf91 | 54 | battery_voltage_condition=battery_voltage(); |
avp2417 | 37:92fcbf22bf91 | 55 | |
avp2417 | 37:92fcbf22bf91 | 56 | if (battery_voltage_condition==3) |
avp2417 | 37:92fcbf22bf91 | 57 | { |
avp2417 | 37:92fcbf22bf91 | 58 | DisableTouch(); |
avp2417 | 37:92fcbf22bf91 | 59 | } |
avp2417 | 37:92fcbf22bf91 | 60 | |
avp2417 | 37:92fcbf22bf91 | 61 | |
avp2417 | 37:92fcbf22bf91 | 62 | else |
avp2417 | 37:92fcbf22bf91 | 63 | { |
avp2417 | 37:92fcbf22bf91 | 64 | |
avp2417 | 37:92fcbf22bf91 | 65 | EnableTouch(); |
nikitateggi | 19:1650bbc923cc | 66 | switch(main_state) // main state machine |
nikitateggi | 19:1650bbc923cc | 67 | { |
nikitateggi | 22:ffa88619551d | 68 | case 1: state_display=touch(state_touch); // touch state |
nikitateggi | 22:ffa88619551d | 69 | if(state_display==12) |
nikitateggi | 22:ffa88619551d | 70 | main_state=3; |
nikitateggi | 19:1650bbc923cc | 71 | |
nikitateggi | 22:ffa88619551d | 72 | else |
nikitateggi | 22:ffa88619551d | 73 | main_state=2; |
nikitateggi | 19:1650bbc923cc | 74 | break; |
nikitateggi | 19:1650bbc923cc | 75 | |
nikitateggi | 19:1650bbc923cc | 76 | case 2: state_touch=display(state_display); //display state |
nikitateggi | 22:ffa88619551d | 77 | /* if (b_voltage<3.5) |
nikitateggi | 22:ffa88619551d | 78 | { |
nikitateggi | 22:ffa88619551d | 79 | bat_screen_nocharge(); |
nikitateggi | 22:ffa88619551d | 80 | DisableTouch(); |
nikitateggi | 22:ffa88619551d | 81 | } |
nikitateggi | 22:ffa88619551d | 82 | else { */ |
nikitateggi | 22:ffa88619551d | 83 | // bat_screen_charge(); |
nikitateggi | 22:ffa88619551d | 84 | main_state=1; |
nikitateggi | 22:ffa88619551d | 85 | // } |
nikitateggi | 22:ffa88619551d | 86 | break; |
nikitateggi | 19:1650bbc923cc | 87 | |
nikitateggi | 19:1650bbc923cc | 88 | |
nikitateggi | 19:1650bbc923cc | 89 | case 3: DisableTouch(); // bluetooth send |
nikitateggi | 19:1650bbc923cc | 90 | if(BT==1) |
nikitateggi | 19:1650bbc923cc | 91 | { |
nikitateggi | 31:0f67acfc6236 | 92 | |
nikitateggi | 31:0f67acfc6236 | 93 | BT_connection() ; // displaying connection on bluetooth |
nikitateggi | 19:1650bbc923cc | 94 | state_r=bt_send(state_t); |
nikitateggi | 19:1650bbc923cc | 95 | main_state=4; |
nikitateggi | 19:1650bbc923cc | 96 | } |
nikitateggi | 19:1650bbc923cc | 97 | else |
nikitateggi | 31:0f67acfc6236 | 98 | { |
nikitateggi | 31:0f67acfc6236 | 99 | BT_no_connection(); |
nikitateggi | 19:1650bbc923cc | 100 | gc.printf("timeout"); |
nikitateggi | 31:0f67acfc6236 | 101 | } |
nikitateggi | 19:1650bbc923cc | 102 | break; |
nikitateggi | 19:1650bbc923cc | 103 | |
nikitateggi | 19:1650bbc923cc | 104 | case 4: |
nikitateggi | 19:1650bbc923cc | 105 | state_t=bt_receive(state_r); // bluetooth receive |
nikitateggi | 19:1650bbc923cc | 106 | main_state=3; |
nikitateggi | 19:1650bbc923cc | 107 | // gc.printf("statet=%d",state_t); |
nikitateggi | 19:1650bbc923cc | 108 | if(state_t ==0) |
nikitateggi | 19:1650bbc923cc | 109 | { |
nikitateggi | 31:0f67acfc6236 | 110 | BT_finished(); |
nikitateggi | 31:0f67acfc6236 | 111 | screen_BT_return(); |
nikitateggi | 19:1650bbc923cc | 112 | EnableTouch(); |
nikitateggi | 19:1650bbc923cc | 113 | main_state=1; |
nikitateggi | 31:0f67acfc6236 | 114 | state_touch=12; // jumping to touch case 12 |
nikitateggi | 19:1650bbc923cc | 115 | } |
nikitateggi | 19:1650bbc923cc | 116 | break; |
avp2417 | 37:92fcbf22bf91 | 117 | } |
nikitateggi | 19:1650bbc923cc | 118 | |
nikitateggi | 19:1650bbc923cc | 119 | } |
nikitateggi | 22:ffa88619551d | 120 | } |
nikitateggi | 19:1650bbc923cc | 121 | |
nikitateggi | 19:1650bbc923cc | 122 | } |
nikitateggi | 19:1650bbc923cc | 123 | |
nikitateggi | 22:ffa88619551d | 124 | //} |
nikitateggi | 19:1650bbc923cc | 125 | |
nikitateggi | 19:1650bbc923cc | 126 | |
nikitateggi | 19:1650bbc923cc | 127 | uint8_t touch(uint8_t state) |
nikitateggi | 19:1650bbc923cc | 128 | { |
nikitateggi | 19:1650bbc923cc | 129 | static uint8_t state1=0; |
avp2417 | 37:92fcbf22bf91 | 130 | detect_touch(state); // determine the touch points |
nikitateggi | 1:8316c23ec6b9 | 131 | |
nikitateggi | 4:6bd81bb1790d | 132 | switch(state) // state for touch |
nikitateggi | 0:c47fb0c1bbf6 | 133 | { |
nikitateggi | 0:c47fb0c1bbf6 | 134 | case 1: state1=touch_main(); // determining the touch for main screen |
nikitateggi | 0:c47fb0c1bbf6 | 135 | state=0; |
nikitateggi | 1:8316c23ec6b9 | 136 | nstate1=state1; |
nikitateggi | 3:9a06c2bed650 | 137 | break; |
nikitateggi | 0:c47fb0c1bbf6 | 138 | |
nikitateggi | 0:c47fb0c1bbf6 | 139 | case 2: |
nikitateggi | 4:6bd81bb1790d | 140 | state1=touch_main_1(); // determining the touch for SYSTEM CONFIGURATION screen |
nikitateggi | 0:c47fb0c1bbf6 | 141 | state=0; |
nikitateggi | 3:9a06c2bed650 | 142 | nstate1=state1; |
nikitateggi | 0:c47fb0c1bbf6 | 143 | break; |
nikitateggi | 0:c47fb0c1bbf6 | 144 | |
nikitateggi | 0:c47fb0c1bbf6 | 145 | case 3: |
nikitateggi | 4:6bd81bb1790d | 146 | state1=touch_main_2(); //// determining the touch for TEST screen |
nikitateggi | 20:7c64e6ecad76 | 147 | |
nikitateggi | 0:c47fb0c1bbf6 | 148 | state=0; |
nikitateggi | 1:8316c23ec6b9 | 149 | nstate1=state1; |
nikitateggi | 0:c47fb0c1bbf6 | 150 | break; |
nikitateggi | 0:c47fb0c1bbf6 | 151 | |
nikitateggi | 0:c47fb0c1bbf6 | 152 | case 4: |
nikitateggi | 4:6bd81bb1790d | 153 | state1=touch_glc(); // determining the touch for GLC screen |
nikitateggi | 1:8316c23ec6b9 | 154 | state=0; |
nikitateggi | 1:8316c23ec6b9 | 155 | nstate1=state1; |
nikitateggi | 1:8316c23ec6b9 | 156 | break; |
nikitateggi | 1:8316c23ec6b9 | 157 | |
nikitateggi | 1:8316c23ec6b9 | 158 | case 5: |
nikitateggi | 4:6bd81bb1790d | 159 | state1=touch_ecg(); // determining the touch for ECG screen |
nikitateggi | 1:8316c23ec6b9 | 160 | state=0; |
nikitateggi | 3:9a06c2bed650 | 161 | nstate1=state1; |
nikitateggi | 3:9a06c2bed650 | 162 | break; |
nikitateggi | 4:6bd81bb1790d | 163 | case 6: |
nikitateggi | 4:6bd81bb1790d | 164 | state1=touch_ret(); // determining the touch for returning back to the main screen |
nikitateggi | 20:7c64e6ecad76 | 165 | /* if (ecg_flag==1) |
nikitateggi | 20:7c64e6ecad76 | 166 | state1=8; |
nikitateggi | 20:7c64e6ecad76 | 167 | else if (glc_flag==1) |
nikitateggi | 20:7c64e6ecad76 | 168 | state1=7; */ |
nikitateggi | 0:c47fb0c1bbf6 | 169 | state=0; |
nikitateggi | 3:9a06c2bed650 | 170 | nstate1=state1; |
nikitateggi | 1:8316c23ec6b9 | 171 | break; |
nikitateggi | 1:8316c23ec6b9 | 172 | |
nikitateggi | 4:6bd81bb1790d | 173 | case 7: |
suhasini | 5:a3ea7c82b7e1 | 174 | state1=touch_again_ecg(); // determining the touch when readings are taken more than once screen |
nikitateggi | 1:8316c23ec6b9 | 175 | state=0; |
nikitateggi | 1:8316c23ec6b9 | 176 | nstate1=state1; |
nikitateggi | 1:8316c23ec6b9 | 177 | break; |
nikitateggi | 0:c47fb0c1bbf6 | 178 | |
nikitateggi | 3:9a06c2bed650 | 179 | case 8: |
nikitateggi | 4:6bd81bb1790d | 180 | state1=touch_bp(); // determining the touch for BP screen |
nikitateggi | 3:9a06c2bed650 | 181 | state=0; |
nikitateggi | 3:9a06c2bed650 | 182 | nstate1=state1; |
nikitateggi | 3:9a06c2bed650 | 183 | break; |
nikitateggi | 3:9a06c2bed650 | 184 | |
suhasini | 5:a3ea7c82b7e1 | 185 | case 9: state1=touch_again_glc(); |
suhasini | 5:a3ea7c82b7e1 | 186 | state=0; |
suhasini | 5:a3ea7c82b7e1 | 187 | nstate1=state1; |
suhasini | 5:a3ea7c82b7e1 | 188 | break; |
nikitateggi | 3:9a06c2bed650 | 189 | |
nikitateggi | 1:8316c23ec6b9 | 190 | case 10 : DisableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 191 | wait_ms(300); |
nikitateggi | 1:8316c23ec6b9 | 192 | EnableTouch(); |
nikitateggi | 3:9a06c2bed650 | 193 | state=nstate; |
nikitateggi | 3:9a06c2bed650 | 194 | break; |
suhasini | 5:a3ea7c82b7e1 | 195 | |
suhasini | 5:a3ea7c82b7e1 | 196 | |
suhasini | 5:a3ea7c82b7e1 | 197 | case 11: state1=touch_again_bp(); |
suhasini | 5:a3ea7c82b7e1 | 198 | state=0; |
suhasini | 5:a3ea7c82b7e1 | 199 | nstate1=state1; |
suhasini | 5:a3ea7c82b7e1 | 200 | break; |
suhasini | 5:a3ea7c82b7e1 | 201 | |
nikitateggi | 31:0f67acfc6236 | 202 | case 12: state1=BT_return(); |
nikitateggi | 31:0f67acfc6236 | 203 | state=0; |
nikitateggi | 31:0f67acfc6236 | 204 | nstate1=state1; |
nikitateggi | 31:0f67acfc6236 | 205 | break; |
suhasini | 5:a3ea7c82b7e1 | 206 | |
nikitateggi | 4:6bd81bb1790d | 207 | default : DisableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 208 | wait_ms(300); |
nikitateggi | 1:8316c23ec6b9 | 209 | EnableTouch(); |
nikitateggi | 3:9a06c2bed650 | 210 | state=nstate; |
nikitateggi | 3:9a06c2bed650 | 211 | break; |
nikitateggi | 1:8316c23ec6b9 | 212 | |
nikitateggi | 0:c47fb0c1bbf6 | 213 | } |
nikitateggi | 0:c47fb0c1bbf6 | 214 | |
nikitateggi | 19:1650bbc923cc | 215 | return state1; |
nikitateggi | 19:1650bbc923cc | 216 | } |
nikitateggi | 0:c47fb0c1bbf6 | 217 | |
nikitateggi | 0:c47fb0c1bbf6 | 218 | |
nikitateggi | 19:1650bbc923cc | 219 | uint8_t display(uint8_t state1) |
nikitateggi | 19:1650bbc923cc | 220 | { |
nikitateggi | 19:1650bbc923cc | 221 | static uint8_t state=0; |
nikitateggi | 0:c47fb0c1bbf6 | 222 | |
nikitateggi | 4:6bd81bb1790d | 223 | switch(state1) // state for display screens |
nikitateggi | 0:c47fb0c1bbf6 | 224 | { |
nikitateggi | 4:6bd81bb1790d | 225 | |
nikitateggi | 1:8316c23ec6b9 | 226 | |
nikitateggi | 3:9a06c2bed650 | 227 | case 1: DisableTouch(); |
nikitateggi | 4:6bd81bb1790d | 228 | screen_main(); // main screen |
nikitateggi | 1:8316c23ec6b9 | 229 | state1=0; |
nikitateggi | 1:8316c23ec6b9 | 230 | state=1; |
nikitateggi | 1:8316c23ec6b9 | 231 | nstate=state; |
nikitateggi | 1:8316c23ec6b9 | 232 | flag=0; |
nikitateggi | 4:6bd81bb1790d | 233 | ecg_flag=0; // ecg, glc flag to determine whether the readings are taken more than once |
nikitateggi | 1:8316c23ec6b9 | 234 | glc_flag=0; |
nikitateggi | 3:9a06c2bed650 | 235 | EnableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 236 | break; |
nikitateggi | 1:8316c23ec6b9 | 237 | |
nikitateggi | 3:9a06c2bed650 | 238 | case 2: DisableTouch(); |
nikitateggi | 19:1650bbc923cc | 239 | // bt(); |
nikitateggi | 4:6bd81bb1790d | 240 | screen_main_1(); // System configration screen |
nikitateggi | 0:c47fb0c1bbf6 | 241 | state1=0; |
nikitateggi | 0:c47fb0c1bbf6 | 242 | state=2; |
nikitateggi | 1:8316c23ec6b9 | 243 | nstate=state; |
nikitateggi | 3:9a06c2bed650 | 244 | EnableTouch(); |
nikitateggi | 0:c47fb0c1bbf6 | 245 | break; |
nikitateggi | 0:c47fb0c1bbf6 | 246 | |
nikitateggi | 3:9a06c2bed650 | 247 | case 3: DisableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 248 | if (flag==0) |
nikitateggi | 1:8316c23ec6b9 | 249 | { |
nikitateggi | 4:6bd81bb1790d | 250 | //pid=pid+1; |
nikitateggi | 4:6bd81bb1790d | 251 | pid=eprom_read(1); // reading the patient id from eeprom |
nikitateggi | 19:1650bbc923cc | 252 | gc.printf("pidinit=%d",pid); |
nikitateggi | 4:6bd81bb1790d | 253 | pid=pid+1; |
nikitateggi | 19:1650bbc923cc | 254 | gc.printf("pid+1=%d",pid); |
nikitateggi | 4:6bd81bb1790d | 255 | eprom_write(1,pid); // writing the patient id to eeprom |
nikitateggi | 1:8316c23ec6b9 | 256 | screen_main_2(pid); |
nikitateggi | 19:1650bbc923cc | 257 | /* sd_open_GLCfilee(pid); // only opening the glc,bp and ecg file |
nikitateggi | 1:8316c23ec6b9 | 258 | sd_close(); |
nikitateggi | 2:3b7b71bfc941 | 259 | sd_open_ECGfilee(pid); |
nikitateggi | 1:8316c23ec6b9 | 260 | sd_close(); |
nikitateggi | 4:6bd81bb1790d | 261 | sd_open_BPfilee(pid); |
nidhinvarghese | 14:f5c62d30c6fc | 262 | sd_close();*/ |
nikitateggi | 1:8316c23ec6b9 | 263 | flag=1; |
nikitateggi | 1:8316c23ec6b9 | 264 | } |
nikitateggi | 1:8316c23ec6b9 | 265 | else |
nikitateggi | 1:8316c23ec6b9 | 266 | { |
nikitateggi | 4:6bd81bb1790d | 267 | screen_main_2(pid); // TEST screen |
nikitateggi | 1:8316c23ec6b9 | 268 | } |
nikitateggi | 1:8316c23ec6b9 | 269 | |
nikitateggi | 1:8316c23ec6b9 | 270 | state1=0; |
nikitateggi | 1:8316c23ec6b9 | 271 | state=3; |
nikitateggi | 1:8316c23ec6b9 | 272 | nstate=state; |
nikitateggi | 3:9a06c2bed650 | 273 | EnableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 274 | break; |
nikitateggi | 0:c47fb0c1bbf6 | 275 | |
nikitateggi | 3:9a06c2bed650 | 276 | case 4: DisableTouch(); |
nikitateggi | 4:6bd81bb1790d | 277 | if (glc_flag==1) // glc_flag=1 when already the reading has been taken |
nikitateggi | 1:8316c23ec6b9 | 278 | { |
nikitateggi | 4:6bd81bb1790d | 279 | screen_again(); |
nikitateggi | 1:8316c23ec6b9 | 280 | state1=0; |
suhasini | 5:a3ea7c82b7e1 | 281 | state=9; |
nikitateggi | 1:8316c23ec6b9 | 282 | nstate=state; |
nikitateggi | 1:8316c23ec6b9 | 283 | } |
nikitateggi | 1:8316c23ec6b9 | 284 | else |
nikitateggi | 19:1650bbc923cc | 285 | { |
nikitateggi | 19:1650bbc923cc | 286 | screen_glc(); // glc screen |
nikitateggi | 0:c47fb0c1bbf6 | 287 | state1=0; |
nikitateggi | 0:c47fb0c1bbf6 | 288 | state=4; |
nikitateggi | 1:8316c23ec6b9 | 289 | nstate=state; |
nikitateggi | 1:8316c23ec6b9 | 290 | } |
nikitateggi | 3:9a06c2bed650 | 291 | EnableTouch(); |
nikitateggi | 3:9a06c2bed650 | 292 | |
nikitateggi | 0:c47fb0c1bbf6 | 293 | break; |
nikitateggi | 1:8316c23ec6b9 | 294 | |
nikitateggi | 1:8316c23ec6b9 | 295 | |
nikitateggi | 3:9a06c2bed650 | 296 | case 5: DisableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 297 | if (ecg_flag==1) |
nikitateggi | 1:8316c23ec6b9 | 298 | { |
nikitateggi | 1:8316c23ec6b9 | 299 | screen_again(); |
nikitateggi | 1:8316c23ec6b9 | 300 | state1=0; |
nikitateggi | 1:8316c23ec6b9 | 301 | state=7; |
nikitateggi | 1:8316c23ec6b9 | 302 | nstate=state; |
nikitateggi | 1:8316c23ec6b9 | 303 | } |
nikitateggi | 1:8316c23ec6b9 | 304 | |
nikitateggi | 1:8316c23ec6b9 | 305 | else |
nikitateggi | 1:8316c23ec6b9 | 306 | { |
nikitateggi | 4:6bd81bb1790d | 307 | screen_ecg(); //ecg main screen |
nikitateggi | 1:8316c23ec6b9 | 308 | state1=0; |
nikitateggi | 1:8316c23ec6b9 | 309 | state=5; |
nikitateggi | 1:8316c23ec6b9 | 310 | nstate=state; |
nikitateggi | 1:8316c23ec6b9 | 311 | } |
nikitateggi | 3:9a06c2bed650 | 312 | EnableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 313 | break; |
nikitateggi | 1:8316c23ec6b9 | 314 | |
nikitateggi | 3:9a06c2bed650 | 315 | case 6: DisableTouch(); |
nikitateggi | 4:6bd81bb1790d | 316 | screen_bp(); // bp main screen |
suhasini | 6:5e33a0f01476 | 317 | //EnableTouch(); |
nikitateggi | 3:9a06c2bed650 | 318 | state1=0; |
nikitateggi | 3:9a06c2bed650 | 319 | state=8; |
suhasini | 6:5e33a0f01476 | 320 | nstate=state; /////// |
suhasini | 6:5e33a0f01476 | 321 | EnableTouch(); /////// |
nikitateggi | 3:9a06c2bed650 | 322 | break; |
nikitateggi | 3:9a06c2bed650 | 323 | |
nikitateggi | 3:9a06c2bed650 | 324 | |
nikitateggi | 3:9a06c2bed650 | 325 | |
nikitateggi | 3:9a06c2bed650 | 326 | |
nikitateggi | 3:9a06c2bed650 | 327 | |
nikitateggi | 4:6bd81bb1790d | 328 | case 7: DisableTouch(); |
nikitateggi | 4:6bd81bb1790d | 329 | glc(pid); // glc measurement |
nikitateggi | 19:1650bbc923cc | 330 | // bt(); |
nikitateggi | 1:8316c23ec6b9 | 331 | glc_flag=1; |
avp2417 | 35:43133f017ed4 | 332 | wait(1); |
nikitateggi | 4:6bd81bb1790d | 333 | state1=0; |
nikitateggi | 4:6bd81bb1790d | 334 | screen_glc_2(); |
nikitateggi | 20:7c64e6ecad76 | 335 | state=6; |
nikitateggi | 24:d992ee8369f4 | 336 | eprom_write_8(30,0); |
nikitateggi | 1:8316c23ec6b9 | 337 | // gc.printf("%d", state); |
suhasini | 6:5e33a0f01476 | 338 | nstate=state; ////////////// |
nikitateggi | 3:9a06c2bed650 | 339 | EnableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 340 | break; |
nikitateggi | 1:8316c23ec6b9 | 341 | |
nikitateggi | 3:9a06c2bed650 | 342 | case 8: DisableTouch(); |
nikitateggi | 4:6bd81bb1790d | 343 | ecg_countdown(); // countdown before ecg capture |
suhasini | 13:5d3b478ea9c7 | 344 | heart_rate=ecg(pid); // capturing ecg |
nikitateggi | 1:8316c23ec6b9 | 345 | state1=0; |
nikitateggi | 20:7c64e6ecad76 | 346 | if (heart_rate==0) |
nikitateggi | 20:7c64e6ecad76 | 347 | { |
avp2417 | 34:8f6b0dc124e8 | 348 | |
nikitateggi | 20:7c64e6ecad76 | 349 | screen_ecg_lead(); |
nikitateggi | 20:7c64e6ecad76 | 350 | } |
nikitateggi | 31:0f67acfc6236 | 351 | else if(heart_rate==1) // if heart rate goes above or below range display error // 10/7/17 nikita |
nikitateggi | 31:0f67acfc6236 | 352 | { |
nikitateggi | 31:0f67acfc6236 | 353 | screen_ecg_error(); |
nikitateggi | 31:0f67acfc6236 | 354 | |
nikitateggi | 31:0f67acfc6236 | 355 | } |
avp2417 | 34:8f6b0dc124e8 | 356 | else |
avp2417 | 34:8f6b0dc124e8 | 357 | { |
avp2417 | 34:8f6b0dc124e8 | 358 | |
nikitateggi | 20:7c64e6ecad76 | 359 | screen_ecg_2(heart_rate); |
nikitateggi | 20:7c64e6ecad76 | 360 | ecg_flag=1; |
nikitateggi | 20:7c64e6ecad76 | 361 | } |
nikitateggi | 1:8316c23ec6b9 | 362 | state=6; |
nikitateggi | 24:d992ee8369f4 | 363 | eprom_write_8(30,1); |
nikitateggi | 20:7c64e6ecad76 | 364 | nstate=state; |
nikitateggi | 20:7c64e6ecad76 | 365 | screen_ecg_bp(); |
nikitateggi | 4:6bd81bb1790d | 366 | EnableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 367 | break; |
nikitateggi | 1:8316c23ec6b9 | 368 | |
nikitateggi | 1:8316c23ec6b9 | 369 | |
nikitateggi | 4:6bd81bb1790d | 370 | /*case 9: |
nikitateggi | 3:9a06c2bed650 | 371 | DisableTouch(); |
nikitateggi | 4:6bd81bb1790d | 372 | screen_glc_2(); |
nikitateggi | 4:6bd81bb1790d | 373 | state1=0; |
nikitateggi | 1:8316c23ec6b9 | 374 | state=6; |
nikitateggi | 1:8316c23ec6b9 | 375 | nstate=state; |
nikitateggi | 3:9a06c2bed650 | 376 | EnableTouch(); |
nikitateggi | 4:6bd81bb1790d | 377 | break;*/ |
nikitateggi | 3:9a06c2bed650 | 378 | |
nikitateggi | 19:1650bbc923cc | 379 | case 9: |
nikitateggi | 3:9a06c2bed650 | 380 | DisableTouch(); |
nikitateggi | 4:6bd81bb1790d | 381 | screen_bp2(); // bp main screen |
suhasini | 6:5e33a0f01476 | 382 | bp_countdown(); // countdown for bp |
nidhinvarghese | 8:adf2ba7e6412 | 383 | bp(pid); // measuring bp earlier bp() changed to bp(pid) 28/4/2017 |
nikitateggi | 3:9a06c2bed650 | 384 | state1=0; |
nikitateggi | 3:9a06c2bed650 | 385 | // wait(1); |
nikitateggi | 3:9a06c2bed650 | 386 | state=6; |
nikitateggi | 24:d992ee8369f4 | 387 | eprom_write_8(30,2); |
nikitateggi | 3:9a06c2bed650 | 388 | nstate=state; |
nikitateggi | 3:9a06c2bed650 | 389 | EnableTouch(); |
nikitateggi | 3:9a06c2bed650 | 390 | break; |
nikitateggi | 31:0f67acfc6236 | 391 | |
nikitateggi | 31:0f67acfc6236 | 392 | |
nikitateggi | 31:0f67acfc6236 | 393 | case 10 : DisableTouch(); |
nikitateggi | 31:0f67acfc6236 | 394 | wait_ms(300); |
nikitateggi | 31:0f67acfc6236 | 395 | EnableTouch(); |
nikitateggi | 31:0f67acfc6236 | 396 | state=nstate; |
nikitateggi | 31:0f67acfc6236 | 397 | break; |
nikitateggi | 31:0f67acfc6236 | 398 | |
nikitateggi | 31:0f67acfc6236 | 399 | case 11 : DisableTouch(); |
nikitateggi | 31:0f67acfc6236 | 400 | current_test_pid=eprom_read(1); |
nikitateggi | 31:0f67acfc6236 | 401 | bt_file_sent_pid=eprom_read(6); |
nikitateggi | 31:0f67acfc6236 | 402 | screen_patient_info(current_test_pid, bt_file_sent_pid); |
nikitateggi | 31:0f67acfc6236 | 403 | state1=0; |
nikitateggi | 31:0f67acfc6236 | 404 | state=12; |
nikitateggi | 31:0f67acfc6236 | 405 | EnableTouch(); |
nikitateggi | 31:0f67acfc6236 | 406 | break; |
nikitateggi | 31:0f67acfc6236 | 407 | |
nikitateggi | 31:0f67acfc6236 | 408 | |
nikitateggi | 1:8316c23ec6b9 | 409 | default : |
nikitateggi | 3:9a06c2bed650 | 410 | |
nikitateggi | 1:8316c23ec6b9 | 411 | state1=nstate1; |
nikitateggi | 1:8316c23ec6b9 | 412 | break; |
nikitateggi | 1:8316c23ec6b9 | 413 | |
nikitateggi | 0:c47fb0c1bbf6 | 414 | |
nikitateggi | 0:c47fb0c1bbf6 | 415 | } |
nikitateggi | 0:c47fb0c1bbf6 | 416 | |
nikitateggi | 0:c47fb0c1bbf6 | 417 | |
nikitateggi | 0:c47fb0c1bbf6 | 418 | |
nikitateggi | 19:1650bbc923cc | 419 | return state; |
nikitateggi | 0:c47fb0c1bbf6 | 420 | |
avp2417 | 34:8f6b0dc124e8 | 421 | } |