encoder read and write to file

Dependencies:   mbed QEI SDFileSystem

Files at this revision

API Documentation at this revision

Comitter:
malithjkd
Date:
Fri Sep 20 05:31:06 2019 +0000
Parent:
2:2054280a7b93
Commit message:
data analysis

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Sep 06 07:00:34 2019 +0000
+++ b/main.cpp	Fri Sep 20 05:31:06 2019 +0000
@@ -9,7 +9,9 @@
 QEI wheel(p29, p30, NC, 2000, QEI::X4_ENCODING);     // Encoder input pins p29 - A, p30 - B
 
 void SD_card_test();
+
 Timer t;
+int pulse = 0;
 
 int main()
 {
@@ -26,26 +28,24 @@
     for (int x; x<1000; x++)
     {
         myled = !myled;
-        fprintf(fp,"%d,%d,%d\r\n",x,t.read_us(),wheel.getPulses());
+        //fprintf(fp,"%d,%d,%d\r\n",x,t.read_us(),wheel.getPulses());
+        pulse = wheel.getPulses();
+        fprintf(fp, "%d\t %d\t %d\t \r\n",x,t.read_us(),pulse);
+        pulse = 0;
     }
     t.stop();
     fclose(fp);
-    
-    
 }
-    
-
 
 void SD_card_test()
 {
     mkdir("/sd/mydir", 0777);
     
     FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
-    if(fp == NULL) {
+    if(fp == NULL)
+    {
         error("Could not open file for write\n");
     }
-    fprintf(fp, "malith test 01 \r\n");
+    fprintf(fp, "malith test final day\r\n");
     fclose(fp); 
-    
-    
 }
\ No newline at end of file