Petter Bellander / Mbed 2 deprecated Saab-BT

Dependencies:   mbed

Revision:
6:c454f88524d6
Parent:
3:b76c74783d0d
Child:
9:9a4c81493a3d
diff -r 8e468fef2754 -r c454f88524d6 CDC.cpp
--- a/CDC.cpp	Mon Jan 11 20:49:59 2016 +0000
+++ b/CDC.cpp	Wed Jan 13 22:11:50 2016 +0000
@@ -42,24 +42,7 @@
 bool cdc_active = false; // True while our module, the simulated CDC, is active.
 bool mute = false;
 int toggle_shuffle = 1;
-int ninefive_poweron_cmd[4][9] = {
-    {0x32,0x00,0x00,0x03,0x01,0x02,0x00,0x00,-1},
-    {0x42,0x00,0x00,0x22,0x00,0x00,0x00,0x00,-1},
-    {0x52,0x00,0x00,0x22,0x00,0x00,0x00,0x00,-1},
-    {0x62,0x00,0x00,0x22,0x00,0x00,0x00,0x00,-1}
-};
-int ninefive_active_cmd[4][9] = {
-    {0x32,0x00,0x00,0x16,0x01,0x02,0x00,0x00,-1},
-    {0x42,0x00,0x00,0x36,0x00,0x00,0x00,0x00,-1},
-    {0x52,0x00,0x00,0x36,0x00,0x00,0x00,0x00,-1},
-    {0x62,0x00,0x00,0x36,0x00,0x00,0x00,0x00,-1},
-};
-int ninefive_powerdown_cmd[4][9] = {
-    {0x32,0x00,0x00,0x19,0x01,0x00,0x00,0x00,-1},
-    {0x42,0x00,0x00,0x38,0x01,0x00,0x00,0x00,-1},
-    {0x52,0x00,0x00,0x38,0x01,0x00,0x00,0x00,-1},
-    {0x62,0x00,0x00,0x38,0x01,0x00,0x00,0x00,-1}
-};
+int ninefive_cmd[] = {0x32,0x00,0x00,0x16,0x01,0x02,0x00,0x00,-1};
 int beep_cmd[] = {0x80,0x04,0x00,0x00,0x00,0x00,0x00,0x00,-1};
 int cdc_status_cmd[] = {0xE0,0x00,0x01,0x41,0x01,0x00,0x00,0xD0,-1};
 int display_request_cmd[] = {CDC_APL_ADR,0x02,0x05,CDC_SID_FUNCTION_ID,0x00,0x00,0x00,0x00,-1};
@@ -110,7 +93,7 @@
     CAN_DispMsg[0].data[2] = 0x02; // Writing to row 2
     CAN_DispMsg[1].data[2] = 0x02; // Writing to row 2
     CAN_DispMsg[2].data[2] = 0x02; // Writing to row 2
-    display("BT REDO");
+    display("PETTERS BT");
 }
 
 /** Handles an incoming (RX) frame **/
@@ -136,23 +119,7 @@
                 led1 = !led1;
                 break;
             case NODE_STATUS_RX:
-                switch (CAN_RxMsg.data[3] & 0x0F){
-                    case (0x3):
-                        for (int i = 0; i < 4; i++) {
-                            send_can_frame(NODE_STATUS_TX, ninefive_poweron_cmd[i]);
-                        }
-                        break;
-                    case (0x2):
-                        for (int i = 0; i < 4; i++) {
-                            send_can_frame(NODE_STATUS_TX, ninefive_active_cmd[i]);
-                        }
-                        break;
-                    case (0x8):
-                        for (int i = 0; i < 4; i++) {
-                            send_can_frame(NODE_STATUS_TX, ninefive_powerdown_cmd[i]);
-                        }
-                        break;
-                }
+                send_can_frame(NODE_STATUS_TX, ninefive_cmd);
                 break;
             case IHU_BUTTONS:
                 return get_ihu_cmd();
@@ -311,6 +278,11 @@
     playback.start();
 }
 
+/** Sets the current track number as playing **/
+void CDC::set_track(char track_number) {
+    cdc_status_cmd[4] = track_number;
+}
+
 
 /** Formats and puts a frame on CAN bus **/
 void CDC::send_can_frame(int message_id, int *msg) {