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.
Dependencies: mbed mbed-rtos SDFileSystem11
Diff: main.cpp
- Revision:
- 2:39d41fd0f52b
- Parent:
- 1:ddbed1542633
- Child:
- 3:869a56651e96
--- a/main.cpp Mon Apr 26 21:13:10 2021 +0000 +++ b/main.cpp Mon Apr 26 21:20:36 2021 +0000 @@ -43,6 +43,9 @@ Ticker t1; int main() { + bool holdNotes = 0; //Stop reading notes file + bool holdStart = 0; //Stop reading start times + bool holdFinish = 0; //Stop reading in finish times pc.baud(115200); const char * d; std::string str = "123.4567"; @@ -62,47 +65,52 @@ FILE *fpfinish = fopen("/sd/notesfinish.txt","r"); unsigned char c; pc.printf("I'm here\n"); - + Note myNote = Note(0, 0, 0); while (!feof(fpn)){ // while not end of file + while(!holdNotes) { c = fgetc(fpn); // get a character/byte from the file if(c == ','){ stringstream degree(output); degree >> temp; - pc.printf("%d\n", temp-1); + pc.printf("%d\n", temp); output = ""; + holdNotes = 1; } else { output += c; } - } + } + myNote.midiNote = temp; output = ""; - while(!feof(fpstart)){ - c = fgetc(fpstart); - if(c == ','){ - d = output.c_str(); - num_float = std::atof(d); - pc.printf("%f\n", num_float); - output = ""; - } else { - output+= c; - } + while(!holdStart) { + c = fgetc(fpstart); + if(c == ','){ + d = output.c_str(); + num_float = std::atof(d); + pc.printf("%f\n", num_float); + output = ""; + myNote.start = num_float; + holdStart = 1; + } else { + output+= c; + } - } + } output = ""; - while(!feof(fpfinish)){ + while(!holdFinish){ c = fgetc(fpfinish); if(c == ','){ d = output.c_str(); num_float = std::atof(d); pc.printf("%f\n", num_float); output = ""; + myNote.stop = num_float; + holdFinish = 1; } else { output+= c; } - } - - - float note1 = 1.0/(NOTE_A4*2); + } //ONCE WE REACH THIS POINT ALL PARTS OF THE NOTE OBJECT SHOULD BE SET + float note1 = 1.0/(NOTE_A4*2); float note2 = 1.0/(NOTE_CS5*2); float note2m = 1.0/(NOTE_C5*2); float note3 = 1.0/(NOTE_E5*2); @@ -110,7 +118,6 @@ t1.attach(&f1, &Flipper::flip, note2); pc.printf("Hello World!\n"); pc.printf("%f\n",note1); - Note myNote = Note(1, 1.0, 1.0); pc.printf("%d", myNote.midiNote); // spin in a main loop. flipper will interrupt it to call flip while(1) { @@ -130,4 +137,9 @@ } } + +} + + + } \ No newline at end of file