Added 4 point or 8 point averaging function .

Dependencies:   SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217

Fork of merged_code2_3rd_nov_2017 by nikita teggi

Revision:
47:3716dd41dba6
Parent:
46:162ed3f051b2
Child:
48:f90edb35a20e
--- a/bt.cpp	Wed Sep 13 06:06:41 2017 +0000
+++ b/bt.cpp	Wed Sep 13 11:24:19 2017 +0000
@@ -54,12 +54,13 @@
                   file_start=0;           
                   count_send=0;  total_samples=0;  
                   file_pointer_position=0;
-    
+    mc.printf("bt_pid = %d\n",get_btpid());
                 if(get_filepid()>get_btpid())                           //check for pid and bluetooth pid by reading from file
                 {
                     send_initial_string(); 
-                    state_rx = 1;
                     blue.printf("\n"); 
+                    file=sd_open_read(get_btpid());
+                    state_rx = 1;  
                 }
                          
                 else 
@@ -71,7 +72,7 @@
                          
                    
        case 2:   total_samples=0; 
-                 file=sd_open_read(get_btpid());  
+                 //file=sd_open_read(get_btpid());  
                  total_file_size=file_size() ;                           // determined the file size 
                  sd_read1(bt_file1);                                    // read the sd card file
                  mc.printf("sd file opened to read data in it\n");
@@ -213,7 +214,7 @@
                       { 
                        
                         state_tx=1;
-                      //  sd_close();
+                       sd_close();
                       }
                    break;                 
  
@@ -232,7 +233,7 @@
                       
                         state_tx=2;
                         setpos1(file_pointer_position);
-                        sd_close();                                                     //file closed which was opened earlier because it opens again in bt_send case 1
+                        //sd_close();                                                     //file closed which was opened earlier because it opens again in bt_send case 1
              
                         }
                     //blue.scanf("%02x%02x%08x%02x",&sos_rx,&ack_rx,&eos_rx,&chksum_rx);
@@ -285,7 +286,8 @@
                 {
                     sd_close();
                     increment_btpid();                // increment the bluetooth pid and write in the file
-                    mc.printf("next file");       
+                    mc.printf("next file");   
+                    mc.printf("bt_pid = %d\n",get_btpid());    
                     state_tx=1;
                           
                 }