Updated with option to return from BP screen to main screen, resolved screen navigation issues
Dependencies: SDFileSystem TFTLCD_8bit ds3231 program mbed
Fork of poc_dis_5 by
sdcard.cpp@5:a3ea7c82b7e1, 2017-03-30 (annotated)
- Committer:
- suhasini
- Date:
- Thu Mar 30 11:34:04 2017 +0000
- Revision:
- 5:a3ea7c82b7e1
- Parent:
- 4:6bd81bb1790d
PID updation possible, Proper screen navigation enabled, Return functionality from BP to main screen-done, date-time format modified, BP data not saved into SD card
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nikitateggi | 1:8316c23ec6b9 | 1 | #include "mbed.h" |
nikitateggi | 1:8316c23ec6b9 | 2 | #include <stdio.h> |
nikitateggi | 1:8316c23ec6b9 | 3 | #include "SDFileSystem.h" |
nikitateggi | 1:8316c23ec6b9 | 4 | #include "sdcard.h" |
nikitateggi | 1:8316c23ec6b9 | 5 | #include "rtc.h" |
nikitateggi | 3:9a06c2bed650 | 6 | |
nikitateggi | 1:8316c23ec6b9 | 7 | |
nikitateggi | 1:8316c23ec6b9 | 8 | SDFileSystem sd(PTE1, PTE3, PTE2, PTE4, "sd"); |
nikitateggi | 1:8316c23ec6b9 | 9 | FILE *fp=NULL; |
nikitateggi | 1:8316c23ec6b9 | 10 | |
nikitateggi | 4:6bd81bb1790d | 11 | void sd_open_GLCfile(int pid) // opening the glc file |
nikitateggi | 1:8316c23ec6b9 | 12 | { |
nikitateggi | 1:8316c23ec6b9 | 13 | |
nikitateggi | 1:8316c23ec6b9 | 14 | char buffer[32]; |
nikitateggi | 1:8316c23ec6b9 | 15 | char buffer1[32]; |
nikitateggi | 1:8316c23ec6b9 | 16 | time_t epoch_time1; |
nikitateggi | 1:8316c23ec6b9 | 17 | epoch_time1=rtc_read(); |
nikitateggi | 1:8316c23ec6b9 | 18 | // strftime(buffer, 32, "GLC_%s", pid); |
nikitateggi | 1:8316c23ec6b9 | 19 | |
nikitateggi | 4:6bd81bb1790d | 20 | sprintf(buffer1,"/sd/%d_GLC.csv",pid); |
nikitateggi | 1:8316c23ec6b9 | 21 | fp = fopen(buffer1,"a"); |
nikitateggi | 4:6bd81bb1790d | 22 | fprintf(fp,"%s\n",ctime(&epoch_time1) ); //writing the date, time into the file |
nikitateggi | 1:8316c23ec6b9 | 23 | |
nikitateggi | 1:8316c23ec6b9 | 24 | |
nikitateggi | 1:8316c23ec6b9 | 25 | } |
nikitateggi | 3:9a06c2bed650 | 26 | |
nikitateggi | 4:6bd81bb1790d | 27 | void sd_open_GLCfilee(int pid) // only opening the glc file after entering TEST screen |
nikitateggi | 2:3b7b71bfc941 | 28 | { |
nikitateggi | 2:3b7b71bfc941 | 29 | |
nikitateggi | 4:6bd81bb1790d | 30 | |
nikitateggi | 2:3b7b71bfc941 | 31 | char buffer1[32]; |
nikitateggi | 4:6bd81bb1790d | 32 | sprintf(buffer1,"/sd/%d_GLC.csv",pid); |
nikitateggi | 2:3b7b71bfc941 | 33 | fp = fopen(buffer1,"a"); |
nikitateggi | 2:3b7b71bfc941 | 34 | fprintf(fp,"PATIENT ID %d\n",pid); |
nikitateggi | 2:3b7b71bfc941 | 35 | |
nikitateggi | 1:8316c23ec6b9 | 36 | |
nikitateggi | 2:3b7b71bfc941 | 37 | } |
nikitateggi | 4:6bd81bb1790d | 38 | |
nikitateggi | 4:6bd81bb1790d | 39 | void sd_open_ECGfile(int pid) |
nikitateggi | 1:8316c23ec6b9 | 40 | { |
nikitateggi | 1:8316c23ec6b9 | 41 | |
nikitateggi | 1:8316c23ec6b9 | 42 | // char buffer[32]; |
nikitateggi | 1:8316c23ec6b9 | 43 | char buffer1[32]; |
nikitateggi | 1:8316c23ec6b9 | 44 | time_t epoch_time1; |
nikitateggi | 1:8316c23ec6b9 | 45 | epoch_time1=rtc_read(); |
nikitateggi | 1:8316c23ec6b9 | 46 | // strftime(buffer, 32, "ECG_%d", pid); |
nikitateggi | 1:8316c23ec6b9 | 47 | |
nikitateggi | 2:3b7b71bfc941 | 48 | sprintf(buffer1,"/sd/%d_ECG.csv",pid); |
nikitateggi | 1:8316c23ec6b9 | 49 | fp = fopen(buffer1,"a"); |
nikitateggi | 1:8316c23ec6b9 | 50 | fprintf(fp,"%s\n",ctime(&epoch_time1) ); |
nikitateggi | 4:6bd81bb1790d | 51 | |
nikitateggi | 1:8316c23ec6b9 | 52 | } |
nikitateggi | 1:8316c23ec6b9 | 53 | |
nikitateggi | 4:6bd81bb1790d | 54 | void sd_open_ECGfilee(int pid) // only opening the ECG file after entering TEST screen |
nikitateggi | 2:3b7b71bfc941 | 55 | { |
nikitateggi | 2:3b7b71bfc941 | 56 | |
nikitateggi | 2:3b7b71bfc941 | 57 | char buffer1[32]; |
nikitateggi | 4:6bd81bb1790d | 58 | sprintf(buffer1,"/sd/%d_ECG.csv",pid); |
nikitateggi | 2:3b7b71bfc941 | 59 | fp = fopen(buffer1,"a"); |
nikitateggi | 2:3b7b71bfc941 | 60 | fprintf(fp,"PATIENT ID %d\n",pid ); |
nikitateggi | 4:6bd81bb1790d | 61 | |
nikitateggi | 2:3b7b71bfc941 | 62 | } |
nikitateggi | 4:6bd81bb1790d | 63 | |
nikitateggi | 4:6bd81bb1790d | 64 | |
nikitateggi | 4:6bd81bb1790d | 65 | void sd_open_BPfile(int pid) |
nikitateggi | 1:8316c23ec6b9 | 66 | { |
nikitateggi | 1:8316c23ec6b9 | 67 | |
nikitateggi | 1:8316c23ec6b9 | 68 | char buffer[32]; |
nikitateggi | 1:8316c23ec6b9 | 69 | char buffer1[32]; |
nikitateggi | 1:8316c23ec6b9 | 70 | time_t epoch_time1; |
nikitateggi | 1:8316c23ec6b9 | 71 | epoch_time1=rtc_read(); |
nikitateggi | 1:8316c23ec6b9 | 72 | // strftime(buffer, 32, "ECG_%d", pid); |
nikitateggi | 1:8316c23ec6b9 | 73 | |
nikitateggi | 2:3b7b71bfc941 | 74 | sprintf(buffer1,"/sd/%d_BP.csv",pid); |
nikitateggi | 1:8316c23ec6b9 | 75 | fp = fopen(buffer1,"a"); |
nikitateggi | 1:8316c23ec6b9 | 76 | fprintf(fp,"%s\n",ctime(&epoch_time1) ); |
nikitateggi | 1:8316c23ec6b9 | 77 | } |
nikitateggi | 1:8316c23ec6b9 | 78 | |
nikitateggi | 4:6bd81bb1790d | 79 | void sd_open_BPfilee(int pid) // only opening the BP file after entering TEST screen |
nikitateggi | 4:6bd81bb1790d | 80 | { |
nikitateggi | 4:6bd81bb1790d | 81 | |
nikitateggi | 1:8316c23ec6b9 | 82 | |
nikitateggi | 4:6bd81bb1790d | 83 | char buffer1[32]; |
nikitateggi | 4:6bd81bb1790d | 84 | sprintf(buffer1,"/sd/%d_BP.csv",pid); |
nikitateggi | 4:6bd81bb1790d | 85 | fp = fopen(buffer1,"a"); |
nikitateggi | 4:6bd81bb1790d | 86 | fprintf(fp,"PATIENT ID %d\n",pid ); |
nikitateggi | 4:6bd81bb1790d | 87 | |
nikitateggi | 4:6bd81bb1790d | 88 | } |
nikitateggi | 4:6bd81bb1790d | 89 | |
nikitateggi | 4:6bd81bb1790d | 90 | void sd_write (int value) // writing data into the file |
nikitateggi | 1:8316c23ec6b9 | 91 | { |
nikitateggi | 1:8316c23ec6b9 | 92 | |
nikitateggi | 1:8316c23ec6b9 | 93 | fprintf(fp,"%d\n", value); |
nikitateggi | 1:8316c23ec6b9 | 94 | } |
nikitateggi | 1:8316c23ec6b9 | 95 | |
nikitateggi | 4:6bd81bb1790d | 96 | void sd_close() //closing the file |
nikitateggi | 1:8316c23ec6b9 | 97 | { |
nikitateggi | 1:8316c23ec6b9 | 98 | fclose(fp); |
nikitateggi | 1:8316c23ec6b9 | 99 | } |
nikitateggi | 1:8316c23ec6b9 | 100 | |
nikitateggi | 1:8316c23ec6b9 | 101 |