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:
- 2:10c60edc8573
- Parent:
- 0:6cf6e566c0da
- Child:
- 3:b76c74783d0d
--- a/main.cpp Mon Jan 04 18:54:24 2016 +0000 +++ b/main.cpp Mon Jan 04 23:36:50 2016 +0000 @@ -11,9 +11,6 @@ RN52 rn52; RN52_RESULT res; -Timer playback; - - Serial pc(USBTX, USBRX); // tx, rx int main() { @@ -22,8 +19,8 @@ cdc.init(); rn52.init(); printf("Starting loop\r\n"); - playback.start(); //only for debug while(1) { + //Debug connection to PC if(pc.readable()) { switch (pc.getc()) { case 'p': @@ -43,12 +40,16 @@ printf("getting status\r\n"); rn52.get(RN52_GETSTATUS, &res); printf("%s", res.response); + break; case 't': rn52.get(RN52_CALLER_ID, &res); printf("%s", res.response); + break; + case 'e': + cdc.start_elapsed_time(); + break; } } - cdc.set_time((char)(((int)playback.read())/60),(char)(((int)playback.read())%60)); switch (cdc.get_cmd()) { case IBUS_OTHER_MESSAGE: break; @@ -91,23 +92,29 @@ break; } if(rn52.changed()) { + printf("got RN52 event\r\n"); rn52.get(RN52_GETSTATUS, &res); + printf("raw: %s",res.response); + printf("event: %i\r\n", res.event); + printf("connection: %i\r\n", res.connection); + printf("media_profile: %i\r\n", res.media_connected); + printf("phone_profile: %i\r\n", res.phone_connected); switch (res.event) { case RN52_CALLER_ID_EVENT: rn52.get(RN52_CALLER_ID, &res); break; case RN52_TRACK_CHANGE_EVENT: rn52.get(RN52_TRACK_METADATA, &res); - playback.reset(); + cdc.reset_elapsed_time(); break; - default: //no event occured, check connection status + case RN52_NO_EVENT: //no event occured, check connection status if(res.connection == RN52_AUDIO_STREAMING) { cdc.display("BT SPELAR"); - playback.start(); + cdc.start_elapsed_time(); } else { - playback.stop(); - playback.reset(); + cdc.stop_elapsed_time(); + cdc.reset_elapsed_time(); } }