Nicola d'Ambrosio / Mbed 2 deprecated ncola_f4_def_v2_def

Dependencies:   SDFileSystem_conMOD mbed-rtos mbed

Fork of ncola_f4_def_v2_def by Unina_corse

Files at this revision

API Documentation at this revision

Comitter:
NdA994
Date:
Mon Jan 29 13:31:16 2018 +0000
Parent:
11:295d7cea3c7d
Commit message:
ruote foniche con binario;

Changed in this revision

lettoreSD.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib 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 295d7cea3c7d -r f5aae967c4d7 lettoreSD.h
--- a/lettoreSD.h	Mon Jan 29 12:15:24 2018 +0000
+++ b/lettoreSD.h	Mon Jan 29 13:31:16 2018 +0000
@@ -3,11 +3,13 @@
 
 #include "SDFileSystem.h"
 
+void inviaMessaggio(char ax, char ay);
 int nFile = 1;
  
 SDFileSystem sd(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, "sd");
 FILE *fp;
-char buffer[86100];
+
+char buffer[10];
 int nCounter = 0;
 
 void initFile(){
@@ -19,13 +21,13 @@
     char destinazione[14];
     char path[21]="/sd/mydir/";
     sprintf(destinazione, "%d", nFile); 
-    strcat(destinazione, ".txt");
+    strcat(destinazione, ".dat");
     strcat(path, destinazione);
     fp = fopen(path, "a");
     if(fp == NULL){
         error("Could not open file for write\n");
     }
-    fprintf(fp, "###########FLAG MARCATORE RESET/ACCENSIONE-SPEGNIMENTO############\r\n");
+    inviaMessaggio(255, 150);
     return fp;
 }
     
diff -r 295d7cea3c7d -r f5aae967c4d7 main.cpp
--- a/main.cpp	Mon Jan 29 12:15:24 2018 +0000
+++ b/main.cpp	Mon Jan 29 13:31:16 2018 +0000
@@ -2,6 +2,7 @@
 #include "setting.h"
 #include "lettoreSD.h"
 #include "accellerometro.h"
+#include "sd_binario.h"
             
 DigitalIn mybutton(USER_BUTTON);            
             
@@ -25,19 +26,22 @@
         nad2=nad;
          nas=nad=0;
         timer.start();
-        fprintf(fp,"%d %.d\n\r",50*nad2/64.0,50*nas2/64.0);
+        //fprintf(fp,"%d %.d\n\r",50*nad2/64.0,50*nas2/64.0);
+        inviaMessaggio((char)(500*nad2/64.0), (char)(500*nas2/64.0));
+
+        
          //fprintf(fp,"%.2f %.2f\n\r",50*nad/64.0,50*nas/64.0);
-         pc.printf("%.2f %.2f\n\r",50*nad2/64.0,50*nas2/64.0);
+         pc.printf("%.2f %.2f\n\r",500*nad2/64.0, 500*nas2/64.0);
         
         //raccoltaDati();
         //stampaFile("A1xxxxoooooggggggeeeeeeerrrryyyyynhgrgr#2\r\n");
         //fprintf(fp, "A1xxxxoooooggggggeeeeeeerrrryyyyynhgrgr#2\r\n");
         timer.stop();
         if(timer.read_ms()>20){//non si tiene conto del tempo perso per scrive i dati
-                int overTime = (timer.read_ms() / 10) + 1;
-                 pc.printf("tempo: %d e overtime %d\n\r ", timer.read_ms(), overTime);
+                int overTime = (timer.read_ms() / 20) + 1;
+                pc.printf("tempo: %d e overtime %d\n\r ", timer.read_ms(), overTime);
                 for (int i=0; i<overTime; i++){
-                fprintf(fp,"#\n\r");
+                inviaMessaggio(255, 200);
                 } 
         }
         else{
@@ -48,7 +52,7 @@
         if (mybutton == 0) {
             //chiusuraFile();
             //aperturaFile(); 
-            fprintf(fp, "###########FLAG MARCATORE PRESSIONE PULSANTE############\r\n");
+            inviaMessaggio(255, 255);
             wait(1); 
         }
         
diff -r 295d7cea3c7d -r f5aae967c4d7 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Mon Jan 29 13:31:16 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/mbed_official/code/mbed-rtos/#5713cbbdb706
diff -r 295d7cea3c7d -r f5aae967c4d7 sd_binario.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sd_binario.h	Mon Jan 29 13:31:16 2018 +0000
@@ -0,0 +1,31 @@
+#ifndef __BINARIO__
+#define __BINARIO__
+
+#include "lettoreSD.h"
+
+typedef struct {
+    char ax;
+    char ay;       
+} message_t;
+
+void inviaMessaggio(char ax, char ay){
+        message_t message;
+        message.ax = ax;
+        message.ay = ay;
+        fwrite(&message, sizeof(message_t), 1, fp); 
+}
+
+struct r_f{
+    char r_d;
+    char r_s;    
+};
+
+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);     
+}
+
+#endif 
\ No newline at end of file