251

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

Тестирование

Дисплей OLED 0.96' I2C
Энкодер D8,D9,D10 \ clk,dt,sw
Кнопка Input      D2
Кнопка SET        D3
Кнопка POWER   D4
Кнопка MUTE      D5
выход STANDBY D13
Вход IR              D12

Тестирование громкости, переключателя входа и предусилителя входа.
Тестирование центральных частот TREBLE, BASS, MIDDLE, LOUDNESS.
Добротность BASS, TREBLE, MIDDLE.
Аттенюаторы всех выходов LF RF LR RR SUB от -79 до +15 дБ
Усиление LOUDNESS
IR пульт дублирует все кнопки и энкодер, добавить свои коды кнопок, коды кнопок в мониторе порта.
Все перечисленные параметры должны сохранятся в энергонезависимой памяти после 5 секунд после изменения параметра.

Прошивать Arduino NANO как UNO

#define ENC_BUTTON       10
#define IN_BUTTON        2
#define SET_BUTTON       3
#define POWER_BUTTON     4
#define STANDBY_OUT     13
#define MUTE_BUTTON      5

#define IR_POWER    0x33B800FF
#define IR_MUTE     0x33B8649B
#define IR_UP       0x33B810EF
#define IR_DW       0x33B8E01F
#define IR_MENU     0x33B820DF
#define IR_INPUT    0x33B8A45B
#define IR_SET      0x33B824DB


#include <Wire.h> 
#include <OLED_I2C.h>           // http://rcl-radio.ru/wp-content/uploads/2022/01/OLED_I2C.zip
#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 <BD37534FV.h>
 BD37534FV tda; 
 OLED  myOLED(SDA, SCL, 8);
 extern uint8_t SmallFont[],BigNumbers[];
 IRrecv irrecv(12); // указываем вывод модуля IR приемника
 Encoder myEnc(9, 8);// DT, CLK
 decode_results ir; 
 long times,oldPosition  = -999,newPosition;
 int menu,vol_reg,in_reg,treb_reg,bass_reg,mid_reg,gain0,gain1,gain2,gain3;
 bool w2,w,www,gr1,gr2,power,mute;
 int f_treb,q_treb,f_mid,q_mid,f_bass,q_bass,set=0,f_sub,f_lon,gain_lon;
 int gain_lf,gain_rf,gain_lr,gain_rr,gain_sub;

void setup(){
  Wire.begin();Wire.setClock(400000L);
  irrecv.enableIRIn();
  myOLED.begin();
  myOLED.setBrightness(100);
  Serial.begin(9600);
  pinMode(ENC_BUTTON,INPUT);        
  pinMode(IN_BUTTON,INPUT_PULLUP); // КНОПКА INPUT
  pinMode(SET_BUTTON,INPUT_PULLUP); // КНОПКА SET MENU2
  pinMode(MUTE_BUTTON,INPUT_PULLUP);  // КНОПКА MUTE 
  pinMode(STANDBY_OUT,OUTPUT);       // ВЫХОД УПРАВЛЕНИЯ STANDBY
  pinMode(POWER_BUTTON,INPUT_PULLUP); // КНОПКА POWER
 
  MsTimer2::set(3, to_Timer);MsTimer2::start();
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении  
  myOLED.clrScr();
  myOLED.setFont(SmallFont);
  myOLED.print(F("Sound Processors"), CENTER, 10);
  myOLED.print(F("BD37534FV"), CENTER, 30);
  myOLED.update();
  delay(2000);
  vol_reg = EEPROM.read(0)-79;in_reg = EEPROM.read(1);gain1 = EEPROM.read(2);gain2 = EEPROM.read(3);gain3 = EEPROM.read(4);
  treb_reg = EEPROM.read(5)-20;f_treb = EEPROM.read(6);q_treb = EEPROM.read(7);
  mid_reg = EEPROM.read(8)-20;f_mid = EEPROM.read(9);q_mid = EEPROM.read(10);
  bass_reg = EEPROM.read(11)-20;f_bass = EEPROM.read(12);q_bass = EEPROM.read(13);f_sub = EEPROM.read(14);
  f_lon = EEPROM.read(15);gain_lon = EEPROM.read(16);
  gain_lf = EEPROM.read(17)-79;gain_rf = EEPROM.read(18)-79;gain_lr = EEPROM.read(19)-79;gain_rr = EEPROM.read(20)-79;gain_sub = EEPROM.read(21)-79;

  switch(in_reg){
   case 0: gain0 = gain1;break;
   case 1: gain0 = gain2;break;
   case 2: gain0 = gain3;break;
   }
  } 

void to_Timer(){newPosition = myEnc.read()/4;}   

void loop(){
/// IR ////////////////////////////////////////
   if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();times=millis();w=1;w2=1;}
   if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта 
   
//////// BUTTON //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if((digitalRead(POWER_BUTTON)==LOW || ir.value==IR_POWER)&& power==0){power=1;mute=1;gr1=0;gr2=0;cl();
    myOLED.setFont(SmallFont);myOLED.print(F("POWER OFF"), CENTER, 10);myOLED.update();delay(1500);cl();menu=100;myOLED.setBrightness(0);}
  if((digitalRead(POWER_BUTTON)==LOW || ir.value==IR_POWER)&& power==1){power=0;mute=0;myOLED.setBrightness(100);gr1=0;gr2=0;times=millis();w=1;w2=1;
    myOLED.setFont(SmallFont);myOLED.print(F("POWER ON"), CENTER, 10);myOLED.update();delay(1500);cl();menu=0;}  

if(power==0 && mute==0){  
  if(digitalRead(SET_BUTTON)==LOW || ir.value==IR_SET){set=1;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;
    myOLED.setFont(SmallFont);myOLED.print(F("SETTING MENU"), CENTER, 10);myOLED.update();delay(1500);cl();menu=10;
  }
  if((digitalRead(ENC_BUTTON)==LOW || ir.value==IR_MENU) && set==0){menu++;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;if(menu>3){menu=0;}}
  if((digitalRead(ENC_BUTTON)==LOW || ir.value==IR_MENU) && set==1){menu++;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;if(menu>23){menu=10;}}
  if(digitalRead(IN_BUTTON)==LOW || ir.value==IR_INPUT){in_reg++;menu=5;cl();times=millis();w=1;w2=1;www=1;if(in_reg>2){in_reg=0;}} 
}
if(power==0){
  if((digitalRead(MUTE_BUTTON)==LOW || ir.value==IR_MUTE)&& mute==0){mute=1;gr1=0;gr2=0;cl();
    myOLED.setFont(SmallFont);myOLED.print(F("MUTE"), CENTER, 10);myOLED.update();cl();menu=100;}
  if((digitalRead(MUTE_BUTTON)==LOW  || ir.value==IR_MUTE)&& mute==1){mute=0;gr1=0;gr2=0;times=millis();w=1;w2=1;cl();menu=0;}  
}
if(power==1){digitalWrite(STANDBY_OUT, HIGH);}else{digitalWrite(STANDBY_OUT, LOW);} 
//////// VOLUME //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==0){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();vol_reg=vol_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;vol_func();audio();}

   if(ir.value==IR_UP){vol_reg++;ir_low();vol_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){vol_reg++;ir_low2();vol_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){vol_reg--;ir_low1();vol_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){vol_reg--;ir_low3();vol_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("VOLUME"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(vol_reg+79, 75, 0);
  myOLED.setFont(SmallFont);myOLED.print(F("IN"), LEFT, 10);
  myOLED.printNumI(in_reg+1, 30, 10);myOLED.print(F("GAIN"), LEFT, 20);myOLED.printNumI(gain0, 30, 20);
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);myOLED.print(F("TREBLE"), LEFT, 35);myOLED.printNumI(treb_reg, 75, 35);
  myOLED.setFont(SmallFont);myOLED.print(F("MIDDLE"), LEFT, 45);myOLED.printNumI(mid_reg, 75, 45);
  myOLED.setFont(SmallFont);myOLED.print(F("BASS"), LEFT, 55);myOLED.printNumI(bass_reg, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// TREBLE //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==1){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();treb_reg=treb_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;treb_func();audio();}

   if(ir.value==IR_UP){treb_reg++;ir_low();treb_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){treb_reg++;ir_low2();treb_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){treb_reg--;ir_low1();treb_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){treb_reg--;ir_low3();treb_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("TREBLE"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(treb_reg, 75, 0);
  myOLED.setFont(SmallFont);
  switch(f_treb){
  case 0:myOLED.print(F("F 7.5 kHz"), LEFT, 10);break;
  case 1:myOLED.print(F("F 10  kHz"), LEFT, 10);break;
  case 2:myOLED.print(F("F 12.5kHz"), LEFT, 10);break;
  case 3:myOLED.print(F("F 15  kHz"), LEFT, 10);break;
  }
  myOLED.setFont(SmallFont);
  switch(q_treb){
  case 0: myOLED.print(F("Q 0.75"), LEFT, 20);break;
  case 1: myOLED.print(F("Q 1.25"), LEFT, 20);break;
  }
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);
  myOLED.print(F("MIDDLE"), LEFT, 35);myOLED.printNumI(mid_reg, 75, 35);
  myOLED.print(F("BASS"), LEFT, 45);myOLED.printNumI(bass_reg, 75, 45);
  myOLED.print(F("VOLUME"), LEFT, 55);myOLED.printNumI(vol_reg+79, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// MIDDLE //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==2){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();mid_reg=mid_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;mid_func();audio();}

   if(ir.value==IR_UP){mid_reg++;ir_low();mid_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){mid_reg++;ir_low2();mid_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){mid_reg--;ir_low1();mid_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){mid_reg--;ir_low3();mid_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("MIDDLE"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(mid_reg, 75, 0);
  myOLED.setFont(SmallFont);
  switch(f_mid){
  case 0:myOLED.print(F("F 500 Hz"), LEFT, 10);break;
  case 1:myOLED.print(F("F 1  kHz"), LEFT, 10);break;
  case 2:myOLED.print(F("F 1.5kHz"), LEFT, 10);break;
  case 3:myOLED.print(F("F 2.5kHz"), LEFT, 10);break;
  }
  myOLED.setFont(SmallFont);
  switch(q_mid){
  case 0: myOLED.print(F("Q 0.75"), LEFT, 20);break;
  case 1: myOLED.print(F("Q 1.00"), LEFT, 20);break;
  case 2: myOLED.print(F("Q 1.25"), LEFT, 20);break;
  case 3: myOLED.print(F("Q 1.50"), LEFT, 20);break;
  }
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);
  myOLED.print(F("BASS"), LEFT, 35);myOLED.printNumI(bass_reg, 75, 35);
  myOLED.print(F("VOLUME"), LEFT, 45);myOLED.printNumI(vol_reg+79, 75, 45);
  myOLED.print(F("TERBLE"), LEFT, 55);myOLED.printNumI(treb_reg, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// BASS //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==3){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();bass_reg=bass_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;bass_func();audio();}

   if(ir.value==IR_UP){bass_reg++;ir_low();bass_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){bass_reg++;ir_low2();bass_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){bass_reg--;ir_low1();bass_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){bass_reg--;ir_low3();bass_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("BASS"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(bass_reg, 75, 0);
  myOLED.setFont(SmallFont);
  switch(f_bass){
  case 0:myOLED.print(F("F 60 Hz"), LEFT, 10);break;
  case 1:myOLED.print(F("F 80 Hz"), LEFT, 10);break;
  case 2:myOLED.print(F("F 100kHz"), LEFT, 10);break;
  case 3:myOLED.print(F("F 120kHz"), LEFT, 10);break;
  }
  switch(q_bass){
  case 0: myOLED.print(F("Q 0.50"), LEFT, 20);break;
  case 1: myOLED.print(F("Q 1.00"), LEFT, 20);break;
  case 2: myOLED.print(F("Q 1.50"), LEFT, 20);break;
  case 3: myOLED.print(F("Q 2.00"), LEFT, 20);break;
  }
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);
  myOLED.print(F("VOLUME"), LEFT, 35);myOLED.printNumI(vol_reg+79, 75, 35);
  myOLED.print(F("TREBLE"), LEFT, 45);myOLED.printNumI(treb_reg, 75, 45);
  myOLED.print(F("MIDDLE"), LEFT, 55);myOLED.printNumI(mid_reg, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

////////////// INPUT GAIN ///////////////////////////////////////////////////////////////////
 if(menu==5){
  switch(in_reg){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
   if(ir.value==IR_UP){gain0++;ir_low();gain_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain0++;ir_low2();gain_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain0--;ir_low1();gain_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain0--;ir_low3();gain_func();audio();}// кнопка <<<<<<
 
  if (newPosition != oldPosition){oldPosition = newPosition;enc_err();gain0=gain0+newPosition;myEnc.write(0);newPosition=0;times=millis();www=1;w=1;w2=1;gain_func();}
  switch(in_reg){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     }  
  if(www==1){audio();www=0;}
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("INPUT"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(in_reg+1, 65, 0);
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);myOLED.print(F("GAIN"), LEFT, 35);myOLED.setFont(BigNumbers);myOLED.printNumI(gain0, 65, 35);
  myOLED.update();
  }} 

////////////// SET F_TREB ///////////////////////////////////////////////////////////////////  
if(menu==10){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_treb=f_treb+newPosition;en_low();f_treb_func();audio();}

   if(ir.value==IR_UP){f_treb++;ir_low();f_treb_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_treb--;ir_low1();f_treb_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency TREBLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(f_treb){
  case 0:myOLED.print(F("7.50"), CENTER, 20);break;
  case 1:myOLED.print(F("10.0"), CENTER, 20);break;
  case 2:myOLED.print(F("12.5"), CENTER, 20);break;
  case 3:myOLED.print(F("15.0"), CENTER, 20);break;
  }
  myOLED.setFont(SmallFont);myOLED.print(F("kHz"), CENTER, 50);
  myOLED.update();}
  }
////////////// SET F_MID ///////////////////////////////////////////////////////////////////  
if(menu==11){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_mid=f_mid+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;f_mid_func();audio();}

   if(ir.value==IR_UP){f_mid++;ir_low();f_mid_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_mid--;ir_low1();f_mid_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency MIDDLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(f_mid){
  case 0:myOLED.print(F("0.5"), CENTER, 20);break;
  case 1:myOLED.print(F("1.0"), CENTER, 20);break;
  case 2:myOLED.print(F("1.5"), CENTER, 20);break;
  case 3:myOLED.print(F("2.5"), CENTER, 20);break;
  }
  myOLED.setFont(SmallFont);myOLED.print(F("kHz"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET F_BASS ///////////////////////////////////////////////////////////////////  
if(menu==12){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_bass=f_bass+newPosition;en_low();f_bass_func();audio();}

   if(ir.value==IR_UP){f_bass++;ir_low();f_bass_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_bass--;ir_low1();f_bass_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency BASS"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(f_bass){
  case 0:myOLED.print(F("60"), CENTER, 20);break;
  case 1:myOLED.print(F("80"), CENTER, 20);break;
  case 2:myOLED.print(F("100"), CENTER, 20);break;
  case 3:myOLED.print(F("120"), CENTER, 20);break;
  }
  myOLED.setFont(SmallFont);myOLED.print(F("Hz"), CENTER, 50);
  myOLED.update();}
  }   
////////////// SET F_SUB ///////////////////////////////////////////////////////////////////  
if(menu==13){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_sub=f_sub+newPosition;en_low();f_sub_func();audio();}

   if(ir.value==IR_UP){f_sub++;ir_low();f_sub_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_sub--;ir_low1();f_sub_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency SUBWOOFER"), CENTER, 0);
  switch(f_sub){
  case 0:myOLED.setFont(SmallFont);myOLED.print(F("OFF"), CENTER, 20);break;
  case 1:myOLED.setFont(BigNumbers);myOLED.print(F("55"), CENTER, 20);break;
  case 2:myOLED.setFont(BigNumbers);myOLED.print(F("85"), CENTER, 20);break;
  case 3:myOLED.setFont(BigNumbers);myOLED.print(F("120"), CENTER, 20);break;
  case 4:myOLED.setFont(BigNumbers);myOLED.print(F("160"), CENTER, 20);break;
  }
  if(f_sub>0){myOLED.setFont(SmallFont);myOLED.print(F("Hz"), CENTER, 50);}
  myOLED.update();}
  }   
////////////// SET F_LOUDNESS ///////////////////////////////////////////////////////////////////  
if(menu==14){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_lon=f_lon+newPosition;en_low();f_lon_func();audio();}

  if(ir.value==IR_UP){f_lon++;ir_low();f_lon_func();audio();}// кнопка > 
  if(ir.value==IR_DW){f_lon--;ir_low1();f_lon_func();audio();}// кнопка <

  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency LOUDNESS"), CENTER, 0);
  switch(f_lon){
  case 0:myOLED.setFont(BigNumbers);myOLED.print(F("250"), CENTER, 20);break;
  case 1:myOLED.setFont(BigNumbers);myOLED.print(F("400"), CENTER, 20);break;
  case 2:myOLED.setFont(BigNumbers);myOLED.print(F("800"), CENTER, 20);break;
  case 3:myOLED.setFont(SmallFont);myOLED.print(F("Prohibition"), CENTER, 20);break;
  }
  if(f_lon<3){myOLED.setFont(SmallFont);myOLED.print(F("Hz"), CENTER, 50);}
  myOLED.update();}
  }     
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
////////////// SET Q_TREB ///////////////////////////////////////////////////////////////////  
if(menu==15){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();q_treb=q_treb+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;q_treb_func();audio();}

  if(ir.value==IR_UP){q_treb++;ir_low();q_treb_func();audio();}// кнопка > 
  if(ir.value==IR_DW){q_treb--;ir_low1();q_treb_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Q TREBLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(q_treb){
  case 0: myOLED.print(F("0.75"), CENTER, 20);break;
  case 1: myOLED.print(F("1.25"), CENTER, 20);break;
  }
  myOLED.update();}
  }  
////////////// SET Q_MIDDLE ///////////////////////////////////////////////////////////////////  
if(menu==16){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();q_mid=q_mid+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;q_mid_func();audio();}

  if(ir.value==IR_UP){q_mid++;ir_low();q_mid_func();audio();}// кнопка > 
  if(ir.value==IR_DW){q_mid--;ir_low1();q_mid_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Q MIDDLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(q_mid){
  case 0:myOLED.print(F("0.75"), CENTER, 20);break;
  case 1:myOLED.print(F("1.00"), CENTER, 20);break;
  case 2:myOLED.print(F("1.25"), CENTER, 20);break;
  case 3:myOLED.print(F("1.50"), CENTER, 20);break;
  }
  myOLED.update();}
  }   
////////////// SET Q_BASS ///////////////////////////////////////////////////////////////////  
if(menu==17){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();q_bass=q_bass+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;q_bass_func();audio();}

  if(ir.value==IR_UP){q_bass++;ir_low();q_bass_func();audio();}// кнопка > 
  if(ir.value==IR_DW){q_bass--;ir_low1();q_bass_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Q BASS"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(q_bass){
  case 0: myOLED.print(F("0.50"), CENTER, 20);break;
  case 1: myOLED.print(F("1.00"), CENTER, 20);break;
  case 2: myOLED.print(F("1.50"), CENTER, 20);break;
  case 3: myOLED.print(F("2.00"), CENTER, 20);break;
  }
  myOLED.update();}
  } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////// SET GAIN LOUDNESS ///////////////////////////////////////////////////////////////////  
if(menu==18){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_lon=gain_lon+newPosition;en_low();gain_lon_func();audio();}

   if(ir.value==IR_UP){gain_lon++;ir_low();gain_lon_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_lon++;ir_low2();gain_lon_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_lon--;ir_low1();gain_lon_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_lon--;ir_low3();gain_lon_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN LOUDNESS"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_lon, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }       
////////////// SET GAIN LEFT FRONT ///////////////////////////////////////////////////////////////////  
if(menu==19){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_lf=gain_lf+newPosition;en_low();gain_lf_func();audio();}

   if(ir.value==IR_UP){gain_lf++;ir_low();gain_lf_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_lf++;ir_low2();gain_lf_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_lf--;ir_low1();gain_lf_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_lf--;ir_low3();gain_lf_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN LEFT FRONT"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_lf, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET GAIN RIGHT FRONT ///////////////////////////////////////////////////////////////////  
if(menu==20){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_rf=gain_rf+newPosition;en_low();gain_rf_func();audio();}

   if(ir.value==IR_UP){gain_rf++;ir_low();gain_rf_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_rf++;ir_low2();gain_rf_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_rf--;ir_low1();gain_rf_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_rf--;ir_low3();gain_rf_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN RIGHT FRONT"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_rf, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET GAIN LEFT REAR ///////////////////////////////////////////////////////////////////  
if(menu==21){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_lr=gain_lr+newPosition;en_low();gain_lr_func();audio();}

   if(ir.value==IR_UP){gain_lr++;ir_low();gain_lr_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_lr++;ir_low2();gain_lr_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_lr--;ir_low1();gain_lr_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_lr--;ir_low3();gain_lr_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN LEFT REAR"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_lr, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET GAIN RIGHT REAR ///////////////////////////////////////////////////////////////////  
if(menu==22){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_rr=gain_rr+newPosition;en_low();gain_rr_func();audio();}

   if(ir.value==IR_UP){gain_rr++;ir_low();gain_rr_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_rr++;ir_low2();gain_rr_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_rr--;ir_low1();gain_rr_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_rr--;ir_low3();gain_rr_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN RIGHT REAR"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_rr, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }   
////////////// SET GAIN SUBWOOFER ///////////////////////////////////////////////////////////////////  
if(menu==23){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_sub=gain_sub+newPosition;en_low();gain_sub_func();audio();}

   if(ir.value==IR_UP){gain_sub++;ir_low();gain_sub_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_sub++;ir_low2();gain_sub_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_sub--;ir_low1();gain_sub_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_sub--;ir_low3();gain_sub_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN SUBWOOFER"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_sub, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }     
         

     


////////////////// EEPROM //////////////////////////////////////////////////////////////
 if(millis()-times>5000 && w2==1 && power==0 && mute==0){
     EEPROM.update(0,vol_reg+79);EEPROM.update(1,in_reg);EEPROM.update(2,gain1);EEPROM.update(3,gain2);EEPROM.update(4,gain3);
     EEPROM.update(5,treb_reg+20);EEPROM.update(6,f_treb);EEPROM.update(7,q_treb);
     EEPROM.update(8,mid_reg+20);EEPROM.update(9,f_mid);EEPROM.update(10,q_mid);
     EEPROM.update(11,bass_reg+20);EEPROM.update(12,f_bass);EEPROM.update(13,q_bass);EEPROM.update(14,f_sub);
     EEPROM.update(15,f_lon);EEPROM.update(16,gain_lon);
     EEPROM.update(17,gain_lf+79);EEPROM.update(18,gain_rf+79);EEPROM.update(19,gain_lr+79);EEPROM.update(20,gain_rr+79);EEPROM.update(21,gain_sub+79);
     cl();set=0;menu=0;w2=0;w=1;}        
} // loop end 

void en_low(){myEnc.write(0);newPosition=0;times=millis();myOLED.clrScr();w=1;w2=1;}
void ir_low3(){gr1=0;cl();times=millis();w=1;w2=1;}
void ir_low2(){gr2=0;cl();times=millis();w=1;w2=1;}
void ir_low1(){gr1=0;gr2=1;cl();times=millis();w=1;w2=1;}
void ir_low(){gr1=1;ir_low2();}
void gain_lf_func(){if(gain_lf<-79){gain_lf=-79;}if(gain_lf>15){gain_lf=15;}}
void gain_rf_func(){if(gain_rf<-79){gain_rf=-79;}if(gain_rf>15){gain_rf=15;}}
void gain_lr_func(){if(gain_lr<-79){gain_lr=-79;}if(gain_lr>15){gain_lr=15;}}
void gain_rr_func(){if(gain_rr<-79){gain_rr=-79;}if(gain_rr>15){gain_rr=15;}}
void gain_sub_func(){if(gain_sub<-79){gain_sub=-79;}if(gain_sub>15){gain_sub=15;}}
void gain_lon_func(){if(gain_lon<0){gain_lon=0;}if(gain_lon>20){gain_lon=20;}}
void f_lon_func(){if(f_lon<0){f_lon=0;}if(f_lon>3){f_lon=3;}}
void f_sub_func(){if(f_sub<0){f_sub=0;}if(f_sub>4){f_sub=4;}}
void f_treb_func(){if(f_treb<0){f_treb=0;}if(f_treb>3){f_treb=3;}}
void f_mid_func(){if(f_mid<0){f_mid=0;}if(f_mid>3){f_mid=3;}}
void f_bass_func(){if(f_bass<0){f_bass=0;}if(f_bass>3){f_bass=3;}}
void q_mid_func(){if(q_mid<0){q_mid=0;}if(q_mid>3){q_mid=3;}}
void q_bass_func(){if(q_bass<0){q_bass=0;}if(q_bass>3){q_bass=3;}}
void q_treb_func(){if(q_treb<0){q_treb=0;}if(q_treb>1){q_treb=1;}}
void bass_func(){if(bass_reg<-20){bass_reg=-20;}if(bass_reg>20){bass_reg=20;}}
void mid_func(){if(mid_reg<-20){mid_reg=-20;}if(mid_reg>20){mid_reg=20;}}
void treb_func(){if(treb_reg<-20){treb_reg=-20;}if(treb_reg>20){treb_reg=20;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>20){gain0=20;}}  
void enc_err(){if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}}
void vol_func(){if(vol_reg<-79){vol_reg=-79;}if(vol_reg>15){vol_reg=15;}}
void cl(){myOLED.clrScr();ir.value=0;delay(300);}
void audio(){
   tda.setSetup_1(1,2,0); // default (1,2,0)
   tda.setSetup_2(f_sub,0,0,0); 
                   // int sub_f ------ OFF 55Hz 85Hz 120Hz 160Hz = int 0...4
                   // int sub_out ---- LPF Front Rear Prohibition = int 0...3
                   // int level_metr - HOLD REST = int 0..1
                   // int faza ------- 0 180 = int 0...1
   tda.setLoudness_f(f_lon); // 250Hz 400Hz 800Hz Prohibition = int 0...3
   tda.setIn(in_reg); // 0...2
   tda.setIn_gain(gain0,mute); // in_gain -- 0...20 = 0...20 dB, mute -- 0 default 
   tda.setVol(vol_reg); // -79...+15 dB = int -79...15
   tda.setFront_1(gain_lf); // -79...+15 dB = int -79...15
   tda.setFront_2(gain_rf); // -79...+15 dB = int -79...15
   tda.setRear_1(gain_lr); // -79...+15 dB = int -79...15
   tda.setRear_2(gain_rr); // -79...+15 dB = int -79...15
   tda.setSub(gain_sub); // -79...+15 dB = int -79...15
   tda.mix();
   tda.setBass_setup(q_bass,f_bass); // 0.5 1.0 1.5 2.0 --- int 0...3, 60Hz 80Hz 100Hz 120Hz --- int 0...3
   tda.setMiddle_setup(q_mid,f_mid); // 0.75 1.0 1.25 1.5 --- int 0...3, 500Hz 1kHz 1.5kHz 2.5kHz --- int 0...3
   tda.setTreble_setup(q_treb,f_treb); // 0.75 1.25  --- int 0...1, 7.5kHz 10kHz 12.5kHz 15kHz --- int 0...3
   tda.setBass_gain(bass_reg); // --20 ... +20 dB = int -20 ... 20  
   tda.setMiddle_gain(mid_reg); // --20 ... +20 dB = int -20 ... 20
   tda.setTreble_gain(treb_reg); // --20 ... +20 dB = int -20 ... 20   
   tda.setLoudness_gain(gain_lon); // 0 ... 20 dB = int 0 ... 20
  }  

Скетч использует 31760 байт (98%) памяти устройства. Всего доступно 32256 байт.
Глобальные переменные используют 1779 байт (86%) динамической памяти, оставляя 269 байт для локальных переменных. Максимум: 2048 байт.

252

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

Не получается залить скетч в arduino. У меня Arduino Nano на AtMega328 (Old Bootloader).  Если убрать IR управление, скетч должен уменьшиться?

253

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

Прошивать Arduino NANO как UNO

254

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

Я убрал Serial, коды кнопок возьмете из другого скетча

#define ENC_BUTTON       10
#define IN_BUTTON        2
#define SET_BUTTON       3
#define POWER_BUTTON     4
#define STANDBY_OUT     13
#define MUTE_BUTTON      5

#define IR_POWER    0x33B800FF
#define IR_MUTE     0x33B8649B
#define IR_UP       0x33B810EF
#define IR_DW       0x33B8E01F
#define IR_MENU     0x33B820DF
#define IR_INPUT    0x33B8A45B
#define IR_SET      0x33B824DB


#include <Wire.h> 
#include <OLED_I2C.h>           // http://rcl-radio.ru/wp-content/uploads/2022/01/OLED_I2C.zip
#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 <BD37534FV.h>
 BD37534FV tda; 
 OLED  myOLED(SDA, SCL, 8);
 extern uint8_t SmallFont[],BigNumbers[];
 IRrecv irrecv(12); // указываем вывод модуля IR приемника
 Encoder myEnc(9, 8);// DT, CLK
 decode_results ir; 
 long times,oldPosition  = -999,newPosition;
 int menu,vol_reg,in_reg,treb_reg,bass_reg,mid_reg,gain0,gain1,gain2,gain3;
 bool w2,w,www,gr1,gr2,power,mute;
 int f_treb,q_treb,f_mid,q_mid,f_bass,q_bass,set=0,f_sub,f_lon,gain_lon;
 int gain_lf,gain_rf,gain_lr,gain_rr,gain_sub;

void setup(){
  Wire.begin();Wire.setClock(400000L);
  irrecv.enableIRIn();
  myOLED.begin();
  myOLED.setBrightness(100);
  //Serial.begin(9600);
  pinMode(ENC_BUTTON,INPUT);        
  pinMode(IN_BUTTON,INPUT_PULLUP); // КНОПКА INPUT
  pinMode(SET_BUTTON,INPUT_PULLUP); // КНОПКА SET MENU2
  pinMode(MUTE_BUTTON,INPUT_PULLUP);  // КНОПКА MUTE 
  pinMode(STANDBY_OUT,OUTPUT);       // ВЫХОД УПРАВЛЕНИЯ STANDBY
  pinMode(POWER_BUTTON,INPUT_PULLUP); // КНОПКА POWER
 
  MsTimer2::set(3, to_Timer);MsTimer2::start();
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении  
  myOLED.clrScr();
  myOLED.setFont(SmallFont);
  myOLED.print(F("Sound Processors"), CENTER, 10);
  myOLED.print(F("BD37534FV"), CENTER, 30);
  myOLED.update();
  delay(2000);
  vol_reg = EEPROM.read(0)-79;in_reg = EEPROM.read(1);gain1 = EEPROM.read(2);gain2 = EEPROM.read(3);gain3 = EEPROM.read(4);
  treb_reg = EEPROM.read(5)-20;f_treb = EEPROM.read(6);q_treb = EEPROM.read(7);
  mid_reg = EEPROM.read(8)-20;f_mid = EEPROM.read(9);q_mid = EEPROM.read(10);
  bass_reg = EEPROM.read(11)-20;f_bass = EEPROM.read(12);q_bass = EEPROM.read(13);f_sub = EEPROM.read(14);
  f_lon = EEPROM.read(15);gain_lon = EEPROM.read(16);
  gain_lf = EEPROM.read(17)-79;gain_rf = EEPROM.read(18)-79;gain_lr = EEPROM.read(19)-79;gain_rr = EEPROM.read(20)-79;gain_sub = EEPROM.read(21)-79;

  switch(in_reg){
   case 0: gain0 = gain1;break;
   case 1: gain0 = gain2;break;
   case 2: gain0 = gain3;break;
   }
  } 

void to_Timer(){newPosition = myEnc.read()/4;}   

void loop(){
/// IR ////////////////////////////////////////
   if ( irrecv.decode( &ir )) {//Serial.print("0x");Serial.println( ir.value,HEX);
   irrecv.resume();times=millis();w=1;w2=1;}
   if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта 
   
//////// BUTTON //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if((digitalRead(POWER_BUTTON)==LOW || ir.value==IR_POWER)&& power==0){power=1;mute=1;gr1=0;gr2=0;cl();
    myOLED.setFont(SmallFont);myOLED.print(F("POWER OFF"), CENTER, 10);myOLED.update();delay(1500);cl();menu=100;myOLED.setBrightness(0);}
  if((digitalRead(POWER_BUTTON)==LOW || ir.value==IR_POWER)&& power==1){power=0;mute=0;myOLED.setBrightness(100);gr1=0;gr2=0;times=millis();w=1;w2=1;
    myOLED.setFont(SmallFont);myOLED.print(F("POWER ON"), CENTER, 10);myOLED.update();delay(1500);cl();menu=0;}  

if(power==0 && mute==0){  
  if(digitalRead(SET_BUTTON)==LOW || ir.value==IR_SET){set=1;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;
    myOLED.setFont(SmallFont);myOLED.print(F("SETTING MENU"), CENTER, 10);myOLED.update();delay(1500);cl();menu=10;
  }
  if((digitalRead(ENC_BUTTON)==LOW || ir.value==IR_MENU) && set==0){menu++;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;if(menu>3){menu=0;}}
  if((digitalRead(ENC_BUTTON)==LOW || ir.value==IR_MENU) && set==1){menu++;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;if(menu>23){menu=10;}}
  if(digitalRead(IN_BUTTON)==LOW || ir.value==IR_INPUT){in_reg++;menu=5;cl();times=millis();w=1;w2=1;www=1;if(in_reg>2){in_reg=0;}} 
}
if(power==0){
  if((digitalRead(MUTE_BUTTON)==LOW || ir.value==IR_MUTE)&& mute==0){mute=1;gr1=0;gr2=0;cl();
    myOLED.setFont(SmallFont);myOLED.print(F("MUTE"), CENTER, 10);myOLED.update();cl();menu=100;}
  if((digitalRead(MUTE_BUTTON)==LOW  || ir.value==IR_MUTE)&& mute==1){mute=0;gr1=0;gr2=0;times=millis();w=1;w2=1;cl();menu=0;}  
}
if(power==1){digitalWrite(STANDBY_OUT, HIGH);}else{digitalWrite(STANDBY_OUT, LOW);} 
//////// VOLUME //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==0){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();vol_reg=vol_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;vol_func();audio();}

   if(ir.value==IR_UP){vol_reg++;ir_low();vol_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){vol_reg++;ir_low2();vol_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){vol_reg--;ir_low1();vol_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){vol_reg--;ir_low3();vol_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("VOLUME"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(vol_reg+79, 75, 0);
  myOLED.setFont(SmallFont);myOLED.print(F("IN"), LEFT, 10);
  myOLED.printNumI(in_reg+1, 30, 10);myOLED.print(F("GAIN"), LEFT, 20);myOLED.printNumI(gain0, 30, 20);
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);myOLED.print(F("TREBLE"), LEFT, 35);myOLED.printNumI(treb_reg, 75, 35);
  myOLED.setFont(SmallFont);myOLED.print(F("MIDDLE"), LEFT, 45);myOLED.printNumI(mid_reg, 75, 45);
  myOLED.setFont(SmallFont);myOLED.print(F("BASS"), LEFT, 55);myOLED.printNumI(bass_reg, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// TREBLE //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==1){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();treb_reg=treb_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;treb_func();audio();}

   if(ir.value==IR_UP){treb_reg++;ir_low();treb_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){treb_reg++;ir_low2();treb_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){treb_reg--;ir_low1();treb_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){treb_reg--;ir_low3();treb_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("TREBLE"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(treb_reg, 75, 0);
  myOLED.setFont(SmallFont);
  switch(f_treb){
  case 0:myOLED.print(F("F 7.5 kHz"), LEFT, 10);break;
  case 1:myOLED.print(F("F 10  kHz"), LEFT, 10);break;
  case 2:myOLED.print(F("F 12.5kHz"), LEFT, 10);break;
  case 3:myOLED.print(F("F 15  kHz"), LEFT, 10);break;
  }
  myOLED.setFont(SmallFont);
  switch(q_treb){
  case 0: myOLED.print(F("Q 0.75"), LEFT, 20);break;
  case 1: myOLED.print(F("Q 1.25"), LEFT, 20);break;
  }
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);
  myOLED.print(F("MIDDLE"), LEFT, 35);myOLED.printNumI(mid_reg, 75, 35);
  myOLED.print(F("BASS"), LEFT, 45);myOLED.printNumI(bass_reg, 75, 45);
  myOLED.print(F("VOLUME"), LEFT, 55);myOLED.printNumI(vol_reg+79, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// MIDDLE //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==2){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();mid_reg=mid_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;mid_func();audio();}

   if(ir.value==IR_UP){mid_reg++;ir_low();mid_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){mid_reg++;ir_low2();mid_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){mid_reg--;ir_low1();mid_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){mid_reg--;ir_low3();mid_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("MIDDLE"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(mid_reg, 75, 0);
  myOLED.setFont(SmallFont);
  switch(f_mid){
  case 0:myOLED.print(F("F 500 Hz"), LEFT, 10);break;
  case 1:myOLED.print(F("F 1  kHz"), LEFT, 10);break;
  case 2:myOLED.print(F("F 1.5kHz"), LEFT, 10);break;
  case 3:myOLED.print(F("F 2.5kHz"), LEFT, 10);break;
  }
  myOLED.setFont(SmallFont);
  switch(q_mid){
  case 0: myOLED.print(F("Q 0.75"), LEFT, 20);break;
  case 1: myOLED.print(F("Q 1.00"), LEFT, 20);break;
  case 2: myOLED.print(F("Q 1.25"), LEFT, 20);break;
  case 3: myOLED.print(F("Q 1.50"), LEFT, 20);break;
  }
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);
  myOLED.print(F("BASS"), LEFT, 35);myOLED.printNumI(bass_reg, 75, 35);
  myOLED.print(F("VOLUME"), LEFT, 45);myOLED.printNumI(vol_reg+79, 75, 45);
  myOLED.print(F("TERBLE"), LEFT, 55);myOLED.printNumI(treb_reg, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// BASS //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==3){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();bass_reg=bass_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;bass_func();audio();}

   if(ir.value==IR_UP){bass_reg++;ir_low();bass_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){bass_reg++;ir_low2();bass_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){bass_reg--;ir_low1();bass_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){bass_reg--;ir_low3();bass_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("BASS"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(bass_reg, 75, 0);
  myOLED.setFont(SmallFont);
  switch(f_bass){
  case 0:myOLED.print(F("F 60 Hz"), LEFT, 10);break;
  case 1:myOLED.print(F("F 80 Hz"), LEFT, 10);break;
  case 2:myOLED.print(F("F 100kHz"), LEFT, 10);break;
  case 3:myOLED.print(F("F 120kHz"), LEFT, 10);break;
  }
  switch(q_bass){
  case 0: myOLED.print(F("Q 0.50"), LEFT, 20);break;
  case 1: myOLED.print(F("Q 1.00"), LEFT, 20);break;
  case 2: myOLED.print(F("Q 1.50"), LEFT, 20);break;
  case 3: myOLED.print(F("Q 2.00"), LEFT, 20);break;
  }
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);
  myOLED.print(F("VOLUME"), LEFT, 35);myOLED.printNumI(vol_reg+79, 75, 35);
  myOLED.print(F("TREBLE"), LEFT, 45);myOLED.printNumI(treb_reg, 75, 45);
  myOLED.print(F("MIDDLE"), LEFT, 55);myOLED.printNumI(mid_reg, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

////////////// INPUT GAIN ///////////////////////////////////////////////////////////////////
 if(menu==5){
  switch(in_reg){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
   if(ir.value==IR_UP){gain0++;ir_low();gain_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain0++;ir_low2();gain_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain0--;ir_low1();gain_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain0--;ir_low3();gain_func();audio();}// кнопка <<<<<<
 
  if (newPosition != oldPosition){oldPosition = newPosition;enc_err();gain0=gain0+newPosition;myEnc.write(0);newPosition=0;times=millis();www=1;w=1;w2=1;gain_func();}
  switch(in_reg){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     }  
  if(www==1){audio();www=0;}
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("INPUT"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(in_reg+1, 65, 0);
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);myOLED.print(F("GAIN"), LEFT, 35);myOLED.setFont(BigNumbers);myOLED.printNumI(gain0, 65, 35);
  myOLED.update();
  }} 

////////////// SET F_TREB ///////////////////////////////////////////////////////////////////  
if(menu==10){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_treb=f_treb+newPosition;en_low();f_treb_func();audio();}

   if(ir.value==IR_UP){f_treb++;ir_low();f_treb_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_treb--;ir_low1();f_treb_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency TREBLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(f_treb){
  case 0:myOLED.print(F("7.50"), CENTER, 20);break;
  case 1:myOLED.print(F("10.0"), CENTER, 20);break;
  case 2:myOLED.print(F("12.5"), CENTER, 20);break;
  case 3:myOLED.print(F("15.0"), CENTER, 20);break;
  }
  myOLED.setFont(SmallFont);myOLED.print(F("kHz"), CENTER, 50);
  myOLED.update();}
  }
////////////// SET F_MID ///////////////////////////////////////////////////////////////////  
if(menu==11){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_mid=f_mid+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;f_mid_func();audio();}

   if(ir.value==IR_UP){f_mid++;ir_low();f_mid_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_mid--;ir_low1();f_mid_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency MIDDLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(f_mid){
  case 0:myOLED.print(F("0.5"), CENTER, 20);break;
  case 1:myOLED.print(F("1.0"), CENTER, 20);break;
  case 2:myOLED.print(F("1.5"), CENTER, 20);break;
  case 3:myOLED.print(F("2.5"), CENTER, 20);break;
  }
  myOLED.setFont(SmallFont);myOLED.print(F("kHz"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET F_BASS ///////////////////////////////////////////////////////////////////  
if(menu==12){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_bass=f_bass+newPosition;en_low();f_bass_func();audio();}

   if(ir.value==IR_UP){f_bass++;ir_low();f_bass_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_bass--;ir_low1();f_bass_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency BASS"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(f_bass){
  case 0:myOLED.print(F("60"), CENTER, 20);break;
  case 1:myOLED.print(F("80"), CENTER, 20);break;
  case 2:myOLED.print(F("100"), CENTER, 20);break;
  case 3:myOLED.print(F("120"), CENTER, 20);break;
  }
  myOLED.setFont(SmallFont);myOLED.print(F("Hz"), CENTER, 50);
  myOLED.update();}
  }   
////////////// SET F_SUB ///////////////////////////////////////////////////////////////////  
if(menu==13){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_sub=f_sub+newPosition;en_low();f_sub_func();audio();}

   if(ir.value==IR_UP){f_sub++;ir_low();f_sub_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_sub--;ir_low1();f_sub_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency SUBWOOFER"), CENTER, 0);
  switch(f_sub){
  case 0:myOLED.setFont(SmallFont);myOLED.print(F("OFF"), CENTER, 20);break;
  case 1:myOLED.setFont(BigNumbers);myOLED.print(F("55"), CENTER, 20);break;
  case 2:myOLED.setFont(BigNumbers);myOLED.print(F("85"), CENTER, 20);break;
  case 3:myOLED.setFont(BigNumbers);myOLED.print(F("120"), CENTER, 20);break;
  case 4:myOLED.setFont(BigNumbers);myOLED.print(F("160"), CENTER, 20);break;
  }
  if(f_sub>0){myOLED.setFont(SmallFont);myOLED.print(F("Hz"), CENTER, 50);}
  myOLED.update();}
  }   
////////////// SET F_LOUDNESS ///////////////////////////////////////////////////////////////////  
if(menu==14){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_lon=f_lon+newPosition;en_low();f_lon_func();audio();}

  if(ir.value==IR_UP){f_lon++;ir_low();f_lon_func();audio();}// кнопка > 
  if(ir.value==IR_DW){f_lon--;ir_low1();f_lon_func();audio();}// кнопка <

  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency LOUDNESS"), CENTER, 0);
  switch(f_lon){
  case 0:myOLED.setFont(BigNumbers);myOLED.print(F("250"), CENTER, 20);break;
  case 1:myOLED.setFont(BigNumbers);myOLED.print(F("400"), CENTER, 20);break;
  case 2:myOLED.setFont(BigNumbers);myOLED.print(F("800"), CENTER, 20);break;
  case 3:myOLED.setFont(SmallFont);myOLED.print(F("Prohibition"), CENTER, 20);break;
  }
  if(f_lon<3){myOLED.setFont(SmallFont);myOLED.print(F("Hz"), CENTER, 50);}
  myOLED.update();}
  }     
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
////////////// SET Q_TREB ///////////////////////////////////////////////////////////////////  
if(menu==15){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();q_treb=q_treb+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;q_treb_func();audio();}

  if(ir.value==IR_UP){q_treb++;ir_low();q_treb_func();audio();}// кнопка > 
  if(ir.value==IR_DW){q_treb--;ir_low1();q_treb_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Q TREBLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(q_treb){
  case 0: myOLED.print(F("0.75"), CENTER, 20);break;
  case 1: myOLED.print(F("1.25"), CENTER, 20);break;
  }
  myOLED.update();}
  }  
////////////// SET Q_MIDDLE ///////////////////////////////////////////////////////////////////  
if(menu==16){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();q_mid=q_mid+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;q_mid_func();audio();}

  if(ir.value==IR_UP){q_mid++;ir_low();q_mid_func();audio();}// кнопка > 
  if(ir.value==IR_DW){q_mid--;ir_low1();q_mid_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Q MIDDLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(q_mid){
  case 0:myOLED.print(F("0.75"), CENTER, 20);break;
  case 1:myOLED.print(F("1.00"), CENTER, 20);break;
  case 2:myOLED.print(F("1.25"), CENTER, 20);break;
  case 3:myOLED.print(F("1.50"), CENTER, 20);break;
  }
  myOLED.update();}
  }   
////////////// SET Q_BASS ///////////////////////////////////////////////////////////////////  
if(menu==17){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();q_bass=q_bass+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;q_bass_func();audio();}

  if(ir.value==IR_UP){q_bass++;ir_low();q_bass_func();audio();}// кнопка > 
  if(ir.value==IR_DW){q_bass--;ir_low1();q_bass_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Q BASS"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(q_bass){
  case 0: myOLED.print(F("0.50"), CENTER, 20);break;
  case 1: myOLED.print(F("1.00"), CENTER, 20);break;
  case 2: myOLED.print(F("1.50"), CENTER, 20);break;
  case 3: myOLED.print(F("2.00"), CENTER, 20);break;
  }
  myOLED.update();}
  } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////// SET GAIN LOUDNESS ///////////////////////////////////////////////////////////////////  
if(menu==18){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_lon=gain_lon+newPosition;en_low();gain_lon_func();audio();}

   if(ir.value==IR_UP){gain_lon++;ir_low();gain_lon_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_lon++;ir_low2();gain_lon_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_lon--;ir_low1();gain_lon_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_lon--;ir_low3();gain_lon_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN LOUDNESS"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_lon, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }       
////////////// SET GAIN LEFT FRONT ///////////////////////////////////////////////////////////////////  
if(menu==19){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_lf=gain_lf+newPosition;en_low();gain_lf_func();audio();}

   if(ir.value==IR_UP){gain_lf++;ir_low();gain_lf_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_lf++;ir_low2();gain_lf_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_lf--;ir_low1();gain_lf_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_lf--;ir_low3();gain_lf_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN LEFT FRONT"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_lf, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET GAIN RIGHT FRONT ///////////////////////////////////////////////////////////////////  
if(menu==20){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_rf=gain_rf+newPosition;en_low();gain_rf_func();audio();}

   if(ir.value==IR_UP){gain_rf++;ir_low();gain_rf_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_rf++;ir_low2();gain_rf_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_rf--;ir_low1();gain_rf_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_rf--;ir_low3();gain_rf_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN RIGHT FRONT"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_rf, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET GAIN LEFT REAR ///////////////////////////////////////////////////////////////////  
if(menu==21){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_lr=gain_lr+newPosition;en_low();gain_lr_func();audio();}

   if(ir.value==IR_UP){gain_lr++;ir_low();gain_lr_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_lr++;ir_low2();gain_lr_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_lr--;ir_low1();gain_lr_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_lr--;ir_low3();gain_lr_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN LEFT REAR"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_lr, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET GAIN RIGHT REAR ///////////////////////////////////////////////////////////////////  
if(menu==22){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_rr=gain_rr+newPosition;en_low();gain_rr_func();audio();}

   if(ir.value==IR_UP){gain_rr++;ir_low();gain_rr_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_rr++;ir_low2();gain_rr_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_rr--;ir_low1();gain_rr_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_rr--;ir_low3();gain_rr_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN RIGHT REAR"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_rr, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }   
////////////// SET GAIN SUBWOOFER ///////////////////////////////////////////////////////////////////  
if(menu==23){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_sub=gain_sub+newPosition;en_low();gain_sub_func();audio();}

   if(ir.value==IR_UP){gain_sub++;ir_low();gain_sub_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_sub++;ir_low2();gain_sub_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_sub--;ir_low1();gain_sub_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_sub--;ir_low3();gain_sub_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN SUBWOOFER"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_sub, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }     
         

////////////////// EEPROM //////////////////////////////////////////////////////////////
 if(millis()-times>5000 && w2==1 && power==0 && mute==0){
     EEPROM.update(0,vol_reg+79);EEPROM.update(1,in_reg);EEPROM.update(2,gain1);EEPROM.update(3,gain2);EEPROM.update(4,gain3);
     EEPROM.update(5,treb_reg+20);EEPROM.update(6,f_treb);EEPROM.update(7,q_treb);
     EEPROM.update(8,mid_reg+20);EEPROM.update(9,f_mid);EEPROM.update(10,q_mid);
     EEPROM.update(11,bass_reg+20);EEPROM.update(12,f_bass);EEPROM.update(13,q_bass);EEPROM.update(14,f_sub);
     EEPROM.update(15,f_lon);EEPROM.update(16,gain_lon);
     EEPROM.update(17,gain_lf+79);EEPROM.update(18,gain_rf+79);EEPROM.update(19,gain_lr+79);EEPROM.update(20,gain_rr+79);EEPROM.update(21,gain_sub+79);
     cl();set=0;menu=0;w2=0;w=1;}        
} // loop end 

void en_low(){myEnc.write(0);newPosition=0;times=millis();myOLED.clrScr();w=1;w2=1;}
void ir_low3(){gr1=0;cl();times=millis();w=1;w2=1;}
void ir_low2(){gr2=0;cl();times=millis();w=1;w2=1;}
void ir_low1(){gr1=0;gr2=1;cl();times=millis();w=1;w2=1;}
void ir_low(){gr1=1;ir_low2();}
void gain_lf_func(){if(gain_lf<-79){gain_lf=-79;}if(gain_lf>15){gain_lf=15;}}
void gain_rf_func(){if(gain_rf<-79){gain_rf=-79;}if(gain_rf>15){gain_rf=15;}}
void gain_lr_func(){if(gain_lr<-79){gain_lr=-79;}if(gain_lr>15){gain_lr=15;}}
void gain_rr_func(){if(gain_rr<-79){gain_rr=-79;}if(gain_rr>15){gain_rr=15;}}
void gain_sub_func(){if(gain_sub<-79){gain_sub=-79;}if(gain_sub>15){gain_sub=15;}}
void gain_lon_func(){if(gain_lon<0){gain_lon=0;}if(gain_lon>20){gain_lon=20;}}
void f_lon_func(){if(f_lon<0){f_lon=0;}if(f_lon>3){f_lon=3;}}
void f_sub_func(){if(f_sub<0){f_sub=0;}if(f_sub>4){f_sub=4;}}
void f_treb_func(){if(f_treb<0){f_treb=0;}if(f_treb>3){f_treb=3;}}
void f_mid_func(){if(f_mid<0){f_mid=0;}if(f_mid>3){f_mid=3;}}
void f_bass_func(){if(f_bass<0){f_bass=0;}if(f_bass>3){f_bass=3;}}
void q_mid_func(){if(q_mid<0){q_mid=0;}if(q_mid>3){q_mid=3;}}
void q_bass_func(){if(q_bass<0){q_bass=0;}if(q_bass>3){q_bass=3;}}
void q_treb_func(){if(q_treb<0){q_treb=0;}if(q_treb>1){q_treb=1;}}
void bass_func(){if(bass_reg<-20){bass_reg=-20;}if(bass_reg>20){bass_reg=20;}}
void mid_func(){if(mid_reg<-20){mid_reg=-20;}if(mid_reg>20){mid_reg=20;}}
void treb_func(){if(treb_reg<-20){treb_reg=-20;}if(treb_reg>20){treb_reg=20;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>20){gain0=20;}}  
void enc_err(){if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}}
void vol_func(){if(vol_reg<-79){vol_reg=-79;}if(vol_reg>15){vol_reg=15;}}
void cl(){myOLED.clrScr();ir.value=0;delay(300);}
void audio(){
   tda.setSetup_1(1,2,0); // default (1,2,0)
   tda.setSetup_2(f_sub,0,0,0); 
                   // int sub_f ------ OFF 55Hz 85Hz 120Hz 160Hz = int 0...4
                   // int sub_out ---- LPF Front Rear Prohibition = int 0...3
                   // int level_metr - HOLD REST = int 0..1
                   // int faza ------- 0 180 = int 0...1
   tda.setLoudness_f(f_lon); // 250Hz 400Hz 800Hz Prohibition = int 0...3
   tda.setIn(in_reg); // 0...2
   tda.setIn_gain(gain0,mute); // in_gain -- 0...20 = 0...20 dB, mute -- 0 default 
   tda.setVol(vol_reg); // -79...+15 dB = int -79...15
   tda.setFront_1(gain_lf); // -79...+15 dB = int -79...15
   tda.setFront_2(gain_rf); // -79...+15 dB = int -79...15
   tda.setRear_1(gain_lr); // -79...+15 dB = int -79...15
   tda.setRear_2(gain_rr); // -79...+15 dB = int -79...15
   tda.setSub(gain_sub); // -79...+15 dB = int -79...15
   tda.mix();
   tda.setBass_setup(q_bass,f_bass); // 0.5 1.0 1.5 2.0 --- int 0...3, 60Hz 80Hz 100Hz 120Hz --- int 0...3
   tda.setMiddle_setup(q_mid,f_mid); // 0.75 1.0 1.25 1.5 --- int 0...3, 500Hz 1kHz 1.5kHz 2.5kHz --- int 0...3
   tda.setTreble_setup(q_treb,f_treb); // 0.75 1.25  --- int 0...1, 7.5kHz 10kHz 12.5kHz 15kHz --- int 0...3
   tda.setBass_gain(bass_reg); // --20 ... +20 dB = int -20 ... 20  
   tda.setMiddle_gain(mid_reg); // --20 ... +20 dB = int -20 ... 20
   tda.setTreble_gain(treb_reg); // --20 ... +20 dB = int -20 ... 20   
   tda.setLoudness_gain(gain_lon); // 0 ... 20 dB = int 0 ... 20
  }  

Для NANO

Скетч использует 30648 байт (99%) памяти устройства. Всего доступно 30720 байт.
Глобальные переменные используют 1598 байт (78%) динамической памяти, оставляя 450 байт для локальных переменных. Максимум: 2048 байт.

255

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

Циклично переключается Power off, Power on, Mute

256

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

Все кнопки замыкание на GND==нажатие, подтягивающих резисторов не должно стоять.

257

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

Энкодер нужен, на плате энкодера должны быть 3 резистора по 10 кОм (подтягивающие к +5В)

258

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

Да, разобрался. Работает, но нет пункта регулировки faza sub

259

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

видео работы пока без звука. Позже протестирую со звуком

260

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

Основная статья - http://rcl-radio.ru/?p=130653

Добавлено faza sub

#define ENC_BUTTON       10
#define IN_BUTTON        2
#define SET_BUTTON       3
#define POWER_BUTTON     4
#define STANDBY_OUT     13
#define MUTE_BUTTON      5

#define IR_POWER    0x33B800FF
#define IR_MUTE     0x33B8649B
#define IR_UP       0x33B810EF
#define IR_DW       0x33B8E01F
#define IR_MENU     0x33B820DF
#define IR_INPUT    0x33B8A45B
#define IR_SET      0x33B824DB


#include <Wire.h> 
#include <OLED_I2C.h>           // http://rcl-radio.ru/wp-content/uploads/2022/01/OLED_I2C.zip
#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 <BD37534FV.h>
 BD37534FV tda; 
 OLED  myOLED(SDA, SCL, 8);
 extern uint8_t SmallFont[],BigNumbers[];
 IRrecv irrecv(12); // указываем вывод модуля IR приемника
 Encoder myEnc(9, 8);// DT, CLK
 decode_results ir; 
 long times,oldPosition  = -999,newPosition;
 int menu,vol_reg,in_reg,treb_reg,bass_reg,mid_reg,gain0,gain1,gain2,gain3;
 bool w2,w,www,gr1,gr2,power,mute;
 int f_treb,q_treb,f_mid,q_mid,f_bass,q_bass,set=0,f_sub,f_lon,gain_lon;
 int gain_lf,gain_rf,gain_lr,gain_rr,gain_sub,faza_sub;

void setup(){
  Wire.begin();Wire.setClock(400000L);
  irrecv.enableIRIn();
  myOLED.begin();
  myOLED.setBrightness(100);
  //Serial.begin(9600);
  pinMode(ENC_BUTTON,INPUT);        
  pinMode(IN_BUTTON,INPUT_PULLUP); // КНОПКА INPUT
  pinMode(SET_BUTTON,INPUT_PULLUP); // КНОПКА SET MENU2
  pinMode(MUTE_BUTTON,INPUT_PULLUP);  // КНОПКА MUTE 
  pinMode(STANDBY_OUT,OUTPUT);       // ВЫХОД УПРАВЛЕНИЯ STANDBY
  pinMode(POWER_BUTTON,INPUT_PULLUP); // КНОПКА POWER
 
  MsTimer2::set(3, to_Timer);MsTimer2::start();
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении  
  myOLED.clrScr();
  myOLED.setFont(SmallFont);
  myOLED.print(F("Sound Processors"), CENTER, 10);
  myOLED.print(F("BD37534FV"), CENTER, 30);
  myOLED.update();
  delay(2000);
  vol_reg = EEPROM.read(0)-79;in_reg = EEPROM.read(1);gain1 = EEPROM.read(2);gain2 = EEPROM.read(3);gain3 = EEPROM.read(4);
  treb_reg = EEPROM.read(5)-20;f_treb = EEPROM.read(6);q_treb = EEPROM.read(7);
  mid_reg = EEPROM.read(8)-20;f_mid = EEPROM.read(9);q_mid = EEPROM.read(10);
  bass_reg = EEPROM.read(11)-20;f_bass = EEPROM.read(12);q_bass = EEPROM.read(13);f_sub = EEPROM.read(14);
  f_lon = EEPROM.read(15);gain_lon = EEPROM.read(16);
  gain_lf = EEPROM.read(17)-79;gain_rf = EEPROM.read(18)-79;gain_lr = EEPROM.read(19)-79;gain_rr = EEPROM.read(20)-79;gain_sub = EEPROM.read(21)-79;
  faza_sub = EEPROM.read(22);

  switch(in_reg){
   case 0: gain0 = gain1;break;
   case 1: gain0 = gain2;break;
   case 2: gain0 = gain3;break;
   }
  } 

void to_Timer(){newPosition = myEnc.read()/4;}   

void loop(){
/// IR ////////////////////////////////////////
   if ( irrecv.decode( &ir )) {//Serial.print("0x");Serial.println( ir.value,HEX);
   irrecv.resume();times=millis();w=1;w2=1;}
   if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта 
   
//////// BUTTON //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if((digitalRead(POWER_BUTTON)==LOW || ir.value==IR_POWER)&& power==0){power=1;mute=1;gr1=0;gr2=0;cl();
    myOLED.setFont(SmallFont);myOLED.print(F("POWER OFF"), CENTER, 10);myOLED.update();delay(1500);cl();menu=100;myOLED.setBrightness(0);}
  if((digitalRead(POWER_BUTTON)==LOW || ir.value==IR_POWER)&& power==1){power=0;mute=0;myOLED.setBrightness(100);gr1=0;gr2=0;times=millis();w=1;w2=1;
    myOLED.setFont(SmallFont);myOLED.print(F("POWER ON"), CENTER, 10);myOLED.update();delay(1500);cl();menu=0;}  

if(power==0 && mute==0){  
  if(digitalRead(SET_BUTTON)==LOW || ir.value==IR_SET){set=1;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;
    myOLED.setFont(SmallFont);myOLED.print(F("SETTING MENU"), CENTER, 10);myOLED.update();delay(1500);cl();menu=10;
  }
  if((digitalRead(ENC_BUTTON)==LOW || ir.value==IR_MENU) && set==0){menu++;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;if(menu>3){menu=0;}}
  if((digitalRead(ENC_BUTTON)==LOW || ir.value==IR_MENU) && set==1){menu++;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;if(menu>24){menu=10;}}
  if(digitalRead(IN_BUTTON)==LOW || ir.value==IR_INPUT){in_reg++;menu=5;cl();times=millis();w=1;w2=1;www=1;if(in_reg>2){in_reg=0;}} 
}
if(power==0){
  if((digitalRead(MUTE_BUTTON)==LOW || ir.value==IR_MUTE)&& mute==0){mute=1;gr1=0;gr2=0;cl();
    myOLED.setFont(SmallFont);myOLED.print(F("MUTE"), CENTER, 10);myOLED.update();cl();menu=100;}
  if((digitalRead(MUTE_BUTTON)==LOW  || ir.value==IR_MUTE)&& mute==1){mute=0;gr1=0;gr2=0;times=millis();w=1;w2=1;cl();menu=0;}  
}
if(power==1){digitalWrite(STANDBY_OUT, HIGH);}else{digitalWrite(STANDBY_OUT, LOW);} 
//////// VOLUME //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==0){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();vol_reg=vol_reg+newPosition;low_low();vol_func();audio();}

   if(ir.value==IR_UP){vol_reg++;ir_low();vol_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){vol_reg++;ir_low2();vol_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){vol_reg--;ir_low1();vol_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){vol_reg--;ir_low3();vol_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("VOLUME"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(vol_reg+79, 75, 0);
  myOLED.setFont(SmallFont);myOLED.print(F("IN"), LEFT, 10);
  myOLED.printNumI(in_reg+1, 30, 10);myOLED.print(F("GAIN"), LEFT, 20);myOLED.printNumI(gain0, 30, 20);
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);myOLED.print(F("TREBLE"), LEFT, 35);myOLED.printNumI(treb_reg, 75, 35);
  myOLED.setFont(SmallFont);myOLED.print(F("MIDDLE"), LEFT, 45);myOLED.printNumI(mid_reg, 75, 45);
  myOLED.setFont(SmallFont);myOLED.print(F("BASS"), LEFT, 55);myOLED.printNumI(bass_reg, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// TREBLE //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==1){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();treb_reg=treb_reg+newPosition;low_low();treb_func();audio();}

   if(ir.value==IR_UP){treb_reg++;ir_low();treb_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){treb_reg++;ir_low2();treb_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){treb_reg--;ir_low1();treb_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){treb_reg--;ir_low3();treb_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("TREBLE"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(treb_reg, 75, 0);
  myOLED.setFont(SmallFont);
  switch(f_treb){
  case 0:myOLED.print(F("F 7.5 kHz"), LEFT, 10);break;
  case 1:myOLED.print(F("F 10  kHz"), LEFT, 10);break;
  case 2:myOLED.print(F("F 12.5kHz"), LEFT, 10);break;
  case 3:myOLED.print(F("F 15  kHz"), LEFT, 10);break;
  }
  myOLED.setFont(SmallFont);
  switch(q_treb){
  case 0: myOLED.print(F("Q 0.75"), LEFT, 20);break;
  case 1: myOLED.print(F("Q 1.25"), LEFT, 20);break;
  }
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);
  myOLED.print(F("MIDDLE"), LEFT, 35);myOLED.printNumI(mid_reg, 75, 35);
  myOLED.print(F("BASS"), LEFT, 45);myOLED.printNumI(bass_reg, 75, 45);
  myOLED.print(F("VOLUME"), LEFT, 55);myOLED.printNumI(vol_reg+79, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// MIDDLE //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==2){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();mid_reg=mid_reg+newPosition;low_low();mid_func();audio();}

   if(ir.value==IR_UP){mid_reg++;ir_low();mid_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){mid_reg++;ir_low2();mid_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){mid_reg--;ir_low1();mid_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){mid_reg--;ir_low3();mid_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("MIDDLE"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(mid_reg, 75, 0);
  myOLED.setFont(SmallFont);
  switch(f_mid){
  case 0:myOLED.print(F("F 500 Hz"), LEFT, 10);break;
  case 1:myOLED.print(F("F 1  kHz"), LEFT, 10);break;
  case 2:myOLED.print(F("F 1.5kHz"), LEFT, 10);break;
  case 3:myOLED.print(F("F 2.5kHz"), LEFT, 10);break;
  }
  myOLED.setFont(SmallFont);
  switch(q_mid){
  case 0: myOLED.print(F("Q 0.75"), LEFT, 20);break;
  case 1: myOLED.print(F("Q 1.00"), LEFT, 20);break;
  case 2: myOLED.print(F("Q 1.25"), LEFT, 20);break;
  case 3: myOLED.print(F("Q 1.50"), LEFT, 20);break;
  }
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);
  myOLED.print(F("BASS"), LEFT, 35);myOLED.printNumI(bass_reg, 75, 35);
  myOLED.print(F("VOLUME"), LEFT, 45);myOLED.printNumI(vol_reg+79, 75, 45);
  myOLED.print(F("TERBLE"), LEFT, 55);myOLED.printNumI(treb_reg, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// BASS //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==3){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();bass_reg=bass_reg+newPosition;low_low();bass_func();audio();}

   if(ir.value==IR_UP){bass_reg++;ir_low();bass_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){bass_reg++;ir_low2();bass_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){bass_reg--;ir_low1();bass_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){bass_reg--;ir_low3();bass_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("BASS"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(bass_reg, 75, 0);
  myOLED.setFont(SmallFont);
  switch(f_bass){
  case 0:myOLED.print(F("F 60 Hz"), LEFT, 10);break;
  case 1:myOLED.print(F("F 80 Hz"), LEFT, 10);break;
  case 2:myOLED.print(F("F 100kHz"), LEFT, 10);break;
  case 3:myOLED.print(F("F 120kHz"), LEFT, 10);break;
  }
  switch(q_bass){
  case 0: myOLED.print(F("Q 0.50"), LEFT, 20);break;
  case 1: myOLED.print(F("Q 1.00"), LEFT, 20);break;
  case 2: myOLED.print(F("Q 1.50"), LEFT, 20);break;
  case 3: myOLED.print(F("Q 2.00"), LEFT, 20);break;
  }
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);
  myOLED.print(F("VOLUME"), LEFT, 35);myOLED.printNumI(vol_reg+79, 75, 35);
  myOLED.print(F("TREBLE"), LEFT, 45);myOLED.printNumI(treb_reg, 75, 45);
  myOLED.print(F("MIDDLE"), LEFT, 55);myOLED.printNumI(mid_reg, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

////////////// INPUT GAIN ///////////////////////////////////////////////////////////////////
 if(menu==5){
  switch(in_reg){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
   if(ir.value==IR_UP){gain0++;ir_low();gain_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain0++;ir_low2();gain_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain0--;ir_low1();gain_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain0--;ir_low3();gain_func();audio();}// кнопка <<<<<<
 
  if (newPosition != oldPosition){oldPosition = newPosition;enc_err();gain0=gain0+newPosition;myEnc.write(0);newPosition=0;times=millis();www=1;w=1;w2=1;gain_func();}
  switch(in_reg){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     }  
  if(www==1){audio();www=0;}
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("INPUT"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(in_reg+1, 65, 0);
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);myOLED.print(F("GAIN"), LEFT, 35);myOLED.setFont(BigNumbers);myOLED.printNumI(gain0, 65, 35);
  myOLED.update();
  }} 

////////////// SET F_TREB ///////////////////////////////////////////////////////////////////  
if(menu==10){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_treb=f_treb+newPosition;en_low();f_treb_func();audio();}

   if(ir.value==IR_UP){f_treb++;ir_low();f_treb_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_treb--;ir_low1();f_treb_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency TREBLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(f_treb){
  case 0:myOLED.print(F("7.50"), CENTER, 20);break;
  case 1:myOLED.print(F("10.0"), CENTER, 20);break;
  case 2:myOLED.print(F("12.5"), CENTER, 20);break;
  case 3:myOLED.print(F("15.0"), CENTER, 20);break;
  }
  myOLED.setFont(SmallFont);myOLED.print(F("kHz"), CENTER, 50);
  myOLED.update();}
  }
////////////// SET F_MID ///////////////////////////////////////////////////////////////////  
if(menu==11){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_mid=f_mid+newPosition;low_low();f_mid_func();audio();}

   if(ir.value==IR_UP){f_mid++;ir_low();f_mid_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_mid--;ir_low1();f_mid_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency MIDDLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(f_mid){
  case 0:myOLED.print(F("0.5"), CENTER, 20);break;
  case 1:myOLED.print(F("1.0"), CENTER, 20);break;
  case 2:myOLED.print(F("1.5"), CENTER, 20);break;
  case 3:myOLED.print(F("2.5"), CENTER, 20);break;
  }
  myOLED.setFont(SmallFont);myOLED.print(F("kHz"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET F_BASS ///////////////////////////////////////////////////////////////////  
if(menu==12){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_bass=f_bass+newPosition;en_low();f_bass_func();audio();}

   if(ir.value==IR_UP){f_bass++;ir_low();f_bass_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_bass--;ir_low1();f_bass_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency BASS"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(f_bass){
  case 0:myOLED.print(F("60"), CENTER, 20);break;
  case 1:myOLED.print(F("80"), CENTER, 20);break;
  case 2:myOLED.print(F("100"), CENTER, 20);break;
  case 3:myOLED.print(F("120"), CENTER, 20);break;
  }
  myOLED.setFont(SmallFont);myOLED.print(F("Hz"), CENTER, 50);
  myOLED.update();}
  }   
////////////// SET F_SUB ///////////////////////////////////////////////////////////////////  
if(menu==13){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_sub=f_sub+newPosition;en_low();f_sub_func();audio();}

   if(ir.value==IR_UP){f_sub++;ir_low();f_sub_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_sub--;ir_low1();f_sub_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency SUBWOOFER"), CENTER, 0);
  switch(f_sub){
  case 0:myOLED.setFont(SmallFont);myOLED.print(F("OFF"), CENTER, 20);break;
  case 1:myOLED.setFont(BigNumbers);myOLED.print(F("55"), CENTER, 20);break;
  case 2:myOLED.setFont(BigNumbers);myOLED.print(F("85"), CENTER, 20);break;
  case 3:myOLED.setFont(BigNumbers);myOLED.print(F("120"), CENTER, 20);break;
  case 4:myOLED.setFont(BigNumbers);myOLED.print(F("160"), CENTER, 20);break;
  }
  if(f_sub>0){myOLED.setFont(SmallFont);myOLED.print(F("Hz"), CENTER, 50);}
  myOLED.update();}
  }   
////////////// SET F_LOUDNESS ///////////////////////////////////////////////////////////////////  
if(menu==14){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_lon=f_lon+newPosition;en_low();f_lon_func();audio();}

  if(ir.value==IR_UP){f_lon++;ir_low();f_lon_func();audio();}// кнопка > 
  if(ir.value==IR_DW){f_lon--;ir_low1();f_lon_func();audio();}// кнопка <

  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency LOUDNESS"), CENTER, 0);
  switch(f_lon){
  case 0:myOLED.setFont(BigNumbers);myOLED.print(F("250"), CENTER, 20);break;
  case 1:myOLED.setFont(BigNumbers);myOLED.print(F("400"), CENTER, 20);break;
  case 2:myOLED.setFont(BigNumbers);myOLED.print(F("800"), CENTER, 20);break;
  case 3:myOLED.setFont(SmallFont);myOLED.print(F("Prohibition"), CENTER, 20);break;
  }
  if(f_lon<3){myOLED.setFont(SmallFont);myOLED.print(F("Hz"), CENTER, 50);}
  myOLED.update();}
  }     
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
////////////// SET Q_TREB ///////////////////////////////////////////////////////////////////  
if(menu==15){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();q_treb=q_treb+newPosition;low_low();q_treb_func();audio();}

  if(ir.value==IR_UP){q_treb++;ir_low();q_treb_func();audio();}// кнопка > 
  if(ir.value==IR_DW){q_treb--;ir_low1();q_treb_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Q TREBLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(q_treb){
  case 0: myOLED.print(F("0.75"), CENTER, 20);break;
  case 1: myOLED.print(F("1.25"), CENTER, 20);break;
  }
  myOLED.update();}
  }  
////////////// SET Q_MIDDLE ///////////////////////////////////////////////////////////////////  
if(menu==16){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();q_mid=q_mid+newPosition;low_low();q_mid_func();audio();}

  if(ir.value==IR_UP){q_mid++;ir_low();q_mid_func();audio();}// кнопка > 
  if(ir.value==IR_DW){q_mid--;ir_low1();q_mid_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Q MIDDLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(q_mid){
  case 0:myOLED.print(F("0.75"), CENTER, 20);break;
  case 1:myOLED.print(F("1.00"), CENTER, 20);break;
  case 2:myOLED.print(F("1.25"), CENTER, 20);break;
  case 3:myOLED.print(F("1.50"), CENTER, 20);break;
  }
  myOLED.update();}
  }   
////////////// SET Q_BASS ///////////////////////////////////////////////////////////////////  
if(menu==17){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();q_bass=q_bass+newPosition;low_low();q_bass_func();audio();}

  if(ir.value==IR_UP){q_bass++;ir_low();q_bass_func();audio();}// кнопка > 
  if(ir.value==IR_DW){q_bass--;ir_low1();q_bass_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Q BASS"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(q_bass){
  case 0: myOLED.print(F("0.50"), CENTER, 20);break;
  case 1: myOLED.print(F("1.00"), CENTER, 20);break;
  case 2: myOLED.print(F("1.50"), CENTER, 20);break;
  case 3: myOLED.print(F("2.00"), CENTER, 20);break;
  }
  myOLED.update();}
  } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////// SET GAIN LOUDNESS ///////////////////////////////////////////////////////////////////  
if(menu==18){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_lon=gain_lon+newPosition;en_low();gain_lon_func();audio();}

   if(ir.value==IR_UP){gain_lon++;ir_low();gain_lon_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_lon++;ir_low2();gain_lon_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_lon--;ir_low1();gain_lon_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_lon--;ir_low3();gain_lon_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN LOUDNESS"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_lon, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }       
////////////// SET GAIN LEFT FRONT ///////////////////////////////////////////////////////////////////  
if(menu==19){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_lf=gain_lf+newPosition;en_low();gain_lf_func();audio();}

   if(ir.value==IR_UP){gain_lf++;ir_low();gain_lf_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_lf++;ir_low2();gain_lf_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_lf--;ir_low1();gain_lf_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_lf--;ir_low3();gain_lf_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN LEFT FRONT"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_lf, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET GAIN RIGHT FRONT ///////////////////////////////////////////////////////////////////  
if(menu==20){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_rf=gain_rf+newPosition;en_low();gain_rf_func();audio();}

   if(ir.value==IR_UP){gain_rf++;ir_low();gain_rf_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_rf++;ir_low2();gain_rf_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_rf--;ir_low1();gain_rf_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_rf--;ir_low3();gain_rf_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN RIGHT FRONT"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_rf, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET GAIN LEFT REAR ///////////////////////////////////////////////////////////////////  
if(menu==21){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_lr=gain_lr+newPosition;en_low();gain_lr_func();audio();}

   if(ir.value==IR_UP){gain_lr++;ir_low();gain_lr_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_lr++;ir_low2();gain_lr_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_lr--;ir_low1();gain_lr_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_lr--;ir_low3();gain_lr_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN LEFT REAR"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_lr, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET GAIN RIGHT REAR ///////////////////////////////////////////////////////////////////  
if(menu==22){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_rr=gain_rr+newPosition;en_low();gain_rr_func();audio();}

   if(ir.value==IR_UP){gain_rr++;ir_low();gain_rr_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_rr++;ir_low2();gain_rr_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_rr--;ir_low1();gain_rr_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_rr--;ir_low3();gain_rr_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN RIGHT REAR"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_rr, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }   
////////////// SET GAIN SUBWOOFER ///////////////////////////////////////////////////////////////////  
if(menu==23){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_sub=gain_sub+newPosition;en_low();gain_sub_func();audio();}

   if(ir.value==IR_UP){gain_sub++;ir_low();gain_sub_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_sub++;ir_low2();gain_sub_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_sub--;ir_low1();gain_sub_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_sub--;ir_low3();gain_sub_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN SUBWOOFER"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_sub, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }    

////////////// SET FAZA SUBWOOFER ///////////////////////////////////////////////////////////////////  
if(menu==24){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();faza_sub=faza_sub+newPosition;en_low();faza_sub_func();audio();}

   if(ir.value==IR_UP){faza_sub++;ir_low();faza_sub_func();audio();}// кнопка > 
   if(ir.value==IR_DW){faza_sub--;ir_low1();faza_sub_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("PHASE SUBWOOFER"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(faza_sub*180, CENTER, 20);
  myOLED.update();}
  }  
   
         

////////////////// EEPROM //////////////////////////////////////////////////////////////
 if(millis()-times>5000 && w2==1 && power==0 && mute==0){
     EEPROM.update(0,vol_reg+79);EEPROM.update(1,in_reg);EEPROM.update(2,gain1);EEPROM.update(3,gain2);EEPROM.update(4,gain3);
     EEPROM.update(5,treb_reg+20);EEPROM.update(6,f_treb);EEPROM.update(7,q_treb);
     EEPROM.update(8,mid_reg+20);EEPROM.update(9,f_mid);EEPROM.update(10,q_mid);
     EEPROM.update(11,bass_reg+20);EEPROM.update(12,f_bass);EEPROM.update(13,q_bass);EEPROM.update(14,f_sub);
     EEPROM.update(15,f_lon);EEPROM.update(16,gain_lon);
     EEPROM.update(17,gain_lf+79);EEPROM.update(18,gain_rf+79);EEPROM.update(19,gain_lr+79);EEPROM.update(20,gain_rr+79);EEPROM.update(21,gain_sub+79);
     EEPROM.update(22,faza_sub);
     cl();set=0;menu=0;w2=0;w=1;}        
} // loop end 


void low_low(){myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;}
void en_low(){myEnc.write(0);newPosition=0;times=millis();myOLED.clrScr();w=1;w2=1;}
void ir_low3(){gr1=0;cl();times=millis();w=1;w2=1;}
void ir_low2(){gr2=0;cl();times=millis();w=1;w2=1;}
void ir_low1(){gr1=0;gr2=1;cl();times=millis();w=1;w2=1;}
void ir_low(){gr1=1;ir_low2();}
void faza_sub_func(){if(faza_sub<0){faza_sub=1;}if(faza_sub>1){faza_sub=0;}}
void gain_lf_func(){if(gain_lf<-79){gain_lf=-79;}if(gain_lf>15){gain_lf=15;}}
void gain_rf_func(){if(gain_rf<-79){gain_rf=-79;}if(gain_rf>15){gain_rf=15;}}
void gain_lr_func(){if(gain_lr<-79){gain_lr=-79;}if(gain_lr>15){gain_lr=15;}}
void gain_rr_func(){if(gain_rr<-79){gain_rr=-79;}if(gain_rr>15){gain_rr=15;}}
void gain_sub_func(){if(gain_sub<-79){gain_sub=-79;}if(gain_sub>15){gain_sub=15;}}
void gain_lon_func(){if(gain_lon<0){gain_lon=0;}if(gain_lon>20){gain_lon=20;}}
void f_lon_func(){if(f_lon<0){f_lon=0;}if(f_lon>3){f_lon=3;}}
void f_sub_func(){if(f_sub<0){f_sub=0;}if(f_sub>4){f_sub=4;}}
void f_treb_func(){if(f_treb<0){f_treb=0;}if(f_treb>3){f_treb=3;}}
void f_mid_func(){if(f_mid<0){f_mid=0;}if(f_mid>3){f_mid=3;}}
void f_bass_func(){if(f_bass<0){f_bass=0;}if(f_bass>3){f_bass=3;}}
void q_mid_func(){if(q_mid<0){q_mid=0;}if(q_mid>3){q_mid=3;}}
void q_bass_func(){if(q_bass<0){q_bass=0;}if(q_bass>3){q_bass=3;}}
void q_treb_func(){if(q_treb<0){q_treb=0;}if(q_treb>1){q_treb=1;}}
void bass_func(){if(bass_reg<-20){bass_reg=-20;}if(bass_reg>20){bass_reg=20;}}
void mid_func(){if(mid_reg<-20){mid_reg=-20;}if(mid_reg>20){mid_reg=20;}}
void treb_func(){if(treb_reg<-20){treb_reg=-20;}if(treb_reg>20){treb_reg=20;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>20){gain0=20;}}  
void enc_err(){if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}}
void vol_func(){if(vol_reg<-79){vol_reg=-79;}if(vol_reg>15){vol_reg=15;}}
void cl(){myOLED.clrScr();ir.value=0;delay(300);}
void audio(){
   tda.setSetup_1(1,2,0); // default (1,2,0)
   tda.setSetup_2(f_sub,0,0,faza_sub); 
                   // int sub_f ------ OFF 55Hz 85Hz 120Hz 160Hz = int 0...4
                   // int sub_out ---- LPF Front Rear Prohibition = int 0...3
                   // int level_metr - HOLD REST = int 0..1
                   // int faza ------- 0 180 = int 0...1
   tda.setLoudness_f(f_lon); // 250Hz 400Hz 800Hz Prohibition = int 0...3
   tda.setIn(in_reg); // 0...2
   tda.setIn_gain(gain0,mute); // in_gain -- 0...20 = 0...20 dB, mute -- 0 default 
   tda.setVol(vol_reg); // -79...+15 dB = int -79...15
   tda.setFront_1(gain_lf); // -79...+15 dB = int -79...15
   tda.setFront_2(gain_rf); // -79...+15 dB = int -79...15
   tda.setRear_1(gain_lr); // -79...+15 dB = int -79...15
   tda.setRear_2(gain_rr); // -79...+15 dB = int -79...15
   tda.setSub(gain_sub); // -79...+15 dB = int -79...15
   tda.mix();
   tda.setBass_setup(q_bass,f_bass); // 0.5 1.0 1.5 2.0 --- int 0...3, 60Hz 80Hz 100Hz 120Hz --- int 0...3
   tda.setMiddle_setup(q_mid,f_mid); // 0.75 1.0 1.25 1.5 --- int 0...3, 500Hz 1kHz 1.5kHz 2.5kHz --- int 0...3
   tda.setTreble_setup(q_treb,f_treb); // 0.75 1.25  --- int 0...1, 7.5kHz 10kHz 12.5kHz 15kHz --- int 0...3
   tda.setBass_gain(bass_reg); // --20 ... +20 dB = int -20 ... 20  
   tda.setMiddle_gain(mid_reg); // --20 ... +20 dB = int -20 ... 20
   tda.setTreble_gain(treb_reg); // --20 ... +20 dB = int -20 ... 20   
   tda.setLoudness_gain(gain_lon); // 0 ... 20 dB = int 0 ... 20
  }  

261

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

liman324 пишет:

Основная статья - http://rcl-radio.ru/?p=130653

Hi liman324,
I am very new here. Therefore please excuse me if I make a mistake. Would you please check your e-mail including spam folder. Since I have very limited Russian knowledge, I had to write in English.
Best wishes,

Добавлено faza sub

#define ENC_BUTTON       10
#define IN_BUTTON        2
#define SET_BUTTON       3
#define POWER_BUTTON     4
#define STANDBY_OUT     13
#define MUTE_BUTTON      5

#define IR_POWER    0x33B800FF
#define IR_MUTE     0x33B8649B
#define IR_UP       0x33B810EF
#define IR_DW       0x33B8E01F
#define IR_MENU     0x33B820DF
#define IR_INPUT    0x33B8A45B
#define IR_SET      0x33B824DB


#include <Wire.h> 
#include <OLED_I2C.h>           // http://rcl-radio.ru/wp-content/uploads/2022/01/OLED_I2C.zip
#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 <BD37534FV.h>
 BD37534FV tda; 
 OLED  myOLED(SDA, SCL, 8);
 extern uint8_t SmallFont[],BigNumbers[];
 IRrecv irrecv(12); // указываем вывод модуля IR приемника
 Encoder myEnc(9, 8);// DT, CLK
 decode_results ir; 
 long times,oldPosition  = -999,newPosition;
 int menu,vol_reg,in_reg,treb_reg,bass_reg,mid_reg,gain0,gain1,gain2,gain3;
 bool w2,w,www,gr1,gr2,power,mute;
 int f_treb,q_treb,f_mid,q_mid,f_bass,q_bass,set=0,f_sub,f_lon,gain_lon;
 int gain_lf,gain_rf,gain_lr,gain_rr,gain_sub,faza_sub;

void setup(){
  Wire.begin();Wire.setClock(400000L);
  irrecv.enableIRIn();
  myOLED.begin();
  myOLED.setBrightness(100);
  //Serial.begin(9600);
  pinMode(ENC_BUTTON,INPUT);        
  pinMode(IN_BUTTON,INPUT_PULLUP); // КНОПКА INPUT
  pinMode(SET_BUTTON,INPUT_PULLUP); // КНОПКА SET MENU2
  pinMode(MUTE_BUTTON,INPUT_PULLUP);  // КНОПКА MUTE 
  pinMode(STANDBY_OUT,OUTPUT);       // ВЫХОД УПРАВЛЕНИЯ STANDBY
  pinMode(POWER_BUTTON,INPUT_PULLUP); // КНОПКА POWER
 
  MsTimer2::set(3, to_Timer);MsTimer2::start();
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении  
  myOLED.clrScr();
  myOLED.setFont(SmallFont);
  myOLED.print(F("Sound Processors"), CENTER, 10);
  myOLED.print(F("BD37534FV"), CENTER, 30);
  myOLED.update();
  delay(2000);
  vol_reg = EEPROM.read(0)-79;in_reg = EEPROM.read(1);gain1 = EEPROM.read(2);gain2 = EEPROM.read(3);gain3 = EEPROM.read(4);
  treb_reg = EEPROM.read(5)-20;f_treb = EEPROM.read(6);q_treb = EEPROM.read(7);
  mid_reg = EEPROM.read(8)-20;f_mid = EEPROM.read(9);q_mid = EEPROM.read(10);
  bass_reg = EEPROM.read(11)-20;f_bass = EEPROM.read(12);q_bass = EEPROM.read(13);f_sub = EEPROM.read(14);
  f_lon = EEPROM.read(15);gain_lon = EEPROM.read(16);
  gain_lf = EEPROM.read(17)-79;gain_rf = EEPROM.read(18)-79;gain_lr = EEPROM.read(19)-79;gain_rr = EEPROM.read(20)-79;gain_sub = EEPROM.read(21)-79;
  faza_sub = EEPROM.read(22);

  switch(in_reg){
   case 0: gain0 = gain1;break;
   case 1: gain0 = gain2;break;
   case 2: gain0 = gain3;break;
   }
  } 

void to_Timer(){newPosition = myEnc.read()/4;}   

void loop(){
/// IR ////////////////////////////////////////
   if ( irrecv.decode( &ir )) {//Serial.print("0x");Serial.println( ir.value,HEX);
   irrecv.resume();times=millis();w=1;w2=1;}
   if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта 
   
//////// BUTTON //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if((digitalRead(POWER_BUTTON)==LOW || ir.value==IR_POWER)&& power==0){power=1;mute=1;gr1=0;gr2=0;cl();
    myOLED.setFont(SmallFont);myOLED.print(F("POWER OFF"), CENTER, 10);myOLED.update();delay(1500);cl();menu=100;myOLED.setBrightness(0);}
  if((digitalRead(POWER_BUTTON)==LOW || ir.value==IR_POWER)&& power==1){power=0;mute=0;myOLED.setBrightness(100);gr1=0;gr2=0;times=millis();w=1;w2=1;
    myOLED.setFont(SmallFont);myOLED.print(F("POWER ON"), CENTER, 10);myOLED.update();delay(1500);cl();menu=0;}  

if(power==0 && mute==0){  
  if(digitalRead(SET_BUTTON)==LOW || ir.value==IR_SET){set=1;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;
    myOLED.setFont(SmallFont);myOLED.print(F("SETTING MENU"), CENTER, 10);myOLED.update();delay(1500);cl();menu=10;
  }
  if((digitalRead(ENC_BUTTON)==LOW || ir.value==IR_MENU) && set==0){menu++;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;if(menu>3){menu=0;}}
  if((digitalRead(ENC_BUTTON)==LOW || ir.value==IR_MENU) && set==1){menu++;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;if(menu>24){menu=10;}}
  if(digitalRead(IN_BUTTON)==LOW || ir.value==IR_INPUT){in_reg++;menu=5;cl();times=millis();w=1;w2=1;www=1;if(in_reg>2){in_reg=0;}} 
}
if(power==0){
  if((digitalRead(MUTE_BUTTON)==LOW || ir.value==IR_MUTE)&& mute==0){mute=1;gr1=0;gr2=0;cl();
    myOLED.setFont(SmallFont);myOLED.print(F("MUTE"), CENTER, 10);myOLED.update();cl();menu=100;}
  if((digitalRead(MUTE_BUTTON)==LOW  || ir.value==IR_MUTE)&& mute==1){mute=0;gr1=0;gr2=0;times=millis();w=1;w2=1;cl();menu=0;}  
}
if(power==1){digitalWrite(STANDBY_OUT, HIGH);}else{digitalWrite(STANDBY_OUT, LOW);} 
//////// VOLUME //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==0){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();vol_reg=vol_reg+newPosition;low_low();vol_func();audio();}

   if(ir.value==IR_UP){vol_reg++;ir_low();vol_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){vol_reg++;ir_low2();vol_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){vol_reg--;ir_low1();vol_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){vol_reg--;ir_low3();vol_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("VOLUME"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(vol_reg+79, 75, 0);
  myOLED.setFont(SmallFont);myOLED.print(F("IN"), LEFT, 10);
  myOLED.printNumI(in_reg+1, 30, 10);myOLED.print(F("GAIN"), LEFT, 20);myOLED.printNumI(gain0, 30, 20);
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);myOLED.print(F("TREBLE"), LEFT, 35);myOLED.printNumI(treb_reg, 75, 35);
  myOLED.setFont(SmallFont);myOLED.print(F("MIDDLE"), LEFT, 45);myOLED.printNumI(mid_reg, 75, 45);
  myOLED.setFont(SmallFont);myOLED.print(F("BASS"), LEFT, 55);myOLED.printNumI(bass_reg, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// TREBLE //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==1){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();treb_reg=treb_reg+newPosition;low_low();treb_func();audio();}

   if(ir.value==IR_UP){treb_reg++;ir_low();treb_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){treb_reg++;ir_low2();treb_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){treb_reg--;ir_low1();treb_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){treb_reg--;ir_low3();treb_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("TREBLE"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(treb_reg, 75, 0);
  myOLED.setFont(SmallFont);
  switch(f_treb){
  case 0:myOLED.print(F("F 7.5 kHz"), LEFT, 10);break;
  case 1:myOLED.print(F("F 10  kHz"), LEFT, 10);break;
  case 2:myOLED.print(F("F 12.5kHz"), LEFT, 10);break;
  case 3:myOLED.print(F("F 15  kHz"), LEFT, 10);break;
  }
  myOLED.setFont(SmallFont);
  switch(q_treb){
  case 0: myOLED.print(F("Q 0.75"), LEFT, 20);break;
  case 1: myOLED.print(F("Q 1.25"), LEFT, 20);break;
  }
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);
  myOLED.print(F("MIDDLE"), LEFT, 35);myOLED.printNumI(mid_reg, 75, 35);
  myOLED.print(F("BASS"), LEFT, 45);myOLED.printNumI(bass_reg, 75, 45);
  myOLED.print(F("VOLUME"), LEFT, 55);myOLED.printNumI(vol_reg+79, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// MIDDLE //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==2){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();mid_reg=mid_reg+newPosition;low_low();mid_func();audio();}

   if(ir.value==IR_UP){mid_reg++;ir_low();mid_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){mid_reg++;ir_low2();mid_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){mid_reg--;ir_low1();mid_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){mid_reg--;ir_low3();mid_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("MIDDLE"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(mid_reg, 75, 0);
  myOLED.setFont(SmallFont);
  switch(f_mid){
  case 0:myOLED.print(F("F 500 Hz"), LEFT, 10);break;
  case 1:myOLED.print(F("F 1  kHz"), LEFT, 10);break;
  case 2:myOLED.print(F("F 1.5kHz"), LEFT, 10);break;
  case 3:myOLED.print(F("F 2.5kHz"), LEFT, 10);break;
  }
  myOLED.setFont(SmallFont);
  switch(q_mid){
  case 0: myOLED.print(F("Q 0.75"), LEFT, 20);break;
  case 1: myOLED.print(F("Q 1.00"), LEFT, 20);break;
  case 2: myOLED.print(F("Q 1.25"), LEFT, 20);break;
  case 3: myOLED.print(F("Q 1.50"), LEFT, 20);break;
  }
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);
  myOLED.print(F("BASS"), LEFT, 35);myOLED.printNumI(bass_reg, 75, 35);
  myOLED.print(F("VOLUME"), LEFT, 45);myOLED.printNumI(vol_reg+79, 75, 45);
  myOLED.print(F("TERBLE"), LEFT, 55);myOLED.printNumI(treb_reg, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// BASS //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
 if(menu==3){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();bass_reg=bass_reg+newPosition;low_low();bass_func();audio();}

   if(ir.value==IR_UP){bass_reg++;ir_low();bass_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){bass_reg++;ir_low2();bass_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){bass_reg--;ir_low1();bass_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){bass_reg--;ir_low3();bass_func();audio();}// кнопка <<<<<<
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("BASS"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(bass_reg, 75, 0);
  myOLED.setFont(SmallFont);
  switch(f_bass){
  case 0:myOLED.print(F("F 60 Hz"), LEFT, 10);break;
  case 1:myOLED.print(F("F 80 Hz"), LEFT, 10);break;
  case 2:myOLED.print(F("F 100kHz"), LEFT, 10);break;
  case 3:myOLED.print(F("F 120kHz"), LEFT, 10);break;
  }
  switch(q_bass){
  case 0: myOLED.print(F("Q 0.50"), LEFT, 20);break;
  case 1: myOLED.print(F("Q 1.00"), LEFT, 20);break;
  case 2: myOLED.print(F("Q 1.50"), LEFT, 20);break;
  case 3: myOLED.print(F("Q 2.00"), LEFT, 20);break;
  }
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);
  myOLED.print(F("VOLUME"), LEFT, 35);myOLED.printNumI(vol_reg+79, 75, 35);
  myOLED.print(F("TREBLE"), LEFT, 45);myOLED.printNumI(treb_reg, 75, 45);
  myOLED.print(F("MIDDLE"), LEFT, 55);myOLED.printNumI(mid_reg, 75, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

////////////// INPUT GAIN ///////////////////////////////////////////////////////////////////
 if(menu==5){
  switch(in_reg){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
   if(ir.value==IR_UP){gain0++;ir_low();gain_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain0++;ir_low2();gain_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain0--;ir_low1();gain_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain0--;ir_low3();gain_func();audio();}// кнопка <<<<<<
 
  if (newPosition != oldPosition){oldPosition = newPosition;enc_err();gain0=gain0+newPosition;myEnc.write(0);newPosition=0;times=millis();www=1;w=1;w2=1;gain_func();}
  switch(in_reg){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     }  
  if(www==1){audio();www=0;}
 
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);myOLED.print(F("INPUT"), LEFT, 0);myOLED.setFont(BigNumbers);myOLED.printNumI(in_reg+1, 65, 0);
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);myOLED.print(F("GAIN"), LEFT, 35);myOLED.setFont(BigNumbers);myOLED.printNumI(gain0, 65, 35);
  myOLED.update();
  }} 

////////////// SET F_TREB ///////////////////////////////////////////////////////////////////  
if(menu==10){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_treb=f_treb+newPosition;en_low();f_treb_func();audio();}

   if(ir.value==IR_UP){f_treb++;ir_low();f_treb_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_treb--;ir_low1();f_treb_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency TREBLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(f_treb){
  case 0:myOLED.print(F("7.50"), CENTER, 20);break;
  case 1:myOLED.print(F("10.0"), CENTER, 20);break;
  case 2:myOLED.print(F("12.5"), CENTER, 20);break;
  case 3:myOLED.print(F("15.0"), CENTER, 20);break;
  }
  myOLED.setFont(SmallFont);myOLED.print(F("kHz"), CENTER, 50);
  myOLED.update();}
  }
////////////// SET F_MID ///////////////////////////////////////////////////////////////////  
if(menu==11){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_mid=f_mid+newPosition;low_low();f_mid_func();audio();}

   if(ir.value==IR_UP){f_mid++;ir_low();f_mid_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_mid--;ir_low1();f_mid_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency MIDDLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(f_mid){
  case 0:myOLED.print(F("0.5"), CENTER, 20);break;
  case 1:myOLED.print(F("1.0"), CENTER, 20);break;
  case 2:myOLED.print(F("1.5"), CENTER, 20);break;
  case 3:myOLED.print(F("2.5"), CENTER, 20);break;
  }
  myOLED.setFont(SmallFont);myOLED.print(F("kHz"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET F_BASS ///////////////////////////////////////////////////////////////////  
if(menu==12){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_bass=f_bass+newPosition;en_low();f_bass_func();audio();}

   if(ir.value==IR_UP){f_bass++;ir_low();f_bass_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_bass--;ir_low1();f_bass_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency BASS"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(f_bass){
  case 0:myOLED.print(F("60"), CENTER, 20);break;
  case 1:myOLED.print(F("80"), CENTER, 20);break;
  case 2:myOLED.print(F("100"), CENTER, 20);break;
  case 3:myOLED.print(F("120"), CENTER, 20);break;
  }
  myOLED.setFont(SmallFont);myOLED.print(F("Hz"), CENTER, 50);
  myOLED.update();}
  }   
////////////// SET F_SUB ///////////////////////////////////////////////////////////////////  
if(menu==13){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_sub=f_sub+newPosition;en_low();f_sub_func();audio();}

   if(ir.value==IR_UP){f_sub++;ir_low();f_sub_func();audio();}// кнопка > 
   if(ir.value==IR_DW){f_sub--;ir_low1();f_sub_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency SUBWOOFER"), CENTER, 0);
  switch(f_sub){
  case 0:myOLED.setFont(SmallFont);myOLED.print(F("OFF"), CENTER, 20);break;
  case 1:myOLED.setFont(BigNumbers);myOLED.print(F("55"), CENTER, 20);break;
  case 2:myOLED.setFont(BigNumbers);myOLED.print(F("85"), CENTER, 20);break;
  case 3:myOLED.setFont(BigNumbers);myOLED.print(F("120"), CENTER, 20);break;
  case 4:myOLED.setFont(BigNumbers);myOLED.print(F("160"), CENTER, 20);break;
  }
  if(f_sub>0){myOLED.setFont(SmallFont);myOLED.print(F("Hz"), CENTER, 50);}
  myOLED.update();}
  }   
////////////// SET F_LOUDNESS ///////////////////////////////////////////////////////////////////  
if(menu==14){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();f_lon=f_lon+newPosition;en_low();f_lon_func();audio();}

  if(ir.value==IR_UP){f_lon++;ir_low();f_lon_func();audio();}// кнопка > 
  if(ir.value==IR_DW){f_lon--;ir_low1();f_lon_func();audio();}// кнопка <

  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Frequency LOUDNESS"), CENTER, 0);
  switch(f_lon){
  case 0:myOLED.setFont(BigNumbers);myOLED.print(F("250"), CENTER, 20);break;
  case 1:myOLED.setFont(BigNumbers);myOLED.print(F("400"), CENTER, 20);break;
  case 2:myOLED.setFont(BigNumbers);myOLED.print(F("800"), CENTER, 20);break;
  case 3:myOLED.setFont(SmallFont);myOLED.print(F("Prohibition"), CENTER, 20);break;
  }
  if(f_lon<3){myOLED.setFont(SmallFont);myOLED.print(F("Hz"), CENTER, 50);}
  myOLED.update();}
  }     
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
////////////// SET Q_TREB ///////////////////////////////////////////////////////////////////  
if(menu==15){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();q_treb=q_treb+newPosition;low_low();q_treb_func();audio();}

  if(ir.value==IR_UP){q_treb++;ir_low();q_treb_func();audio();}// кнопка > 
  if(ir.value==IR_DW){q_treb--;ir_low1();q_treb_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Q TREBLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(q_treb){
  case 0: myOLED.print(F("0.75"), CENTER, 20);break;
  case 1: myOLED.print(F("1.25"), CENTER, 20);break;
  }
  myOLED.update();}
  }  
////////////// SET Q_MIDDLE ///////////////////////////////////////////////////////////////////  
if(menu==16){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();q_mid=q_mid+newPosition;low_low();q_mid_func();audio();}

  if(ir.value==IR_UP){q_mid++;ir_low();q_mid_func();audio();}// кнопка > 
  if(ir.value==IR_DW){q_mid--;ir_low1();q_mid_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Q MIDDLE"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(q_mid){
  case 0:myOLED.print(F("0.75"), CENTER, 20);break;
  case 1:myOLED.print(F("1.00"), CENTER, 20);break;
  case 2:myOLED.print(F("1.25"), CENTER, 20);break;
  case 3:myOLED.print(F("1.50"), CENTER, 20);break;
  }
  myOLED.update();}
  }   
////////////// SET Q_BASS ///////////////////////////////////////////////////////////////////  
if(menu==17){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();q_bass=q_bass+newPosition;low_low();q_bass_func();audio();}

  if(ir.value==IR_UP){q_bass++;ir_low();q_bass_func();audio();}// кнопка > 
  if(ir.value==IR_DW){q_bass--;ir_low1();q_bass_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("Q BASS"), CENTER, 0);
  myOLED.setFont(BigNumbers);
  switch(q_bass){
  case 0: myOLED.print(F("0.50"), CENTER, 20);break;
  case 1: myOLED.print(F("1.00"), CENTER, 20);break;
  case 2: myOLED.print(F("1.50"), CENTER, 20);break;
  case 3: myOLED.print(F("2.00"), CENTER, 20);break;
  }
  myOLED.update();}
  } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////// SET GAIN LOUDNESS ///////////////////////////////////////////////////////////////////  
if(menu==18){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_lon=gain_lon+newPosition;en_low();gain_lon_func();audio();}

   if(ir.value==IR_UP){gain_lon++;ir_low();gain_lon_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_lon++;ir_low2();gain_lon_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_lon--;ir_low1();gain_lon_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_lon--;ir_low3();gain_lon_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN LOUDNESS"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_lon, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }       
////////////// SET GAIN LEFT FRONT ///////////////////////////////////////////////////////////////////  
if(menu==19){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_lf=gain_lf+newPosition;en_low();gain_lf_func();audio();}

   if(ir.value==IR_UP){gain_lf++;ir_low();gain_lf_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_lf++;ir_low2();gain_lf_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_lf--;ir_low1();gain_lf_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_lf--;ir_low3();gain_lf_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN LEFT FRONT"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_lf, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET GAIN RIGHT FRONT ///////////////////////////////////////////////////////////////////  
if(menu==20){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_rf=gain_rf+newPosition;en_low();gain_rf_func();audio();}

   if(ir.value==IR_UP){gain_rf++;ir_low();gain_rf_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_rf++;ir_low2();gain_rf_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_rf--;ir_low1();gain_rf_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_rf--;ir_low3();gain_rf_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN RIGHT FRONT"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_rf, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET GAIN LEFT REAR ///////////////////////////////////////////////////////////////////  
if(menu==21){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_lr=gain_lr+newPosition;en_low();gain_lr_func();audio();}

   if(ir.value==IR_UP){gain_lr++;ir_low();gain_lr_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_lr++;ir_low2();gain_lr_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_lr--;ir_low1();gain_lr_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_lr--;ir_low3();gain_lr_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN LEFT REAR"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_lr, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }  
////////////// SET GAIN RIGHT REAR ///////////////////////////////////////////////////////////////////  
if(menu==22){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_rr=gain_rr+newPosition;en_low();gain_rr_func();audio();}

   if(ir.value==IR_UP){gain_rr++;ir_low();gain_rr_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_rr++;ir_low2();gain_rr_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_rr--;ir_low1();gain_rr_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_rr--;ir_low3();gain_rr_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN RIGHT REAR"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_rr, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }   
////////////// SET GAIN SUBWOOFER ///////////////////////////////////////////////////////////////////  
if(menu==23){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();gain_sub=gain_sub+newPosition;en_low();gain_sub_func();audio();}

   if(ir.value==IR_UP){gain_sub++;ir_low();gain_sub_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain_sub++;ir_low2();gain_sub_func();audio();}// кнопка >>>>>>
   if(ir.value==IR_DW){gain_sub--;ir_low1();gain_sub_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain_sub--;ir_low3();gain_sub_func();audio();}// кнопка <<<<<<
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("GAIN SUBWOOFER"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(gain_sub, CENTER, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), CENTER, 50);
  myOLED.update();}
  }    

////////////// SET FAZA SUBWOOFER ///////////////////////////////////////////////////////////////////  
if(menu==24){
  if(newPosition != oldPosition){oldPosition = newPosition;enc_err();faza_sub=faza_sub+newPosition;en_low();faza_sub_func();audio();}

   if(ir.value==IR_UP){faza_sub++;ir_low();faza_sub_func();audio();}// кнопка > 
   if(ir.value==IR_DW){faza_sub--;ir_low1();faza_sub_func();audio();}// кнопка <
  
  if(w==1){w=0;
  myOLED.setFont(SmallFont);
  myOLED.print(F("PHASE SUBWOOFER"), CENTER, 0);
  myOLED.setFont(BigNumbers);myOLED.printNumI(faza_sub*180, CENTER, 20);
  myOLED.update();}
  }  
   
         

////////////////// EEPROM //////////////////////////////////////////////////////////////
 if(millis()-times>5000 && w2==1 && power==0 && mute==0){
     EEPROM.update(0,vol_reg+79);EEPROM.update(1,in_reg);EEPROM.update(2,gain1);EEPROM.update(3,gain2);EEPROM.update(4,gain3);
     EEPROM.update(5,treb_reg+20);EEPROM.update(6,f_treb);EEPROM.update(7,q_treb);
     EEPROM.update(8,mid_reg+20);EEPROM.update(9,f_mid);EEPROM.update(10,q_mid);
     EEPROM.update(11,bass_reg+20);EEPROM.update(12,f_bass);EEPROM.update(13,q_bass);EEPROM.update(14,f_sub);
     EEPROM.update(15,f_lon);EEPROM.update(16,gain_lon);
     EEPROM.update(17,gain_lf+79);EEPROM.update(18,gain_rf+79);EEPROM.update(19,gain_lr+79);EEPROM.update(20,gain_rr+79);EEPROM.update(21,gain_sub+79);
     EEPROM.update(22,faza_sub);
     cl();set=0;menu=0;w2=0;w=1;}        
} // loop end 


void low_low(){myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;}
void en_low(){myEnc.write(0);newPosition=0;times=millis();myOLED.clrScr();w=1;w2=1;}
void ir_low3(){gr1=0;cl();times=millis();w=1;w2=1;}
void ir_low2(){gr2=0;cl();times=millis();w=1;w2=1;}
void ir_low1(){gr1=0;gr2=1;cl();times=millis();w=1;w2=1;}
void ir_low(){gr1=1;ir_low2();}
void faza_sub_func(){if(faza_sub<0){faza_sub=1;}if(faza_sub>1){faza_sub=0;}}
void gain_lf_func(){if(gain_lf<-79){gain_lf=-79;}if(gain_lf>15){gain_lf=15;}}
void gain_rf_func(){if(gain_rf<-79){gain_rf=-79;}if(gain_rf>15){gain_rf=15;}}
void gain_lr_func(){if(gain_lr<-79){gain_lr=-79;}if(gain_lr>15){gain_lr=15;}}
void gain_rr_func(){if(gain_rr<-79){gain_rr=-79;}if(gain_rr>15){gain_rr=15;}}
void gain_sub_func(){if(gain_sub<-79){gain_sub=-79;}if(gain_sub>15){gain_sub=15;}}
void gain_lon_func(){if(gain_lon<0){gain_lon=0;}if(gain_lon>20){gain_lon=20;}}
void f_lon_func(){if(f_lon<0){f_lon=0;}if(f_lon>3){f_lon=3;}}
void f_sub_func(){if(f_sub<0){f_sub=0;}if(f_sub>4){f_sub=4;}}
void f_treb_func(){if(f_treb<0){f_treb=0;}if(f_treb>3){f_treb=3;}}
void f_mid_func(){if(f_mid<0){f_mid=0;}if(f_mid>3){f_mid=3;}}
void f_bass_func(){if(f_bass<0){f_bass=0;}if(f_bass>3){f_bass=3;}}
void q_mid_func(){if(q_mid<0){q_mid=0;}if(q_mid>3){q_mid=3;}}
void q_bass_func(){if(q_bass<0){q_bass=0;}if(q_bass>3){q_bass=3;}}
void q_treb_func(){if(q_treb<0){q_treb=0;}if(q_treb>1){q_treb=1;}}
void bass_func(){if(bass_reg<-20){bass_reg=-20;}if(bass_reg>20){bass_reg=20;}}
void mid_func(){if(mid_reg<-20){mid_reg=-20;}if(mid_reg>20){mid_reg=20;}}
void treb_func(){if(treb_reg<-20){treb_reg=-20;}if(treb_reg>20){treb_reg=20;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>20){gain0=20;}}  
void enc_err(){if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}}
void vol_func(){if(vol_reg<-79){vol_reg=-79;}if(vol_reg>15){vol_reg=15;}}
void cl(){myOLED.clrScr();ir.value=0;delay(300);}
void audio(){
   tda.setSetup_1(1,2,0); // default (1,2,0)
   tda.setSetup_2(f_sub,0,0,faza_sub); 
                   // int sub_f ------ OFF 55Hz 85Hz 120Hz 160Hz = int 0...4
                   // int sub_out ---- LPF Front Rear Prohibition = int 0...3
                   // int level_metr - HOLD REST = int 0..1
                   // int faza ------- 0 180 = int 0...1
   tda.setLoudness_f(f_lon); // 250Hz 400Hz 800Hz Prohibition = int 0...3
   tda.setIn(in_reg); // 0...2
   tda.setIn_gain(gain0,mute); // in_gain -- 0...20 = 0...20 dB, mute -- 0 default 
   tda.setVol(vol_reg); // -79...+15 dB = int -79...15
   tda.setFront_1(gain_lf); // -79...+15 dB = int -79...15
   tda.setFront_2(gain_rf); // -79...+15 dB = int -79...15
   tda.setRear_1(gain_lr); // -79...+15 dB = int -79...15
   tda.setRear_2(gain_rr); // -79...+15 dB = int -79...15
   tda.setSub(gain_sub); // -79...+15 dB = int -79...15
   tda.mix();
   tda.setBass_setup(q_bass,f_bass); // 0.5 1.0 1.5 2.0 --- int 0...3, 60Hz 80Hz 100Hz 120Hz --- int 0...3
   tda.setMiddle_setup(q_mid,f_mid); // 0.75 1.0 1.25 1.5 --- int 0...3, 500Hz 1kHz 1.5kHz 2.5kHz --- int 0...3
   tda.setTreble_setup(q_treb,f_treb); // 0.75 1.25  --- int 0...1, 7.5kHz 10kHz 12.5kHz 15kHz --- int 0...3
   tda.setBass_gain(bass_reg); // --20 ... +20 dB = int -20 ... 20  
   tda.setMiddle_gain(mid_reg); // --20 ... +20 dB = int -20 ... 20
   tda.setTreble_gain(treb_reg); // --20 ... +20 dB = int -20 ... 20   
   tda.setLoudness_gain(gain_lon); // 0 ... 20 dB = int 0 ... 20
  }  

262

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

There are no messages

263

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

liman324 пишет:

There are no messages

Check please coming from a gmail account that I have.
Best wishes,
Ferda

264

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

Привет брат как делишки .........для вас это легко а для меня как машину изобретать сделайте это скетц для lcd 2004 с часами

#define  CH_UP  0x2FDF20D
#define  CH_DW  0x2FDF30D
#define  CH     0x2FDF50D
#define  IN     0x2FDF70D
#define  VOL_UP 0x2FDF40D
#define  VOL_DW 0x2FDF80D


#include <Wire.h>
#include <PT2322.h>
#include <PT2323.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <Encoder.h>
#include <MsTimer2.h>
#include <boarddefs.h>
#include <IRremote.h>
 PT2322 pt; PT2323 pt0; 
  Encoder myEnc(9, 8);//CLK, DT подключение энкодера
  IRrecv irrecv(13); // указываем вывод модуля IR приемника
   decode_results ir;
 LiquidCrystal lcd(7, 6, 2, 3, 4, 5);// RS,E,D4,D5,D6,D7 подключение LCD
   byte a1[8]={0b00000,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b00000};
   byte a2[8]={0b00000,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b00000};
   byte a3[8]={0b00000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b00000};
    unsigned long newPosition,time,oldPosition  = -999;
   int menu,menu2,w,vol,vol_d,z,z0,z1,in,bass,bass_d,mid,mid_d,treb,treb_d,attfl,attfl_d,attcn,attcn_d,attsub,attsub_d,ddd,tembro,x,attfr,attfr_d,atttl,atttl_d,atttr,atttr_d,mute;
   int g1,g2,inn;
   
void setup() {
  Wire.begin();Serial.begin(9600);irrecv.enableIRIn(); // запускаем модуль IR
  lcd.begin(16, 2);lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);
  pinMode(A0,INPUT); // menu кнопка энкодера 
  pinMode(12,INPUT); // MUTE
  pinMode(11,INPUT); // IN
  MsTimer2::set(2, to_Timer);MsTimer2::start();
   vol = EEPROM.read(0)-79;in = EEPROM.read(1);bass = EEPROM.read(2)-7;mid = EEPROM.read(3)-7;treb = EEPROM.read(4)-7;
  attfl = EEPROM.read(5)-14;attcn = EEPROM.read(7)-14;attsub = EEPROM.read(8)-14;ddd = EEPROM.read(9);tembro = EEPROM.read(10);
  attfr = EEPROM.read(11)-14;atttl = EEPROM.read(12)-14;atttr = EEPROM.read(13)-14;
  delay(500);
  audio();audio_in();
}
 void to_Timer(){newPosition = myEnc.read()/4;}
 
 void loop(){delay(10);
  if(analogRead(A0)<900){menu++;cl1();myEnc.write(0);time=millis();w=1;if(menu>11){menu=0;}}// меню
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);time=millis();w=1;irrecv.resume();}// IR приемник  
  
   if(ir.value==CH_UP){menu++;g1=0;g2=0;cl1();time=millis();w=1;if(menu>11){menu=0;}}// меню кнопка CH+
   if(ir.value==CH_DW){menu--;g1=0;g2=0;cl1();time=millis();w=1;if(menu<0){menu=11;}}// меню кнопка CH-
   if(ir.value==CH){menu=0;g1=0;g2=0;cl1();time=millis();w=1;}// меню кнопка CH (menu===0)
   if(ir.value==IN){inn=1;g1=0;g2=0;time=millis();w=1;audio();}//  кнопка IN 
 //////////////////////////////////////// Громкость -79...0 дБ //////////////////////////////////////
 if(menu==0){   
     if(ir.value==VOL_UP){vol++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+  0xFFA857
     if(ir.value==0xFFFFFFFF and g1==1){vol++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){vol--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){vol--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
     if(vol>79){vol=79;}if(vol<0){vol=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    vol=vol+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(vol>79){vol=79;}if(vol<0){vol=0;}audio();}
  lcd.setCursor(0,0);lcd.print("Volume  ");
  lcd.print(" ");lcd.print(-79+vol);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");vol_d=vol-32;
   for(z=0,z0=0,z1=0;z<=vol_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0,1);lcd.write((uint8_t)2);}}
 //////////////////////////////////////// Тембр НЧ +-14 дБ //////////////////////////////////////
 if(menu==1){
     if(ir.value==VOL_UP){bass++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+
     if(ir.value==0xFFFFFFFF and g1==1){bass++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){bass--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){bass--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(bass<-7){bass=-7;}if(bass>7){bass=7;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    bass=bass+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(bass<-7){bass=-7;}if(bass>7){bass=7;}audio();}
  lcd.setCursor(0,0);lcd.print("Bass    ");
  lcd.print(" ");lcd.print(bass*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");bass_d=(bass+7)*2;
   for(z=0,z0=0,z1=0;z<=bass_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}   
 //////////////////////////////////////// Тембр CЧ +-14 дБ //////////////////////////////////////
 if(menu==2){
     if(ir.value==VOL_UP){mid++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+
     if(ir.value==0xFFFFFFFF and g1==1){mid++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){mid--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){mid--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(mid<-7){mid=-7;}if(mid>7){mid=7;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    mid=mid+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(mid<-7){mid=-7;}if(mid>7){mid=7;}audio();}
  lcd.setCursor(0,0);lcd.print("Middle  ");
  lcd.print(" ");lcd.print(mid*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");mid_d=(mid+7)*2;
   for(z=0,z0=0,z1=0;z<=mid_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("   ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}} 
 //////////////////////////////////////// Тембр BЧ +-14 дБ //////////////////////////////////////
 if(menu==3){
     if(ir.value==VOL_UP){treb++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+
     if(ir.value==0xFFFFFFFF and g1==1){treb++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){treb--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){treb--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(treb<-7){treb=-7;}if(treb>7){treb=7;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    treb=treb+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(treb<-7){treb=-7;}if(treb>7){treb=7;}audio();}
  lcd.setCursor(0,0);lcd.print("Treble  ");
  lcd.print(" ");lcd.print(treb*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");treb_d=(treb+7)*2;
   for(z=0,z0=0,z1=0;z<=treb_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}    
   //////////////////////////////////// rock pop classic //////////////////////      
  if(menu==4){
     if(ir.value==VOL_UP){tembro++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+
     if(ir.value==0xFFFFFFFF and g1==1){tembro++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){tembro--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){tembro--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
      if(tembro>4){tembro=0;}if(tembro<0){tembro=4;}
     if (newPosition != oldPosition) {
    oldPosition = newPosition;
    tembro=tembro+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(tembro>4){tembro=0;}if(tembro<0){tembro=4;}}
    lcd.setCursor(0,0);lcd.print(" Preset timbre  ");
    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("    CLASSIC    ");bass=0,mid=0;treb=-2;x=1;}
    if(tembro==4){lcd.setCursor(0,1);lcd.print("    default    ");bass=0,mid=0;treb=0;x=1;}
    if(x==1){audio();x=0;}
  }
   
  /////////////////////// ATT FL ///////////////////
   if(menu==5){
     if(ir.value==VOL_UP){attfl++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+
     if(ir.value==0xFFFFFFFF and g1==1){attfl++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){attfl--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){attfl--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(attfl<-14){attfl=-14;}if(attfl>0){attfl=0;}
     
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    attfl=attfl+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attfl<-14){attfl=-14;}if(attfl>0){attfl=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT FL   ");
  lcd.print(" ");lcd.print(attfl);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attfl_d=(attfl+14)*2;
   for(z=0,z0=0,z1=0;z<=attfl_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}  
  /////////////////////// ATT FR ///////////////////
   if(menu==6){
     if(ir.value==VOL_UP){attfr++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+
     if(ir.value==0xFFFFFFFF and g1==1){attfr++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){attfr--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){attfr--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(attfr<-14){attfr=-14;}if(attfr>0){attfr=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    attfr=attfr+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attfr<-14){attfr=-14;}if(attfr>0){attfr=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT FR   ");
  lcd.print(" ");lcd.print(attfr);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attfr_d=(attfr+14)*2;
   for(z=0,z0=0,z1=0;z<=attfr_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}  
  /////////////////////// ATT TL ///////////////////
  if(menu==7){
     if(ir.value==VOL_UP){atttl++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+
     if(ir.value==0xFFFFFFFF and g1==1){atttl++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){atttl--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){atttl--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(atttl<-14){atttl=-14;}if(atttl>0){atttl=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    atttl=atttl+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(atttl<-14){atttl=-14;}if(atttl>0){atttl=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT TL   ");
  lcd.print(" ");lcd.print(atttl);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");atttl_d=(atttl+14)*2;
   for(z=0,z0=0,z1=0;z<=atttl_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}} 
 /////////////////////// ATT TR ///////////////////
  if(menu==8){
     if(ir.value==VOL_UP){atttr++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+
     if(ir.value==0xFFFFFFFF and g1==1){atttr++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){atttr--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){atttr--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(atttr<-14){atttr=-14;}if(atttr>0){atttr=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    atttr=atttr+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(atttr<-14){atttr=-14;}if(atttr>0){atttr=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT TR   ");
  lcd.print(" ");lcd.print(atttr);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");atttr_d=(atttr+14)*2;
   for(z=0,z0=0,z1=0;z<=atttr_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}} 
 /////////////////////// ATT CN ///////////////////
    if(menu==9){
     if(ir.value==VOL_UP){attcn++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+
     if(ir.value==0xFFFFFFFF and g1==1){attcn++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){attcn--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){attcn--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
      if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    attcn=attcn+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT CN   ");
  lcd.print(" ");lcd.print(attcn);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attcn_d=(attcn+14)*2;
   for(z=0,z0=0,z1=0;z<=attcn_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}  
  /////////////////////// ATT SUB ///////////////////
     if(menu==10){
     if(ir.value==VOL_UP){attsub++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+
     if(ir.value==0xFFFFFFFF and g1==1){attsub++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){attsub--;g1=0;g2=1;cl();audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){attsub--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
       if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;time=millis();}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    attsub=attsub+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT SUB  ");
  lcd.print(" ");lcd.print(attsub);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attsub_d=(attsub+14)*2;
   for(z=0,z0=0,z1=0;z<=attsub_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}  
   
  //////////////////////////// 3d ///////////////////////////////////////////////
 if(menu==11){
     if(ir.value==VOL_UP){ddd++;g1=1;g2=0;cl1();time=millis();w=1;audio();}// кнопка VOL+
     if(ir.value==0xFFFFFFFF and g1==1){ddd++;g2=0;cl1();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){ddd--;g1=0;g2=1;cl1();audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){ddd--;g1=0;cl1();time=millis();w=1;audio();}// кнопка <<<<<<
   if(ddd<0){ddd=1;}if(ddd>1){ddd=0;}
   if (newPosition != oldPosition) {
    oldPosition = newPosition;
    ddd=ddd+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(ddd<0){ddd=1;}if(ddd>1){ddd=0;}audio();}
   lcd.setCursor(0,0); if(ddd==0){lcd.print("     3D  ON  ");}else{lcd.print("     3D  OFF  ");} }  
 //////////// mute ////////////////////////
  if(mute==1&&(digitalRead(12)==HIGH)){mute=0;menu=0;audio();cl1();}  
  if(digitalRead(12)==HIGH){mute=1;menu=100;audio();cl1();}
  if(mute==1){lcd.setCursor(0,0);lcd.print("      MUTE      ");delay(300);}
   
   ////////////////////////////////////////////////////////////////////////////////
  if(digitalRead(11)==HIGH||inn==1){in++;if(in>4){in=0;}audio_in();cl1();lcd.setCursor(0,0);lcd.print("    INPUT  ");lcd.print(in+1);delay(2000);time=millis();w=1;inn=0;}// in
   
   if(millis()-time>10000&& w==1&&mute==0){
     EEPROM.update(0,vol+79);EEPROM.update(1,in);EEPROM.update(2,bass+7);EEPROM.update(3,mid+7);EEPROM.update(4,treb+7);
     EEPROM.update(5,attfl+14);EEPROM.update(7,attcn+14);EEPROM.update(8,attsub+14);EEPROM.update(9,ddd);EEPROM.update(10,tembro);
     EEPROM.update(11,attfr+14);EEPROM.update(12,atttl+14);EEPROM.update(13,atttr+14);
     menu=0;w=0;cl();}
 
   
 }//loop
 
 void cl(){ir.value=0;delay(100);}
 void cl1(){ir.value=0;delay(300);lcd.clear();}
 void audio_in(){
  pt0.setInput(in); 
  pt0.setMute(0,0,0,0,0,0,0); 
  pt0.setFeature(1,1); 
}
 void audio(){
  pt.setFront_lk_att(abs(attfl));// att front L
  pt.setFront_rk_att(abs(attfr));// att front R
  pt.setCenter_att(abs(attcn));  // att center
  pt.setRear_lk_att(abs(atttl)); // att rear L
  pt.setRear_rk_att(abs(atttr)); // att rear R
  pt.setSub_att(abs(attsub));     // att sub
  pt.setFunc(mute,ddd,0); // mute,3d,тембр on/off
  pt.setBass(bass);            // BASS    -14...0...14 dB (int -7...0...7)
  pt.setMiddle(mid);          // MIDDLE  -14...0...14 dB (int -7...0...7)
  pt.setTreble(treb);          // TREBLE  -14...0...14 dB (int -7...0...7)
  pt.setVol(abs(vol)); // -79...0
}

265

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

fictionvoyager пишет:
liman324 пишет:

There are no messages

Check please coming from a gmail account that I have.
Best wishes,
Ferda

Hi All,
Here are some of the results from my setup and distortion measurement of the preamplifier section.http://forum.rcl-radio.ru/uploads/images/2023/11/808005f5d9db60afebfe88eeddefcd29.jpg http://forum.rcl-radio.ru/uploads/images/2023/11/d76fe7cf7045cda3c95735ab8d779b53.jpg http://forum.rcl-radio.ru/uploads/images/2023/11/dd30e45de6239a2cacc871f9d5221c94.jpg http://forum.rcl-radio.ru/uploads/images/2023/11/ac9b215bfd0bb1f1559ca1b48ec2442e.jpg

266

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

всём привет
залил прошивку с поста 254 без сериал порта
заметил что при включении на порту 13 ноль  а при выключении,,1
как изменить при включении. "" 1"  выкл "0'

267

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

if(power==1){digitalWrite(STANDBY_OUT, HIGH);}else{digitalWrite(STANDBY_OUT, LOW);}

>>>

if(power==0){digitalWrite(STANDBY_OUT, HIGH);}else{digitalWrite(STANDBY_OUT, LOW);}

268

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

liman324 пишет:

if(power==1){digitalWrite(STANDBY_OUT, HIGH);}else{digitalWrite(STANDBY_OUT, LOW);}

>>>

if(power==0){digitalWrite(STANDBY_OUT, HIGH);}else{digitalWrite(STANDBY_OUT, LOW);}

спасибо большое

269 (2024-01-16 18:52:12 отредактировано romahca)

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

всём доброго дня.
Осмелюсь спросить можно добавить в прошивку с поста 254 без сериал порта
индикатор разряда АКБ. мерить допустим (А1...) через делитель, а выход на порту (  PB1....) мигает допустим редко -11v
                   часто  - 10.6v
      постоянно светится ниже  10.6v

хотя бы просто светится ниже определённого напряжения.
зарание спасибо!!!

270 (2024-06-14 18:09:48 отредактировано lechuk)

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

Немного оживлю тему. Всем привет!
Данный сетап успешно работает в самодельном комбайне с raspberry + volumio. Хотелось бы исключить из цепочки arduino, OLED экран и управлять процессором через raspberry по i2c. Может кто-то сталкивался с такими проектами ?

271

Re: BD37534FV - Sound Processor with Built-in 3-band Equalizer

Доброго дня, может подскажите как залить этот скетч в lgt8f328? в режиме uno в ошибку падает (праграмматор не отвечает) а так места не хватает.