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.
Diff: main.cpp
- Revision:
- 22:997c013e0f13
- Parent:
- 21:828582e4d4ef
--- a/main.cpp Sun Mar 26 15:42:10 2017 +0000 +++ b/main.cpp Sun Mar 26 18:58:16 2017 +0000 @@ -186,11 +186,8 @@ float returnNote(const note_t &n) { - unsigned octMult = 1; - for (uint8_t i=0; i<n.oct; ++i){ - octMult = octMult << 1; - } + octMult = octMult << n.oct; return 1.0f/( octMult*octaveMap[n.note - 'A'] ); } @@ -205,7 +202,6 @@ } void calculatePID(){ - TIME = 1; //Calculate new PID Control Point if((total_rev/rev_target) > 0.75f){ dist_pid.setProcessValue(total_rev); @@ -215,7 +211,6 @@ velocity_pid.setProcessValue(partial_vel); dutyout = velocity_pid.compute(); } - TIME =0; } //Basic synchronisation routine @@ -292,7 +287,7 @@ } void changestate_isr(){ - + //TIME = 1; //led2 = !led2; // Profiling: Test time duration of ISR /*if(test == 0){ @@ -347,10 +342,11 @@ driveto = (intState-orState+(direction*lead)+6)%6; motorOut(driveto); } - + //TIME = 0; } -void pid_isr(){ +void pid_isr(){ + //TIME = 1; //117 Pulses per revolution pulse_count++; @@ -371,7 +367,7 @@ //Total Revolution Count total_rev = (count/6.0f) + partial_rev; - + //TIME = 0; } /*__________________________Main Function_____________________________________*/ @@ -393,7 +389,8 @@ bool accent_marker; string note=""; uint8_t duration=0; - + Timer t; + t.start(); string input; while(1){ r=0; @@ -403,8 +400,11 @@ note_marker=false; dur_marker=false; accent_marker=false; - pc.printf("Please enter something\r\n"); + t.stop(); + pc.printf("Time taken was %f seconds. \r\n Please enter something\r\n", t.read()); pc.scanf("%s",&buf); + t.reset(); + t.start(); input=buf; pc.printf("The input string is %s\r\n",buf);