
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 54:f2a413d5dffd, committed 2017-09-27
- Comitter:
- nikitateggi
- Date:
- Wed Sep 27 09:36:26 2017 +0000
- Parent:
- 53:cc6e65480a67
- Child:
- 55:057f4af9d581
- Commit message:
- Modification in LPF and GLC
Changed in this revision
--- a/bt.cpp Wed Sep 20 11:02:08 2017 +0000 +++ b/bt.cpp Wed Sep 27 09:36:26 2017 +0000 @@ -33,7 +33,7 @@ static uint32_t counter=0; static uint32_t v1[NO_OF_SAMPLES]; uint8_t file=0; - +static uint32_t bt_pid = 0; uint8_t bt_send(uint8_t state_tx) { @@ -54,12 +54,13 @@ file_start=0; count_send=0; total_samples=0; file_pointer_position=0; + bt_pid = get_btpid()+1; //added on 22/09/2017 nikita mc.printf("bt_pid = %d\n",get_btpid()); - if(get_filepid()>get_btpid()) //check for pid and bluetooth pid by reading from file + if(get_filepid()>bt_pid) //check for pid and bluetooth pid by reading from file { send_initial_string(); blue.printf("\n"); - file=sd_open_read(get_btpid()); // open the file for reading + file=sd_open_read(bt_pid); // open the file for reading total_file_size=file_size(); // determined the file size state_rx = 1; }
--- a/display_modules.cpp Wed Sep 20 11:02:08 2017 +0000 +++ b/display_modules.cpp Wed Sep 27 09:36:26 2017 +0000 @@ -120,7 +120,7 @@ TFT.fillrect( 10,130,100,200,GreenYellow); TFT.locate(38,160) ; //changed from 30 to 38 //rashmi 24/7/17 //changed from 40 to 30 //rashmi 22/7/17 TFT.printf("BT") ; -TFT.fillrect( 130,130,220,200,GreenYellow); + TFT.fillrect( 130,130,220,200,GreenYellow); TFT.locate(140,160) ; //changed from 135 to 145 //rashmi 22/7/17 // TFT.printf("P-Inf") ; TFT.fillrect( 10,215,100,285,GreenYellow); @@ -128,7 +128,7 @@ TFT.printf("HOME") ; ////changed from BLE to BT //rashmi 24/7/17 - if ((read_debug_status()== 1) && get_timer_debug()<TIMER_ENABLE_DEBUG_MODE) // checking for the debug status and timer + if ((read_debug_status()== true) && get_timer_debug()<TIMER_ENABLE_DEBUG_MODE) // checking for the debug status and timer { TFT.fillrect(130,215,220,285,GreenYellow); TFT.locate(150,230) ;
--- a/ecgg.cpp Wed Sep 20 11:02:08 2017 +0000 +++ b/ecgg.cpp Wed Sep 27 09:36:26 2017 +0000 @@ -135,7 +135,7 @@ // ------------------------- Declaration for Heart Rate calculation -------------------------- uint8_t n=0; - float pos_dif; // changed from float to uint16_t- Suhasini- 8-8-17, changed back to float- 17th aug,2017 + uint16_t pos_dif; // changed from float to uint16_t- Suhasini- 8-8-17, changed back to float- 17th aug,2017 float HR[10],HR1,t_pos_dif; uint8_t t_sec = 60; float HR_sum = 0,HR_avg; @@ -222,7 +222,7 @@ { pos_dif = pk_pos[i+1] - pk_pos[i]; // difference between two consequtive peaks pc.printf("peak position diff is = %d\n",pos_dif); - t_pos_dif = pos_dif/fs; // sample difference between peak positions divided by sampling frequency gives the difference value in terms of actual time + t_pos_dif = (float)pos_dif/fs; // sample difference between peak positions divided by sampling frequency gives the difference value in terms of actual time pc.printf("time in seconds is = %f\n",t_pos_dif); HR[i] = t_sec/t_pos_dif; //HR calculation pc.printf("Heart Rate is = %f\n",HR[i]); @@ -278,8 +278,8 @@ FILE *fpecg1; // FILE pointer to read raw data ECG file added by Suhasini 5-8-17 FILE *fpeecg_lpf; // FILE pointer to read and write into LPF output file added by Suhasini 5-8-17 static uint32_t ecg_raw_temp[5]; // changed by rohit on 13 sep - static uint32_t ecg_raw[5]; // Buff of 5 samples created to Stores input samples for LPF added by Suhasini - 5-8-17 - static uint32_t lpf_op[5]= {0.0}; // for LPF output added by Suhasini - 5-8-17 // changed from double to int32_t- 16-8-17 + uint32_t ecg_raw[5]; // Buff of 5 samples created to Stores input samples for LPF added by Suhasini - 5-8-17 added by rohit + uint32_t lpf_op[5]= {0.0}; // for LPF output added by Suhasini - 5-8-17 // changed from double to int32_t- 16-8-17 added by rohit uint32_t lpf_4samp = 0; // Variable to move 16 samples back from current in input file - changed by Suhasini- 5-8-17 char buffer3[32];
--- a/glc.cpp Wed Sep 20 11:02:08 2017 +0000 +++ b/glc.cpp Wed Sep 27 09:36:26 2017 +0000 @@ -86,21 +86,6 @@ datafinal1 = (uint16_t ) NUMB1*(data2*VREF/(TOTAL))-NUMB2; datafinal2 = (uint16_t ) NUMB1*(daata1*VREF/(TOTAL))-NUMB2; mgdl = (uint16_t) NUMB1*(((daata1+data2)/2)*VREF/(TOTAL))-NUMB2; // Nidhin 5/6/17 mgdl = (uint16_t) NUMB1*(((daata1+data2)/2)*VREF/(TOTAL))-NUMB2; - - - - if (err == 0) - { - - glc_4(mgdl); - - } - - else - { - // gtc.printf("err=1\n"); Commented Nidhin 8/6/2017 - - } GLC_START = 0; flipper1.detach();// ticker for computation is disabled } @@ -109,7 +94,8 @@ void glc(uint32_t pid){ char t_s_d = 0; - i2c_spec(); // programming the i2c expander + i2c_spec(); // programming the i2c expander + uint8_t err_no_teststip = 0; sd_open_GLCfilee(pid); // Opens GLC file in APPEND mode @@ -238,16 +224,21 @@ } } if(test_strip) // added on 11/8/17 nikita - glc_error_test_strip_removed(); + { + err_no_teststip = 1; + + + } wait_ms(800); } //gtc.printf("mgdl is - %d\n", mgdll); } wait(2.25); - - if (err==0) + gtc.printf("error = %d\n", err); + if ((err==0) && (err_no_teststip == 0) && ( mgdl < MAX_GLC_THRESHOLD) && ( mgdl > MIN_GLC_THRESHOLD)) { + glc_4(mgdl); gtc.printf("DATA1 is - %d\n", data1n); gtc.printf("DATA2 is - %d\n", data2n); gtc.printf("mgdl is - %d\n", mgdl); @@ -262,18 +253,27 @@ BLEMsg_info_glc.cal_data.cal_sbp_dummy = (uint16_t) glc_testtype; // Data stored into structure BLEMsg_info_glc.cal_data.cal_dbp_OTtyp = (uint16_t) mgdl; //To be checked for reliable results - structure_file(ptr_BLEMsg_info_glc, pid); // Copy the structure into the GLC file + 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 + 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 + else // added threshold to check value out of range { - gtc.printf("replace teststip"); - glc_error(); //disaply for showing error//10/7/17//nikita + if(err_no_teststip == 1) // added on 22/09/2017 nikita // to separately detect what is the parameter failed while testing + { + glc_error_test_strip_removed(); + } + + else if(err == 1 || mgdl > MAX_GLC_THRESHOLD || mgdl < MIN_GLC_THRESHOLD) + { + gtc.printf("replace teststip"); + glc_error(); //disaply for showing error//10/7/17//nikita + } + delete_subfiles(pid); // added on 11/8/17 nikita }
--- a/main.cpp Wed Sep 20 11:02:08 2017 +0000 +++ b/main.cpp Wed Sep 27 09:36:26 2017 +0000 @@ -37,11 +37,11 @@ Timer timer_bt; // timer for bluetooth Timer timer_battery; // timer for battery Timer timer_debug; // timer for entering the debug mode -static bool debug_mode=0; // holds the status of the debug mode "1" indicates the device is in debug mode +static bool debug_mode=false; // holds the status of the debug mode "1" indicates the device is in debug mode char debug_message_rx[6]; // buffer to receive the debug message data char debug_message[6]={"debug"}; //debug message to be received void debug_status_monitoring(); // debug status monitoring - +static uint32_t pid = 0; // patient ID int main() { @@ -57,6 +57,7 @@ gc.baud(115200); blue1.baud(115200); init_screen(); //initialize lcd + pid = get_filepid() + 1; //added on 22/09/2017 nikita screen_main(); // display of main screen battery_monitor(); // monitor battery at the start only battery_status_display(); // display of main screen @@ -67,7 +68,7 @@ while(1) { - if (read_debug_status() == 0) // checking the debug_mode status + if (read_debug_status() == false) // checking the debug_mode status { if(timer_debug.read_ms()<TIMER_ENTER_DEBUG_MODE) { @@ -317,7 +318,7 @@ static uint8_t ecg_flag=0; // ecg_flag to indicate the ecg test is already done for the same pid static uint8_t glc_flag=0; // glc_flag to indicate the glc test is already done for the same pid uint16_t heart_rate=0; - static uint32_t pid = 0; // patient ID + switch(state1) // state for display screens { @@ -628,8 +629,8 @@ { -if(get_timer_debug()<TIMER_ENTER_DEBUG_MODE) -{ +//if(get_timer_debug()<TIMER_ENTER_DEBUG_MODE) +//{ if (gc.readable()) // check for the user input { @@ -644,13 +645,13 @@ if (strcmp(debug_message_rx, debug_message) == 0) // compare the message with the required one { - debug_mode = 1; // enable the debug mode status + debug_mode = true; // enable the debug mode status gc.printf("entered into debug mode\n"); timer_debug.reset(); timer_debug.start(); // timer is started in orede } } -} +//} }
--- a/main.h Wed Sep 20 11:02:08 2017 +0000 +++ b/main.h Wed Sep 27 09:36:26 2017 +0000 @@ -1,7 +1,7 @@ #ifndef MAIN_H_ #define MAIN_H_ -#define TIMER_ENABLE_DEBUG_MODE 60000 +#define TIMER_ENABLE_DEBUG_MODE 600000 //added on 22/09/2017 nikita bool get_filecreated_status(void); //get status of file created void set_filecreated_status(void); //set file created
--- a/touch_modules.cpp Wed Sep 20 11:02:08 2017 +0000 +++ b/touch_modules.cpp Wed Sep 27 09:36:26 2017 +0000 @@ -113,7 +113,7 @@ } - else if ((read_debug_status()== 1) && get_timer_debug()<TIMER_ENABLE_DEBUG_MODE) // checking for the debug status and timer + else if ((read_debug_status()== true) && get_timer_debug()<TIMER_ENABLE_DEBUG_MODE) // checking for the debug status and timer { if ( ((xt >= DEBUG_MAIN_X_MIN) && (xt <= DEBUG_MAIN_X_MAX)) && ( (yt >= DEBUG_MAIN_Y_MIN) && (yt <= DEBUG_MAIN_Y_MAX) ) ) // DELETE {