
Changes done in ECG and BT
Dependencies: SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217
Fork of merged_code2_20sept_2017_4th_oct_2017 by
Revision 43:85a7f399cb9d, committed 2017-09-11
- Comitter:
- rashmivenkataramaiah
- Date:
- Mon Sep 11 13:09:29 2017 +0000
- Parent:
- 42:c81673b04b6a
- Child:
- 44:05dbea558c9a
- Commit message:
- PID tracking with get and inc file pid and bt pid
Changed in this revision
--- a/bp.cpp Mon Sep 11 10:02:46 2017 +0000 +++ b/bp.cpp Mon Sep 11 13:09:29 2017 +0000 @@ -15,6 +15,7 @@ #include "ec_bp.h" #include "bp.h" #include "display_modules.h" +#include "main.h" #define MAX_SBP_THRESHOLD 300 @@ -41,7 +42,7 @@ uint16_t ebp = 0; // variable for LOOP operation to read value from File i == ECG , j == PPG uint16_t pbp = 0; //int to uint16_t-Suhasini-21stJuly2017 -void bp(int32_t pid) { +void bp(uint32_t pid) { uint8_t uch_dummy; uint32_t ppgdata; @@ -226,7 +227,12 @@ structure_file(ptr_BLEMsg_info_bp, pid); // Copy BP structure to main file bpfile_mainfile(pid); screen_bp1(SBP,DBP); - } + if(get_filecreated_status() == false) //if file is in write mode + { + set_filecreated_status(); + increment_filepid (); + } + } } //Added Nidhin 16/6/17 else //Added Nidhin 16/6/17
--- a/bp.h Mon Sep 11 10:02:46 2017 +0000 +++ b/bp.h Mon Sep 11 13:09:29 2017 +0000 @@ -14,7 +14,7 @@ #define PPG_SPLS BUFFER*PPG_LOOP #define BPLEN_BYT 10778 // TOTAL length in BYTEs for BP inclu Should change if BUffer is changed -void bp(int32_t pid); +void bp(uint32_t pid); uint16_t sd_BP_ECGMAX(int32_t pid); // updated- Suhasini-21/7/17 uint16_t sd_BP_PPGMAX(int32_t pid); // updated- Suhasini-21/7/17
--- a/ecg_dec.h Mon Sep 11 10:02:46 2017 +0000 +++ b/ecg_dec.h Mon Sep 11 13:09:29 2017 +0000 @@ -3,5 +3,5 @@ #ifndef ECG_DEC_H_ #define ECG_DEC_H_ -uint16_t ecg(int32_t pid); +uint16_t ecg(uint32_t pid); #endif \ No newline at end of file
--- a/ecgg.cpp Mon Sep 11 10:02:46 2017 +0000 +++ b/ecgg.cpp Mon Sep 11 13:09:29 2017 +0000 @@ -14,7 +14,7 @@ #include "ec_bp.h" #include "eeprom_pgm.h" #include "struct.h" // Added on 31/5/17_Nidhin - +#include "main.h" //#include "test_type.h" //Added on 31/5/17_Nidhin #define MAX_HR_THRESHOLD 205 @@ -25,7 +25,7 @@ Serial pc(USBTX,USBRX); -uint16_t ecg(int32_t pid) +uint16_t ecg(uint32_t pid) //float ecg(int pid) { @@ -248,6 +248,11 @@ structure_file(ptr_BLEMsg_info_ecg, pid); //copy the ECG structure to Main file //COMMENTED Nidhin 10/6/2017 ecgfile_mainfile(pid); // copy raw data to the main file and ECG file is cleared. //COMMENTED Nidhin 10/6/2017 + if(get_filecreated_status() == false) //if file is in write mode + { + set_filecreated_status(); + increment_filepid (); + } pc.printf("Closed the main file\n"); return HR_avg; }
--- a/glc.cpp Mon Sep 11 10:02:46 2017 +0000 +++ b/glc.cpp Mon Sep 11 13:09:29 2017 +0000 @@ -10,7 +10,7 @@ #include "rtc.h" #include "sdcard.h" #include "eeprom_pgm.h" // Nidhin 12/6/17 - +#include "main.h" #include "struct.h" //Nidhin 31/5/2017 //#include "test_type.h" //Nidhin 31/5/2017 @@ -106,7 +106,7 @@ } -void glc(int32_t pid){ +void glc(uint32_t pid){ char t_s_d = 0; i2c_spec(); // programming the i2c expander @@ -264,7 +264,12 @@ structure_file(ptr_BLEMsg_info_glc, pid); // Copy the structure into the GLC file glcfile_mainfile(pid); - } + if(get_filecreated_status() == false) //if file is in write mode + { + set_filecreated_status(); + increment_filepid (); + } + } else if(err == 1 || mgdl > MAX_GLC_THRESHOLD || mgdl < MIN_GLC_THRESHOLD) // added threshold to check value out of range { gtc.printf("replace teststip");
--- a/glc.h Mon Sep 11 10:02:46 2017 +0000 +++ b/glc.h Mon Sep 11 13:09:29 2017 +0000 @@ -13,6 +13,6 @@ #define alpha 0.99 #define beta 0.01 -void glc(int32_t pid); +void glc(uint32_t pid); #endif \ No newline at end of file
--- a/main.cpp Mon Sep 11 10:02:46 2017 +0000 +++ b/main.cpp Mon Sep 11 13:09:29 2017 +0000 @@ -26,10 +26,9 @@ static uint8_t nstate1=0; static uint32_t current_test_pid=0; static uint32_t bt_file_sent_pid=0; -uint32_t pid = 0; // patient ID -bool file_created_status = false; //initialise file created to 0 -static uint32_t pid_btpid[2]; -uint32_t filepid_btpid[2] = {}; +static uint32_t pid = 0; // patient ID +static bool file_created_status = false; //initialise file created to 0 +static uint32_t filepid_btpid[2] = {}; int main() { @@ -292,11 +291,6 @@ case 7: DisableTouch(); glc(pid); // glc measurement - if(get_filecreated_status() == false) //if file is in write mode - { - set_filecreated_status(); - increment_pid (); - } glc_flag=1; wait(1); state1=0; @@ -326,13 +320,7 @@ screen_ecg_2(heart_rate); ecg_flag=1; - } - if(get_filecreated_status() == false) //if file is in write mode - { - set_filecreated_status(); - increment_pid (); - } - + } state=6; eprom_write_8(30,1); nstate=state; @@ -345,11 +333,6 @@ screen_bp2(); // bp main screen bp_countdown(); // countdown for bp bp(pid); // measuring bp earlier bp() changed to bp(pid) 28/4/2017 - if(get_filecreated_status() == false) //if file is in write mode - { - set_filecreated_status(); - increment_pid (); - } state1=0; state=6; eprom_write_8(30,2); @@ -408,9 +391,9 @@ file_created_status = false; } -void increment_pid (void) //increment pid if a test is completed +void increment_filepid (void) //increment pid if a test is completed { - uint32_t filepid_btpid[2] = {}; + //uint32_t filepid_btpid[2] = {}; //set_filecreated_status(); //set it to make it append mode sd_read(filepid_btpid); //read pid from sd card @@ -419,6 +402,17 @@ } +void increment_btpid (void) //increment pid if a test is completed +{ + //uint32_t filepid_btpid[2] = {}; + + //set_filecreated_status(); //set it to make it append mode + sd_read(filepid_btpid); //read pid from sd card + filepid_btpid[0] = filepid_btpid[1] + 1; //increment it by 1 + sd_write(filepid_btpid); //write it back to sd card + +} + uint32_t get_filepid(void) { //uint32_t filepid_btpid[2] = {};
--- a/main.h Mon Sep 11 10:02:46 2017 +0000 +++ b/main.h Mon Sep 11 13:09:29 2017 +0000 @@ -6,8 +6,8 @@ bool get_filecreated_status(void); //get status of file created void set_filecreated_status(void); //set file created void clear_filecreated_status(void); //clear file created -void increment_pid (void); - +void increment_filepid (void); +void increment_btpid (void); uint32_t get_btpid(void); void store_btpid(uint32_t bt_pid); uint32_t get_filepid(void);
--- a/sdcard.cpp Mon Sep 11 10:02:46 2017 +0000 +++ b/sdcard.cpp Mon Sep 11 13:09:29 2017 +0000 @@ -54,7 +54,7 @@ } */ - void sd_open_GLCfilee(int32_t pid) // only opening the glc file after entering TEST screen + void sd_open_GLCfilee(uint32_t pid) // only opening the glc file after entering TEST screen { char buffer1[32]; sprintf(buffer1,"/sd/%d_GLC.csv",pid); @@ -63,7 +63,7 @@ } - void sd_open_ECGfilee(int32_t pid) // only opening the ECG file after entering TEST screen + void sd_open_ECGfilee(uint32_t pid) // only opening the ECG file after entering TEST screen { char buffer1[32]; @@ -74,7 +74,7 @@ } -void sd_open_BPfilee(int32_t pid) // only opening the BP file after entering TEST screen +void sd_open_BPfilee(uint32_t pid) // only opening the BP file after entering TEST screen { @@ -91,7 +91,7 @@ } -uint8_t sd_open_read(int32_t pid) // opening the file for read // CHNAGED to return value +uint8_t sd_open_read(uint32_t pid) // opening the file for read // CHNAGED to return value { char buffer1[32]; @@ -184,7 +184,7 @@ } //-----------------------------------------------SD Read - void sd_reopen_BPfilee(int32_t pid) // only opening the BP file after entering TEST screen + void sd_reopen_BPfilee(uint32_t pid) // only opening the BP file after entering TEST screen { @@ -201,7 +201,7 @@ //--------------------------------------- - void sd_open_BP_ECGfile(int32_t pid) + void sd_open_BP_ECGfile(uint32_t pid) { //char buffer[32]; @@ -221,7 +221,7 @@ } - void sd_open_BP_PPGfile(int32_t pid) + void sd_open_BP_PPGfile(uint32_t pid) { char buffer1[32]; @@ -278,7 +278,7 @@ //------- FUNCTION TO CREATE SINGLE BP FILE --------2/5/2017 (NIDHIN)---------------// - void create_single_BPfile(int32_t pid) + void create_single_BPfile(uint32_t pid) { //int ecgbuf[64] = {0}; @@ -341,7 +341,7 @@ //Creating strcuture file Common to All Functions -void structure_file(BLEMsg_info *ptr, int32_t pid) +void structure_file(BLEMsg_info *ptr, uint32_t pid) { char buffer3[32]; sprintf(buffer3, "/sd/%d.csv", pid); //Printing file path to the buffer @@ -362,7 +362,7 @@ //Copy Data into file. -void bpfile_mainfile(int32_t pid) //Copy data of bp file to main +void bpfile_mainfile(uint32_t pid) //Copy data of bp file to main { char buffer3[32]; sprintf(buffer3, "/sd/%d.csv", pid); @@ -394,7 +394,7 @@ //------------ Function to write ECG data to main file -void ecgfile_mainfile(int32_t pid) +void ecgfile_mainfile(uint32_t pid) { char buffer3[32]; sprintf(buffer3, "/sd/%d.csv", pid); @@ -428,7 +428,7 @@ //---------------------- Function to write GLC data to GLC file -void sd_glcwrite(uint32_t *glc_ptr, int32_t pid) +void sd_glcwrite(uint32_t *glc_ptr, uint32_t pid) { char buffer3[32]; sprintf(buffer3, "/sd/%d_GLC.csv", pid); @@ -441,7 +441,7 @@ // --------------------------Fuinction to write GLC data to Main file -void glcfile_mainfile(int32_t pid) +void glcfile_mainfile(uint32_t pid) { char buffer3[32]; sprintf(buffer3, "/sd/%d.csv", pid); @@ -465,7 +465,7 @@ } -void delete_subfiles(int32_t pid) +void delete_subfiles(uint32_t pid) { char buffer3[32]; int success1 , success2, success3; @@ -499,7 +499,7 @@ } -void del_ppg_ecg_BPfile(int32_t pid) +void del_ppg_ecg_BPfile(uint32_t pid) { int status = 1 ; char buffer3[32];
--- a/sdcard.h Mon Sep 11 10:02:46 2017 +0000 +++ b/sdcard.h Mon Sep 11 13:09:29 2017 +0000 @@ -7,16 +7,16 @@ #include "struct.h" //void sd_open_ECGfile(int pid); -void sd_open_ECGfilee(int32_t pid); +void sd_open_ECGfilee(uint32_t pid); //void sd_open_GLCfile(int pid); -void sd_open_GLCfilee(int32_t pid); -void sd_open_BPfilee(int32_t pid); +void sd_open_GLCfilee(uint32_t pid); +void sd_open_BPfilee(uint32_t pid); //void sd_open_BPfile(int pid); void sd_write (int value); int file_size() ; int file_size1() ; void sd_read(uint32_t *v1, int size); -uint8_t sd_open_read(int32_t pid); +uint8_t sd_open_read(uint32_t pid); void sd_read1(BLEMsg_info &f); void setpos(); void setpos1(uint32_t position); @@ -26,8 +26,8 @@ FILE *sd_BP_ecgwrite (uint32_t *fpdrum11); FILE *sd_BP_ppgwrite (uint32_t *fpdrum21); -void sd_open_BP_ECGfile(int32_t pid); //added to write ECG to seperate file BP -void sd_open_BP_PPGfile(int32_t pid); //added to write PPG to seperate file BP +void sd_open_BP_ECGfile(uint32_t pid); //added to write ECG to seperate file BP +void sd_open_BP_PPGfile(uint32_t pid); //added to write PPG to seperate file BP void sd_close(); // Close files opend with FILE pointer fp void sd_close_ecg() ; // Close files opend with FILE pointer fpeecg @@ -35,23 +35,23 @@ //void sd_close1(); -void create_single_BPfile(int32_t pid); //Function to create 1 file from 2 temp BP file (ECG &PPG) +void create_single_BPfile(uint32_t pid); //Function to create 1 file from 2 temp BP file (ECG &PPG) -void sd_open_mainfile(int32_t pid); // Function for oprning main file +void sd_open_mainfile(uint32_t pid); // Function for oprning main file //----------------- For testing -void structure_file(BLEMsg_info *ptr, int32_t pid); // Writes structure to the File. +void structure_file(BLEMsg_info *ptr, uint32_t pid); // Writes structure to the File. -void bpfile_mainfile(int32_t pid); +void bpfile_mainfile(uint32_t pid); void sd_ecgwrite(uint32_t *ecg_ptr); //to print ECG data in ECG func as binary using fwrite. NIDHIN 25 May 2017 -void ecgfile_mainfile(int32_t pid); +void ecgfile_mainfile(uint32_t pid); -void sd_glcwrite(uint32_t *glc_ptr, int32_t pid); // GLC raw data to GLC file -void glcfile_mainfile(int32_t pid); // GLC file to main file +void sd_glcwrite(uint32_t *glc_ptr, uint32_t pid); // GLC raw data to GLC file +void glcfile_mainfile(uint32_t pid); // GLC file to main file -void delete_subfiles(int32_t pid); //deletes all subfiles under a pid +void delete_subfiles(uint32_t pid); //deletes all subfiles under a pid -void del_ppg_ecg_BPfile(int32_t pid); // deletes temporary ECG_PPG files in BP when ERROR condition- 22/7/17-Suhasini +void del_ppg_ecg_BPfile(uint32_t pid); // deletes temporary ECG_PPG files in BP when ERROR condition- 22/7/17-Suhasini void sd_write(uint32_t *pid_btpid); void sd_read(uint32_t *pid_btpid);