Log measurements on SD card added on DISCO-L476VG board acceleration, omega, compass & 5 Analog values

Dependencies:   BSP_DISCO_L476VG COMPASS_DISCO_L476VG ConfigFile GYRO_DISCO_L476VG SDFileSystem mbed

Revision:
0:0861bf46efe4
Child:
1:e1f3b4b8b99b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DataFile/DataFile.cpp	Fri Feb 12 20:54:38 2016 +0000
@@ -0,0 +1,85 @@
+#include "DataFile.h"
+#include "ConfigFile.h" //pour lire le fichier de configuration
+
+#include "mbed.h"
+#include "util.h"
+
+//tDataFile::tDataFile(DigitalOut* apLedRecord)
+tDataFile::tDataFile()
+{
+ Opened=0;  
+ //pLedRecord=apLedRecord;
+}
+
+
+
+
+void tDataFile::New()
+{
+    
+    char DataFileName[40] ;
+    char NumFich[40];
+    char *keyIndex = "Index";
+    char value[BUFSIZ];
+    ConfigFile cfg;
+    if (Opened==0)
+    {
+        //récupère le n° d'index dans un fichier de configuration
+        if (!cfg.read("/sd/index.txt")) {
+            error("Failure to read index file.\n");
+        }  
+        cfg.getValue(keyIndex, &value[0], sizeof(value));
+        Index=atoi(value);
+        printf("Index=%d\r\n", Index);    
+    
+        //crèe le non de fichier à créer
+        //  printf("OpenDataFile\n\r");
+        strcpy(DataFileName,"/sd/"); 
+        //  printf("DataFileName=%s\n\r",DataFileName);
+        itoa(Index,NumFich);
+        //  printf("numFich=%s\n\r",NumFich);
+        strcat (DataFileName,NumFich);
+        //   printf("DataFileName=%s\n\r",DataFileName);
+        strcat (DataFileName,".txt");
+        printf("DataFileName=%s\n\r",DataFileName);
+    
+        //met à jour l'index
+        
+        itoa(Index+1,NumFich);
+        printf("Prochain fichier a ecrire=%s\n\r",NumFich);
+        cfg.setValue(keyIndex, NumFich);
+        cfg.write("/sd/index.txt","index",cfg.DOS);
+    
+        //ouvre le fichier
+        fp= fopen(DataFileName, "a");  // Open "xxx.txt" on the local file system for writing
+    
+        fprintf(fp, "Gx\tGy\tGz\tWx\tWy\tWz\tMx\tMy\tMz\n");  
+        Opened=1;  
+        printf("DataFile opened\n\r"); 
+        
+          
+    }
+}
+
+void tDataFile::Close()
+{
+  if (Opened==1)
+  {
+      fclose(fp);  
+      Opened=0;
+      printf("DataFile Closed\n\n\r"); 
+    }
+}
+
+void tDataFile::SaveMesures(tMesure * apMesure)
+{
+ 
+  if (Opened==1)
+    {
+     printf("sauvegarde en cours\r\n");
+     apMesure->Save(fp);
+    }
+}
+
+
+