Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LocalFileSystem_Read by
localRead.cpp@3:bf1ad768a7b3, 2015-07-02 (annotated)
- Committer:
- nathanhonka
- Date:
- Thu Jul 02 21:38:09 2015 +0000
- Revision:
- 3:bf1ad768a7b3
- Parent:
- 2:67fab81637b1
Corrected header file include guards (did not encapsulate entire header). Also, removed redundant (and linker-breaking) mbed library inclusion.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| cashdollar | 1:a5555eb914bb | 1 | #include "mbed.h" |
| cashdollar | 1:a5555eb914bb | 2 | #include "initExoVars.h" |
| cashdollar | 1:a5555eb914bb | 3 | |
| cashdollar | 1:a5555eb914bb | 4 | |
| cashdollar | 1:a5555eb914bb | 5 | //Serial pc(USBTX, USBRX); // tx, rx |
| cashdollar | 1:a5555eb914bb | 6 | DigitalOut myled(LED4); |
| cashdollar | 1:a5555eb914bb | 7 | |
| cashdollar | 1:a5555eb914bb | 8 | float RightCalib;//=1.123456; // gemeten waarde bij 4mA ( 0..1 <> 0..3.3v ) |
| cashdollar | 1:a5555eb914bb | 9 | float LeftCalib;//=1.123; // gemeten waarde bij 4mA ( 0..1 <> 0..3.3v ) |
| cashdollar | 1:a5555eb914bb | 10 | char A[10];//, B[10]; |
| cashdollar | 1:a5555eb914bb | 11 | |
| cashdollar | 1:a5555eb914bb | 12 | //MAYBE PUT THIS IN INIT |
| cashdollar | 1:a5555eb914bb | 13 | LocalFileSystem local("local"); // Create the local filesystem under the name "local" |
| cashdollar | 1:a5555eb914bb | 14 | |
| cashdollar | 1:a5555eb914bb | 15 | void ReadFile (void) |
| cashdollar | 1:a5555eb914bb | 16 | { |
| cashdollar | 1:a5555eb914bb | 17 | FILE *set = fopen("/local/calib.txt", "r"); // Open "setup.txt" on the local file system for read |
| cashdollar | 1:a5555eb914bb | 18 | fscanf(set,"%s %f",A,&LeftCalib); // read offset |
| cashdollar | 1:a5555eb914bb | 19 | fscanf(set,"%s %f",A,&RightCalib); // read offset |
| cashdollar | 1:a5555eb914bb | 20 | fclose(set); |
| cashdollar | 1:a5555eb914bb | 21 | } |
| cashdollar | 1:a5555eb914bb | 22 | /* |
| cashdollar | 1:a5555eb914bb | 23 | void WriteFile(void) // write to USB memory |
| cashdollar | 1:a5555eb914bb | 24 | { |
| cashdollar | 1:a5555eb914bb | 25 | FILE *fp = fopen("/local/calib.txt", "w"); // Open "setup.txt" on the local file system for write |
| cashdollar | 1:a5555eb914bb | 26 | fprintf(fp,"LeftCalib %f\r\n",Left); // read offset |
| cashdollar | 1:a5555eb914bb | 27 | fprintf(fp,"RightCalib %f\r\n",Right); // read offset |
| cashdollar | 1:a5555eb914bb | 28 | //fprintf(fp,"gain %f\r\n",lOffset); // read gain |
| cashdollar | 1:a5555eb914bb | 29 | fclose(fp); |
| cashdollar | 1:a5555eb914bb | 30 | }*/ |
| cashdollar | 1:a5555eb914bb | 31 | |
| cashdollar | 1:a5555eb914bb | 32 | void localRead() |
| cashdollar | 1:a5555eb914bb | 33 | { |
| cashdollar | 1:a5555eb914bb | 34 | //char A[10]; |
| cashdollar | 2:67fab81637b1 | 35 | //myled=1; |
| cashdollar | 1:a5555eb914bb | 36 | __disable_irq(); // Disable Interrupts |
| cashdollar | 1:a5555eb914bb | 37 | ReadFile();// when you run first time without this line, the setup file is on created |
| cashdollar | 1:a5555eb914bb | 38 | pc.printf("Calibration settings loaded. \r\nLeft Offset is: %f, Right Offset is: %f\r\n", LeftCalib, RightCalib); |
| cashdollar | 1:a5555eb914bb | 39 | //pc.printf("%f\n roffset", roff); |
| cashdollar | 1:a5555eb914bb | 40 | __enable_irq(); // Disable Interrupts |
| cashdollar | 1:a5555eb914bb | 41 | } |
