lab7
Dependencies: SDFileSystem mbed
Revision 0:fa63e288286a, committed 2017-11-09
- Comitter:
- philliptran011
- Date:
- Thu Nov 09 19:02:08 2017 +0000
- Commit message:
- lab7
Changed in this revision
diff -r 000000000000 -r fa63e288286a SDFileSystem.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Thu Nov 09 19:02:08 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/AlexVC97/code/SDFileSystem/#3bdfc1556537
diff -r 000000000000 -r fa63e288286a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 09 19:02:08 2017 +0000 @@ -0,0 +1,55 @@ +#include "mbed.h" +#include "SDFileSystem.h" +#include <stdint.h> + + +Serial pc(USBTX, USBRX); +InterruptIn R_Button(SW1); +AnalogIn measure(PTB0); +SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd"); +Ticker t; +float buffer; +bool flag = 0; + +void active() { + FILE *samples = fopen("/sd/samples.csv", "a"); + buffer = measure.read(); + if(buffer!=0) { + fprintf(samples, "%f\n", buffer); + pc.printf("Reading %f\n", buffer); + buffer = 0; + } + fclose(samples); +} + +void change() { + pc.printf("In change function\n"); + if (flag == 0) { + printf("Enabling Oscilloscope\n"); + t.attach(&active, .01); + flag = 1; + printf("Flag set to 1\n"); + } + else { + printf("Disabling Oscilloscope\n"); + t.detach(); + flag = 0; + printf("Flag set to 0\n"); + } +} + +int main() { + pc.baud(115200); + pc.printf("Connection Established\n"); + pc.printf("File should be created\n"); + FILE *samples = fopen("/sd/samples.csv", "w"); + if(samples == NULL) { + pc.printf("But the file doesn't exist \n"); + } + + fclose(samples); + R_Button.mode(PullUp); + R_Button.fall(&change); + while(true) { + } +} \ No newline at end of file
diff -r 000000000000 -r fa63e288286a mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Nov 09 19:02:08 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/176b8275d35d \ No newline at end of file