Closed istals closed 2 years ago
Yes
But also I needed to add SetStateIdleThenPlay();
after init Init_VWCDC();
to get radio playing, I feel that I'm missing something
what exactly do you need to do with them? if you press button on MFSW or on radio then emulator will change track
Ok, then that is not happening, I'm using Arduino Uno (__AVR_ATmega328P__) defs and things I changed in code
// #define DUMPMODE
// #define DUMPMODE2
//#define DISC_TRACK_NUMBER_FROM_MPD
// #define BLUETOOTH
#define RADIO_COMMAND PB0 //ICP
#define RADIO_COMMAND_DDR DDRB
#define RADIO_COMMAND_PORT PORTB
#define RADIO_COMMAND_PIN PINB
//standard pinout 8,11,13
#define RADIO_CLOCK PB5
#define RADIO_CLOCK_DDR DDRB
#define RADIO_CLOCK_PORT PORTB
#if defined(__AVR_ATmega328PB__) //cannot use pb3 with serial1
#define RADIO_DATA PB2
#else
#define RADIO_DATA PB3
#endif
#define RADIO_DATA_DDR DDRB
#define RADIO_DATA_PORT PORTB
//my pinout, 8,6,A0
//#define RADIO_CLOCK PD4
//#define RADIO_CLOCK_DDR DDRD
//#define RADIO_CLOCK_PORT PORTD
//#define RADIO_DATA PC3
//#define RADIO_DATA_DDR DDRC
//#define RADIO_DATA_PORT PORTC
//#define RADIO_ACC 3 // PD3 = INT1
int main()
{
Serial.begin(9600);
pinMode(D_CTRL_PREV_PIN, OUTPUT);
pinMode(D_CTRL_NEXT_PIN, OUTPUT);
pinMode(D_CTRL_LED_PIN, OUTPUT);
digitalWrite(D_CTRL_PREV_PIN, LOW);
digitalWrite(D_CTRL_NEXT_PIN, LOW);
digitalWrite(D_CTRL_LED_PIN, LOW);
#ifdef BLUETOOTH
#if defined(__AVR_ATmega324__) || defined(__AVR_ATmega324A__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega324PB__) || defined(__AVR_ATmega324PB__) || defined(__AVR_ATmega328PB__)
Serial1.begin(9600);
#else
Serial.begin(9600);
//
#endif
#endif
#ifdef DISC_TRACK_NUMBER_FROM_MPD
#if defined(__AVR_ATmega324__) || defined(__AVR_ATmega324A__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega324PB__) || defined(__AVR_ATmega324PB__)
Serial1.begin(115200);
#else
Serial.begin(115200);
#endif
#endif
//Serial.println("COM+SNAME+VWCDPIC1");
unsigned long delay_time = 0;
int next_high = 0;
int prev_high = 0;
Init_VWCDC();
// starts playing Bluetooth stream
// SetStateIdleThenPlay();
//#if defined(__AVR_ATmega328P__)
// Serial.println("__AVR_ATmega328P__ board");
//#endif
// my board __AVR_ATmega328P__
#ifdef DISC_TRACK_NUMBER_FROM_MPD
//start in idle mode
SetStateIdle();
#endif
//Serial.println("COM+TONEOFF");
while (1)
{
CDC_Protocol();
if (D_CTRL_LED_STATE == 1) {
digitalWrite(D_CTRL_LED_PIN, HIGH);
} else {
digitalWrite(D_CTRL_LED_PIN, LOW);
}
if (D_CTRL_NEXT > 0) {
Serial.println("D_CTRL_NEXT press");
if (delay_time == 0) {
delay_time = millis();
digitalWrite(D_CTRL_NEXT_PIN, HIGH);
next_high = 1;
} else if (delay_time + 200 <= millis()) {
digitalWrite(D_CTRL_NEXT_PIN, LOW);
next_high = 0;
delay_time = 0;
D_CTRL_NEXT = 0;
}
} else if (next_high == 1) {
digitalWrite(D_CTRL_NEXT_PIN, LOW);
next_high = 0;
}
if (D_CTRL_PREV > 0) {
Serial.println("D_CTRL_PREV press");
int delay_plus = 150;
if(D_CTRL_PREV == 1) delay_plus = 250;
if (delay_time == 0) {
delay_time = millis();
digitalWrite(D_CTRL_PREV_PIN, HIGH);
prev_high = 1;
} else if (delay_time + delay_plus <= millis()) {
digitalWrite(D_CTRL_PREV_PIN, LOW);
prev_high = 0;
delay_time = 0;
if (D_CTRL_PREV == 2) {
D_CTRL_PREV = 0;
} else {
D_CTRL_PREV = 2;
}
}
} else if (prev_high == 1) {
digitalWrite(D_CTRL_NEXT_PIN, LOW);
prev_high = 0;
}
}
}
is it working without your changes ?
Regarding this, how could I test that these buttons are working and I'm receiving those bytes? DUMPMODE and DUMPMODE2 must be enabled?
No, not working no data from head unit
arduino pin 8 is connected to dataout on the radio?
RADIO PIN -> arduino pin DataOut -> digital 8 (ICP1) DataIn -> digital 11(PB3) (10 for atmega328PB) Clock -> digital 13(PB5)
Yes, Double checked
you should see some commands on serial at startup of radio, mainly disable and enable, depends on state in which radio started
Looks like my head unit is not providing any data, closing
radio must be coded to have cdc enabled, try it
http://wiki.ross-tech.com/wiki/index.php/Audi_Radio_Generation_I#Coding
Hey!
I have a question,
Is there a possibility to get prev/next commands from the head unit and multi steering next/prev track signals pass to CDC emulators?