aggiunta scrittura binaria

Dependencies:   SDFileSystem_conMOD mbed

Fork of f4_def_v2_def by Unina_corse

Files at this revision

API Documentation at this revision

Comitter:
rattokiller
Date:
Mon Jan 22 18:38:24 2018 +0000
Parent:
10:3ec4696ad874
Commit message:
prova all

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
sd_binario.h Show annotated file Show diff for this revision Revisions of this file
diff -r 3ec4696ad874 -r 870db9864028 main.cpp
--- a/main.cpp	Wed Dec 13 21:08:45 2017 +0000
+++ b/main.cpp	Mon Jan 22 18:38:24 2018 +0000
@@ -2,9 +2,21 @@
 #include "setting.h"
 #include "lettoreSD.h"
 #include "accellerometro.h"
-            
+#include "sd_binario.h"         
 DigitalIn mybutton(USER_BUTTON);            
-            
+
+void simula_dati(){
+static int n=0;
+float ax,ay,az;
+    ax=n++ /100.0;
+    ay=4.56;
+    az=-4.358;
+    //prelivevo dei dati fatto in tempo
+
+ invia_m(1000*ax+4000,1000*ay+4000,1000*az+4000,0,0,0);   
+}
+
+          
 int main() {
     init();  
     initFile();
@@ -16,7 +28,8 @@
     while(1){ 
         
         timer.start();
-        raccoltaDati();
+        //raccoltaDati();
+        simula_dati();
         //stampaFile("A1xxxxoooooggggggeeeeeeerrrryyyyynhgrgr#2\r\n");
         //fprintf(fp, "A1xxxxoooooggggggeeeeeeerrrryyyyynhgrgr#2\r\n");
         timer.stop();
diff -r 3ec4696ad874 -r 870db9864028 sd_binario.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sd_binario.h	Mon Jan 22 18:38:24 2018 +0000
@@ -0,0 +1,57 @@
+
+typedef struct {
+    char ax[2];
+    char ay[2];
+    char az[2];
+    char gx[2];
+    char gy[2];
+    char gz[2];             
+} message_t;
+
+
+struct r_f{
+char r_d;
+char r_s;   
+    
+};
+char num_n0(int a){
+  return a%256;
+}
+char num_n1(int a){
+    return (char)( a / 256);
+}
+
+void scrivi_rf(r_f ruote,bool flag=false){
+
+    if(flag){
+     ruote.r_d=255;
+    ruote.r_s=255;
+    }
+ fwrite(&ruote, sizeof(r_f), 1, fp);    
+    
+    
+}
+
+#define N 10
+void scrivi_imu(message_t*  imu){
+static int n=0;
+ fwrite(&imu, sizeof(message_t ), 1, fp);    
+
+
+ 
+}
+void invia_m (int ax,int ay,int az,int gx,int gy,int gz) {
+    
+    {
+        
+        message_t *message ;
+        message->ax[0] = num_n0(ax); message->ax[1] = num_n1(ax);
+        message->ay[0] = num_n0(ay); message->ay[1] = num_n1(ay);
+        message->az[0] = num_n0(az); message->az[1] = num_n1(az);
+        message->gx[0] = num_n0(gx); message->gx[1] = num_n1(gx);
+        message->gy[0] = num_n0(gy); message->gy[1] = num_n1(gy);
+        message->gz[0] = num_n0(gz); message->gz[1] = num_n1(gz);
+    scrivi_imu(message);
+    }
+}
+