Thursday, October 11, 2012

Possible New Name

So, the Belkin F8Z492TTP device SUCKS. The sound quality is so shitty, it's amazing. I wired a 3.5mm plug inside my box so I can plug a line directly into the sound system, or through the bluetooth dongle. The sound quality is night & day. The direct connect almost sounds too bass-y, but with the shitty Belkin module, there are no mids. It sounds metallic and hollow like you're listening to your music from a boombox in a hallway.

Hence the name change...I could maybe buy a different bluetooth module (I was looking at the Logitech 980-000540; it has great reviews for sound quality, but it's big as shit), but another problem I've noticed is the lack of "auto reconnect" that these bluetooth devices (don't) have. It's kind of a PITA to have to reselect and connect to the damn thing each & everytime you want to use it.

So for the meantime, I've changed the SID to display "iSaab Aux". It's more generic but still gets the point across.

Code for the SID change is below.


// ----------------------------------------------
// SECUDUINO
// http://secuduino.blogspot.com/
// By Igor Real
// 16/05/2011
//
// Saab CDC Changer Emulator
// http://BlueSaab.blogspot.com/
// By Seth Evans
// 5 Oct 2012
// ----------------------------------------------

#include <CAN.h>

int cdbutton;

void setup() {
  // set up CAN
  CAN.begin(47);  // Saab I-Bus is 47.619kbps
  Serial.begin(115200);
  cdbutton = 0;
  CAN_TxMsg.header.rtr=0;     // this value never changes
  CAN_TxMsg.header.length=8;  // this value never changes
}

void loop() {
  // CDC code needs sent every second or less so all loops
  // running added together need to take less than 1000ms
  // but no more or the car won't "see" the CDC
  CDC();
  if (cdbutton==1) {
    Serial.println("iPod ON");
    iPodOn();
  }
  else {
    Serial.println("iPod OFF");
    //iPodOff();
    //delay(400);
  }
  for (int i = 0; i <= 900; i++) {
    delay(1);
    // this loop takes 850ms
    if (CAN.CheckNew()) {
      CAN_TxMsg.data[0]++;
      CAN.ReadFromDevice(&CAN_RxMsg);
      //PrintBus();
      if (CAN_RxMsg.id==0x3C0) {
        if (CAN_RxMsg.data[0]==0x80) {
          switch (CAN_RxMsg.data[1]) {
          case 0x24:
            cdbutton = 1;
            Serial.println("CDC");
            break;
          case 0x14:
            cdbutton = 0;  
            Serial.println("Radio");
            break;
          }
        }
      }
    }
  }
}

void CDC() {
  CAN_TxMsg.id=0x3C8;     // CD Changer
  CAN_TxMsg.data[0]=0xE0;
  CAN_TxMsg.data[1]=0x00;
  CAN_TxMsg.data[2]=0x3F; // all 6 discs inserted
  CAN_TxMsg.data[3]=0x31; // playing , disc 1
  CAN_TxMsg.data[4]=0xFF;
  CAN_TxMsg.data[5]=0xFF;
  CAN_TxMsg.data[6]=0xFF;
  CAN_TxMsg.data[7]=0xD0; // married "OK" code
  CAN.send(&CAN_TxMsg);
}

void iPodOn() {
  // This loop takes 0ms
  CAN_TxMsg.id=0x328;     // SID audio text
  CAN_TxMsg.data[0]=0x42; // message 2
  CAN_TxMsg.data[1]=0x96;
  CAN_TxMsg.data[2]=0x02; // Row 2
  CAN_TxMsg.data[3]=0x69; // i
  CAN_TxMsg.data[4]=0x53; // S
  CAN_TxMsg.data[5]=0x61; // a
  CAN_TxMsg.data[6]=0x61; // a
  CAN_TxMsg.data[7]=0x62; // b
  CAN.send(&CAN_TxMsg);
  delay(10);

  CAN_TxMsg.data[0]=0x01; // message 1
  CAN_TxMsg.data[3]=0x20; // _
  CAN_TxMsg.data[4]=0x41; // A
  CAN_TxMsg.data[5]=0x75; // u
  CAN_TxMsg.data[6]=0x78; // x
  CAN_TxMsg.data[7]=0x20; // _
  CAN.send(&CAN_TxMsg);
  delay(10);

  CAN_TxMsg.data[0]=0x00; // message 0
  CAN_TxMsg.data[3]=0x00; // _
  CAN_TxMsg.data[4]=0x00; // _
  CAN_TxMsg.data[5]=0x00; //
  CAN_TxMsg.data[6]=0x00; //
  CAN_TxMsg.data[7]=0x00; //
  CAN.send(&CAN_TxMsg);
  delay(10);

  CAN_TxMsg.id=0x348;     // audio text control
  CAN_TxMsg.data[0]=0x11;
  CAN_TxMsg.data[1]=0x02; // Row 2
  CAN_TxMsg.data[2]=0x05;
  CAN_TxMsg.data[3]=0x18; // priority 18?
  CAN_TxMsg.data[4]=0x00;
  CAN_TxMsg.data[5]=0x00;
  CAN_TxMsg.data[6]=0x00;
  CAN_TxMsg.data[7]=0x00;
  CAN.send(&CAN_TxMsg);
  delay(10);

  CAN_TxMsg.id=0x368;     // SID text priority
  CAN_TxMsg.data[0]=0x02; // Row 2
  CAN_TxMsg.data[1]=0x18; // priority 18?
  CAN_TxMsg.data[2]=0x00;
  CAN_TxMsg.data[3]=0x00;
  CAN_TxMsg.data[4]=0x00;
  CAN_TxMsg.data[5]=0x00;
  CAN_TxMsg.data[6]=0x00;
  CAN_TxMsg.data[7]=0x00;
  CAN.send(&CAN_TxMsg);
  delay(10);
}

void iPodOff() {
  // I don't think this code is needed at all...
  CAN_TxMsg.id=0x368;     // turn off the SID (SPA) text
  CAN_TxMsg.data[0]=0x02;
  CAN_TxMsg.data[1]=0x19;
  CAN_TxMsg.data[2]=0x00;
  CAN_TxMsg.data[3]=0x00;
  CAN_TxMsg.data[4]=0x00;
  CAN_TxMsg.data[5]=0x00;
  CAN_TxMsg.data[6]=0x00;
  CAN_TxMsg.data[7]=0x00;
  CAN.send(&CAN_TxMsg);
  delay(10);
}

void PrintBus() {
  if (CAN_RxMsg.id==0x3C0) {
    Serial.print(CAN_RxMsg.id,HEX);
    Serial.print(";");
    Serial.print(CAN_RxMsg.data[0],HEX);
    Serial.print(";");
    Serial.print(CAN_RxMsg.data[1],HEX);
    Serial.print(";");
    Serial.print(CAN_RxMsg.data[2],HEX);
    Serial.print(";");
    Serial.print(CAN_RxMsg.data[3],HEX);
    Serial.print(";");
    Serial.print(CAN_RxMsg.data[4],HEX);
    Serial.print(";");
    Serial.print(CAN_RxMsg.data[5],HEX);
    Serial.print(";");
    Serial.print(CAN_RxMsg.data[6],HEX);
    Serial.print(";");
    Serial.println(CAN_RxMsg.data[7],HEX);
  }
}

No comments:

Post a Comment