#define IR1 16478351 // INPUT
#define IR2 16459991 // MUTE
#define IR3 16492631 // 3D
#define IR4 16494671 // EQ
#define IR5 16449791 // UP VOL
#define IR6 16482431 // DW VOL
#define IR7 16476311 // STANDBY
#define IR8 16474271 // TREBLE
#define IR9 16457951 // BASS
#define IR10 16470191 // FRONT
#define IR11 16453871 // REAR
#define IR12 16490591 // CENTER
#define IR13 16486511 // SUB
#define IR14 16462031 // OUTPUT
#define IR15 0x2FD48B7 // STANDBY TV
#define IR16 0x2FD08F7 // MUTE TV
#define IR17 0x2FD58A7 // UP VOL TV
#define IR18 0x2FD7887 // DW VOL TV
#include <Wire.h>
#include <PT2322.h>
#include <PT2323.h>
#include <LiquidCrystal_I2C.h> // http://forum.rcl-radio.ru/misc.php?action=pan_download&item=45&download=1
#include <EEPROM.h>
#include <Encoder.h>
#include <MsTimer2.h>
#include <boarddefs.h>
#include <IRremote.h>
PT2322 pt; PT2323 pt0;
Encoder myEnc(7, 8);//CLK, DT подключение энкодера
IRrecv irrecv(9); // указываем вывод модуля IR приемника
decode_results ir;
LiquidCrystal_I2C lcd(0x27,16,2); // Устанавливаем дисплей
unsigned long newPosition,time,oldPosition = -999,times_ir;
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;
bool g1,g2;
bool w1=1,power;
int att_front, att_rear;
int w_ir;
unsigned long led_times;
int led_tic;
byte a[6],d1,d2,d3,d4,d5,d6,e1,e2,e3;
void setup() {
Wire.begin();Serial.begin(9600);irrecv.enableIRIn(); // запускаем модуль IR
lcd.init();lcd.backlight();
pinMode(12,INPUT_PULLUP); // MUTE
pinMode(10,INPUT_PULLUP); // IN
pinMode(11,INPUT_PULLUP); // STANDBY
pinMode(3,OUTPUT); // OUTPUT STANDBY AND MUTE
pinMode(4,OUTPUT); // OUTPUT POWER
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;
att_front = EEPROM.read(14)-14;att_rear = EEPROM.read(14)-14;
delay(500);
if(tembro==1){bass=4,mid=-2;treb=5;}
if(tembro==2){bass=-3,mid=3;treb=-2;}
if(tembro==3){bass=7,mid=0;treb=7;}
if(tembro==4){bass=0,mid=0;treb=0;}
audio();audio_in();
}
void to_Timer(){newPosition = myEnc.read()/4;}
void loop(){
if(menu!=0){
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};
lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);
}
else{
byte v1[8] = {0b00111,0b00111,0b00111,0b00111,0b00111,0b00111,0b00111,0b00111};
byte v2[8] = {0b00111,0b00111,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000};
byte v3[8] = {0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b11111,0b11111};
byte v4[8] = {0b11111,0b11111,0b00000,0b00000,0b00000,0b00000,0b11111,0b11111};
byte v5[8] = {0b11100,0b11100,0b00000,0b00000,0b00000,0b00000,0b11100,0b11100};
byte v6[8] = {0b11100,0b11100,0b11100,0b11100,0b11100,0b11100,0b11100,0b11100};
byte v7[8] = {0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00111,0b00111};
byte v8[8] = {0b11111,0b11111,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000};
lcd.createChar(1, v1);lcd.createChar(2, v2);lcd.createChar(3, v3);lcd.createChar(4, v4);
lcd.createChar(5, v5);lcd.createChar(6, v6);lcd.createChar(7, v7);lcd.createChar(8, v8);
}
////////////////////////////////////////////////////////////// INPUT SELECTOR //////////////////////////////
if(power==0){
if(mute==0){
if(digitalRead(10)==LOW || ir.value==IR1){in++;g1=1;g2=0;menu=8;if(in>4){in=2;}if(in==3){in=4;}audio_in();cl1();time=millis();w=1;w1=1;}// in
if(menu==8){
lcd.setCursor(0,0);lcd.print(" INPUT SELECTOR ");
switch(in){
//case 0: lcd.setCursor(0,1);lcd.print(" CD ");break;
//case 1: lcd.setCursor(0,1);lcd.print(" TAPE ");break;
case 2: lcd.setCursor(0,1);lcd.print(" TV");break;
//case 3: lcd.setCursor(0,1);lcd.print(" IN ");break;
case 4: lcd.setCursor(0,1);lcd.print(" AC-3 ");break;
}
}
if(ir.value==IR3){ddd++;menu=11;g1=1;g2=0;cl1();time=millis();w=1;ddd_conf();audio();}
if(ir.value==IR4){tembro++;menu=4;g1=1;g2=0;cl1();time=millis();w=1;w1=1;tembr();audio();}
if(ir.value==IR8){menu=3;g1=1;g2=0;cl1();time=millis();w=1;w1=1;} // treble
if(ir.value==IR9){menu=1;g1=1;g2=0;cl1();time=millis();w=1;w1=1;} // bass
if(ir.value==IR10){menu=5;g1=1;g2=0;cl1();time=millis();w=1;w1=1;} // front
if(ir.value==IR11){menu=6;g1=1;g2=0;cl1();time=millis();w=1;w1=1;} // rear
if(ir.value==IR12){menu=9;g1=1;g2=0;cl1();time=millis();w=1;w1=1;} // center
if(ir.value==IR13){menu=10;g1=1;g2=0;cl1();time=millis();w=1;w1=1;} // sub
} // mute
if((digitalRead(12)==LOW || ir.value==IR2|| ir.value==IR16) && mute==0){mute=1;menu=100;g1=0;g2=0;cl1();time=millis();w=1;w1=1;audio();lcd.setCursor(6,0);lcd.print("MUTE");delay(500);}
if((digitalRead(12)==LOW || ir.value==IR2|| ir.value==IR16) && mute==1){mute=0;menu=0; g1=0;g2=0;cl1();time=millis();w=1;w1=1;audio();}
}
// power
if(mute==1||power==1){digitalWrite(3,HIGH);}else{digitalWrite(3,LOW);}// standby out pin D3
if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);w=0;w1=1;irrecv.resume();}
if((digitalRead(11)==LOW || ir.value==IR7 || ir.value==IR15 ) && power==0){power=1;menu=100;g1=0;g2=0;cl1();time=millis();w=0;w1=1;mute=1;audio();lcd.setCursor(3,0);lcd.print("POWER OFF");delay(1000);lcd.noBacklight();cl1();}
if((digitalRead(11)==LOW || ir.value==IR7 || ir.value==IR15 ) && power==1){power=0;menu=0; g1=0;g2=0;cl1();time=millis();w=0;w1=1;mute=0;audio();lcd.backlight();lcd.setCursor(3,0);lcd.print("POWER ON ");delay(1000);cl1();}
//////////////////////////////////////// Громкость -79...0 дБ //////////////////////////////////////
if(menu==0){
if(ir.value==IR5|| ir.value==IR17){vol++;g1=1;g2=0;cl();time=millis();w=1;w1=1;vol_conf();audio();}// кнопка VOL+ 16449791
if(ir.value==4294967295 and g1==1){vol++;g2=0;cl();time=millis();w=1;w1=1;vol_conf();audio();}// кнопка >>>>>>
if(ir.value==IR6|| ir.value==IR18){vol--;g1=0;g2=1;cl();time=millis();w=1;w1=1;vol_conf();audio();}// кнопка VOL- 16482431
if(ir.value==4294967295 and g2==1){vol--;g1=0;cl();time=millis();w=1;w1=1;vol_conf();audio();}// кнопка <<<<<<
if (newPosition != oldPosition) {
oldPosition = newPosition;
vol=vol+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w1=1;vol_conf();audio();}
lcd.setCursor(0,0);lcd.print("VOLUME ");
lcd.setCursor(0,1);
switch(in){
//case 0: lcd.print(" CD");break;// вывод надпись входа на экране громкости
//case 1: lcd.print("TAPE");break;
case 2: lcd.print(" TV");break;
//case 3: lcd.print(" IN");break;
case 4: lcd.print("AC-3");break;
}
if(w1==1){
a[0]= (vol)/10;a[1]=(vol)%10;
for(x=0;x<2;x++){switch(x){case 0: e1=10,e2=11,e3=12;break;case 1: e1=13,e2=14,e3=15;break;}digit();}}}
//////////////////////////////////////// Тембр НЧ +-14 дБ //////////////////////////////////////
if(menu==1){
if(ir.value==IR5){bass++;g1=1;g2=0;cl();time=millis();w=1;w1=1;bass_conf();audio();}// кнопка VOL+ 16449791
if(ir.value==4294967295 and g1==1){bass++;g2=0;cl();time=millis();w=1;w1=1;bass_conf();audio();}// кнопка >>>>>>
if(ir.value==IR6){bass--;g1=0;g2=1;cl();time=millis();w=1;w1=1;bass_conf();audio();}// кнопка VOL- 16449791
if(ir.value==4294967295 and g2==1){bass--;g1=0;cl();time=millis();w=1;w1=1;bass_conf();audio();}// кнопка <<<<<<
if (newPosition != oldPosition) {
oldPosition = newPosition;
bass=bass+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w1=1;bass_conf();audio();}
lcd.setCursor(0,0);lcd.print("BASS ");
lcd.print(" ");lcd.print(bass);lcd.print(" ");lcd.setCursor(13,0);bass_d=(bass+7)*2;
if(w1==1){w1=0;
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);}}}
//////////////////////////////////////// Тембр CЧ +-14 дБ //////////////////////////////////////
if(menu==2){
if(ir.value==IR5){mid++;g1=1;g2=0;cl();time=millis();w=1;w1=1;mid_conf();audio();}// кнопка VOL+
if(ir.value==4294967295 and g1==1){mid++;g2=0;cl();time=millis();w=1;w1=1;mid_conf();audio();}// кнопка >>>>>>
if(ir.value==IR6){mid--;g1=0;g2=1;cl();time=millis();w=1;w1=1;mid_conf();audio();}// кнопка VOL-
if(ir.value==4294967295 and g2==1){mid--;g1=0;cl();time=millis();w=1;w1=1;mid_conf();audio();}// кнопка <<<<<<
if (newPosition != oldPosition) {
oldPosition = newPosition;
mid=mid+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w1=1;mid_conf();audio();}
lcd.setCursor(0,0);lcd.print("MIDDLE ");
lcd.print(" ");lcd.print(mid);lcd.print(" ");lcd.setCursor(13,0);mid_d=(mid+7)*2;
if(w1==1){w1=0;
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);}}}
//////////////////////////////////////// Тембр BЧ +-14 дБ //////////////////////////////////////
if(menu==3){
if(ir.value==IR5){treb++;g1=1;g2=0;cl();time=millis();w=1;w1=1;treb_conf();audio();}// кнопка VOL+
if(ir.value==4294967295 and g1==1){treb++;g2=0;cl();time=millis();w=1;w1=1;treb_conf();audio();}// кнопка >>>>>>
if(ir.value==IR6){treb--;g1=0;g2=1;cl();time=millis();w=1;w1=1;treb_conf();audio();}// кнопка VOL-
if(ir.value==4294967295 and g2==1){treb--;g1=0;cl();time=millis();w=1;w1=1;treb_conf();audio();}// кнопка <<<<<<
if (newPosition != oldPosition) {
oldPosition = newPosition;
treb=treb+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w1=1;treb_conf();audio();}
lcd.setCursor(0,0);lcd.print("TREBLE ");
lcd.print(" ");lcd.print(treb);lcd.print(" ");lcd.setCursor(13,0);treb_d=(treb+7)*2;
if(w1==1){w1=0;
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==IR5){tembro++;g1=1;g2=0;cl();time=millis();w=1;w1=1;tembr();audio();}// кнопка VOL+
if(ir.value==IR6){tembro--;g1=0;g2=1;cl();time=millis();w=1;w1=1;tembr();audio();}// кнопка VOL-
if (newPosition != oldPosition) {
oldPosition = newPosition;
tembro=tembro+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w1=1;tembr();}
if(w1==1){w1=0;
lcd.setCursor(3,0);lcd.print("Preset EQ");
if(tembro==0){lcd.setCursor(0,1);lcd.print(" manual mode ");}
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(" POP ");bass=-3,mid=3;treb=-2;x=1;}
if(tembro==3){lcd.setCursor(0,1);lcd.print(" DISCO ");bass=6,mid=0;treb=7;x=1;}
if(tembro==4){lcd.setCursor(0,1);lcd.print(" default ");bass=7,mid=0;treb=7;x=1;}
if(x==1){audio();x=0;}
}}
/////////////////////// ATT FRONT ///////////////////
if(menu==5){
if(ir.value==IR5){att_front++;g1=1;g2=0;cl();time=millis();w=1;w1=1;att_front_conf();audio();}// кнопка VOL+
if(ir.value==0xFFFFFFFF and g1==1){att_front++;g2=0;cl();time=millis();w=1;w1=1;att_front_conf();audio();}// кнопка >>>>>>
if(ir.value==IR6){att_front--;g1=0;g2=1;cl();time=millis();w=1;w1=1;att_front_conf();audio();}// кнопка VOL-
if(ir.value==0xFFFFFFFF and g2==1){att_front--;g1=0;cl();time=millis();w=1;w1=1;att_front_conf();audio();}// кнопка <<<<<<
if (newPosition != oldPosition) {
oldPosition = newPosition;
att_front=att_front+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w1=1;att_front_conf();audio();}
lcd.setCursor(3,0);lcd.print("FRONT ");
lcd.print(att_front);lcd.print(" ");lcd.setCursor(13,0);attfl_d=(att_front+14)*2;
if(w1==1){w1=0;
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 REAR ///////////////////
if(menu==6){
if(ir.value==IR5){att_rear++;g1=1;g2=0;cl();time=millis();w=1;w1=1;att_rear_conf();audio();}// кнопка VOL+
if(ir.value==0xFFFFFFFF and g1==1){att_rear++;g2=0;cl();time=millis();w=1;w1=1;att_rear_conf();audio();}// кнопка >>>>>>
if(ir.value==IR6){att_rear--;g1=0;g2=1;cl();time=millis();w=1;w1=1;att_rear_conf();audio();}// кнопка VOL-
if(ir.value==0xFFFFFFFF and g2==1){att_rear--;g1=0;cl();time=millis();w=1;w1=1;att_rear_conf();audio();}// кнопка <<<<<<
if (newPosition != oldPosition) {
oldPosition = newPosition;
att_rear=att_rear+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w1=1;att_rear_conf();audio();}
lcd.setCursor(3,0);lcd.print("REAR ");
lcd.print(att_rear);lcd.print(" ");lcd.setCursor(13,0);atttl_d=(att_rear+14)*2;
if(w1==1){w1=0;
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 CN ///////////////////
if(menu==9){
if(ir.value==IR5){attcn++;g1=1;g2=0;cl();time=millis();w=1;w1=1;att_cn();audio();}// кнопка VOL+
if(ir.value==4294967295 and g1==1){attcn++;g2=0;cl();time=millis();w=1;w1=1;att_cn();audio();}// кнопка >>>>>>
if(ir.value==IR6){attcn--;g1=0;g2=1;cl();time=millis();w=1;w1=1;att_cn();audio();}// кнопка VOL-
if(ir.value==4294967295 and g2==1){attcn--;g1=0;cl();time=millis();w=1;w1=1;att_cn();audio();}// кнопка <<<<<<
if (newPosition != oldPosition) {
oldPosition = newPosition;
attcn=attcn+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w1=1;att_cn();audio();}
lcd.setCursor(3,0);lcd.print("CENTER ");
lcd.print(" ");lcd.print(attcn);lcd.print(" ");lcd.setCursor(13,0);attcn_d=(attcn+14)*2;
if(w1==1){w1=0;
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==IR5){attsub++;g1=1;g2=0;cl();time=millis();w=1;w1=1;att_sub();audio();}// кнопка VOL+
if(ir.value==4294967295 and g1==1){attsub++;g2=0;cl();time=millis();w=1;w1=1;att_sub();audio();}// кнопка >>>>>>
if(ir.value==IR6){attsub--;g1=0;g2=1;cl();time=millis();w=1;w1=1;att_sub();audio();}// кнопка VOL-
if(ir.value==4294967295 and g2==1){attsub--;g1=0;cl();time=millis();w=1;w1=1;att_sub();audio();}// кнопка <<<<<<
if (newPosition != oldPosition) {
oldPosition = newPosition;
attsub=attsub+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w1=1;att_sub();audio();}
lcd.setCursor(3,0);lcd.print("SUB ");
lcd.print(" ");lcd.print(attsub);lcd.print(" ");lcd.setCursor(13,0);attsub_d=(attsub+14)*2;
if(w1==1){w1=0;
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 (newPosition != oldPosition) {
oldPosition = newPosition;
ddd=ddd+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;ddd_conf();audio();}
lcd.setCursor(0,0);lcd.print(" Surround ");
lcd.setCursor(0,1);if(ddd==0){lcd.print(" 3D ON ");}else{lcd.print(" 3D OFF ");}}
//////////////////////////// EEPROM /////////////////////////////////////////////////////////////
if(millis()-time>5000 && w==1 && mute==0 && power==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);
EEPROM.update(14,att_front+14);EEPROM.update(15,att_rear+14);
menu=0;w=0;w1=1;cl1();}
}//loop
void ddd_conf(){if(ddd<0){ddd=1;}if(ddd>1){ddd=0;}}
void att_sub(){if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;}}
void att_cn(){if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}}
void att_rear_conf(){if(att_rear<-14){att_rear=-14;}if(att_rear>0){att_rear=0;}}
void att_front_conf(){if(att_front<-14){att_front=-14;}if(att_front>0){att_front=0;}}
void tembr(){if(tembro>4){tembro=0;}if(tembro<0){tembro=4;}}
void treb_conf(){if(treb<-14){treb=-14;}if(treb>14){treb=14;}}
void mid_conf(){if(mid<-14){mid=-14;}if(mid>14){mid=14;}}
void bass_conf(){if(bass<-14){bass=-14;}if(bass>14){bass=14;}}
void vol_conf(){if(vol>79){vol=79;}if(vol<0){vol=0;}}
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
}
void digit(){switch(a[x]){
case 0: d1=1,d2=8,d3=6,d4=1,d5=3,d6=6;break;case 1: d1=32,d2=2,d3=6,d4=32,d5=32,d6=6;break;
case 2: d1=2,d2=8,d3=6,d4=1,d5=4,d6=5;break;case 3: d1=2,d2=4,d3=6,d4=7,d5=3,d6=6;break;
case 4: d1=1,d2=3,d3=6,d4=32,d5=32,d6=6;break;case 5: d1=1,d2=4,d3=5,d4=7,d5=3,d6=6;break;
case 6: d1=1,d2=4,d3=5,d4=1,d5=3,d6=6;break;case 7: d1=1,d2=8,d3=6,d4=32,d5=32,d6=6;break;
case 8: d1=1,d2=4,d3=6,d4=1,d5=3,d6=6;break;case 9: d1=1,d2=4,d3=6,d4=7,d5=3,d6=6;break;}
lcd.setCursor(e1,0);lcd.write((uint8_t)d1);lcd.setCursor(e2,0);lcd.write((uint8_t)d2);lcd.setCursor(e3,0);lcd.write((uint8_t)d3);
lcd.setCursor(e1,1);lcd.write((uint8_t)d4);lcd.setCursor(e2,1);lcd.write((uint8_t)d5);lcd.setCursor(e3,1);lcd.write((uint8_t)d6);}