126

Re: TDA7313 + DS3231 + IR + LCD2004

я еше раз провериль когда крутишь по одну ДБ норм если бистро крутишь энкодер звук разними становится

127

Re: TDA7313 + DS3231 + IR + LCD2004

На уровень звука может влиять тонкомпенсация, ее нужно отключить > установить параметр LOUND 0  FLAT.
Так же если уровень звука разный в колонках, то его можно выравнить при помощи аттенюаторов выходов.

Посмотрите аттенюатор входа (он доступен если нажать кнопку INPUT), аттенюатор должен быть установлен на 0 дБ

128

Re: TDA7313 + DS3231 + IR + LCD2004

Попробуйте этот код, энкодер должен работать правильно

#define IR_1 0x33B8A05F // Кнопка вверх
#define IR_2 0x33B8609F // Кнопка вниз
#define IR_3 0x33B810EF // Кнопка >
#define IR_4 0x33B8E01F // Кнопка <
#define IR_5 0x33B850AF // Кнопка IN
#define IR_6 0x33B844BB // Кнопка SET
#define IR_7 0x33B8946B // Кнопка MUTE
#define IR_8 0x33B800FF // Кнопка STANDBY (POWER)
 
#define BRIG_H 200      // Яркость 0...255 POWER ON
#define BRIG_L 50       // Яркость 0...255 POWER OFF
 
#include <TDA7719.h>            // http://rcl-radio.ru/wp-content/uploads/2019/07/TDA7719.zip
#include <Wire.h>
#include <LiquidCrystal_I2C.h>  // http://forum.rcl-radio.ru/misc.php?action=pan_download&item=45&download=1
#include <Encoder.h>            // http://rcl-radio.ru/wp-content/uploads/2019/05/Encoder.zip    
#include <EEPROM.h>
#include <MsTimer2.h>           // http://rcl-radio.ru/wp-content/uploads/2018/11/MsTimer2.zip       
#include <boarddefs.h>          // входит в состав библиотеки IRremote
#include <IRremote.h>           // http://rcl-radio.ru/wp-content/uploads/2019/06/IRremote.zip
#include <DS3231.h>             // http://rcl-radio.ru/wp-content/uploads/2022/10/DS3231.zip
 TDA7719 tda;
 DS3231 clock;RTCDateTime DateTime;
 LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
 IRrecv irrecv(12); // указываем вывод модуля IR приемника
 Encoder myEnc(9, 8);// DT, CLK
 decode_results ir; 
 int in,loun,loun_f,vol_att,treb,treb_f,mid,mid_q,bass,bass_q,sub_f,faza=0,mid_f,bass_f;
 int vol,att_lf,att_rf,att_lr,att_rr,att_l,att_r;
 long time0,oldPosition  = -999,newPosition;
 int menu0,menu,temp0,vol_d,bass_d,treb_d,par,z_old,z1,z0,z,menu1,in_time;
 byte q,gr1,gr2,w,w2[4],www,power,in_x,mute=1;
 int hour,minut,secon,mid_d,menu2,gain0,gain1,gain2,gain3;
 byte mesto2[8]={0,10,0,10,0,10,0,10};
 byte mesto3[8]={0,0,1,1,2,2,3,3};
 
void setup() {
  irrecv.enableIRIn();lcd.init();lcd.backlight();clock.begin();Serial.begin(9600);
  pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT_PULLUP);   // КНОПКА SET
  pinMode(3,INPUT_PULLUP);   // КНОПКА IN
  pinMode(4,INPUT_PULLUP);   // КНОПКА MUTE
  pinMode(5,INPUT_PULLUP);   // КНОПКА STANDBY
  pinMode(7,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ STANDBY
  pinMode(6,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ ПОДСВЕТКОЙ
  analogWrite(6, BRIG_H);// больше 200 не делать
  lcd.setCursor(3,1);lcd.print("Sound Processor");lcd.setCursor(7,2);lcd.print("TDA7719"); delay(2000);lcd.clear();
  MsTimer2::set(3, to_Timer);MsTimer2::start();
  //  clock.setDateTime(__DATE__, __TIME__); // Устанавливаем время на часах, основываясь на времени компиляции скетча
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении  
  vol = EEPROM.read(0)-63;bass = EEPROM.read(1)-15;mid = EEPROM.read(2)-15;treb = EEPROM.read(3)-15;
  att_lr = EEPROM.read(4);att_rr = EEPROM.read(5);att_lf = EEPROM.read(6);att_rf = EEPROM.read(7);att_r = EEPROM.read(8);att_l = EEPROM.read(9);
  loun = EEPROM.read(10);loun_f = EEPROM.read(11);
  bass_f = EEPROM.read(12);mid_f = EEPROM.read(13);treb_f = EEPROM.read(14);sub_f = EEPROM.read(15);
  bass_q = EEPROM.read(16);mid_q = EEPROM.read(17);
  gain1 = EEPROM.read(18)-15;gain2 = EEPROM.read(19)-15;gain3 = EEPROM.read(20)-15;
  switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
  w2_arr();audio();cl();
}
 
void to_Timer(){newPosition = myEnc.read()/4;}
 
void loop() {
  DateTime = clock.getDateTime();hour = DateTime.hour;minut = DateTime.minute;secon = DateTime.second;
  /////////////////////////////// УПРАВЛЕНИЕ //////////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();time0=millis();w=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта  
 
  if(power==0){
    if(mute==1){
  if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time0=millis();in_x=0;w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu1++;delay(200);time0=millis();in_x=0;w=1;if(menu1>7){menu1=0;}}// меню 1
  if(digitalRead(10)==LOW&&menu0==2){menu2++;delay(200);time0=millis();in_x=0;w=1;if(menu2>5){menu2=0;}}// меню 2
 
  if(ir.value==IR_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu>3){menu=0;}}//меню 0
  if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu<0){menu=3;}}//меню 0
 
  if(ir.value==IR_2&&menu0==1){menu1++;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu1>7){menu1=0;}}//меню 1
  if(ir.value==IR_1&&menu0==1){menu1--;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu1<0){menu1=7;}}//меню 1
 
  if(ir.value==IR_2&&menu0==2){menu2++;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu2>5){menu2=0;}}//меню 2
  if(ir.value==IR_1&&menu0==2){menu2--;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu2<0){menu2=5;}}//меню 2
 
  if(ir.value==IR_6||digitalRead(2)==LOW){menu0++;if(menu0>2){menu0=0;}cl();in_x=0;w2_arr();time0=millis();w=1;lcd.setCursor(5,1);
     lcd.print("SETTING_");lcd.print(menu0);delay(500);lcd.clear();} 
 
  if(ir.value==IR_5||digitalRead(3)==LOW){in++;cl();time0=millis();in_x=1;w=1;www=1;menu0=100;menu=100;if(in>2){in=0;}}// IN   
    } // mute off
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==1&&power==0){mute=0;in_x=0;mute=0;menu0=100;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");audio();delay(300);}// mute on
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==0&&power==0){mute=1;cl();time0=millis();w=1;w2_arr();menu0=0;menu=0;myEnc.write(0);audio();}// mute off
  }// power on
 
  if((ir.value==IR_8||digitalRead(5)==LOW)&&power==0){power=1;in_x=0;mute=0;cl();audio();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);analogWrite(6,BRIG_L);}// power off
  if((ir.value==IR_8||digitalRead(5)==LOW)&&power==1){power=0;analogWrite(6, BRIG_H);cl();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);mute=1;audio();delay(3000);cl();}// power on
 
 
if(power==0){digitalWrite(7,HIGH);
   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}; 
   byte a4[8] = {0b10000,0b11000,0b11100,0b11110,0b11100,0b11000,0b10000,0b00000}; //>
   byte a5[8] = {0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000};
   lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);lcd.createChar(3,a4);lcd.createChar(4,a5);
  }
  if(power==1){digitalWrite(7,LOW);
      byte v1[8] = {7,7,7,7,7,7,7,7};
      byte v2[8] = {7,7,0, 0, 0, 0, 0, 0};      
      byte v3[8] = { 0, 0, 0, 0, 0,0,31,31};
      byte v4[8] = {31,31, 0, 0, 0, 0,31,31};
      byte v5[8] = { 28, 28, 0, 0, 0, 0, 28, 28};
      byte v6[8] = {28,28,28,28,28,28,28,28};
      byte v7[8] = { 0, 0, 0, 0, 0, 0,7,7};
      byte v8[8] = { 31, 31,0,0,0,0,0, 0};
   byte a[6];
   byte i0,d1,d2,d3,d4,d5,d6,e1,e2,e3;
  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);
 
     a[0]=DateTime.hour/10;
     a[1]=DateTime.hour%10;
     a[2]=DateTime.minute/10;
     a[3]=DateTime.minute%10;
     a[4]=DateTime.second/10;
     a[5]=DateTime.second%10;
 
 for(int i=0;i<6;i++){
      switch(i){
        case 0: e1=0,e2=1,e3=2;break;
        case 1: e1=3,e2=4,e3=5;break;
        case 2: e1=7,e2=8,e3=9;break;
        case 3: e1=10,e2=11,e3=12;break;
        case 4: e1=14,e2=15,e3=16;break;
        case 5: e1=17,e2=18,e3=19;break;
        }
      switch(a[i]){
        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);
  }
  lcd.setCursor(6,0);lcd.print(".");lcd.setCursor(13,0);lcd.print(".");lcd.setCursor(6,1);lcd.print(".");lcd.setCursor(13,1);lcd.print(".");
  lcd.setCursor(5,3);lcd.print("POWER  OFF");
  if(digitalRead(10)==LOW&&digitalRead(2)==LOW){hour++;if(hour>23){hour=0;} clock.setDateTime(2022, 9, 15, hour, minut, secon);delay(100);}    // SET
  if(digitalRead(10)==LOW&&digitalRead(3)==LOW){minut++;if(minut>59){minut=0;} clock.setDateTime(2022, 9, 15, hour, minut, secon);delay(100); }// IN
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW){secon=0; clock.setDateTime(2022, 9, 15, hour, minut, secon);delay(100); }                      // MUTE
  } 
/////////////////////////////// MENU0 = VOLUME TERBLE BASS MIDDLE ///////////////////////////////////////////////////////////////////////
  if(menu0==0){ 
    switch(menu){
      case 0: temp0 = vol;q=0;break;
      case 1: temp0 = bass;q=1;break;
      case 2: temp0 = mid;q=2;break;
      case 3: temp0 = treb;q=3;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка <<<<<<   
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;w2[q]=1;www=1;} 
 
 
     switch(menu){
      case 0: vol = temp0;vol_func();break;
      case 1: bass = temp0;bass_func();break;
      case 2: mid = temp0;mid_func();break;
      case 3: treb = temp0;treb_func();break;
      }
 
   au();
   for(int i=0;i<4;i++){if(menu==i){lcd.setCursor(0,i);lcd.write((uint8_t)3);}else{lcd.setCursor(0,i);lcd.print(" ");}}
   lcd.setCursor(1,0);lcd.print("VOL(");lcd.print(in+1);lcd.print(") ");if(vol>=0){lcd.print(" ");}lcd.print(vol);lcd.print(" ");vol_d=map(vol,-63,0,1,24);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print(" ");bass_d=map(bass,-15,15,1,24);
   lcd.setCursor(1,2);lcd.print("MIDDLE ");if(mid>=0){lcd.print(" ");}lcd.print(mid);lcd.print(" ");mid_d=map(mid,-15,15,1,24);
   lcd.setCursor(1,3);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print(" ");treb_d=map(treb,-15,15,1,24);
 
 
   for(int n=0;n<4;n++){if(w2[n]==1){
   switch(n){
    case 0: par = vol_d;break;
    case 1: par = bass_d;break;
    case 2: par = mid_d;break;
    case 3: par = treb_d;break; 
    } 
 
   for(z=0,z0=0,z1=0;z<=par;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,n);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,n);Serial.println(z0);z_old=7-par/3;while(z_old>0){z_old=z_old-1;lcd.write((uint8_t)4);}}}
   if(z1==3){lcd.setCursor(z0+12,n);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,n);lcd.write((uint8_t)2);}w2[n]=0;}
   }}// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////////////////////
 
 if(menu0==1){
     switch(menu1){
      case 0: temp0 = att_lr;break;
      case 1: temp0 = att_rr;break;
      case 2: temp0 = att_lf;break;
      case 3: temp0 = att_rf;break;
      case 4: temp0 = att_r;break;
      case 5: temp0 = att_l;break;
      case 6: temp0 = loun;break;
      case 7: temp0 = loun_f;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu1){
      case 0: att_lr = temp0;att_lr_func();break;
      case 1: att_rr = temp0;att_rr_func();break;
      case 2: att_lf = temp0;att_lf_func();break;
      case 3: att_rf = temp0;att_rf_func();break;      
      case 4: att_r  = temp0;att_r_func();break;
      case 5: att_l  = temp0;att_l_func();break;
      case 6: loun  = temp0;loun_func();break;
      case 7: loun_f  = temp0;loun_f_func();break;
      }
 
  au();
  for(int i=0;i<8;i++){if(menu1==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.write((uint8_t)3);}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
 
  lcd.setCursor(1,0);lcd.print("AT_LR ");lcd.print(att_lr);lcd.print(" ");lcd.setCursor(11,0);lcd.print("AT_RR ");lcd.print(att_rr);lcd.print(" ");
  lcd.setCursor(1,1);lcd.print("AT_LF ");lcd.print(att_lf);lcd.print(" ");lcd.setCursor(11,1);lcd.print("AT_RF ");lcd.print(att_rf);lcd.print(" ");
  lcd.setCursor(1,2);lcd.print("AT_SR ");lcd.print(att_r);lcd.print(" ");lcd.setCursor(11,2);lcd.print("AT_SL ");lcd.print(att_l);lcd.print(" ");
  lcd.setCursor(1,3);lcd.print("LOUND ");lcd.print(abs(loun));lcd.print(" ");lcd.setCursor(11,3);
  switch(loun_f){
    case 0: lcd.print("FLAT   ");break;
    case 1: lcd.print("400  Hz");break;
    case 2: lcd.print("800  Hz");break;
    case 3: lcd.print("2.4 kHz");break;}
 
 } // menu0 = 1
 
 
///////////////////////////////////////////////////////////////////////////////////////////////
 
 if(menu0==2){
     switch(menu2){
      case 0: temp0 = bass_f;break;
      case 1: temp0 = mid_f;break;
      case 2: temp0 = treb_f;break;
      case 3: temp0 = sub_f;break;
      case 4: temp0 = bass_q;break;
      case 5: temp0 = mid_q;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu2){
      case 0: bass_f = temp0;bass_f_func();break;
      case 1: mid_f = temp0;mid_f_func();break;
      case 2: treb_f = temp0;treb_f_func();break;
      case 3: sub_f = temp0;sub_f_func();break;      
      case 4: bass_q  = temp0;bass_q_func();break;
      case 5: mid_q  = temp0;mid_q_func();break;
      }
 
  au();
  for(int i=0;i<6;i++){if(menu2==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.write((uint8_t)3);}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
 
  lcd.setCursor(1,0);lcd.print("BF ");
    switch(bass_f){
    case 0: lcd.print(" 60 Hz");break;
    case 1: lcd.print(" 80 Hz");break;
    case 2: lcd.print("100 Hz");break;
    case 3: lcd.print("200 Hz");break;}
  lcd.setCursor(11,0);lcd.print("MF ");
    switch(mid_f){
      case 0: lcd.print("0.5kHz");break;
      case 1: lcd.print("1.0kHz");break;
      case 2: lcd.print("1.5kHz");break;
      case 3: lcd.print("2.5kHz");break;}
 
  lcd.setCursor(1,1);lcd.print("TF");
    switch(treb_f){
      case 0: lcd.print("10.0kHz");break;
      case 1: lcd.print("12.5kHz");break;
      case 2: lcd.print("15.0kHz");break;
      case 3: lcd.print("17.5kHz");break;}
 
  lcd.setCursor(11,1);lcd.print("SF ");
    switch(sub_f){
      case 0: lcd.print("FLAT  ");break;
      case 1: lcd.print("400 Hz");break;
      case 2: lcd.print("800 Hz");break;
      case 3: lcd.print("2.4kHz");break;}
 
  lcd.setCursor(1,2);lcd.print("BQ ");
    switch(bass_q){
      case 0: lcd.print("1.0 ");break;
      case 1: lcd.print("1.25");break;
      case 2: lcd.print("1.5 ");break;
      case 3: lcd.print("2.0 ");break;}
 
  lcd.setCursor(11,2);lcd.print("MQ ");
    switch(mid_q){
      case 0: lcd.print("0.5 ");break;
      case 1: lcd.print("0.75");break;
      case 2: lcd.print("1.0 ");break;
      case 3: lcd.print("1.25");break;}
 
 } // menu0 = 2 
 
 
////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
   switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
 
     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка <<<<<<  
 
    if (newPosition != oldPosition) {oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time0=millis();www=1;w=1;gain_func();} 
 
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     }
 
  au();
  lcd.setCursor(7,1);lcd.print("INPUT ");lcd.print(in+1);lcd.setCursor(5,2);lcd.print("GAIN ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(14,2);lcd.print("dB ");
   }
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){in_time=3000;}else{in_time=10000;}
if(millis()-time0>in_time&&w==1&&mute==1&&power==0){if(menu0==1){cl();}w=0;if(menu0!=0){cl();}menu0=0;menu=0;in_x=0;w2_arr();
   EEPROM.update(0,vol+63);EEPROM.update(1,bass+15);EEPROM.update(2,mid+15);EEPROM.update(3,treb+15);
   EEPROM.update(4,att_lr);EEPROM.update(5,att_rr);EEPROM.update(6,att_lf);EEPROM.update(7,att_rf);EEPROM.update(8,att_r);EEPROM.update(9,att_l);
   EEPROM.update(10,loun);EEPROM.update(11,loun_f);
   EEPROM.update(12,bass_f);EEPROM.update(13,mid_f);EEPROM.update(14,treb_f);EEPROM.update(15,sub_f);
   EEPROM.update(16,bass_q);EEPROM.update(17,mid_q);
   EEPROM.update(18,gain1+15);EEPROM.update(19,gain2+15);EEPROM.update(20,gain3+15);
   }


}
 
 
void gain_func(){if(gain0<-15){gain0=-15;}if(gain0>15){gain0=15;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void loun_f_func(){if(loun_f>3){loun_f=3;}if(loun_f<0){loun_f=0;}}
void loun_func(){if(loun<0){loun=0;}if(loun>15){loun=15;}}
void att_lr_func(){if(att_lr>16){att_lr=16;}if(att_lr<0){att_lr=0;}}
void att_rr_func(){if(att_rr>16){att_rr=16;}if(att_rr<0){att_rr=0;}}
void att_lf_func(){if(att_lf>16){att_lf=16;}if(att_lf<0){att_lf=0;}}
void att_rf_func(){if(att_rf>16){att_rf=16;}if(att_rf<0){att_rf=0;}}
void att_r_func(){if(att_r>16){att_r=16;}if(att_r<0){att_r=0;}}
void att_l_func(){if(att_r>16){att_r=16;}if(att_r<0){att_r=0;}}
void vol_func(){if(vol<-63){vol=-63;}if(vol>0){vol=0;}}
void treb_func(){if(treb<-15){treb=-15;}if(treb>15){treb=15;}}
void bass_func(){if(bass<-15){bass=-15;}if(bass>15){bass=15;}}
void mid_func(){if(mid<-15){mid=-15;}if(mid>15){mid=15;}}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(200);}  
void au(){if(www==1){audio();www=0;}}
void bass_f_func(){if(bass_f>3){bass_f=3;}if(bass_f<0){bass_f=0;}}
void mid_f_func(){if(mid_f>3){mid_f=3;}if(mid_f<0){mid_f=0;}}
void treb_f_func(){if(treb_f>3){treb_f=3;}if(treb_f<0){treb_f=0;}}
void sub_f_func(){if(sub_f>3){sub_f=3;}if(sub_f<0){sub_f=0;}}
void bass_q_func(){if(bass_q>3){bass_q=3;}if(bass_q<0){bass_q=0;}}
void mid_q_func(){if(mid_q>3){mid_q=3;}if(mid_q<0){mid_q=0;}}
 
void audio(){
tda.setInput(in,1,1,2); // 0...7, 0...1, 0...1, 0...7
tda.setInput_2(0,0,1,1,1,1); // 0...7, 0...1, 0...1, 0...1, 0...1, 0...1 
tda.setMix_source(7,0); // 0...7, 0...-31
tda.setMix_cont(1,1,1,1,1,1,1,1); // all 0...1
tda.setMute(mute,0,0,1,0,1,1); // 0...1, 0...1, 0...3, 0...1, 0...1, 0...1, 0...1 mute off = 1
tda.setSoft_1(1,1,1,1,1,1,1,1); //all 0...1
tda.setSoft_2(1,1,1,1,0,3); // 0...1, 0...1, 0...1, 0...1, 0...2, 0...3
tda.setLoudness(-loun,loun_f,1,1); // 0...-15, 0...3, 0...1, 0...1 
tda.setVol(gain0,1,1); // -15...+15, 0...1, 0...1
tda.setTreble(treb,treb_f,1); // -15...+15, 0...3, 0...1
tda.setMiddle(mid,mid_q,1); // -15...+15, 0...3, 0...1
tda.setBass(bass,bass_q,1); // -15...+15, 0...3, 0...1
tda.setSMB(sub_f,faza,mid_f,bass_f,1); // 0...3, 0...1, 0...3, 0...3, 0...1
tda.setVol_LF(vol-att_lf,1); // 0...-79, 0...1 lov=63+16 att
tda.setVol_RF(vol-att_rf,1); // 0...-79, 0...1
tda.setVol_LR(vol-att_lr,1); // 0...-79, 0...1
tda.setVol_RR(vol-att_rr,1); // 0...-79, 0...1
tda.setVol_SUB_L(vol-att_l,1); // 0...-79, 0...1
tda.setVol_SUB_R(vol-att_r,1); // 0...-79, 0...1
tda.setTest1(0,14,1,1); // 0...1, 0...15, 0...1, 0...1
tda.setTest2(0,1,1,3); // 0...1, 0...1, 0...1, 0...3
}

129

Re: TDA7313 + DS3231 + IR + LCD2004

Новый скетч должен исправить эту проблему.

130

Re: TDA7313 + DS3231 + IR + LCD2004

брат ты супер классно толку надо исправить ИК

131

Re: TDA7313 + DS3231 + IR + LCD2004

Опишите подробней что с ИК, у меня нет проблем, ИК пульт регулирует нормально.

132

Re: TDA7313 + DS3231 + IR + LCD2004

да иногда тормозить

133

Re: TDA7313 + DS3231 + IR + LCD2004

Это вероятней всего зависит не от скетча, причин много, разряд батареек пульта, помехи, угол наклона пульта относительно ик датчика. Даже слишком сильный сигнал пульта может быть причиной.

Если есть положение пульта при котором все работает отлично, то это точно не скетч.

134

Re: TDA7313 + DS3231 + IR + LCD2004

ок понятно завтра проверяю дуругой пулта я тебя очень силно замучаль сегодня добрый ночьи БОЛЬШОЙ СПАСИБО брат

135 (2022-10-11 15:25:33 отредактировано shuhrat.ps)

Re: TDA7313 + DS3231 + IR + LCD2004

привет брат я проверял 5 пултов и  датчик ИК.... эфект тотже самый но сам пульт и датчик исправный на другой скетче работаеть отлично который ты написаль

136

Re: TDA7313 + DS3231 + IR + LCD2004

Опишите подробнее проблему.

137

Re: TDA7313 + DS3231 + IR + LCD2004

тормозить,глючит иногда совсем не работаеть

138

Re: TDA7313 + DS3231 + IR + LCD2004

У меня собрана схема, все работает, ИК пульт в моей сборке работает отлично. Вы установили библиотеку IRremote с этого источника - http://rcl-radio.ru/wp-content/uploads/ … remote.zip  ?

139

Re: TDA7313 + DS3231 + IR + LCD2004

сейчач попробую

140 (2022-10-11 17:53:38 отредактировано shuhrat.ps)

Re: TDA7313 + DS3231 + IR + LCD2004

брат тот же самый жутко тормозить первова раза не работаеть

141

Re: TDA7313 + DS3231 + IR + LCD2004

Я увеличило скорость работы пульта, но скорее всего это не поможет.

#define IR_1 0x33B8A05F // Кнопка вверх
#define IR_2 0x33B8609F // Кнопка вниз
#define IR_3 0x33B810EF // Кнопка >
#define IR_4 0x33B8E01F // Кнопка <
#define IR_5 0x33B850AF // Кнопка IN
#define IR_6 0x33B844BB // Кнопка SET
#define IR_7 0x33B8946B // Кнопка MUTE
#define IR_8 0x33B800FF // Кнопка STANDBY (POWER)
 
#define BRIG_H 200      // Яркость 0...255 POWER ON
#define BRIG_L 50       // Яркость 0...255 POWER OFF
 
#include <TDA7719.h>            // http://rcl-radio.ru/wp-content/uploads/2019/07/TDA7719.zip
#include <Wire.h>
#include <LiquidCrystal_I2C.h>  // http://forum.rcl-radio.ru/misc.php?action=pan_download&item=45&download=1
#include <Encoder.h>            // http://rcl-radio.ru/wp-content/uploads/2019/05/Encoder.zip    
#include <EEPROM.h>
#include <MsTimer2.h>           // http://rcl-radio.ru/wp-content/uploads/2018/11/MsTimer2.zip       
#include <boarddefs.h>          // входит в состав библиотеки IRremote
#include <IRremote.h>           // http://rcl-radio.ru/wp-content/uploads/2019/06/IRremote.zip
#include <DS3231.h>             // http://rcl-radio.ru/wp-content/uploads/2022/10/DS3231.zip
 TDA7719 tda;
 DS3231 clock;RTCDateTime DateTime;
 LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
 IRrecv irrecv(12); // указываем вывод модуля IR приемника
 Encoder myEnc(9, 8);// DT, CLK
 decode_results ir; 
 int in,loun,loun_f,vol_att,treb,treb_f,mid,mid_q,bass,bass_q,sub_f,faza=0,mid_f,bass_f;
 int vol,att_lf,att_rf,att_lr,att_rr,att_l,att_r;
 long time0,oldPosition  = -999,newPosition;
 int menu0,menu,temp0,vol_d,bass_d,treb_d,par,z_old,z1,z0,z,menu1,in_time;
 byte q,gr1,gr2,w,w2[4],www,power,in_x,mute=1;
 int hour,minut,secon,mid_d,menu2,gain0,gain1,gain2,gain3;
 byte mesto2[8]={0,10,0,10,0,10,0,10};
 byte mesto3[8]={0,0,1,1,2,2,3,3};
 
void setup() {
  irrecv.enableIRIn();lcd.init();lcd.backlight();clock.begin();Serial.begin(9600);
  pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT_PULLUP);   // КНОПКА SET
  pinMode(3,INPUT_PULLUP);   // КНОПКА IN
  pinMode(4,INPUT_PULLUP);   // КНОПКА MUTE
  pinMode(5,INPUT_PULLUP);   // КНОПКА STANDBY
  pinMode(7,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ STANDBY
  pinMode(6,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ ПОДСВЕТКОЙ
  analogWrite(6, BRIG_H);// больше 200 не делать
  lcd.setCursor(3,1);lcd.print("Sound Processor");lcd.setCursor(7,2);lcd.print("TDA7719"); delay(2000);lcd.clear();
  MsTimer2::set(4, to_Timer);MsTimer2::start();
  //  clock.setDateTime(__DATE__, __TIME__); // Устанавливаем время на часах, основываясь на времени компиляции скетча
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении  
  vol = EEPROM.read(0)-63;bass = EEPROM.read(1)-15;mid = EEPROM.read(2)-15;treb = EEPROM.read(3)-15;
  att_lr = EEPROM.read(4);att_rr = EEPROM.read(5);att_lf = EEPROM.read(6);att_rf = EEPROM.read(7);att_r = EEPROM.read(8);att_l = EEPROM.read(9);
  loun = EEPROM.read(10);loun_f = EEPROM.read(11);
  bass_f = EEPROM.read(12);mid_f = EEPROM.read(13);treb_f = EEPROM.read(14);sub_f = EEPROM.read(15);
  bass_q = EEPROM.read(16);mid_q = EEPROM.read(17);
  gain1 = EEPROM.read(18)-15;gain2 = EEPROM.read(19)-15;gain3 = EEPROM.read(20)-15;
  switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
  w2_arr();audio();cl();
}
 
void to_Timer(){newPosition = myEnc.read()/4;}
 
void loop() {
  DateTime = clock.getDateTime();hour = DateTime.hour;minut = DateTime.minute;secon = DateTime.second;
  /////////////////////////////// УПРАВЛЕНИЕ //////////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();time0=millis();w=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта  
 
  if(power==0){
    if(mute==1){
  if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time0=millis();in_x=0;w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu1++;delay(200);time0=millis();in_x=0;w=1;if(menu1>7){menu1=0;}}// меню 1
  if(digitalRead(10)==LOW&&menu0==2){menu2++;delay(200);time0=millis();in_x=0;w=1;if(menu2>5){menu2=0;}}// меню 2
 
  if(ir.value==IR_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu>3){menu=0;}}//меню 0
  if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu<0){menu=3;}}//меню 0
 
  if(ir.value==IR_2&&menu0==1){menu1++;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu1>7){menu1=0;}}//меню 1
  if(ir.value==IR_1&&menu0==1){menu1--;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu1<0){menu1=7;}}//меню 1
 
  if(ir.value==IR_2&&menu0==2){menu2++;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu2>5){menu2=0;}}//меню 2
  if(ir.value==IR_1&&menu0==2){menu2--;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu2<0){menu2=5;}}//меню 2
 
  if(ir.value==IR_6||digitalRead(2)==LOW){menu0++;if(menu0>2){menu0=0;}cl();in_x=0;w2_arr();time0=millis();w=1;lcd.setCursor(5,1);
     lcd.print("SETTING_");lcd.print(menu0);delay(500);lcd.clear();} 
 
  if(ir.value==IR_5||digitalRead(3)==LOW){in++;cl();time0=millis();in_x=1;w=1;www=1;menu0=100;menu=100;if(in>2){in=0;}}// IN   
    } // mute off
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==1&&power==0){mute=0;in_x=0;mute=0;menu0=100;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");audio();delay(300);}// mute on
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==0&&power==0){mute=1;cl();time0=millis();w=1;w2_arr();menu0=0;menu=0;myEnc.write(0);audio();}// mute off
  }// power on
 
  if((ir.value==IR_8||digitalRead(5)==LOW)&&power==0){power=1;in_x=0;mute=0;cl();audio();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);analogWrite(6,BRIG_L);}// power off
  if((ir.value==IR_8||digitalRead(5)==LOW)&&power==1){power=0;analogWrite(6, BRIG_H);cl();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);mute=1;audio();delay(3000);cl();}// power on
 
 
if(power==0){digitalWrite(7,HIGH);
   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}; 
   byte a4[8] = {0b10000,0b11000,0b11100,0b11110,0b11100,0b11000,0b10000,0b00000}; //>
   byte a5[8] = {0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000};
   lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);lcd.createChar(3,a4);lcd.createChar(4,a5);
  }
  if(power==1){digitalWrite(7,LOW);
      byte v1[8] = {7,7,7,7,7,7,7,7};
      byte v2[8] = {7,7,0, 0, 0, 0, 0, 0};      
      byte v3[8] = { 0, 0, 0, 0, 0,0,31,31};
      byte v4[8] = {31,31, 0, 0, 0, 0,31,31};
      byte v5[8] = { 28, 28, 0, 0, 0, 0, 28, 28};
      byte v6[8] = {28,28,28,28,28,28,28,28};
      byte v7[8] = { 0, 0, 0, 0, 0, 0,7,7};
      byte v8[8] = { 31, 31,0,0,0,0,0, 0};
   byte a[6];
   byte i0,d1,d2,d3,d4,d5,d6,e1,e2,e3;
  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);
 
     a[0]=DateTime.hour/10;
     a[1]=DateTime.hour%10;
     a[2]=DateTime.minute/10;
     a[3]=DateTime.minute%10;
     a[4]=DateTime.second/10;
     a[5]=DateTime.second%10;
 
 for(int i=0;i<6;i++){
      switch(i){
        case 0: e1=0,e2=1,e3=2;break;
        case 1: e1=3,e2=4,e3=5;break;
        case 2: e1=7,e2=8,e3=9;break;
        case 3: e1=10,e2=11,e3=12;break;
        case 4: e1=14,e2=15,e3=16;break;
        case 5: e1=17,e2=18,e3=19;break;
        }
      switch(a[i]){
        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);
  }
  lcd.setCursor(6,0);lcd.print(".");lcd.setCursor(13,0);lcd.print(".");lcd.setCursor(6,1);lcd.print(".");lcd.setCursor(13,1);lcd.print(".");
  lcd.setCursor(5,3);lcd.print("POWER  OFF");
  if(digitalRead(10)==LOW&&digitalRead(2)==LOW){hour++;if(hour>23){hour=0;} clock.setDateTime(2022, 9, 15, hour, minut, secon);delay(100);}    // SET
  if(digitalRead(10)==LOW&&digitalRead(3)==LOW){minut++;if(minut>59){minut=0;} clock.setDateTime(2022, 9, 15, hour, minut, secon);delay(100); }// IN
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW){secon=0; clock.setDateTime(2022, 9, 15, hour, minut, secon);delay(100); }                      // MUTE
  } 
/////////////////////////////// MENU0 = VOLUME TERBLE BASS MIDDLE ///////////////////////////////////////////////////////////////////////
  if(menu0==0){ 
    switch(menu){
      case 0: temp0 = vol;q=0;break;
      case 1: temp0 = bass;q=1;break;
      case 2: temp0 = mid;q=2;break;
      case 3: temp0 = treb;q=3;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка <<<<<<   
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;w2[q]=1;www=1;} 
 
 
     switch(menu){
      case 0: vol = temp0;vol_func();break;
      case 1: bass = temp0;bass_func();break;
      case 2: mid = temp0;mid_func();break;
      case 3: treb = temp0;treb_func();break;
      }
 
   au();
   for(int i=0;i<4;i++){if(menu==i){lcd.setCursor(0,i);lcd.write((uint8_t)3);}else{lcd.setCursor(0,i);lcd.print(" ");}}
   lcd.setCursor(1,0);lcd.print("VOL(");lcd.print(in+1);lcd.print(") ");if(vol>=0){lcd.print(" ");}lcd.print(vol);lcd.print(" ");vol_d=map(vol,-63,0,1,24);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print(" ");bass_d=map(bass,-15,15,1,24);
   lcd.setCursor(1,2);lcd.print("MIDDLE ");if(mid>=0){lcd.print(" ");}lcd.print(mid);lcd.print(" ");mid_d=map(mid,-15,15,1,24);
   lcd.setCursor(1,3);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print(" ");treb_d=map(treb,-15,15,1,24);
 
 
   for(int n=0;n<4;n++){if(w2[n]==1){
   switch(n){
    case 0: par = vol_d;break;
    case 1: par = bass_d;break;
    case 2: par = mid_d;break;
    case 3: par = treb_d;break; 
    } 
 
   for(z=0,z0=0,z1=0;z<=par;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,n);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,n);Serial.println(z0);z_old=7-par/3;while(z_old>0){z_old=z_old-1;lcd.write((uint8_t)4);}}}
   if(z1==3){lcd.setCursor(z0+12,n);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,n);lcd.write((uint8_t)2);}w2[n]=0;}
   }}// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////////////////////
 
 if(menu0==1){
     switch(menu1){
      case 0: temp0 = att_lr;break;
      case 1: temp0 = att_rr;break;
      case 2: temp0 = att_lf;break;
      case 3: temp0 = att_rf;break;
      case 4: temp0 = att_r;break;
      case 5: temp0 = att_l;break;
      case 6: temp0 = loun;break;
      case 7: temp0 = loun_f;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu1){
      case 0: att_lr = temp0;att_lr_func();break;
      case 1: att_rr = temp0;att_rr_func();break;
      case 2: att_lf = temp0;att_lf_func();break;
      case 3: att_rf = temp0;att_rf_func();break;      
      case 4: att_r  = temp0;att_r_func();break;
      case 5: att_l  = temp0;att_l_func();break;
      case 6: loun  = temp0;loun_func();break;
      case 7: loun_f  = temp0;loun_f_func();break;
      }
 
  au();
  for(int i=0;i<8;i++){if(menu1==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.write((uint8_t)3);}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
 
  lcd.setCursor(1,0);lcd.print("AT_LR ");lcd.print(att_lr);lcd.print(" ");lcd.setCursor(11,0);lcd.print("AT_RR ");lcd.print(att_rr);lcd.print(" ");
  lcd.setCursor(1,1);lcd.print("AT_LF ");lcd.print(att_lf);lcd.print(" ");lcd.setCursor(11,1);lcd.print("AT_RF ");lcd.print(att_rf);lcd.print(" ");
  lcd.setCursor(1,2);lcd.print("AT_SR ");lcd.print(att_r);lcd.print(" ");lcd.setCursor(11,2);lcd.print("AT_SL ");lcd.print(att_l);lcd.print(" ");
  lcd.setCursor(1,3);lcd.print("LOUND ");lcd.print(abs(loun));lcd.print(" ");lcd.setCursor(11,3);
  switch(loun_f){
    case 0: lcd.print("FLAT   ");break;
    case 1: lcd.print("400  Hz");break;
    case 2: lcd.print("800  Hz");break;
    case 3: lcd.print("2.4 kHz");break;}
 
 } // menu0 = 1
 
 
///////////////////////////////////////////////////////////////////////////////////////////////
 
 if(menu0==2){
     switch(menu2){
      case 0: temp0 = bass_f;break;
      case 1: temp0 = mid_f;break;
      case 2: temp0 = treb_f;break;
      case 3: temp0 = sub_f;break;
      case 4: temp0 = bass_q;break;
      case 5: temp0 = mid_q;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu2){
      case 0: bass_f = temp0;bass_f_func();break;
      case 1: mid_f = temp0;mid_f_func();break;
      case 2: treb_f = temp0;treb_f_func();break;
      case 3: sub_f = temp0;sub_f_func();break;      
      case 4: bass_q  = temp0;bass_q_func();break;
      case 5: mid_q  = temp0;mid_q_func();break;
      }
 
  au();
  for(int i=0;i<6;i++){if(menu2==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.write((uint8_t)3);}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
 
  lcd.setCursor(1,0);lcd.print("BF ");
    switch(bass_f){
    case 0: lcd.print(" 60 Hz");break;
    case 1: lcd.print(" 80 Hz");break;
    case 2: lcd.print("100 Hz");break;
    case 3: lcd.print("200 Hz");break;}
  lcd.setCursor(11,0);lcd.print("MF ");
    switch(mid_f){
      case 0: lcd.print("0.5kHz");break;
      case 1: lcd.print("1.0kHz");break;
      case 2: lcd.print("1.5kHz");break;
      case 3: lcd.print("2.5kHz");break;}
 
  lcd.setCursor(1,1);lcd.print("TF");
    switch(treb_f){
      case 0: lcd.print("10.0kHz");break;
      case 1: lcd.print("12.5kHz");break;
      case 2: lcd.print("15.0kHz");break;
      case 3: lcd.print("17.5kHz");break;}
 
  lcd.setCursor(11,1);lcd.print("SF ");
    switch(sub_f){
      case 0: lcd.print("FLAT  ");break;
      case 1: lcd.print("400 Hz");break;
      case 2: lcd.print("800 Hz");break;
      case 3: lcd.print("2.4kHz");break;}
 
  lcd.setCursor(1,2);lcd.print("BQ ");
    switch(bass_q){
      case 0: lcd.print("1.0 ");break;
      case 1: lcd.print("1.25");break;
      case 2: lcd.print("1.5 ");break;
      case 3: lcd.print("2.0 ");break;}
 
  lcd.setCursor(11,2);lcd.print("MQ ");
    switch(mid_q){
      case 0: lcd.print("0.5 ");break;
      case 1: lcd.print("0.75");break;
      case 2: lcd.print("1.0 ");break;
      case 3: lcd.print("1.25");break;}
 
 } // menu0 = 2 
 
 
////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
   switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
 
     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка <<<<<<  
 
    if (newPosition != oldPosition) {oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time0=millis();www=1;w=1;gain_func();} 
 
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     }
 
  au();
  lcd.setCursor(7,1);lcd.print("INPUT ");lcd.print(in+1);lcd.setCursor(5,2);lcd.print("GAIN ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(14,2);lcd.print("dB ");
   }
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){in_time=3000;}else{in_time=10000;}
if(millis()-time0>in_time&&w==1&&mute==1&&power==0){if(menu0==1){cl();}w=0;if(menu0!=0){cl();}menu0=0;menu=0;in_x=0;w2_arr();
   EEPROM.update(0,vol+63);EEPROM.update(1,bass+15);EEPROM.update(2,mid+15);EEPROM.update(3,treb+15);
   EEPROM.update(4,att_lr);EEPROM.update(5,att_rr);EEPROM.update(6,att_lf);EEPROM.update(7,att_rf);EEPROM.update(8,att_r);EEPROM.update(9,att_l);
   EEPROM.update(10,loun);EEPROM.update(11,loun_f);
   EEPROM.update(12,bass_f);EEPROM.update(13,mid_f);EEPROM.update(14,treb_f);EEPROM.update(15,sub_f);
   EEPROM.update(16,bass_q);EEPROM.update(17,mid_q);
   EEPROM.update(18,gain1+15);EEPROM.update(19,gain2+15);EEPROM.update(20,gain3+15);
   }

   Serial.println(-loun);
}
 
 
void gain_func(){if(gain0<-15){gain0=-15;}if(gain0>15){gain0=15;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void loun_f_func(){if(loun_f>3){loun_f=3;}if(loun_f<0){loun_f=0;}}
void loun_func(){if(loun<0){loun=0;}if(loun>15){loun=15;}}
void att_lr_func(){if(att_lr>16){att_lr=16;}if(att_lr<0){att_lr=0;}}
void att_rr_func(){if(att_rr>16){att_rr=16;}if(att_rr<0){att_rr=0;}}
void att_lf_func(){if(att_lf>16){att_lf=16;}if(att_lf<0){att_lf=0;}}
void att_rf_func(){if(att_rf>16){att_rf=16;}if(att_rf<0){att_rf=0;}}
void att_r_func(){if(att_r>16){att_r=16;}if(att_r<0){att_r=0;}}
void att_l_func(){if(att_r>16){att_r=16;}if(att_r<0){att_r=0;}}
void vol_func(){if(vol<-63){vol=-63;}if(vol>0){vol=0;}}
void treb_func(){if(treb<-15){treb=-15;}if(treb>15){treb=15;}}
void bass_func(){if(bass<-15){bass=-15;}if(bass>15){bass=15;}}
void mid_func(){if(mid<-15){mid=-15;}if(mid>15){mid=15;}}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(50);}  
void au(){if(www==1){audio();www=0;}}
void bass_f_func(){if(bass_f>3){bass_f=3;}if(bass_f<0){bass_f=0;}}
void mid_f_func(){if(mid_f>3){mid_f=3;}if(mid_f<0){mid_f=0;}}
void treb_f_func(){if(treb_f>3){treb_f=3;}if(treb_f<0){treb_f=0;}}
void sub_f_func(){if(sub_f>3){sub_f=3;}if(sub_f<0){sub_f=0;}}
void bass_q_func(){if(bass_q>3){bass_q=3;}if(bass_q<0){bass_q=0;}}
void mid_q_func(){if(mid_q>3){mid_q=3;}if(mid_q<0){mid_q=0;}}
 
void audio(){
tda.setInput(in,1,1,2); // 0...7, 0...1, 0...1, 0...7
tda.setInput_2(0,0,1,1,1,1); // 0...7, 0...1, 0...1, 0...1, 0...1, 0...1 
tda.setMix_source(7,0); // 0...7, 0...-31
tda.setMix_cont(1,1,1,1,1,1,1,1); // all 0...1
tda.setMute(mute,0,0,1,0,1,1); // 0...1, 0...1, 0...3, 0...1, 0...1, 0...1, 0...1 mute off = 1
tda.setSoft_1(1,1,1,1,1,1,1,1); //all 0...1
tda.setSoft_2(1,1,1,1,0,3); // 0...1, 0...1, 0...1, 0...1, 0...2, 0...3
tda.setLoudness(-loun,loun_f,1,1); // 0...-15, 0...3, 0...1, 0...1 
tda.setVol(gain0,1,1); // -15...+15, 0...1, 0...1
tda.setTreble(treb,treb_f,1); // -15...+15, 0...3, 0...1
tda.setMiddle(mid,mid_q,1); // -15...+15, 0...3, 0...1
tda.setBass(bass,bass_q,1); // -15...+15, 0...3, 0...1
tda.setSMB(sub_f,faza,mid_f,bass_f,1); // 0...3, 0...1, 0...3, 0...3, 0...1
tda.setVol_LF(vol-att_lf,1); // 0...-79, 0...1 lov=63+16 att
tda.setVol_RF(vol-att_rf,1); // 0...-79, 0...1
tda.setVol_LR(vol-att_lr,1); // 0...-79, 0...1
tda.setVol_RR(vol-att_rr,1); // 0...-79, 0...1
tda.setVol_SUB_L(vol-att_l,1); // 0...-79, 0...1
tda.setVol_SUB_R(vol-att_r,1); // 0...-79, 0...1
tda.setTest1(0,14,1,1); // 0...1, 0...15, 0...1, 0...1
tda.setTest2(0,1,1,3); // 0...1, 0...1, 0...1, 0...3
}

142

Re: TDA7313 + DS3231 + IR + LCD2004

да не помог почему тогда на скетче tda7313 работаеть отлично

143

Re: TDA7313 + DS3231 + IR + LCD2004

Поменяйте вход ИК датчика на D11

#define IR_1 0x33B8A05F // Кнопка вверх
#define IR_2 0x33B8609F // Кнопка вниз
#define IR_3 0x33B810EF // Кнопка >
#define IR_4 0x33B8E01F // Кнопка <
#define IR_5 0x33B850AF // Кнопка IN
#define IR_6 0x33B844BB // Кнопка SET
#define IR_7 0x33B8946B // Кнопка MUTE
#define IR_8 0x33B800FF // Кнопка STANDBY (POWER)
 
#define BRIG_H 200      // Яркость 0...255 POWER ON
#define BRIG_L 50       // Яркость 0...255 POWER OFF
 
#include <TDA7719.h>            // http://rcl-radio.ru/wp-content/uploads/2019/07/TDA7719.zip
#include <Wire.h>
#include <LiquidCrystal_I2C.h>  // http://forum.rcl-radio.ru/misc.php?action=pan_download&item=45&download=1
#include <Encoder.h>            // http://rcl-radio.ru/wp-content/uploads/2019/05/Encoder.zip    
#include <EEPROM.h>
#include <MsTimer2.h>           // http://rcl-radio.ru/wp-content/uploads/2018/11/MsTimer2.zip       
#include <boarddefs.h>          // входит в состав библиотеки IRremote
#include <IRremote.h>           // http://rcl-radio.ru/wp-content/uploads/2019/06/IRremote.zip
#include <DS3231.h>             // http://rcl-radio.ru/wp-content/uploads/2022/10/DS3231.zip
 TDA7719 tda;
 DS3231 clock;RTCDateTime DateTime;
 LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
 IRrecv irrecv(11); // указываем вывод модуля IR приемника
 Encoder myEnc(9, 8);// DT, CLK
 decode_results ir; 
 int in,loun,loun_f,vol_att,treb,treb_f,mid,mid_q,bass,bass_q,sub_f,faza=0,mid_f,bass_f;
 int vol,att_lf,att_rf,att_lr,att_rr,att_l,att_r;
 long time0,oldPosition  = -999,newPosition;
 int menu0,menu,temp0,vol_d,bass_d,treb_d,par,z_old,z1,z0,z,menu1,in_time;
 byte q,gr1,gr2,w,w2[4],www,power,in_x,mute=1;
 int hour,minut,secon,mid_d,menu2,gain0,gain1,gain2,gain3;
 byte mesto2[8]={0,10,0,10,0,10,0,10};
 byte mesto3[8]={0,0,1,1,2,2,3,3};
 
void setup() {
  irrecv.enableIRIn();lcd.init();lcd.backlight();clock.begin();Serial.begin(9600);
  pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT_PULLUP);   // КНОПКА SET
  pinMode(3,INPUT_PULLUP);   // КНОПКА IN
  pinMode(4,INPUT_PULLUP);   // КНОПКА MUTE
  pinMode(5,INPUT_PULLUP);   // КНОПКА STANDBY
  pinMode(7,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ STANDBY
  pinMode(6,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ ПОДСВЕТКОЙ
  analogWrite(6, BRIG_H);// больше 200 не делать
  lcd.setCursor(3,1);lcd.print("Sound Processor");lcd.setCursor(7,2);lcd.print("TDA7719"); delay(2000);lcd.clear();
  MsTimer2::set(4, to_Timer);MsTimer2::start();
  //  clock.setDateTime(__DATE__, __TIME__); // Устанавливаем время на часах, основываясь на времени компиляции скетча
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении  
  vol = EEPROM.read(0)-63;bass = EEPROM.read(1)-15;mid = EEPROM.read(2)-15;treb = EEPROM.read(3)-15;
  att_lr = EEPROM.read(4);att_rr = EEPROM.read(5);att_lf = EEPROM.read(6);att_rf = EEPROM.read(7);att_r = EEPROM.read(8);att_l = EEPROM.read(9);
  loun = EEPROM.read(10);loun_f = EEPROM.read(11);
  bass_f = EEPROM.read(12);mid_f = EEPROM.read(13);treb_f = EEPROM.read(14);sub_f = EEPROM.read(15);
  bass_q = EEPROM.read(16);mid_q = EEPROM.read(17);
  gain1 = EEPROM.read(18)-15;gain2 = EEPROM.read(19)-15;gain3 = EEPROM.read(20)-15;
  switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
  w2_arr();audio();cl();
}
 
void to_Timer(){newPosition = myEnc.read()/4;}
 
void loop() {
 if(power==1){ DateTime = clock.getDateTime();hour = DateTime.hour;minut = DateTime.minute;secon = DateTime.second;}
  /////////////////////////////// УПРАВЛЕНИЕ //////////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();time0=millis();w=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта  
 
  if(power==0){
    if(mute==1){
  if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time0=millis();in_x=0;w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu1++;delay(200);time0=millis();in_x=0;w=1;if(menu1>7){menu1=0;}}// меню 1
  if(digitalRead(10)==LOW&&menu0==2){menu2++;delay(200);time0=millis();in_x=0;w=1;if(menu2>5){menu2=0;}}// меню 2
 
  if(ir.value==IR_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu>3){menu=0;}}//меню 0
  if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu<0){menu=3;}}//меню 0
 
  if(ir.value==IR_2&&menu0==1){menu1++;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu1>7){menu1=0;}}//меню 1
  if(ir.value==IR_1&&menu0==1){menu1--;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu1<0){menu1=7;}}//меню 1
 
  if(ir.value==IR_2&&menu0==2){menu2++;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu2>5){menu2=0;}}//меню 2
  if(ir.value==IR_1&&menu0==2){menu2--;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu2<0){menu2=5;}}//меню 2
 
  if(ir.value==IR_6||digitalRead(2)==LOW){menu0++;if(menu0>2){menu0=0;}cl();in_x=0;w2_arr();time0=millis();w=1;lcd.setCursor(5,1);
     lcd.print("SETTING_");lcd.print(menu0);delay(500);lcd.clear();} 
 
  if(ir.value==IR_5||digitalRead(3)==LOW){in++;cl();time0=millis();in_x=1;w=1;www=1;menu0=100;menu=100;if(in>2){in=0;}}// IN   
    } // mute off
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==1&&power==0){mute=0;in_x=0;mute=0;menu0=100;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");audio();delay(300);}// mute on
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==0&&power==0){mute=1;cl();time0=millis();w=1;w2_arr();menu0=0;menu=0;myEnc.write(0);audio();}// mute off
  }// power on
 
  if((ir.value==IR_8||digitalRead(5)==LOW)&&power==0){power=1;in_x=0;mute=0;cl();audio();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);analogWrite(6,BRIG_L);}// power off
  if((ir.value==IR_8||digitalRead(5)==LOW)&&power==1){power=0;analogWrite(6, BRIG_H);cl();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);mute=1;audio();delay(3000);cl();}// power on
 
 
if(power==0){digitalWrite(7,HIGH);
   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}; 
   byte a4[8] = {0b10000,0b11000,0b11100,0b11110,0b11100,0b11000,0b10000,0b00000}; //>
   byte a5[8] = {0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000};
   lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);lcd.createChar(3,a4);lcd.createChar(4,a5);
  }
  if(power==1){digitalWrite(7,LOW);
      byte v1[8] = {7,7,7,7,7,7,7,7};
      byte v2[8] = {7,7,0, 0, 0, 0, 0, 0};      
      byte v3[8] = { 0, 0, 0, 0, 0,0,31,31};
      byte v4[8] = {31,31, 0, 0, 0, 0,31,31};
      byte v5[8] = { 28, 28, 0, 0, 0, 0, 28, 28};
      byte v6[8] = {28,28,28,28,28,28,28,28};
      byte v7[8] = { 0, 0, 0, 0, 0, 0,7,7};
      byte v8[8] = { 31, 31,0,0,0,0,0, 0};
   byte a[6];
   byte i0,d1,d2,d3,d4,d5,d6,e1,e2,e3;
  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);
 
     a[0]=DateTime.hour/10;
     a[1]=DateTime.hour%10;
     a[2]=DateTime.minute/10;
     a[3]=DateTime.minute%10;
     a[4]=DateTime.second/10;
     a[5]=DateTime.second%10;
 
 for(int i=0;i<6;i++){
      switch(i){
        case 0: e1=0,e2=1,e3=2;break;
        case 1: e1=3,e2=4,e3=5;break;
        case 2: e1=7,e2=8,e3=9;break;
        case 3: e1=10,e2=11,e3=12;break;
        case 4: e1=14,e2=15,e3=16;break;
        case 5: e1=17,e2=18,e3=19;break;
        }
      switch(a[i]){
        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);
  }
  lcd.setCursor(6,0);lcd.print(".");lcd.setCursor(13,0);lcd.print(".");lcd.setCursor(6,1);lcd.print(".");lcd.setCursor(13,1);lcd.print(".");
  lcd.setCursor(5,3);lcd.print("POWER  OFF");
  if(digitalRead(10)==LOW&&digitalRead(2)==LOW){hour++;if(hour>23){hour=0;} clock.setDateTime(2022, 9, 15, hour, minut, secon);delay(100);}    // SET
  if(digitalRead(10)==LOW&&digitalRead(3)==LOW){minut++;if(minut>59){minut=0;} clock.setDateTime(2022, 9, 15, hour, minut, secon);delay(100); }// IN
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW){secon=0; clock.setDateTime(2022, 9, 15, hour, minut, secon);delay(100); }                      // MUTE
  } 
/////////////////////////////// MENU0 = VOLUME TERBLE BASS MIDDLE ///////////////////////////////////////////////////////////////////////
  if(menu0==0){ 
    switch(menu){
      case 0: temp0 = vol;q=0;break;
      case 1: temp0 = bass;q=1;break;
      case 2: temp0 = mid;q=2;break;
      case 3: temp0 = treb;q=3;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка <<<<<<   
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;w2[q]=1;www=1;} 
 
 
     switch(menu){
      case 0: vol = temp0;vol_func();break;
      case 1: bass = temp0;bass_func();break;
      case 2: mid = temp0;mid_func();break;
      case 3: treb = temp0;treb_func();break;
      }
 
   au();
   for(int i=0;i<4;i++){if(menu==i){lcd.setCursor(0,i);lcd.write((uint8_t)3);}else{lcd.setCursor(0,i);lcd.print(" ");}}
   lcd.setCursor(1,0);lcd.print("VOL(");lcd.print(in+1);lcd.print(") ");if(vol>=0){lcd.print(" ");}lcd.print(vol);lcd.print(" ");vol_d=map(vol,-63,0,1,24);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print(" ");bass_d=map(bass,-15,15,1,24);
   lcd.setCursor(1,2);lcd.print("MIDDLE ");if(mid>=0){lcd.print(" ");}lcd.print(mid);lcd.print(" ");mid_d=map(mid,-15,15,1,24);
   lcd.setCursor(1,3);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print(" ");treb_d=map(treb,-15,15,1,24);
 
 
   for(int n=0;n<4;n++){if(w2[n]==1){
   switch(n){
    case 0: par = vol_d;break;
    case 1: par = bass_d;break;
    case 2: par = mid_d;break;
    case 3: par = treb_d;break; 
    } 
 
   for(z=0,z0=0,z1=0;z<=par;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,n);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,n);Serial.println(z0);z_old=7-par/3;while(z_old>0){z_old=z_old-1;lcd.write((uint8_t)4);}}}
   if(z1==3){lcd.setCursor(z0+12,n);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,n);lcd.write((uint8_t)2);}w2[n]=0;}
   }}// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////////////////////
 
 if(menu0==1){
     switch(menu1){
      case 0: temp0 = att_lr;break;
      case 1: temp0 = att_rr;break;
      case 2: temp0 = att_lf;break;
      case 3: temp0 = att_rf;break;
      case 4: temp0 = att_r;break;
      case 5: temp0 = att_l;break;
      case 6: temp0 = loun;break;
      case 7: temp0 = loun_f;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu1){
      case 0: att_lr = temp0;att_lr_func();break;
      case 1: att_rr = temp0;att_rr_func();break;
      case 2: att_lf = temp0;att_lf_func();break;
      case 3: att_rf = temp0;att_rf_func();break;      
      case 4: att_r  = temp0;att_r_func();break;
      case 5: att_l  = temp0;att_l_func();break;
      case 6: loun  = temp0;loun_func();break;
      case 7: loun_f  = temp0;loun_f_func();break;
      }
 
  au();
  for(int i=0;i<8;i++){if(menu1==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.write((uint8_t)3);}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
 
  lcd.setCursor(1,0);lcd.print("AT_LR ");lcd.print(att_lr);lcd.print(" ");lcd.setCursor(11,0);lcd.print("AT_RR ");lcd.print(att_rr);lcd.print(" ");
  lcd.setCursor(1,1);lcd.print("AT_LF ");lcd.print(att_lf);lcd.print(" ");lcd.setCursor(11,1);lcd.print("AT_RF ");lcd.print(att_rf);lcd.print(" ");
  lcd.setCursor(1,2);lcd.print("AT_SR ");lcd.print(att_r);lcd.print(" ");lcd.setCursor(11,2);lcd.print("AT_SL ");lcd.print(att_l);lcd.print(" ");
  lcd.setCursor(1,3);lcd.print("LOUND ");lcd.print(abs(loun));lcd.print(" ");lcd.setCursor(11,3);
  switch(loun_f){
    case 0: lcd.print("FLAT   ");break;
    case 1: lcd.print("400  Hz");break;
    case 2: lcd.print("800  Hz");break;
    case 3: lcd.print("2.4 kHz");break;}
 
 } // menu0 = 1
 
 
///////////////////////////////////////////////////////////////////////////////////////////////
 
 if(menu0==2){
     switch(menu2){
      case 0: temp0 = bass_f;break;
      case 1: temp0 = mid_f;break;
      case 2: temp0 = treb_f;break;
      case 3: temp0 = sub_f;break;
      case 4: temp0 = bass_q;break;
      case 5: temp0 = mid_q;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu2){
      case 0: bass_f = temp0;bass_f_func();break;
      case 1: mid_f = temp0;mid_f_func();break;
      case 2: treb_f = temp0;treb_f_func();break;
      case 3: sub_f = temp0;sub_f_func();break;      
      case 4: bass_q  = temp0;bass_q_func();break;
      case 5: mid_q  = temp0;mid_q_func();break;
      }
 
  au();
  for(int i=0;i<6;i++){if(menu2==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.write((uint8_t)3);}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
 
  lcd.setCursor(1,0);lcd.print("BF ");
    switch(bass_f){
    case 0: lcd.print(" 60 Hz");break;
    case 1: lcd.print(" 80 Hz");break;
    case 2: lcd.print("100 Hz");break;
    case 3: lcd.print("200 Hz");break;}
  lcd.setCursor(11,0);lcd.print("MF ");
    switch(mid_f){
      case 0: lcd.print("0.5kHz");break;
      case 1: lcd.print("1.0kHz");break;
      case 2: lcd.print("1.5kHz");break;
      case 3: lcd.print("2.5kHz");break;}
 
  lcd.setCursor(1,1);lcd.print("TF");
    switch(treb_f){
      case 0: lcd.print("10.0kHz");break;
      case 1: lcd.print("12.5kHz");break;
      case 2: lcd.print("15.0kHz");break;
      case 3: lcd.print("17.5kHz");break;}
 
  lcd.setCursor(11,1);lcd.print("SF ");
    switch(sub_f){
      case 0: lcd.print("FLAT  ");break;
      case 1: lcd.print("400 Hz");break;
      case 2: lcd.print("800 Hz");break;
      case 3: lcd.print("2.4kHz");break;}
 
  lcd.setCursor(1,2);lcd.print("BQ ");
    switch(bass_q){
      case 0: lcd.print("1.0 ");break;
      case 1: lcd.print("1.25");break;
      case 2: lcd.print("1.5 ");break;
      case 3: lcd.print("2.0 ");break;}
 
  lcd.setCursor(11,2);lcd.print("MQ ");
    switch(mid_q){
      case 0: lcd.print("0.5 ");break;
      case 1: lcd.print("0.75");break;
      case 2: lcd.print("1.0 ");break;
      case 3: lcd.print("1.25");break;}
 
 } // menu0 = 2 
 
 
////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
   switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
 
     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка <<<<<<  
 
    if (newPosition != oldPosition) {oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time0=millis();www=1;w=1;gain_func();} 
 
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     }
 
  au();
  lcd.setCursor(7,1);lcd.print("INPUT ");lcd.print(in+1);lcd.setCursor(5,2);lcd.print("GAIN ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(14,2);lcd.print("dB ");
   }
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){in_time=3000;}else{in_time=10000;}
if(millis()-time0>in_time&&w==1&&mute==1&&power==0){if(menu0==1){cl();}w=0;if(menu0!=0){cl();}menu0=0;menu=0;in_x=0;w2_arr();
   EEPROM.update(0,vol+63);EEPROM.update(1,bass+15);EEPROM.update(2,mid+15);EEPROM.update(3,treb+15);
   EEPROM.update(4,att_lr);EEPROM.update(5,att_rr);EEPROM.update(6,att_lf);EEPROM.update(7,att_rf);EEPROM.update(8,att_r);EEPROM.update(9,att_l);
   EEPROM.update(10,loun);EEPROM.update(11,loun_f);
   EEPROM.update(12,bass_f);EEPROM.update(13,mid_f);EEPROM.update(14,treb_f);EEPROM.update(15,sub_f);
   EEPROM.update(16,bass_q);EEPROM.update(17,mid_q);
   EEPROM.update(18,gain1+15);EEPROM.update(19,gain2+15);EEPROM.update(20,gain3+15);
   }

   Serial.println(-loun);
}
 
 
void gain_func(){if(gain0<-15){gain0=-15;}if(gain0>15){gain0=15;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void loun_f_func(){if(loun_f>3){loun_f=3;}if(loun_f<0){loun_f=0;}}
void loun_func(){if(loun<0){loun=0;}if(loun>15){loun=15;}}
void att_lr_func(){if(att_lr>16){att_lr=16;}if(att_lr<0){att_lr=0;}}
void att_rr_func(){if(att_rr>16){att_rr=16;}if(att_rr<0){att_rr=0;}}
void att_lf_func(){if(att_lf>16){att_lf=16;}if(att_lf<0){att_lf=0;}}
void att_rf_func(){if(att_rf>16){att_rf=16;}if(att_rf<0){att_rf=0;}}
void att_r_func(){if(att_r>16){att_r=16;}if(att_r<0){att_r=0;}}
void att_l_func(){if(att_r>16){att_r=16;}if(att_r<0){att_r=0;}}
void vol_func(){if(vol<-63){vol=-63;}if(vol>0){vol=0;}}
void treb_func(){if(treb<-15){treb=-15;}if(treb>15){treb=15;}}
void bass_func(){if(bass<-15){bass=-15;}if(bass>15){bass=15;}}
void mid_func(){if(mid<-15){mid=-15;}if(mid>15){mid=15;}}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(50);}  
void au(){if(www==1){audio();www=0;}}
void bass_f_func(){if(bass_f>3){bass_f=3;}if(bass_f<0){bass_f=0;}}
void mid_f_func(){if(mid_f>3){mid_f=3;}if(mid_f<0){mid_f=0;}}
void treb_f_func(){if(treb_f>3){treb_f=3;}if(treb_f<0){treb_f=0;}}
void sub_f_func(){if(sub_f>3){sub_f=3;}if(sub_f<0){sub_f=0;}}
void bass_q_func(){if(bass_q>3){bass_q=3;}if(bass_q<0){bass_q=0;}}
void mid_q_func(){if(mid_q>3){mid_q=3;}if(mid_q<0){mid_q=0;}}
 
void audio(){
tda.setInput(in,1,1,2); // 0...7, 0...1, 0...1, 0...7
tda.setInput_2(0,0,1,1,1,1); // 0...7, 0...1, 0...1, 0...1, 0...1, 0...1 
tda.setMix_source(7,0); // 0...7, 0...-31
tda.setMix_cont(1,1,1,1,1,1,1,1); // all 0...1
tda.setMute(mute,0,0,1,0,1,1); // 0...1, 0...1, 0...3, 0...1, 0...1, 0...1, 0...1 mute off = 1
tda.setSoft_1(1,1,1,1,1,1,1,1); //all 0...1
tda.setSoft_2(1,1,1,1,0,3); // 0...1, 0...1, 0...1, 0...1, 0...2, 0...3
tda.setLoudness(-loun,loun_f,1,1); // 0...-15, 0...3, 0...1, 0...1 
tda.setVol(gain0,1,1); // -15...+15, 0...1, 0...1
tda.setTreble(treb,treb_f,1); // -15...+15, 0...3, 0...1
tda.setMiddle(mid,mid_q,1); // -15...+15, 0...3, 0...1
tda.setBass(bass,bass_q,1); // -15...+15, 0...3, 0...1
tda.setSMB(sub_f,faza,mid_f,bass_f,1); // 0...3, 0...1, 0...3, 0...3, 0...1
tda.setVol_LF(vol-att_lf,1); // 0...-79, 0...1 lov=63+16 att
tda.setVol_RF(vol-att_rf,1); // 0...-79, 0...1
tda.setVol_LR(vol-att_lr,1); // 0...-79, 0...1
tda.setVol_RR(vol-att_rr,1); // 0...-79, 0...1
tda.setVol_SUB_L(vol-att_l,1); // 0...-79, 0...1
tda.setVol_SUB_R(vol-att_r,1); // 0...-79, 0...1
tda.setTest1(0,14,1,1); // 0...1, 0...15, 0...1, 0...1
tda.setTest2(0,1,1,3); // 0...1, 0...1, 0...1, 0...3
}

144

Re: TDA7313 + DS3231 + IR + LCD2004

Код ИК датчика в скетче полностью аналогичен TDA7313

145

Re: TDA7313 + DS3231 + IR + LCD2004

не какой иизменение  тот же самый

146

Re: TDA7313 + DS3231 + IR + LCD2004

на  скетче  TDA7313 даже не направлю строну датчика работаеть отлично

147

Re: TDA7313 + DS3231 + IR + LCD2004

на монитор порта смотрю все коды считаются но на LCD экран ноль дейстивия

148

Re: TDA7313 + DS3231 + IR + LCD2004

Вы прописали коды кнопок в скечт?

149

Re: TDA7313 + DS3231 + IR + LCD2004

да по прежнему тормозить

150

Re: TDA7313 + DS3231 + IR + LCD2004

Откройте монитор порта нажмите кнопку пульта и удерживаете ее.
Опубликуйте содержимое монитора порта на форуме я посмотрю.

#define IR_1 0x33B8A05F // Кнопка вверх
#define IR_2 0x33B8609F // Кнопка вниз
#define IR_3 0x33B810EF // Кнопка >
#define IR_4 0x33B8E01F // Кнопка <
#define IR_5 0x33B850AF // Кнопка IN
#define IR_6 0x33B844BB // Кнопка SET
#define IR_7 0x33B8946B // Кнопка MUTE
#define IR_8 0x33B800FF // Кнопка STANDBY (POWER)
 
#define BRIG_H 200      // Яркость 0...255 POWER ON
#define BRIG_L 50       // Яркость 0...255 POWER OFF
 
#include <TDA7719.h>            // http://rcl-radio.ru/wp-content/uploads/2019/07/TDA7719.zip
#include <Wire.h>
#include <LiquidCrystal_I2C.h>  // http://forum.rcl-radio.ru/misc.php?action=pan_download&item=45&download=1
#include <Encoder.h>            // http://rcl-radio.ru/wp-content/uploads/2019/05/Encoder.zip    
#include <EEPROM.h>
#include <MsTimer2.h>           // http://rcl-radio.ru/wp-content/uploads/2018/11/MsTimer2.zip       
#include <boarddefs.h>          // входит в состав библиотеки IRremote
#include <IRremote.h>           // http://rcl-radio.ru/wp-content/uploads/2019/06/IRremote.zip
#include <DS3231.h>             // http://rcl-radio.ru/wp-content/uploads/2022/10/DS3231.zip
 TDA7719 tda;
 DS3231 clock;RTCDateTime DateTime;
 LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
 IRrecv irrecv(11); // указываем вывод модуля IR приемника
 Encoder myEnc(9, 8);// DT, CLK
 decode_results ir; 
 int in,loun,loun_f,vol_att,treb,treb_f,mid,mid_q,bass,bass_q,sub_f,faza=0,mid_f,bass_f;
 int vol,att_lf,att_rf,att_lr,att_rr,att_l,att_r;
 long time0,oldPosition  = -999,newPosition;
 int menu0,menu,temp0,vol_d,bass_d,treb_d,par,z_old,z1,z0,z,menu1,in_time;
 byte q,gr1,gr2,w,w2[4],www,power,in_x,mute=1;
 int hour,minut,secon,mid_d,menu2,gain0,gain1,gain2,gain3;
 byte mesto2[8]={0,10,0,10,0,10,0,10};
 byte mesto3[8]={0,0,1,1,2,2,3,3};
 
void setup() {
  irrecv.enableIRIn();lcd.init();lcd.backlight();clock.begin();Serial.begin(9600);
  pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT_PULLUP);   // КНОПКА SET
  pinMode(3,INPUT_PULLUP);   // КНОПКА IN
  pinMode(4,INPUT_PULLUP);   // КНОПКА MUTE
  pinMode(5,INPUT_PULLUP);   // КНОПКА STANDBY
  pinMode(7,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ STANDBY
  pinMode(6,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ ПОДСВЕТКОЙ
  analogWrite(6, BRIG_H);// больше 200 не делать
  lcd.setCursor(3,1);lcd.print("Sound Processor");lcd.setCursor(7,2);lcd.print("TDA7719"); delay(2000);lcd.clear();
  MsTimer2::set(4, to_Timer);MsTimer2::start();
  //  clock.setDateTime(__DATE__, __TIME__); // Устанавливаем время на часах, основываясь на времени компиляции скетча
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении  
  vol = EEPROM.read(0)-63;bass = EEPROM.read(1)-15;mid = EEPROM.read(2)-15;treb = EEPROM.read(3)-15;
  att_lr = EEPROM.read(4);att_rr = EEPROM.read(5);att_lf = EEPROM.read(6);att_rf = EEPROM.read(7);att_r = EEPROM.read(8);att_l = EEPROM.read(9);
  loun = EEPROM.read(10);loun_f = EEPROM.read(11);
  bass_f = EEPROM.read(12);mid_f = EEPROM.read(13);treb_f = EEPROM.read(14);sub_f = EEPROM.read(15);
  bass_q = EEPROM.read(16);mid_q = EEPROM.read(17);
  gain1 = EEPROM.read(18)-15;gain2 = EEPROM.read(19)-15;gain3 = EEPROM.read(20)-15;
  switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
  w2_arr();audio();cl();
}
 
void to_Timer(){newPosition = myEnc.read()/4;}
 
void loop() {
 if(power==1){ DateTime = clock.getDateTime();hour = DateTime.hour;minut = DateTime.minute;secon = DateTime.second;}
  /////////////////////////////// УПРАВЛЕНИЕ //////////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();time0=millis();w=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта  
 
  if(power==0){
    if(mute==1){
  if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time0=millis();in_x=0;w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu1++;delay(200);time0=millis();in_x=0;w=1;if(menu1>7){menu1=0;}}// меню 1
  if(digitalRead(10)==LOW&&menu0==2){menu2++;delay(200);time0=millis();in_x=0;w=1;if(menu2>5){menu2=0;}}// меню 2
 
  if(ir.value==IR_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu>3){menu=0;}}//меню 0
  if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu<0){menu=3;}}//меню 0
 
  if(ir.value==IR_2&&menu0==1){menu1++;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu1>7){menu1=0;}}//меню 1
  if(ir.value==IR_1&&menu0==1){menu1--;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu1<0){menu1=7;}}//меню 1
 
  if(ir.value==IR_2&&menu0==2){menu2++;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu2>5){menu2=0;}}//меню 2
  if(ir.value==IR_1&&menu0==2){menu2--;gr1=0;gr2=0;cl1();time0=millis();in_x=0;w=1;w2_arr();if(menu2<0){menu2=5;}}//меню 2
 
  if(ir.value==IR_6||digitalRead(2)==LOW){menu0++;if(menu0>2){menu0=0;}cl();in_x=0;w2_arr();time0=millis();w=1;lcd.setCursor(5,1);
     lcd.print("SETTING_");lcd.print(menu0);delay(500);lcd.clear();} 
 
  if(ir.value==IR_5||digitalRead(3)==LOW){in++;cl();time0=millis();in_x=1;w=1;www=1;menu0=100;menu=100;if(in>2){in=0;}}// IN   
    } // mute off
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==1&&power==0){mute=0;in_x=0;mute=0;menu0=100;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");audio();delay(300);}// mute on
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==0&&power==0){mute=1;cl();time0=millis();w=1;w2_arr();menu0=0;menu=0;myEnc.write(0);audio();}// mute off
  }// power on
 
  if((ir.value==IR_8||digitalRead(5)==LOW)&&power==0){power=1;in_x=0;mute=0;cl();audio();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);analogWrite(6,BRIG_L);}// power off
  if((ir.value==IR_8||digitalRead(5)==LOW)&&power==1){power=0;analogWrite(6, BRIG_H);cl();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);mute=1;audio();delay(3000);cl();}// power on
 
 
if(power==0){digitalWrite(7,HIGH);
   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}; 
   byte a4[8] = {0b10000,0b11000,0b11100,0b11110,0b11100,0b11000,0b10000,0b00000}; //>
   byte a5[8] = {0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000};
   lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);lcd.createChar(3,a4);lcd.createChar(4,a5);
  }
  if(power==1){digitalWrite(7,LOW);
      byte v1[8] = {7,7,7,7,7,7,7,7};
      byte v2[8] = {7,7,0, 0, 0, 0, 0, 0};      
      byte v3[8] = { 0, 0, 0, 0, 0,0,31,31};
      byte v4[8] = {31,31, 0, 0, 0, 0,31,31};
      byte v5[8] = { 28, 28, 0, 0, 0, 0, 28, 28};
      byte v6[8] = {28,28,28,28,28,28,28,28};
      byte v7[8] = { 0, 0, 0, 0, 0, 0,7,7};
      byte v8[8] = { 31, 31,0,0,0,0,0, 0};
   byte a[6];
   byte i0,d1,d2,d3,d4,d5,d6,e1,e2,e3;
  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);
 
     a[0]=DateTime.hour/10;
     a[1]=DateTime.hour%10;
     a[2]=DateTime.minute/10;
     a[3]=DateTime.minute%10;
     a[4]=DateTime.second/10;
     a[5]=DateTime.second%10;
 
 for(int i=0;i<6;i++){
      switch(i){
        case 0: e1=0,e2=1,e3=2;break;
        case 1: e1=3,e2=4,e3=5;break;
        case 2: e1=7,e2=8,e3=9;break;
        case 3: e1=10,e2=11,e3=12;break;
        case 4: e1=14,e2=15,e3=16;break;
        case 5: e1=17,e2=18,e3=19;break;
        }
      switch(a[i]){
        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);
  }
  lcd.setCursor(6,0);lcd.print(".");lcd.setCursor(13,0);lcd.print(".");lcd.setCursor(6,1);lcd.print(".");lcd.setCursor(13,1);lcd.print(".");
  lcd.setCursor(5,3);lcd.print("POWER  OFF");
  if(digitalRead(10)==LOW&&digitalRead(2)==LOW){hour++;if(hour>23){hour=0;} clock.setDateTime(2022, 9, 15, hour, minut, secon);delay(100);}    // SET
  if(digitalRead(10)==LOW&&digitalRead(3)==LOW){minut++;if(minut>59){minut=0;} clock.setDateTime(2022, 9, 15, hour, minut, secon);delay(100); }// IN
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW){secon=0; clock.setDateTime(2022, 9, 15, hour, minut, secon);delay(100); }                      // MUTE
  } 
/////////////////////////////// MENU0 = VOLUME TERBLE BASS MIDDLE ///////////////////////////////////////////////////////////////////////
  if(menu0==0){ 
    switch(menu){
      case 0: temp0 = vol;q=0;break;
      case 1: temp0 = bass;q=1;break;
      case 2: temp0 = mid;q=2;break;
      case 3: temp0 = treb;q=3;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка <<<<<<   
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;w2[q]=1;www=1;} 
 
 
     switch(menu){
      case 0: vol = temp0;vol_func();break;
      case 1: bass = temp0;bass_func();break;
      case 2: mid = temp0;mid_func();break;
      case 3: treb = temp0;treb_func();break;
      }
 
   au();
   for(int i=0;i<4;i++){if(menu==i){lcd.setCursor(0,i);lcd.write((uint8_t)3);}else{lcd.setCursor(0,i);lcd.print(" ");}}
   lcd.setCursor(1,0);lcd.print("VOL(");lcd.print(in+1);lcd.print(") ");if(vol>=0){lcd.print(" ");}lcd.print(vol);lcd.print(" ");vol_d=map(vol,-63,0,1,24);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print(" ");bass_d=map(bass,-15,15,1,24);
   lcd.setCursor(1,2);lcd.print("MIDDLE ");if(mid>=0){lcd.print(" ");}lcd.print(mid);lcd.print(" ");mid_d=map(mid,-15,15,1,24);
   lcd.setCursor(1,3);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print(" ");treb_d=map(treb,-15,15,1,24);
 
 
   for(int n=0;n<4;n++){if(w2[n]==1){
   switch(n){
    case 0: par = vol_d;break;
    case 1: par = bass_d;break;
    case 2: par = mid_d;break;
    case 3: par = treb_d;break; 
    } 
 
   for(z=0,z0=0,z1=0;z<=par;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,n);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,n);Serial.println(z0);z_old=7-par/3;while(z_old>0){z_old=z_old-1;lcd.write((uint8_t)4);}}}
   if(z1==3){lcd.setCursor(z0+12,n);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,n);lcd.write((uint8_t)2);}w2[n]=0;}
   }}// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////////////////////
 
 if(menu0==1){
     switch(menu1){
      case 0: temp0 = att_lr;break;
      case 1: temp0 = att_rr;break;
      case 2: temp0 = att_lf;break;
      case 3: temp0 = att_rf;break;
      case 4: temp0 = att_r;break;
      case 5: temp0 = att_l;break;
      case 6: temp0 = loun;break;
      case 7: temp0 = loun_f;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu1){
      case 0: att_lr = temp0;att_lr_func();break;
      case 1: att_rr = temp0;att_rr_func();break;
      case 2: att_lf = temp0;att_lf_func();break;
      case 3: att_rf = temp0;att_rf_func();break;      
      case 4: att_r  = temp0;att_r_func();break;
      case 5: att_l  = temp0;att_l_func();break;
      case 6: loun  = temp0;loun_func();break;
      case 7: loun_f  = temp0;loun_f_func();break;
      }
 
  au();
  for(int i=0;i<8;i++){if(menu1==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.write((uint8_t)3);}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
 
  lcd.setCursor(1,0);lcd.print("AT_LR ");lcd.print(att_lr);lcd.print(" ");lcd.setCursor(11,0);lcd.print("AT_RR ");lcd.print(att_rr);lcd.print(" ");
  lcd.setCursor(1,1);lcd.print("AT_LF ");lcd.print(att_lf);lcd.print(" ");lcd.setCursor(11,1);lcd.print("AT_RF ");lcd.print(att_rf);lcd.print(" ");
  lcd.setCursor(1,2);lcd.print("AT_SR ");lcd.print(att_r);lcd.print(" ");lcd.setCursor(11,2);lcd.print("AT_SL ");lcd.print(att_l);lcd.print(" ");
  lcd.setCursor(1,3);lcd.print("LOUND ");lcd.print(abs(loun));lcd.print(" ");lcd.setCursor(11,3);
  switch(loun_f){
    case 0: lcd.print("FLAT   ");break;
    case 1: lcd.print("400  Hz");break;
    case 2: lcd.print("800  Hz");break;
    case 3: lcd.print("2.4 kHz");break;}
 
 } // menu0 = 1
 
 
///////////////////////////////////////////////////////////////////////////////////////////////
 
 if(menu0==2){
     switch(menu2){
      case 0: temp0 = bass_f;break;
      case 1: temp0 = mid_f;break;
      case 2: temp0 = treb_f;break;
      case 3: temp0 = sub_f;break;
      case 4: temp0 = bass_q;break;
      case 5: temp0 = mid_q;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu2){
      case 0: bass_f = temp0;bass_f_func();break;
      case 1: mid_f = temp0;mid_f_func();break;
      case 2: treb_f = temp0;treb_f_func();break;
      case 3: sub_f = temp0;sub_f_func();break;      
      case 4: bass_q  = temp0;bass_q_func();break;
      case 5: mid_q  = temp0;mid_q_func();break;
      }
 
  au();
  for(int i=0;i<6;i++){if(menu2==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.write((uint8_t)3);}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
 
  lcd.setCursor(1,0);lcd.print("BF ");
    switch(bass_f){
    case 0: lcd.print(" 60 Hz");break;
    case 1: lcd.print(" 80 Hz");break;
    case 2: lcd.print("100 Hz");break;
    case 3: lcd.print("200 Hz");break;}
  lcd.setCursor(11,0);lcd.print("MF ");
    switch(mid_f){
      case 0: lcd.print("0.5kHz");break;
      case 1: lcd.print("1.0kHz");break;
      case 2: lcd.print("1.5kHz");break;
      case 3: lcd.print("2.5kHz");break;}
 
  lcd.setCursor(1,1);lcd.print("TF");
    switch(treb_f){
      case 0: lcd.print("10.0kHz");break;
      case 1: lcd.print("12.5kHz");break;
      case 2: lcd.print("15.0kHz");break;
      case 3: lcd.print("17.5kHz");break;}
 
  lcd.setCursor(11,1);lcd.print("SF ");
    switch(sub_f){
      case 0: lcd.print("FLAT  ");break;
      case 1: lcd.print("400 Hz");break;
      case 2: lcd.print("800 Hz");break;
      case 3: lcd.print("2.4kHz");break;}
 
  lcd.setCursor(1,2);lcd.print("BQ ");
    switch(bass_q){
      case 0: lcd.print("1.0 ");break;
      case 1: lcd.print("1.25");break;
      case 2: lcd.print("1.5 ");break;
      case 3: lcd.print("2.0 ");break;}
 
  lcd.setCursor(11,2);lcd.print("MQ ");
    switch(mid_q){
      case 0: lcd.print("0.5 ");break;
      case 1: lcd.print("0.75");break;
      case 2: lcd.print("1.0 ");break;
      case 3: lcd.print("1.25");break;}
 
 } // menu0 = 2 
 
 
////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
   switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
 
     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();time0=millis();www=1;w=1;gain_func();}// кнопка <<<<<<  
 
    if (newPosition != oldPosition) {oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time0=millis();www=1;w=1;gain_func();} 
 
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     }
 
  au();
  lcd.setCursor(7,1);lcd.print("INPUT ");lcd.print(in+1);lcd.setCursor(5,2);lcd.print("GAIN ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(14,2);lcd.print("dB ");
   }
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){in_time=3000;}else{in_time=10000;}
if(millis()-time0>in_time&&w==1&&mute==1&&power==0){if(menu0==1){cl();}w=0;if(menu0!=0){cl();}menu0=0;menu=0;in_x=0;w2_arr();
   EEPROM.update(0,vol+63);EEPROM.update(1,bass+15);EEPROM.update(2,mid+15);EEPROM.update(3,treb+15);
   EEPROM.update(4,att_lr);EEPROM.update(5,att_rr);EEPROM.update(6,att_lf);EEPROM.update(7,att_rf);EEPROM.update(8,att_r);EEPROM.update(9,att_l);
   EEPROM.update(10,loun);EEPROM.update(11,loun_f);
   EEPROM.update(12,bass_f);EEPROM.update(13,mid_f);EEPROM.update(14,treb_f);EEPROM.update(15,sub_f);
   EEPROM.update(16,bass_q);EEPROM.update(17,mid_q);
   EEPROM.update(18,gain1+15);EEPROM.update(19,gain2+15);EEPROM.update(20,gain3+15);
   }

}
 
 
void gain_func(){if(gain0<-15){gain0=-15;}if(gain0>15){gain0=15;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void loun_f_func(){if(loun_f>3){loun_f=3;}if(loun_f<0){loun_f=0;}}
void loun_func(){if(loun<0){loun=0;}if(loun>15){loun=15;}}
void att_lr_func(){if(att_lr>16){att_lr=16;}if(att_lr<0){att_lr=0;}}
void att_rr_func(){if(att_rr>16){att_rr=16;}if(att_rr<0){att_rr=0;}}
void att_lf_func(){if(att_lf>16){att_lf=16;}if(att_lf<0){att_lf=0;}}
void att_rf_func(){if(att_rf>16){att_rf=16;}if(att_rf<0){att_rf=0;}}
void att_r_func(){if(att_r>16){att_r=16;}if(att_r<0){att_r=0;}}
void att_l_func(){if(att_r>16){att_r=16;}if(att_r<0){att_r=0;}}
void vol_func(){if(vol<-63){vol=-63;}if(vol>0){vol=0;}}
void treb_func(){if(treb<-15){treb=-15;}if(treb>15){treb=15;}}
void bass_func(){if(bass<-15){bass=-15;}if(bass>15){bass=15;}}
void mid_func(){if(mid<-15){mid=-15;}if(mid>15){mid=15;}}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(50);}  
void au(){if(www==1){audio();www=0;}}
void bass_f_func(){if(bass_f>3){bass_f=3;}if(bass_f<0){bass_f=0;}}
void mid_f_func(){if(mid_f>3){mid_f=3;}if(mid_f<0){mid_f=0;}}
void treb_f_func(){if(treb_f>3){treb_f=3;}if(treb_f<0){treb_f=0;}}
void sub_f_func(){if(sub_f>3){sub_f=3;}if(sub_f<0){sub_f=0;}}
void bass_q_func(){if(bass_q>3){bass_q=3;}if(bass_q<0){bass_q=0;}}
void mid_q_func(){if(mid_q>3){mid_q=3;}if(mid_q<0){mid_q=0;}}
 
void audio(){
tda.setInput(in,1,1,2); // 0...7, 0...1, 0...1, 0...7
tda.setInput_2(0,0,1,1,1,1); // 0...7, 0...1, 0...1, 0...1, 0...1, 0...1 
tda.setMix_source(7,0); // 0...7, 0...-31
tda.setMix_cont(1,1,1,1,1,1,1,1); // all 0...1
tda.setMute(mute,0,0,1,0,1,1); // 0...1, 0...1, 0...3, 0...1, 0...1, 0...1, 0...1 mute off = 1
tda.setSoft_1(1,1,1,1,1,1,1,1); //all 0...1
tda.setSoft_2(1,1,1,1,0,3); // 0...1, 0...1, 0...1, 0...1, 0...2, 0...3
tda.setLoudness(-loun,loun_f,1,1); // 0...-15, 0...3, 0...1, 0...1 
tda.setVol(gain0,1,1); // -15...+15, 0...1, 0...1
tda.setTreble(treb,treb_f,1); // -15...+15, 0...3, 0...1
tda.setMiddle(mid,mid_q,1); // -15...+15, 0...3, 0...1
tda.setBass(bass,bass_q,1); // -15...+15, 0...3, 0...1
tda.setSMB(sub_f,faza,mid_f,bass_f,1); // 0...3, 0...1, 0...3, 0...3, 0...1
tda.setVol_LF(vol-att_lf,1); // 0...-79, 0...1 lov=63+16 att
tda.setVol_RF(vol-att_rf,1); // 0...-79, 0...1
tda.setVol_LR(vol-att_lr,1); // 0...-79, 0...1
tda.setVol_RR(vol-att_rr,1); // 0...-79, 0...1
tda.setVol_SUB_L(vol-att_l,1); // 0...-79, 0...1
tda.setVol_SUB_R(vol-att_r,1); // 0...-79, 0...1
tda.setTest1(0,14,1,1); // 0...1, 0...15, 0...1, 0...1
tda.setTest2(0,1,1,3); // 0...1, 0...1, 0...1, 0...3
}