Hayley Cashdollar / Mbed 2 deprecated LocalFileSystem_Read

Dependencies:   mbed

Revision:
0:60661ba12125
diff -r 000000000000 -r 60661ba12125 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 30 03:54:44 2015 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+DigitalOut myled(LED1);
+
+float     Right=1.123456;  // gemeten waarde bij 4mA ( 0..1 <> 0..3.3v )
+float     Left=1.123;  // gemeten waarde bij 4mA ( 0..1 <> 0..3.3v )
+char A[10], B[10];
+
+LocalFileSystem local("local");               // Create the local filesystem under the name "local"
+//float leftOff;
+
+
+
+void ReadFile (void)
+{
+    FILE *set = fopen("/local/calib.txt", "r");  // Open "setup.txt" on the local file system for read
+    fscanf(set,"%s %f",A,&Left); // read offset
+    fscanf(set,"%s %f",A,&Right); // read offset
+    fclose(set);
+}
+
+
+void WriteFile(void)   // write to USB memory
+{
+    FILE *fp = fopen("/local/calib.txt", "w");  // Open "setup.txt" on the local file system for write
+    fprintf(fp,"Left %f\r\n",Left); // read offset
+    fprintf(fp,"Right %f\r\n",Right); // read offset
+    //fprintf(fp,"gain %f\r\n",lOffset);   // read gain
+    fclose(fp);
+}
+
+
+int main()
+{
+    pc.baud(912600);
+    WriteFile();
+    wait(3);
+    ReadFile();// when you run first time without this line, the setup file is on created
+    wait(1);
+    pc.printf("Left Offset is: %f, Right Offset is: %f\r\n", Left, Right);
+    //pc.printf("%f\n roffset", roff);
+}