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@3:9a06c2bed650, 2017-02-10 (annotated)
- Committer:
- nikitateggi
- Date:
- Fri Feb 10 10:39:13 2017 +0000
- Revision:
- 3:9a06c2bed650
- Parent:
- 2:3b7b71bfc941
- Child:
- 4:6bd81bb1790d
Peak detect to 400 samples
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 | 1:8316c23ec6b9 | 11 | void sd_open_GLCfile(int pid) |
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 | 2:3b7b71bfc941 | 20 | sprintf(buffer1,"/sd/%d_GLC.csv",pid); |
nikitateggi | 1:8316c23ec6b9 | 21 | fp = fopen(buffer1,"a"); |
nikitateggi | 1:8316c23ec6b9 | 22 | fprintf(fp,"%s\n",ctime(&epoch_time1) ); |
nikitateggi | 1:8316c23ec6b9 | 23 | |
nikitateggi | 1:8316c23ec6b9 | 24 | |
nikitateggi | 1:8316c23ec6b9 | 25 | } |
nikitateggi | 3:9a06c2bed650 | 26 | |
nikitateggi | 2:3b7b71bfc941 | 27 | void sd_open_GLCfilee(int pid) |
nikitateggi | 2:3b7b71bfc941 | 28 | { |
nikitateggi | 2:3b7b71bfc941 | 29 | |
nikitateggi | 2:3b7b71bfc941 | 30 | char buffer[32]; |
nikitateggi | 2:3b7b71bfc941 | 31 | char buffer1[32]; |
nikitateggi | 2:3b7b71bfc941 | 32 | time_t epoch_time1; |
nikitateggi | 2:3b7b71bfc941 | 33 | epoch_time1=rtc_read(); |
nikitateggi | 2:3b7b71bfc941 | 34 | // strftime(buffer, 32, "GLC_%s", pid); |
nikitateggi | 2:3b7b71bfc941 | 35 | |
nikitateggi | 2:3b7b71bfc941 | 36 | sprintf(buffer1,"/sd/%d_GLC.csv",pid); |
nikitateggi | 2:3b7b71bfc941 | 37 | fp = fopen(buffer1,"a"); |
nikitateggi | 2:3b7b71bfc941 | 38 | fprintf(fp,"PATIENT ID %d\n",pid); |
nikitateggi | 2:3b7b71bfc941 | 39 | |
nikitateggi | 1:8316c23ec6b9 | 40 | |
nikitateggi | 2:3b7b71bfc941 | 41 | } |
nikitateggi | 1:8316c23ec6b9 | 42 | void sd_open_ECGfile(int pid) |
nikitateggi | 1:8316c23ec6b9 | 43 | { |
nikitateggi | 1:8316c23ec6b9 | 44 | |
nikitateggi | 1:8316c23ec6b9 | 45 | // char buffer[32]; |
nikitateggi | 1:8316c23ec6b9 | 46 | char buffer1[32]; |
nikitateggi | 1:8316c23ec6b9 | 47 | time_t epoch_time1; |
nikitateggi | 1:8316c23ec6b9 | 48 | epoch_time1=rtc_read(); |
nikitateggi | 1:8316c23ec6b9 | 49 | // strftime(buffer, 32, "ECG_%d", pid); |
nikitateggi | 1:8316c23ec6b9 | 50 | |
nikitateggi | 2:3b7b71bfc941 | 51 | sprintf(buffer1,"/sd/%d_ECG.csv",pid); |
nikitateggi | 1:8316c23ec6b9 | 52 | fp = fopen(buffer1,"a"); |
nikitateggi | 1:8316c23ec6b9 | 53 | fprintf(fp,"%s\n",ctime(&epoch_time1) ); |
nikitateggi | 1:8316c23ec6b9 | 54 | // strftime(buffer, 32, "ECG_%d-%m-%Y_%H_%M",localtime(&epoch_time1)); |
nikitateggi | 1:8316c23ec6b9 | 55 | // fprintf(fp,"%d\n",buffer ); |
nikitateggi | 1:8316c23ec6b9 | 56 | } |
nikitateggi | 1:8316c23ec6b9 | 57 | |
nikitateggi | 2:3b7b71bfc941 | 58 | void sd_open_ECGfilee(int pid) |
nikitateggi | 2:3b7b71bfc941 | 59 | { |
nikitateggi | 2:3b7b71bfc941 | 60 | |
nikitateggi | 2:3b7b71bfc941 | 61 | // char buffer[32]; |
nikitateggi | 2:3b7b71bfc941 | 62 | char buffer1[32]; |
nikitateggi | 2:3b7b71bfc941 | 63 | time_t epoch_time1; |
nikitateggi | 2:3b7b71bfc941 | 64 | epoch_time1=rtc_read(); |
nikitateggi | 2:3b7b71bfc941 | 65 | // strftime(buffer, 32, "ECG_%d", pid); |
nikitateggi | 2:3b7b71bfc941 | 66 | |
nikitateggi | 2:3b7b71bfc941 | 67 | sprintf(buffer1,"/sd/%d_ECG.csv",pid); |
nikitateggi | 2:3b7b71bfc941 | 68 | fp = fopen(buffer1,"a"); |
nikitateggi | 2:3b7b71bfc941 | 69 | fprintf(fp,"PATIENT ID %d\n",pid ); |
nikitateggi | 2:3b7b71bfc941 | 70 | // strftime(buffer, 32, "ECG_%d-%m-%Y_%H_%M",localtime(&epoch_time1)); |
nikitateggi | 2:3b7b71bfc941 | 71 | // fprintf(fp,"%d\n",buffer ); |
nikitateggi | 2:3b7b71bfc941 | 72 | } |
nikitateggi | 1:8316c23ec6b9 | 73 | void sd_open_BPfile(int pid) |
nikitateggi | 1:8316c23ec6b9 | 74 | { |
nikitateggi | 1:8316c23ec6b9 | 75 | |
nikitateggi | 1:8316c23ec6b9 | 76 | char buffer[32]; |
nikitateggi | 1:8316c23ec6b9 | 77 | char buffer1[32]; |
nikitateggi | 1:8316c23ec6b9 | 78 | time_t epoch_time1; |
nikitateggi | 1:8316c23ec6b9 | 79 | epoch_time1=rtc_read(); |
nikitateggi | 1:8316c23ec6b9 | 80 | // strftime(buffer, 32, "ECG_%d", pid); |
nikitateggi | 1:8316c23ec6b9 | 81 | |
nikitateggi | 2:3b7b71bfc941 | 82 | sprintf(buffer1,"/sd/%d_BP.csv",pid); |
nikitateggi | 1:8316c23ec6b9 | 83 | fp = fopen(buffer1,"a"); |
nikitateggi | 1:8316c23ec6b9 | 84 | fprintf(fp,"%s\n",ctime(&epoch_time1) ); |
nikitateggi | 1:8316c23ec6b9 | 85 | } |
nikitateggi | 1:8316c23ec6b9 | 86 | |
nikitateggi | 1:8316c23ec6b9 | 87 | |
nikitateggi | 1:8316c23ec6b9 | 88 | |
nikitateggi | 1:8316c23ec6b9 | 89 | void sd_write (int value) |
nikitateggi | 1:8316c23ec6b9 | 90 | { |
nikitateggi | 1:8316c23ec6b9 | 91 | |
nikitateggi | 1:8316c23ec6b9 | 92 | fprintf(fp,"%d\n", value); |
nikitateggi | 1:8316c23ec6b9 | 93 | } |
nikitateggi | 1:8316c23ec6b9 | 94 | |
nikitateggi | 1:8316c23ec6b9 | 95 | void sd_close() |
nikitateggi | 1:8316c23ec6b9 | 96 | { |
nikitateggi | 1:8316c23ec6b9 | 97 | fclose(fp); |
nikitateggi | 1:8316c23ec6b9 | 98 | } |
nikitateggi | 1:8316c23ec6b9 | 99 | |
nikitateggi | 1:8316c23ec6b9 | 100 |