Думаю будет полезно кому нибудь. http://www.mp3car.com/vbulletin/inpu...ol-pinout.html
Думаю будет полезно кому нибудь. http://www.mp3car.com/vbulletin/inpu...ol-pinout.html
Перенес код для Arduino сюда
Подключить вывод разьема Signal нужно к выводу D7 Arduino NanoPHP код:
#define CHECK_MS 5
#define DOUBLE_MS 400
#define HOLD_MS 1200
#define NO_B 839 //nothing pressed
#define MODE_B 662 // MODE
#define NXTU_B 509 // NEXT UP
#define NXTD_B 380 // NEXT DOWN
#define MUTE_B 273 // MUTE
#define VOLU_B 180 // VOLUME UP
#define VOLD_B 105 // VOLUME DOWN
#define alpPin 7
boolean volUp[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,1,0,1,1,0,1,1, 1,1,0,1,0,1,1,0, 1,1,0,1,0,1,0,1};
boolean volDn[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,1,0,1,1,0,1, 1,1,1,1,0,1,1,0, 1,1,0,1,0,1,0,1};
boolean mute[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,0,1,0,1,1,0,1, 1,1,1,0,1,1,1,0, 1,1,0,1,0,1,0,1};
boolean pstUp[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,0,1,0,1,0,1,1, 1,1,1,0,1,1,1,1, 0,1,0,1,0,1,0,1};
boolean pstDn[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,0,1,0,1,0,1, 1,1,1,1,1,1,1,1, 0,1,0,1,0,1,0,1};
boolean source[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,0,1,1,0,1,1,1, 1,1,0,1,1,0,1,1, 0,1,0,1,0,1,0,1};
boolean trkUp[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 1,0,1,1,1,0,1,1, 1,1,0,1,1,0,1,0, 1,1,0,1,0,1,0,1};
boolean trkDn[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,0,1,1,1,0,1, 1,1,1,1,1,0,1,0, 1,1,0,1,0,1,0,1};
boolean power[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,1,1,0,1,1,1, 1,1,1,0,1,0,1,1, 0,1,0,1,0,1,0,1};
boolean entPlay[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,0,1,0,1,1,1, 1,1,1,1,1,1,0,1, 0,1,0,1,0,1,0,1};
boolean bandProg[48] = {1,1,0,1,0,1,1,1, 1,1,0,1,1,0,1,1, 1,0,1,0,1,0,1,1, 0,1,1,0,1,0,1,1, 1,1,1,1,0,1,1,1, 0,1,0,1,0,1,0,1};
boolean spFlag = 0;
boolean dpFlag = 0;
boolean hpFlag = 0;
int button = 0;
int spbutton = 0;
/*
0-none
1-mode
2-track +
3-track -
4-mute
5-vol+
6-vol-
*/
void setup() {
Serial.begin(9600);
pinMode(7, OUTPUT);
}
void loop() {
static unsigned long oldTime = 0;
int switchStatus = 0;
if (millis() >= oldTime + CHECK_MS) {
oldTime = millis();
switchStatus = CheckSwitch();
if (switchStatus == 0) {
//no button press
} else if (switchStatus == 1) {
// single press
switch (spbutton) {
case 0: // no butto, why are wh here
break;
case 1: // mode
modeSend();
break;
case 2: // next up
trkUpSend();
break;
case 3: // next down
trkDnSend();
break;
case 4: // mute
muteSend();
break;
case 5: // vol up
volUpSend();
break;
case 6: // vol down
volDnSend();
break;
}
} else if (switchStatus == 2) {
//double press
switch (spbutton) {
case 0: // no butto, why are wh here
break;
case 1: // mode
sourceSend();
break;
case 2: // next up
trkUpSend();
break;
case 3: // next down
trkDnSend();
break;
case 4: // mute
muteSend();
break;
case 5: // vol up
volUpSend();
break;
case 6: // vol down
volDnSend();
break;
}
} else if (switchStatus == 3) {
//hold
switch (spbutton) {
case 0: // no butto, why are wh here
break;
case 1: // mode
modeSend();
break;
case 2: // next up
trkUpSend();
break;
case 3: // next down
trkDnSend();
break;
case 4: // mute
muteSend();
break;
case 5: // vol up
volUpSend();
break;
case 6: // vol down
volDnSend();
break;
}
}
}
}
// Service routine called by a timer interrupt
int CheckSwitch() {
static uint16_t State = 0; // Current debounce status
static int curTime = 0;
State=(State<<1) | !RawKeyPressed() | 0xe000;
if (!spFlag) {
if (hpFlag) {
if (State == 0xe000) {
return 3;
} else {
hpFlag = 0;
}
}
if (State==0xf000) {
spFlag = 1;
hpFlag = 1;
dpFlag = 1;
curTime = 0;
spbutton = button;
return 0;
}
}
if (hpFlag && State != 0xe000) {
hpFlag = 0;
}
if (spFlag && hpFlag && curTime > HOLD_MS/CHECK_MS) {
spFlag = 0;
dpFlag = 0;
return 3;
} else if (spFlag && dpFlag && State == 0xf000 && curTime < DOUBLE_MS) {
spFlag = 0;
hpFlag = 0;
dpFlag = 0;
return 2;
} else if (spFlag && !hpFlag && curTime > DOUBLE_MS) {
spFlag = 0;
hpFlag = 0;
dpFlag = 0;
return 1;
} else {
curTime = curTime + CHECK_MS;
return 0;
}
}
boolean RawKeyPressed() {
int anaPin = 0;
anaPin = analogRead(0);
if (anaPin > NO_B - 20) {
button = 0;
return 0;
} else if (anaPin > MODE_B - 20 && anaPin < MODE_B + 20 ) {
button = 1;
return 1;
} else if (anaPin > NXTU_B - 20 && anaPin < NXTU_B + 20 ) {
button = 2;
return 1;
} else if (anaPin > NXTD_B - 20 && anaPin < NXTD_B + 20 ) {
button = 3;
return 1;
} else if (anaPin > MUTE_B - 20 && anaPin < MUTE_B + 20 ) {
button = 4;
return 1;
} else if (anaPin > VOLU_B - 20 && anaPin < VOLU_B + 20 ) {
button = 5;
return 1;
} else if (anaPin < VOLD_B + 20 ) {
button = 6;
return 1;
} else {
button = 0;
return 0;
}
}
//-----------SOURCE------------------
void sourceSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (source[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
}
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41);
}
//---------MODE-----------------------------------------------
void modeSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (entPlay[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
}
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41);
}
//---------NEXT UP-----------------------------------------------
void trkUpSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (trkUp[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
}
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41);
}
//---------NEXT DOWN----------------------------------------------
void trkDnSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (trkDn[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
}
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41);
}
//---------MUTE---------------------------------------------------
void muteSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (mute[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
}
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41);
}
//---------VOL UP-----------------------------------------------
void volUpSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (volUp[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
}
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41);
}
//---------VOL DOWN-----------------------------------------------
void volDnSend() {
//first send 8ms high
digitalWrite(alpPin, HIGH);
delay(8);
// send 4.5ms low
digitalWrite(alpPin, LOW);
delayMicroseconds(4500);
for (int i = 0; i <= 47; i++) {
//send bit for 0.5ms
if (volDn[i] == 1 ) {
digitalWrite(alpPin, HIGH);
} else {
digitalWrite(alpPin, LOW);
}
delayMicroseconds(500);
// wait 0.5ms
digitalWrite(alpPin, LOW);
delayMicroseconds(500);
}
// send 41ms low
digitalWrite(alpPin, LOW);
delay(41);
}
Последний раз редактировалось Chip; 21.03.2017 в 03:39.
кто бы еще кларионовский протокол вскрыл бы
и тач алпайновского монитора.
А магнитолой mitsubishi lancer X возможно?
а усилками алпайновскими тоже можно управлять?такими типа MRD-M605 и проц алпайновский есть с Ai-net как сделать управление им?что для этого нужно?
Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)