read and write to local file system.

Fork of LocalFileSystem_Read by Hayley Cashdollar

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers localRead.cpp Source File

localRead.cpp

00001 #include "mbed.h"
00002 #include "initExoVars.h"
00003 
00004 
00005 //Serial pc(USBTX, USBRX); // tx, rx
00006 DigitalOut myled(LED4);
00007 
00008 float     RightCalib;//=1.123456;  // gemeten waarde bij 4mA ( 0..1 <> 0..3.3v )
00009 float     LeftCalib;//=1.123;  // gemeten waarde bij 4mA ( 0..1 <> 0..3.3v )
00010 char A[10];//, B[10];
00011 
00012 //MAYBE PUT THIS IN INIT
00013 LocalFileSystem local("local");               // Create the local filesystem under the name "local"
00014 
00015 void ReadFile (void)
00016 {
00017     FILE *set = fopen("/local/calib.txt", "r");  // Open "setup.txt" on the local file system for read
00018     fscanf(set,"%s %f",A,&LeftCalib); // read offset
00019     fscanf(set,"%s %f",A,&RightCalib); // read offset
00020     fclose(set);
00021 }
00022 /*
00023 void WriteFile(void)   // write to USB memory
00024 {
00025     FILE *fp = fopen("/local/calib.txt", "w");  // Open "setup.txt" on the local file system for write
00026     fprintf(fp,"LeftCalib %f\r\n",Left); // read offset
00027     fprintf(fp,"RightCalib %f\r\n",Right); // read offset
00028     //fprintf(fp,"gain %f\r\n",lOffset);   // read gain
00029     fclose(fp);
00030 }*/
00031 
00032 void localRead()
00033 {
00034     //char A[10];
00035     //myled=1;
00036     __disable_irq();    // Disable Interrupts
00037     ReadFile();// when you run first time without this line, the setup file is on created
00038     pc.printf("Calibration settings loaded. \r\nLeft Offset is: %f, Right Offset is: %f\r\n", LeftCalib, RightCalib);
00039     //pc.printf("%f\n roffset", roff);
00040     __enable_irq();    // Disable Interrupts
00041 }