sdvsv

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jbillingham
Date:
Sun Oct 22 18:16:23 2017 +0000
Commit message:
dsfcsdv

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Oct 22 18:16:23 2017 +0000
@@ -0,0 +1,38 @@
+//Import libraries
+#include "mbed.h"
+#include "stdio.h"
+#include "math.h"
+
+//Establish serial connection
+Serial pc(USBTX, USBRX);
+//Create the local filesystem
+LocalFileSystem local("local"); 
+
+//Define variables
+int N = 50; //Number of samples
+float T = 0.1; //Sample period
+
+int main() 
+{
+    FILE *settings; //Create file with pointer
+
+    settings = fopen("/local/settings.txt", "w");//Open file for writing
+    pc.printf("File open.\n"); //Indicates file open
+    fprintf(settings, "%i %f", N, T); //Writes settings values onto file
+    fclose(settings); //Close file
+    pc.printf("Settings saved.\n");
+    
+    //Define variables for output
+    int value1;
+    float value2;
+    
+    settings = fopen("/local/settings.txt" , "r"); //Open file for reading
+    fseek(settings, 0 ,SEEK_SET); //Sets cursor to start of file
+    fscanf(settings, "%i", &value1);  //Scans for first number
+    pc.printf("Settings are:\n");
+    pc.printf("%i\n", value1); //Outputs first number
+    fseek(settings, sizeof(int), SEEK_SET); //Sets cursor to after first number
+    fscanf(settings, "%f", &value2); //Scans for second number
+    pc.printf("%f\n", value2); //Outputs second number
+    fclose(settings); //Close file
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Oct 22 18:16:23 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b484a57bc302
\ No newline at end of file