Petter Bellander / Mbed 2 deprecated Saab-BT

Dependencies:   mbed

Revision:
2:10c60edc8573
Parent:
0:6cf6e566c0da
Child:
3:b76c74783d0d
--- a/CDC.cpp	Mon Jan 04 18:54:24 2016 +0000
+++ b/CDC.cpp	Mon Jan 04 23:36:50 2016 +0000
@@ -58,6 +58,9 @@
 DigitalOut led1(LED1, 0);
 DigitalOut led2(LED2, 0);
 
+/** Timers: **/
+Timer playback;
+
 /******************************************************************************
  * PUBLIC METHODS
  ******************************************************************************/
@@ -111,6 +114,7 @@
             }
             case DISPLAY_RESOURCE_REQ:
                 send_can_frame(DISPLAY_RESOURCE_REQ, display_request_cmd);
+                update_elapsed_time();
                 send_can_frame(GENERAL_STATUS_CDC, cdc_status_cmd);
                 led1 = !led1;
                 break;
@@ -253,10 +257,25 @@
     CAN_DispMsg[0].data[2] = 0x02; // Message not changed next transmission unless display() is called 
 }
 
-/** Sets the playback time in the cdc_status message **/
-void CDC::set_time(char minutes, char seconds) {
-    cdc_status_cmd[5] = minutes;
-    cdc_status_cmd[6] = seconds;
+/** Sets the elapsed time in the cdc_status message **/
+void CDC::update_elapsed_time() {
+    cdc_status_cmd[5] = (char)(((int)playback.read())/60);
+    cdc_status_cmd[6] = (char)(((int)playback.read())%60);
+}
+
+/** Resets the elapsed time in the cdc_status message **/
+void CDC::reset_elapsed_time() {
+    playback.reset();
+}
+
+/** Stops the elapsed time in the cdc_status message **/
+void CDC::stop_elapsed_time() {
+    playback.stop();
+}
+
+/** Starts the elapsed time in the cdc_status message **/
+void CDC::start_elapsed_time() {
+    playback.start();
 }