Доброго время суток. Вот скетч на котором почти всё работает:
#include <Wire.h>
#include <PT2322.h>
#include <PT2323.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <Encoder.h>
#include <MsTimer2.h>
#include <boarddefs.h>
#include <IRremote.h>
PT2322 pt; PT2323 pt0;
Encoder myEnc(9, 8);//CLK, DT подключение энкодера
IRrecv irrecv(10); // указываем вывод модуля IR приемника
decode_results ir;
LiquidCrystal lcd(7, 6, 2, 3, 4, 5);// RS,E,D4,D5,D6,D7 подключение LCD
byte a1[8]={0b00000,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b00000};
byte a2[8]={0b00000,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b00000};
byte a3[8]={0b00000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b00000};
unsigned long newPosition,time,oldPosition = -999;
int menu,menu2,w,vol,vol_d,z,z0,z1,in,bass,bass_d,mid,mid_d,treb,treb_d,attfl,attfl_d,attcn,attcn_d,attsub,attsub_d,ddd,tembro,x,attfr,attfr_d,atttl,atttl_d,atttr,atttr_d,mute;
int g1,g2,inn;
void setup() {
Wire.begin();Serial.begin(9600);irrecv.enableIRIn(); // запускаем модульIR
lcd.begin(8, 2);lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);
pinMode(A0,INPUT); // menu кнопка энкодера
pinMode(12,INPUT); // MUTE
pinMode(11,INPUT); // IN
MsTimer2::set(2, to_Timer);MsTimer2::start();
vol = EEPROM.read(0)-79;in = EEPROM.read(1);bass = EEPROM.read(2)-7;mid = EEPROM.read(3)-7;treb = EEPROM.read(4)-7;
attfl = EEPROM.read(5)-14;attcn = EEPROM.read(7)-14;attsub = EEPROM.read(8)-14;ddd = EEPROM.read(9);tembro = EEPROM.read(10);
attfr = EEPROM.read(11)-14;atttl = EEPROM.read(12)-14;atttr = EEPROM.read(13)-14;
delay(500);
audio();audio_in();
}
void to_Timer(){newPosition = myEnc.read()/4;}
void loop(){delay(10);
if(analogRead(A0)<900){menu++;cl1();myEnc.write(0);time=millis();w=1;if(menu>11){menu=0;}}// меню
if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);time=millis();w=1;irrecv.resume();}// IR приемник
if(ir.value==0){g1=0;g2=0;}// запрет нажатий не активных кнопок пульта
if(in==4){digitalWrite(13,HIGH);}else{digitalWrite(13,LOW);} //вкл\выкл AUX5.1
if(ir.value==0x2FD609F){menu++;g1=0;g2=0;cl1();time=millis();w=1;if(menu>11){menu=0;}}// меню кнопка 5.1CH
if(ir.value==0x2FDE01F){menu--;g1=0;g2=0;cl1();time=millis();w=1;if(menu<0){menu=11;}}// меню кнопка 2.1CH
if(ir.value==0x2FDA05F){menu=0;g1=0;g2=0;cl1();time=millis();w=1;}// меню кнопка VSS (menu===0)
if(ir.value==0x2FDC03F){inn=1;g1=0;g2=0;time=millis();w=1;audio();}// кнопка AUX
//////////////////////////////////////// volume -79...0 db //////////////////////////////////////
if(menu==0){
if(ir.value==0x2FD10EF){vol++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+
if(ir.value==0xFFFFFFFF and g1==1){vol++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FD08F7){vol--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
if(ir.value==0xFFFFFFFF and g2==1){vol--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(vol>79){vol=79;}if(vol<0){vol=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
vol=vol+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(vol>79){vol=79;}if(vol<0){vol=0;}audio();}
lcd.setCursor(0,0);lcd.print("Volume ");
lcd.print(" ");lcd.print(-79+vol);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");vol_d=vol-32;
for(z=0,z0=0,z1=0;z<=vol_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0,1);lcd.write((uint8_t)2);}}
//////////////////////////////////////// bass +-14 db //////////////////////////////////////
if(menu==1){
if(ir.value==0x2FD00FF){bass++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка R+
if(ir.value==0xFFFFFFFF and g1==1){bass++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FD38C7){bass--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка L-
if(ir.value==0xFFFFFFFF and g2==1){bass--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(bass<-7){bass=-7;}if(bass>7){bass=7;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
bass=bass+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(bass<-7){bass=-7;}if(bass>7){bass=7;}audio();}
lcd.setCursor(0,0);lcd.print("Bass");
lcd.print(" ");lcd.print(bass*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");bass_d=(bass+7)*2;
for(z=0,z0=0,z1=0;z<=bass_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
//////////////////////////////////////// MIDDLE +-14 db //////////////////////////////////////
if(menu==2){
if(ir.value==0x2FD20DF){mid++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка FRONT+
if(ir.value==0xFFFFFFFF and g1==1){mid++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FD18E7){mid--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка FRONT-
if(ir.value==0xFFFFFFFF and g2==1){mid--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(mid<-7){mid=-7;}if(mid>7){mid=7;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
mid=mid+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(mid<-7){mid=-7;}if(mid>7){mid=7;}audio();}
lcd.setCursor(0,0);lcd.print("Middle ");
lcd.print(" ");lcd.print(mid*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("db");mid_d=(mid+7)*2;
for(z=0,z0=0,z1=0;z<=mid_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
//////////////////////////////////////// treble +-14 db //////////////////////////////////////
if(menu==3){
if(ir.value==0x2FD6897){treb++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка TREBLE+
if(ir.value==0xFFFFFFFF and g1==1){treb++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FDE817){treb--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка TREBLE-
if(ir.value==0xFFFFFFFF and g2==1){treb--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(treb<-7){treb=-7;}if(treb>7){treb=7;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
treb=treb+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(treb<-7){treb=-7;}if(treb>7){treb=7;}audio();}
lcd.setCursor(0,0);lcd.print("Treble ");
lcd.print(" ");lcd.print(treb*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");treb_d=(treb+7)*2;
for(z=0,z0=0,z1=0;z<=treb_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
//////////////////////////////////// rock pop classic //////////////////////
if(menu==4){
if(ir.value==0x2FDD02F){tembro=0;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка LIVE
if(ir.value==0x2FD906F){tembro=1;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка ROCK
if(ir.value==0x2FD50AF){tembro=2;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DISCO
if(ir.value==0x2FDF00F){tembro=3;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка MATR
if(ir.value==0x2FDC837){tembro=4;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка POPS
if(ir.value==0x2FD708F){tembro=5;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CLAS
if(ir.value==0x2FD48B7){tembro=6;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DSP OFF
if(ir.value==0x2FDB04F){tembro=7;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SIMUL
if(ir.value==0x2FD8877){tembro=8;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка HAL
if(tembro>9){tembro=0;}if(tembro<0){tembro=9;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
tembro=tembro+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(tembro>8){tembro=0;}if(tembro<0){tembro=8;}}
lcd.setCursor(0,0);lcd.print(" Preset timbre ");
if(tembro==0){lcd.setCursor(0,1);lcd.print(" LIVE ");bass=2,mid=0,treb=2;x=1;}
if(tembro==1){lcd.setCursor(0,1);lcd.print(" ROCK ");bass=4,mid=-2;treb=5;x=1;}
if(tembro==2){lcd.setCursor(0,1);lcd.print(" DISCO ");bass=10,mid=2;treb=14;x=1;}
if(tembro==3){lcd.setCursor(0,1);lcd.print(" MATR ");bass=-2,mid=0;treb=8;x=1;}
if(tembro==4){lcd.setCursor(0,1);lcd.print(" POP ");bass=4,mid=3;treb=4;x=1;}
if(tembro==5){lcd.setCursor(0,1);lcd.print(" CLASSIC ");bass=0,mid=0;treb=-2;x=1;}
if(tembro==6){lcd.setCursor(0,1);lcd.print(" DSP OFF ");bass=0,mid=0;treb=0;x=1;}
if(tembro==7){lcd.setCursor(0,1);lcd.print(" SIMUL ");}
if(tembro==8){lcd.setCursor(0,1);lcd.print(" HAL ");bass=-2,mid=5;treb=0;x=1;}
if(x==1){audio();x=0;}
}
/////////////////////// ATT FL ///////////////////
if(menu==5){
if(ir.value==0x2FD20DF){attfl++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка FRONT+
if(ir.value==0xFFFFFFFF and g1==1){attfl++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FD18E7){attfl--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка FRONT-
if(ir.value==0xFFFFFFFF and g2==1){attfl--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(attfl<-14){attfl=-14;}if(attfl>0){attfl=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
attfl=attfl+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attfl<-14){attfl=-14;}if(attfl>0){attfl=0;}audio();}
lcd.setCursor(0,0);lcd.print("ATT FL ");
lcd.print(" ");lcd.print(attfl);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attfl_d=(attfl+14)*2;
for(z=0,z0=0,z1=0;z<=attfl_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
/////////////////////// ATT FR ///////////////////
if(menu==6){
if(ir.value==0x2FD20DF){attfr++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка FRONT+
if(ir.value==0xFFFFFFFF and g1==1){attfr++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FD18E7){attfr--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка FRONT-
if(ir.value==0xFFFFFFFF and g2==1){attfr--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(attfr<-14){attfr=-14;}if(attfr>0){attfr=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
attfr=attfr+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attfr<-14){attfr=-14;}if(attfr>0){attfr=0;}audio();}
lcd.setCursor(0,0);lcd.print("ATT FR ");
lcd.print(" ");lcd.print(attfr);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attfr_d=(attfr+14)*2;
for(z=0,z0=0,z1=0;z<=attfr_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
/////////////////////// ATT SL ///////////////////
if(menu==7){
if(ir.value==0x2FDD827){atttl++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SURR+
if(ir.value==0xFFFFFFFF and g1==1){atttl++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FDF807){atttl--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка SURR-
if(ir.value==0xFFFFFFFF and g2==1){atttl--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(atttl<-14){atttl=-14;}if(atttl>0){atttl=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
atttl=atttl+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(atttl<-14){atttl=-14;}if(atttl>0){atttl=0;}audio();}
lcd.setCursor(0,0);lcd.print("ATT TL ");
lcd.print(" ");lcd.print(atttl);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");atttl_d=(atttl+14)*2;
for(z=0,z0=0,z1=0;z<=atttl_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
/////////////////////// ATT SR ///////////////////
if(menu==8){
if(ir.value==0x2FDD827){atttr++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SURR+
if(ir.value==0xFFFFFFFF and g1==1){atttr++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FDF807){atttr--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка SURR-
if(ir.value==0xFFFFFFFF and g2==1){atttr--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(atttr<-14){atttr=-14;}if(atttr>0){atttr=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
atttr=atttr+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(atttr<-14){atttr=-14;}if(atttr>0){atttr=0;}audio();}
lcd.setCursor(0,0);lcd.print("ATT TR ");
lcd.print(" ");lcd.print(atttr);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");atttr_d=(atttr+14)*2;
for(z=0,z0=0,z1=0;z<=atttr_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
/////////////////////// ATT CEN ///////////////////
if(menu==9){
if(ir.value==0x2FD9867){attcn++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CENTR+
if(ir.value==0xFFFFFFFF and g1==1){attcn++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FDB847){attcn--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка CENTR-
if(ir.value==0xFFFFFFFF and g2==1){attcn--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
attcn=attcn+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}audio();}
lcd.setCursor(0,0);lcd.print("ATT CN ");
lcd.print(" ");lcd.print(attcn);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attcn_d=(attcn+14)*2;
for(z=0,z0=0,z1=0;z<=attcn_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
/////////////////////// ATT SUB ///////////////////
if(menu==10){
if(ir.value==0x2FD58A7){attsub++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SAB+
if(ir.value==0xFFFFFFFF and g1==1){attsub++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FD7887){attsub--;g1=0;g2=1;cl();audio();}// кнопка SAB-
if(ir.value==0xFFFFFFFF and g2==1){attsub--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;time=millis();}
if (newPosition != oldPosition) {
oldPosition = newPosition;
attsub=attsub+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;}audio();}
lcd.setCursor(0,0);lcd.print("ATT SUB ");
lcd.print("");lcd.print(attsub);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attsub_d=(attsub+14)*2;
for(z=0,z0=0,z1=0;z<=attsub_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
//////////////////////////// 3d ///////////////////////////////////////////////
if(menu==11){
if(ir.value==0x2FD40BF){ddd++;g1=1;g2=0;cl1();time=millis();w=1;audio();}// кнопка 3D MOD
if(ir.value==0x2FD40BF){ddd--;g1=0;g2=1;cl1();audio();}// кнопка 3D MOD
if(ddd<0){ddd=1;}if(ddd>1){ddd=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
ddd=ddd+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(ddd<0){ddd=1;}if(ddd>1){ddd=0;}audio();}
lcd.setCursor(0,0); if(ddd==0){lcd.print(" 3D ON ");}else{lcd.print(" 3D OFF ");} }
//////////// mute ////////////////////////
if(mute==1&&(digitalRead(12)==HIGH||ir.value==0x2FD30CF)){mute=0;g1=1;g2=0;menu=0;audio();cl1();}
if(mute==0&&(digitalRead(12)==HIGH||ir.value==0x2FD30CF)){mute=1;g1=1;g2=0;menu=100;audio();cl1();}
if(mute==1){lcd.setCursor(0,0);lcd.print(" MUTE ");delay(300);}
/////////////////// INPUT ////////////////////////////////////////////////////////////////////////////////////////
if(digitalRead(11)==HIGH||inn==1){
in++;if(in>4){in=0;}audio_in();cl1();
lcd.setCursor(0,0);lcd.print("");
switch(in){ //
case 0: lcd.print(" AUX 2.1 "); break;
case 1: lcd.print(" BLUETOOTH "); break;
case 2: lcd.print(" DVD AS-3 "); break;
case 3: lcd.print(" RADIO "); break;
case 4: lcd.print(" AUX 5.1 "); break;}
delay(2000);time=millis();w=1;inn=0;}// in
if(millis()-time>10000&& w==1&&mute==0){
EEPROM.update(0,vol+79);EEPROM.update(1,in);EEPROM.update(2,bass+7);EEPROM.update(3,mid+7);EEPROM.update(4,treb+7);
EEPROM.update(5,attfl+14);EEPROM.update(7,attcn+14);EEPROM.update(8,attsub+14);EEPROM.update(9,ddd);EEPROM.update(10,tembro);
EEPROM.update(11,attfr+14);EEPROM.update(12,atttl+14);EEPROM.update(13,atttr+14);
menu=0;w=0;cl();}
}//loop
void cl(){ir.value=0;delay(100);}
void cl1(){ir.value=0;delay(300);lcd.clear();}
void audio_in(){
pt0.setInput(in);
pt0.setMute(0,0,0,0,0,0,0);
pt0.setFeature(1,1);
}
void audio(){
pt.setFront_lk_att(abs(attfl));// att front L
pt.setFront_rk_att(abs(attfr));// att front R
pt.setCenter_att(abs(attcn)); // att center
pt.setRear_lk_att(abs(atttl)); // att rear L
pt.setRear_rk_att(abs(atttr)); // att rear R
pt.setSub_att(abs(attsub)); // att sub
pt.setFunc(mute,ddd,0); // mute,3d,����� on/off
pt.setBass(bass); // BASS -14...0...14 dB (int -7...0...7)
pt.setMiddle(mid); // MIDDLE -14...0...14 dB (int -7...0...7)
pt.setTreble(treb); // TREBLE -14...0...14 dB (int -7...0...7)
pt.setVol(abs(vol)); // -79...0
}#include <Wire.h>
#include <PT2322.h>
#include <PT2323.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <Encoder.h>
#include <MsTimer2.h>
#include <boarddefs.h>
#include <IRremote.h>
PT2322 pt; PT2323 pt0;
Encoder myEnc(9, 8);//CLK, DT подключение энкодера
IRrecv irrecv(10); // указываем вывод модуля IR приемника
decode_results ir;
LiquidCrystal lcd(7, 6, 2, 3, 4, 5);// RS,E,D4,D5,D6,D7 подключение LCD
byte a1[8]={0b00000,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b00000};
byte a2[8]={0b00000,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b00000};
byte a3[8]={0b00000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b00000};
unsigned long newPosition,time,oldPosition = -999;
int menu,menu2,w,vol,vol_d,z,z0,z1,in,bass,bass_d,mid,mid_d,treb,treb_d,attfl,attfl_d,attcn,attcn_d,attsub,attsub_d,ddd,tembro,x,attfr,attfr_d,atttl,atttl_d,atttr,atttr_d,mute;
int g1,g2,inn;
void setup() {
Wire.begin();Serial.begin(9600);irrecv.enableIRIn(); // запускаем модульIR
lcd.begin(8, 2);lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);
pinMode(A0,INPUT); // menu кнопка энкодера
pinMode(12,INPUT); // MUTE
pinMode(11,INPUT); // IN
MsTimer2::set(2, to_Timer);MsTimer2::start();
vol = EEPROM.read(0)-79;in = EEPROM.read(1);bass = EEPROM.read(2)-7;mid = EEPROM.read(3)-7;treb = EEPROM.read(4)-7;
attfl = EEPROM.read(5)-14;attcn = EEPROM.read(7)-14;attsub = EEPROM.read(8)-14;ddd = EEPROM.read(9);tembro = EEPROM.read(10);
attfr = EEPROM.read(11)-14;atttl = EEPROM.read(12)-14;atttr = EEPROM.read(13)-14;
delay(500);
audio();audio_in();
}
void to_Timer(){newPosition = myEnc.read()/4;}
void loop(){delay(10);
if(analogRead(A0)<900){menu++;cl1();myEnc.write(0);time=millis();w=1;if(menu>11){menu=0;}}// меню
if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);time=millis();w=1;irrecv.resume();}// IR приемник
if(ir.value==0){g1=0;g2=0;}// запрет нажатий не активных кнопок пульта
if(in==4){digitalWrite(13,HIGH);}else{digitalWrite(13,LOW);} //вкл\выкл AUX5.1
if(ir.value==0x2FD609F){menu++;g1=0;g2=0;cl1();time=millis();w=1;if(menu>11){menu=0;}}// меню кнопка 5.1CH
if(ir.value==0x2FDE01F){menu--;g1=0;g2=0;cl1();time=millis();w=1;if(menu<0){menu=11;}}// меню кнопка 2.1CH
if(ir.value==0x2FDA05F){menu=0;g1=0;g2=0;cl1();time=millis();w=1;}// меню кнопка VSS (menu===0)
if(ir.value==0x2FDC03F){inn=1;g1=0;g2=0;time=millis();w=1;audio();}// кнопка AUX
//////////////////////////////////////// volume -79...0 db //////////////////////////////////////
if(menu==0){
if(ir.value==0x2FD10EF){vol++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+
if(ir.value==0xFFFFFFFF and g1==1){vol++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FD08F7){vol--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
if(ir.value==0xFFFFFFFF and g2==1){vol--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(vol>79){vol=79;}if(vol<0){vol=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
vol=vol+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(vol>79){vol=79;}if(vol<0){vol=0;}audio();}
lcd.setCursor(0,0);lcd.print("Volume ");
lcd.print(" ");lcd.print(-79+vol);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");vol_d=vol-32;
for(z=0,z0=0,z1=0;z<=vol_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0,1);lcd.write((uint8_t)2);}}
//////////////////////////////////////// bass +-14 db //////////////////////////////////////
if(menu==1){
if(ir.value==0x2FD00FF){bass++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка R+
if(ir.value==0xFFFFFFFF and g1==1){bass++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FD38C7){bass--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка L-
if(ir.value==0xFFFFFFFF and g2==1){bass--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(bass<-7){bass=-7;}if(bass>7){bass=7;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
bass=bass+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(bass<-7){bass=-7;}if(bass>7){bass=7;}audio();}
lcd.setCursor(0,0);lcd.print("Bass");
lcd.print(" ");lcd.print(bass*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");bass_d=(bass+7)*2;
for(z=0,z0=0,z1=0;z<=bass_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
//////////////////////////////////////// MIDDLE +-14 db //////////////////////////////////////
if(menu==2){
if(ir.value==0x2FD20DF){mid++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка FRONT+
if(ir.value==0xFFFFFFFF and g1==1){mid++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FD18E7){mid--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка FRONT-
if(ir.value==0xFFFFFFFF and g2==1){mid--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(mid<-7){mid=-7;}if(mid>7){mid=7;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
mid=mid+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(mid<-7){mid=-7;}if(mid>7){mid=7;}audio();}
lcd.setCursor(0,0);lcd.print("Middle ");
lcd.print(" ");lcd.print(mid*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("db");mid_d=(mid+7)*2;
for(z=0,z0=0,z1=0;z<=mid_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
//////////////////////////////////////// treble +-14 db //////////////////////////////////////
if(menu==3){
if(ir.value==0x2FD6897){treb++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка TREBLE+
if(ir.value==0xFFFFFFFF and g1==1){treb++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FDE817){treb--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка TREBLE-
if(ir.value==0xFFFFFFFF and g2==1){treb--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(treb<-7){treb=-7;}if(treb>7){treb=7;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
treb=treb+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(treb<-7){treb=-7;}if(treb>7){treb=7;}audio();}
lcd.setCursor(0,0);lcd.print("Treble ");
lcd.print(" ");lcd.print(treb*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");treb_d=(treb+7)*2;
for(z=0,z0=0,z1=0;z<=treb_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
//////////////////////////////////// rock pop classic //////////////////////
if(menu==4){
if(ir.value==0x2FDD02F){tembro=0;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка LIVE
if(ir.value==0x2FD906F){tembro=1;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка ROCK
if(ir.value==0x2FD50AF){tembro=2;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DISCO
if(ir.value==0x2FDF00F){tembro=3;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка MATR
if(ir.value==0x2FDC837){tembro=4;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка POPS
if(ir.value==0x2FD708F){tembro=5;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CLAS
if(ir.value==0x2FD48B7){tembro=6;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DSP OFF
if(ir.value==0x2FDB04F){tembro=7;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SIMUL
if(ir.value==0x2FD8877){tembro=8;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка HAL
if(tembro>9){tembro=0;}if(tembro<0){tembro=9;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
tembro=tembro+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(tembro>8){tembro=0;}if(tembro<0){tembro=8;}}
lcd.setCursor(0,0);lcd.print(" Preset timbre ");
if(tembro==0){lcd.setCursor(0,1);lcd.print(" LIVE ");bass=2,mid=0,treb=2;x=1;}
if(tembro==1){lcd.setCursor(0,1);lcd.print(" ROCK ");bass=4,mid=-2;treb=5;x=1;}
if(tembro==2){lcd.setCursor(0,1);lcd.print(" DISCO ");bass=10,mid=2;treb=14;x=1;}
if(tembro==3){lcd.setCursor(0,1);lcd.print(" MATR ");bass=-2,mid=0;treb=8;x=1;}
if(tembro==4){lcd.setCursor(0,1);lcd.print(" POP ");bass=4,mid=3;treb=4;x=1;}
if(tembro==5){lcd.setCursor(0,1);lcd.print(" CLASSIC ");bass=0,mid=0;treb=-2;x=1;}
if(tembro==6){lcd.setCursor(0,1);lcd.print(" DSP OFF ");bass=0,mid=0;treb=0;x=1;}
if(tembro==7){lcd.setCursor(0,1);lcd.print(" SIMUL ");}
if(tembro==8){lcd.setCursor(0,1);lcd.print(" HAL ");bass=-2,mid=5;treb=0;x=1;}
if(x==1){audio();x=0;}
}
/////////////////////// ATT FL ///////////////////
if(menu==5){
if(ir.value==0x2FD20DF){attfl++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка FRONT+
if(ir.value==0xFFFFFFFF and g1==1){attfl++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FD18E7){attfl--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка FRONT-
if(ir.value==0xFFFFFFFF and g2==1){attfl--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(attfl<-14){attfl=-14;}if(attfl>0){attfl=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
attfl=attfl+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attfl<-14){attfl=-14;}if(attfl>0){attfl=0;}audio();}
lcd.setCursor(0,0);lcd.print("ATT FL ");
lcd.print(" ");lcd.print(attfl);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attfl_d=(attfl+14)*2;
for(z=0,z0=0,z1=0;z<=attfl_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
/////////////////////// ATT FR ///////////////////
if(menu==6){
if(ir.value==0x2FD20DF){attfr++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка FRONT+
if(ir.value==0xFFFFFFFF and g1==1){attfr++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FD18E7){attfr--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка FRONT-
if(ir.value==0xFFFFFFFF and g2==1){attfr--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(attfr<-14){attfr=-14;}if(attfr>0){attfr=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
attfr=attfr+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attfr<-14){attfr=-14;}if(attfr>0){attfr=0;}audio();}
lcd.setCursor(0,0);lcd.print("ATT FR ");
lcd.print(" ");lcd.print(attfr);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attfr_d=(attfr+14)*2;
for(z=0,z0=0,z1=0;z<=attfr_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
/////////////////////// ATT SL ///////////////////
if(menu==7){
if(ir.value==0x2FDD827){atttl++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SURR+
if(ir.value==0xFFFFFFFF and g1==1){atttl++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FDF807){atttl--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка SURR-
if(ir.value==0xFFFFFFFF and g2==1){atttl--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(atttl<-14){atttl=-14;}if(atttl>0){atttl=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
atttl=atttl+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(atttl<-14){atttl=-14;}if(atttl>0){atttl=0;}audio();}
lcd.setCursor(0,0);lcd.print("ATT TL ");
lcd.print(" ");lcd.print(atttl);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");atttl_d=(atttl+14)*2;
for(z=0,z0=0,z1=0;z<=atttl_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
/////////////////////// ATT SR ///////////////////
if(menu==8){
if(ir.value==0x2FDD827){atttr++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SURR+
if(ir.value==0xFFFFFFFF and g1==1){atttr++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FDF807){atttr--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка SURR-
if(ir.value==0xFFFFFFFF and g2==1){atttr--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(atttr<-14){atttr=-14;}if(atttr>0){atttr=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
atttr=atttr+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(atttr<-14){atttr=-14;}if(atttr>0){atttr=0;}audio();}
lcd.setCursor(0,0);lcd.print("ATT TR ");
lcd.print(" ");lcd.print(atttr);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");atttr_d=(atttr+14)*2;
for(z=0,z0=0,z1=0;z<=atttr_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
/////////////////////// ATT CEN ///////////////////
if(menu==9){
if(ir.value==0x2FD9867){attcn++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CENTR+
if(ir.value==0xFFFFFFFF and g1==1){attcn++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FDB847){attcn--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка CENTR-
if(ir.value==0xFFFFFFFF and g2==1){attcn--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
attcn=attcn+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}audio();}
lcd.setCursor(0,0);lcd.print("ATT CN ");
lcd.print(" ");lcd.print(attcn);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attcn_d=(attcn+14)*2;
for(z=0,z0=0,z1=0;z<=attcn_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
/////////////////////// ATT SUB ///////////////////
if(menu==10){
if(ir.value==0x2FD58A7){attsub++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SAB+
if(ir.value==0xFFFFFFFF and g1==1){attsub++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
if(ir.value==0x2FD7887){attsub--;g1=0;g2=1;cl();audio();}// кнопка SAB-
if(ir.value==0xFFFFFFFF and g2==1){attsub--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;time=millis();}
if (newPosition != oldPosition) {
oldPosition = newPosition;
attsub=attsub+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;}audio();}
lcd.setCursor(0,0);lcd.print("ATT SUB ");
lcd.print("");lcd.print(attsub);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attsub_d=(attsub+14)*2;
for(z=0,z0=0,z1=0;z<=attsub_d;z++,z1++){if(z1>2){z1=0;z0++;}
if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print(" ");}}
if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}
//////////////////////////// 3d ///////////////////////////////////////////////
if(menu==11){
if(ir.value==0x2FD40BF){ddd++;g1=1;g2=0;cl1();time=millis();w=1;audio();}// кнопка 3D MOD
if(ir.value==0x2FD40BF){ddd--;g1=0;g2=1;cl1();audio();}// кнопка 3D MOD
if(ddd<0){ddd=1;}if(ddd>1){ddd=0;}
if (newPosition != oldPosition) {
oldPosition = newPosition;
ddd=ddd+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(ddd<0){ddd=1;}if(ddd>1){ddd=0;}audio();}
lcd.setCursor(0,0); if(ddd==0){lcd.print(" 3D ON ");}else{lcd.print(" 3D OFF ");} }
//////////// mute ////////////////////////
if(mute==1&&(digitalRead(12)==HIGH||ir.value==0x2FD30CF)){mute=0;g1=1;g2=0;menu=0;audio();cl1();}
if(mute==0&&(digitalRead(12)==HIGH||ir.value==0x2FD30CF)){mute=1;g1=1;g2=0;menu=100;audio();cl1();}
if(mute==1){lcd.setCursor(0,0);lcd.print(" MUTE ");delay(300);}
/////////////////// INPUT ////////////////////////////////////////////////////////////////////////////////////////
if(digitalRead(11)==HIGH||inn==1){
in++;if(in>4){in=0;}audio_in();cl1();
lcd.setCursor(0,0);lcd.print("");
switch(in){ //
case 0: lcd.print(" AUX 2.1 "); break;
case 1: lcd.print(" BLUETOOTH "); break;
case 2: lcd.print(" DVD AS-3 "); break;
case 3: lcd.print(" RADIO "); break;
case 4: lcd.print(" AUX 5.1 "); break;}
delay(2000);time=millis();w=1;inn=0;}// in
if(millis()-time>10000&& w==1&&mute==0){
EEPROM.update(0,vol+79);EEPROM.update(1,in);EEPROM.update(2,bass+7);EEPROM.update(3,mid+7);EEPROM.update(4,treb+7);
EEPROM.update(5,attfl+14);EEPROM.update(7,attcn+14);EEPROM.update(8,attsub+14);EEPROM.update(9,ddd);EEPROM.update(10,tembro);
EEPROM.update(11,attfr+14);EEPROM.update(12,atttl+14);EEPROM.update(13,atttr+14);
menu=0;w=0;cl();}
}//loop
void cl(){ir.value=0;delay(100);}
void cl1(){ir.value=0;delay(300);lcd.clear();}
void audio_in(){
pt0.setInput(in);
pt0.setMute(0,0,0,0,0,0,0);
pt0.setFeature(1,1);
}
void audio(){
pt.setFront_lk_att(abs(attfl));// att front L
pt.setFront_rk_att(abs(attfr));// att front R
pt.setCenter_att(abs(attcn)); // att center
pt.setRear_lk_att(abs(atttl)); // att rear L
pt.setRear_rk_att(abs(atttr)); // att rear R
pt.setSub_att(abs(attsub)); // att sub
pt.setFunc(mute,ddd,0); // mute,3d,����� on/off
pt.setBass(bass); // BASS -14...0...14 dB (int -7...0...7)
pt.setMiddle(mid); // MIDDLE -14...0...14 dB (int -7...0...7)
pt.setTreble(treb); // TREBLE -14...0...14 dB (int -7...0...7)
pt.setVol(abs(vol)); // -79...0
}
Хотелось добавить режим surround как с пульта, так и с экондера,(как раз осталась свободная кнопка на пульте)
и когда его включаешь на А1 появлялось 5В, когда включаешь 3D, на А2 5В. И посмотрите правильно ли я вставил
эту строку: if(ir.value==0){g1=0;g2=0;}// запрет нажатий не активных кнопок пульта.
С ней лучше , но всё равно громкость можно уменьшить или увеличить, в зависимости от того что было последним
любой кнопкой имеющей в скетче код FFFFFFFF. Заранее благодарен.