1

Тема: BD37033FV - Sound Processors for Car Audio

BD37033FV-M is sound processors for car audio. The
functions are stereo input selector with single end 3 and
ground isolation input 2, volume, 3-band parametric
equalizer, loudness, 6ch fader volume, LPF for
subwoofer, anti-aliasing-filter, Mixing volume. Moreover,
“Advanced switch circuit”, that is ROHM original
technology, can reduce various switching noise (ex.
No-signal, low frequency likes 20Hz & large signal
inputs). “Advanced switch” makes control of
microcomputer easier, and can construct high quality car
audio system.

Current upon no signal: 31mA(Typ.)
Total harmonic distortion: 0.002%(Typ.)
Maximum input voltage: 2.1Vrms(Typ.)
Cross-talk between selectors: 100dB(Typ.)
Ripple rejection -65dB(Typ.)
Output noise voltage: 5.5µVrms(Typ.)
Residual output noise voltage: 3.5µVrms(Typ.)
Operating Range of Temperature: -40℃ to +85℃


Данный контент доступен только зарегистрированным пользователям.


test.ino

#include <Wire.h> 
#include <BD37033FV.h>
BD37033FV tda; 

void setup(){
   Wire.begin();
   audio();
}

void loop(){}

void audio(){
        tda.setInitial();
        tda.setSub_setup(0,0,0); // off 55hz 85hz 120hz 160hz pass = int sub_f(0...5) || LPF front rear sub = int sub_out(0...3) 0 - default || 0 180 = int faza(0...1)
        tda.setLoud_f(3,0,0,0); // mix_in off || 400hz 800hz 2400hz Prohibition = int loud_f(0...3) || MIXING 1ch 2ch -- on off = mix_ch1(0...1) mix_ch2(0..1)
        tda.setIn(0); // in1 in2 in3 = int in(0...2)
        tda.setIn_gain(0,0); // 0...16 dB = int in_gain(0...16) || off on = int mute(0...1)
        tda.setVol(0); // -79...+15 dB = int vol(-79...15)
        tda.setFront_1(0); // -79...+15 dB = int -79...15
        tda.setFront_2(0); // -79...+15 dB = int -79...15
        tda.setRear_1(0); // -79...+15 dB = int -79...15
        tda.setRear_2(0); // -79...+15 dB = int -79...15
        tda.setSub1(0); // -79...+15 dB = int -79...15
        tda.setSub2(0); // -79...+15 dB = int -79...15
        tda.setBass_setup(0,0); // 0.5 1.0 1.5 2.0 --- int 0...3, 60Hz 80Hz 100Hz 120Hz --- int 0...3
        tda.setMiddle_setup(0,0); // 0.75 1.0 1.25 1.5 --- int 0...3, 500Hz 1kHz 1.5kHz 2.5kHz --- int 0...3
        tda.setTreble_setup(0,0); // 0.75 1.25  --- int 0...1, 7.5kHz 10kHz 12.5kHz 15kHz --- int 0...3
        tda.setBass_gain(0); // --15 ... +15 dB = int -15 ... 15 
        tda.setMiddle_gain(0); // --15 ... +15 dB = int -15 ... 15
        tda.setTreble_gain(0); // --15 ... +20 dB = int -15 ... 15
        tda.setLoudness_gain(0); // 0 ... 15 dB = int 0 ... 15 
  }

Скетч использует 2310 байт (7%) памяти устройства. Всего доступно 32256 байт.
Глобальные переменные используют 219 байт (10%) динамической памяти, оставляя 1829 байт для локальных переменных. Максимум: 2048 байт.

BD37033FV.h

#ifndef BD37033FV_H
#define BD37033FV_H

#define BD37033FV_address 0b1000000 

#define INITIAL_SETUP        0x01
#define LPF_SETUP            0x02
#define MIXING_SETUP         0x03
#define INPUT_SELECT         0x05
#define INPUT_GAIN           0x06
#define VOLUME_GAIN          0x20
#define FADER_1_FRONT        0x28
#define FADER_2_FRONT        0x29
#define FADER_1_REAR         0x2A
#define FADER_2_REAR         0x2B
#define FADER_SUB_1          0x2C
#define FADER_SUB_2          0x30
#define BASS_SETUP           0x41
#define MIDDLE_SETUP         0x44
#define TREBLE_SETUP         0x47
#define BASS_GAIN            0x51
#define MIDDLE_GAIN          0x54
#define TREBLE_GAIN          0x57
#define LOUDNESS_GAIN        0x75

#include <Arduino.h>
class BD37033FV
{
  public:
    BD37033FV();
    void setInitial();
        void setSub_setup(int sub_f,int sub_out, int faza); // off 55hz 85hz 120hz 160hz pass = int sub_f(0...5) || LPF front rear sub = int sub_out(0...3) 0 - default || 0 180 = int faza(0...1)
        void setLoud_f(int mix_in, int loud_f, int mix_ch1, int mix_ch2); // MIX_IN 0...3 3=off || 400hz 800hz 2400hz Prohibition = int loud_f(0...3) || MIXING 1ch 2ch -- on off = mix_ch1(0...1) mix_ch2(0..1)
        void setIn(int in); // in1 in2 in3 = int in(0...2)
        void setIn_gain(int in_gain, int mute); // 0...16 dB = int in_gain(0...16) || off on = int mute(0...1)
        void setVol(int vol); // -79...+15 dB = int vol(-79...15)
        void setFront_1(int front_1); // -79...+15 dB = int -79...15
        void setFront_2(int front_2); // -79...+15 dB = int -79...15
        void setRear_1(int rear_1); // -79...+15 dB = int -79...15
        void setRear_2(int rear_2); // -79...+15 dB = int -79...15
        void setSub1(int sub1); // -79...+15 dB = int -79...15
        void setSub2(int sub2); // -79...+15 dB = int -79...15
        void setBass_setup(int bass_q, int bass_f); // 0.5 1.0 1.5 2.0 --- int 0...3, 60Hz 80Hz 100Hz 120Hz --- int 0...3
        void setMiddle_setup(int mid_q, int mid_f); // 0.75 1.0 1.25 1.5 --- int 0...3, 500Hz 1kHz 1.5kHz 2.5kHz --- int 0...3
        void setTreble_setup(int treb_q, int treb_f); // 0.75 1.25  --- int 0...1, 7.5kHz 10kHz 12.5kHz 15kHz --- int 0...3
        void setBass_gain(int bass_gain); // --15 ... +15 dB = int -15 ... 15    
        void setMiddle_gain(int mid_gain); // --15 ... +15 dB = int -15 ... 15
        void setTreble_gain(int treb_gain); // --15 ... +20 dB = int -15 ... 15
        void setLoudness_gain(int loud_gain); // 0 ... 15 dB = int 0 ... 15    

  private:
    void writeWire(char a, char b);
};
    
#endif //BD37033FV_H

BD37033FV.cpp

#include <Arduino.h>
#include <Wire.h>
#include "BD37033FV.h"

BD37033FV::BD37033FV(){
    Wire.begin();
}

void BD37033FV::setInitial(){
             int initial = 0b00100100;
           writeWire(INITIAL_SETUP, initial); 
   }

void BD37033FV::setSub_setup(int sub_f,int sub_out, int faza){
          switch(sub_f){
             case 0: sub_f = 0b00000000;break;  
             case 1: sub_f = 0b00000001;break; 
             case 2: sub_f = 0b00000010;break; 
             case 3: sub_f = 0b00000011;break; 
             case 4: sub_f = 0b00000100;break; 
             case 5: sub_f = 0b00000101;break;        
   }   
          switch(sub_out){
             case 0: sub_out = 0b00000000;break;  
             case 1: sub_out = 0b00010000;break; 
             case 2: sub_out = 0b00100000;break; 
             case 3: sub_out = 0b00110000;break;
   } 
          switch(faza){
             case 0: faza = 0b00000000;break;
             case 1: faza = 0b10000000;break;
   }
             int sub_set_sum = sub_f + sub_out + faza;
             writeWire(LPF_SETUP, sub_set_sum); 
   }

void BD37033FV::setLoud_f(int mix_in, int loud_f, int mix_ch1, int mix_ch2){
             switch(mix_in){
             case 0: mix_in = 0b00000000;break;  
             case 1: mix_in = 0b01000000;break; 
             case 2: mix_in = 0b10000000;break; 
             case 3: mix_in = 0b11000000;break; 
   }
             switch(loud_f){
             case 0: loud_f = 0b00000000;break;  
             case 1: loud_f = 0b00001000;break; 
             case 2: loud_f = 0b00010000;break; 
             case 3: loud_f = 0b00011000;break;      
   }   
             switch(mix_ch1){
             case 0: mix_ch1 = 0b00000000;break;  
             case 1: mix_ch1 = 0b00000010;break; 
   }
             switch(mix_ch2){
             case 0: mix_ch2 = 0b00000000;break;  
             case 1: mix_ch2 = 0b00000100;break; 
   }     
             int loun_sum = 0b00000001 + loud_f + mix_ch1 + mix_ch2 + mix_in;
             writeWire(MIXING_SETUP, loun_sum); 
   }

void BD37033FV::setIn(int in){
             switch(in){
             case 0: in = 0b00000000;break;  
             case 1: in = 0b00000001;break; 
             case 2: in = 0b00000010;break;      
   }   
             writeWire(INPUT_SELECT, in); 
   }

void BD37033FV::setIn_gain(int in_gain, int mute){
            switch(mute){
               case 0: mute = 0b00000000;break;
               case 1: mute = 0b10000000;break;
   }
            int sum_in_gain = in_gain + mute;
            writeWire(INPUT_GAIN, sum_in_gain); 
   }

void BD37033FV::setVol(int vol){
            if(vol > 0){vol = 128 - vol;}
            if(vol <= 0){vol = abs(vol) + 128;}
            writeWire(VOLUME_GAIN, vol); 
   }

void BD37033FV::setFront_1(int front_1){
            if(front_1 > 0){front_1 = 128 - front_1;}
            if(front_1 <= 0){front_1 = abs(front_1) + 128;}
            
            writeWire(FADER_1_FRONT, front_1); 
   }

void BD37033FV::setFront_2(int front_2){
            if(front_2 > 0){front_2 = 128 - front_2;}
            if(front_2 <= 0){front_2 = abs(front_2) + 128;}
            
            writeWire(FADER_2_FRONT, front_2); 
   }

void BD37033FV::setRear_1(int rear_1){
            if(rear_1 > 0){rear_1 = 128 - rear_1;}
            if(rear_1 <= 0){rear_1 = abs(rear_1) + 128;}
            
            writeWire(FADER_1_REAR, rear_1); 
   }

void BD37033FV::setRear_2(int rear_2){
            if(rear_2 > 0){rear_2 = 128 - rear_2;}
            if(rear_2 <= 0){rear_2 = abs(rear_2) + 128;}
            
            writeWire(FADER_2_REAR, rear_2); 
   }

void BD37033FV::setSub1(int sub1){
            if(sub1 > 0){sub1 = 128 - sub1;}
            if(sub1 <= 0){sub1 = abs(sub1) + 128;}
            
            writeWire(FADER_SUB_1, sub1); 
   }

void BD37033FV::setSub2(int sub2){
            if(sub2 > 0){sub2 = 128 - sub2;}
            if(sub2 <= 0){sub2 = abs(sub2) + 128;}
            
            writeWire(FADER_SUB_2, sub2); 
   }

void BD37033FV::setBass_setup(int bass_q, int bass_f){
            switch(bass_q){
               case 0: bass_q = 0b00000000;break;
               case 1: bass_q = 0b00000001;break;
               case 2: bass_q = 0b00000010;break;
               case 3: bass_q = 0b00000011;break;  
   }
            switch(bass_f){
               case 0: bass_f = 0b00000000;break;
               case 1: bass_f = 0b00010000;break;
               case 2: bass_f = 0b00100000;break;
               case 3: bass_f = 0b00110000;break;  
   }
            int bass_s_sum = bass_q + bass_f;
            writeWire(BASS_SETUP, bass_s_sum); 
   }

void BD37033FV::setMiddle_setup(int mid_q, int mid_f){
            switch(mid_q){
               case 0: mid_q = 0b00000000;break;
               case 1: mid_q = 0b00000001;break;
               case 2: mid_q = 0b00000010;break;
               case 3: mid_q = 0b00000011;break;  
   }
            switch(mid_f){
               case 0: mid_f = 0b00000000;break;
               case 1: mid_f = 0b00010000;break;
               case 2: mid_f = 0b00100000;break;
               case 3: mid_f = 0b00110000;break;  
   }
            int mid_s_sum = mid_q + mid_f;
            writeWire(MIDDLE_SETUP, mid_s_sum); 
   }

void BD37033FV::setTreble_setup(int treb_q, int treb_f){
            switch(treb_q){
               case 0: treb_q = 0b00000000;break;
               case 1: treb_q = 0b00000001;break; 
   }
            switch(treb_f){
               case 0: treb_f = 0b00000000;break;
               case 1: treb_f = 0b00010000;break;
               case 2: treb_f = 0b00100000;break;
               case 3: treb_f = 0b00110000;break;  
   }
            int treb_s_sum = treb_q + treb_f;
            writeWire(TREBLE_SETUP, treb_s_sum); 
   }

void BD37033FV::setBass_gain(int bass_gain){
                 if(bass_gain>0){bass_gain = bass_gain + 0b00000000;}                     
                 if(bass_gain<=0){bass_gain = abs(bass_gain) + 0b10000000;}  
               writeWire(BASS_GAIN, bass_gain);   
   }

void BD37033FV::setMiddle_gain(int mid_gain){
                 if(mid_gain>0){mid_gain = mid_gain + 0b00000000;}                     
                 if(mid_gain<=0){mid_gain = abs(mid_gain) + 0b10000000;}  
               writeWire(MIDDLE_GAIN, mid_gain);   
   }

void BD37033FV::setTreble_gain(int treb_gain){
                 if(treb_gain>0){treb_gain = treb_gain + 0b00000000;}                     
                 if(treb_gain<=0){treb_gain = abs(treb_gain) + 0b10000000;}  
               writeWire(TREBLE_GAIN, treb_gain);   
   }

void BD37033FV::setLoudness_gain(int loud_gain){
               writeWire(LOUDNESS_GAIN, loud_gain);  
   }



void BD37033FV::writeWire(char a, char b){
  Wire.beginTransmission(BD37033FV_address);
  Wire.write (a);
  Wire.write (b);
  Wire.endTransmission();
}

2

Re: BD37033FV - Sound Processors for Car Audio

Протестировано!!!

https://github.com/liman324/BD37033FV

Данный контент доступен только зарегистрированным пользователям.
http://rcl-radio.ru/wp-content/uploads/ … ncoder.zip
http://rcl-radio.ru/wp-content/uploads/ … Timer2.zip
http://rcl-radio.ru/wp-content/uploads/ … remote.zip
http://forum.rcl-radio.ru/misc.php?acti … download=1

#define IR_1 0x2FDD02F // Кнопка вверх
#define IR_2 0x2FD32CD // Кнопка вниз
#define IR_3 0x2FD906F // Кнопка >
#define IR_4 0x2FDF20D // Кнопка <
#define IR_5 0x2FD708F // Кнопка IN
#define IR_6 0x2FD6A95 // Кнопка MUTE
#define IR_7 0x2FD00FF // Кнопка POWER
#define IR_8 0x2FDB24D // Кнопка MENU2

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <BD37033FV.h>
#include <Encoder.h>
#include <EEPROM.h>
#include <MsTimer2.h>
#include <boarddefs.h>
#include <IRremote.h>
  BD37033FV tda; 
  LiquidCrystal_I2C lcd(0x27,16,2);  // Устанавливаем дисплей
  IRrecv irrecv(12); // указываем вывод модуля IR приемника
  Encoder myEnc(9, 8);// DT, CLK
  decode_results ir; 
   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 time,oldPosition  = -999,newPosition;   
   int vol,vol_d,bass,bass_d,middle,middle_d,treb,treb_d,menu,menu2=100,in,gain0,gain1,gain2,gain3,gain_d,lon_f,lon,lon_d;
   int out,vol_out,rf,lf,rt,lt,sab1,sab2,treb_c,mid_c,bas_c,sab_f,treb_q,mid_q,bas_q,faza;
   byte z,z0,z1;
   boolean w,w2,gr1,gr2,power,www,mute;

void setup() {
  irrecv.enableIRIn();lcd.init();lcd.backlight();
  lcd.setCursor(0,0);lcd.print("   BD37033FV   ");delay(2000);
  Serial.begin(9600); lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);
   pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
   pinMode(2,INPUT);   // ВЫБОР ВХОДА КНОПКА IN
   pinMode(3,INPUT);   // КНОПКА MUTE
   pinMode(4,INPUT);   // КНОПКА POWER
   pinMode(7,OUTPUT);  // ВЫХОД STANDBY
   pinMode(5,INPUT);   // КНОПКА MENU2
   MsTimer2::set(3, to_Timer);MsTimer2::start();
   if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении 
   vol = EEPROM.read(0)-79;treb = EEPROM.read(1)-15;middle = EEPROM.read(2)-15;bass = EEPROM.read(3)-15;in = EEPROM.read(4);
   gain1 = EEPROM.read(5);gain2 = EEPROM.read(6);gain3 = EEPROM.read(7);lon = EEPROM.read(8);lon_f = EEPROM.read(9);
   rf = EEPROM.read(10)-79;lf = EEPROM.read(11)-79;rt = EEPROM.read(12)-79;lt = EEPROM.read(13)-79;sab1 = EEPROM.read(14)-79;sab2 = EEPROM.read(24)-79;
   treb_c = EEPROM.read(15);mid_c = EEPROM.read(16);bas_c = EEPROM.read(17);sab_f = EEPROM.read(18);
   treb_q = EEPROM.read(19);mid_q = EEPROM.read(20);bas_q = EEPROM.read(21);faza = EEPROM.read(22);
   cl();audio();}

void loop() {
  if(digitalRead(10)==LOW&&power==0&&menu2==100){menu++;cl();time=millis();w=1;w2=1;if(menu>3){menu=0;}}// меню
  if(digitalRead(2)==HIGH&&power==0&&menu2!=3&&mute==0){in++;;cl();time=millis();w=1;w2=1;www=1;if(in>2){in=0;};lcd.setCursor(0,0);lcd.print("    INPUT ");lcd.print(in+1);audio();delay(2000);}// КНОПКА ВЫБОРА ВХОДА I

  if(digitalRead(3)==HIGH&&mute==0&&power==0){mute=1;cl();w=0;w2=1;lcd.print("      MUTE     ");menu=100;menu2=100;audio();}// mute on
  if(digitalRead(3)==HIGH&&mute==1&&power==0){mute=0;cl();time=millis();w=1;w2=1;menu=0;myEnc.write(0);audio();}// mute off

  if(digitalRead(4)==HIGH&&power==0){power=1;mute=1;audio();lcd.clear();lcd.setCursor(0,0);lcd.print("   POWER OFF   ");w=0;menu=100;menu2=100;delay(3000);lcd.noBacklight();}// power off
  if(digitalRead(4)==HIGH&&power==1){power=0;mute=0;audio();lcd.backlight();lcd.clear();lcd.setCursor(0,0);lcd.print("   POWER  ON   ");menu=0;time=millis();w=1;w2=1;myEnc.write(0);delay(3000);lcd.clear();}// power on
  if(power==0){digitalWrite(7,HIGH);}else{digitalWrite(7,LOW);} // выход STANDBY

  if(digitalRead(5)==HIGH&&power==0&&menu<4){menu2=0;menu=100;cl();time=millis();w=1;w2=1;lcd.setCursor(0,0);lcd.print("     MENU 2   ");delay(2000);}// menu 2 on
  if(digitalRead(5)==HIGH&&power==0&&menu>3){menu2=100;menu=0;cl();time=millis();w=1;w2=1;}// menu2 off
  if(digitalRead(10)==LOW&&power==0&&menu>3){menu2++;cl();time=millis();w=1;w2=1;if(menu2>11){menu2=0;}}// меню 2
   
   ////////////////////// IR /////////////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();time=millis();w=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта
  if(power==0){
  if(ir.value==IR_1&&menu2==100){menu++;gr1=0;gr2=0;cl();time=millis();w=1;w2=1;if(menu>3){menu=0;}}// меню кнопка вверх 
  if(ir.value==IR_2&&menu2==100){menu--;gr1=0;gr2=0;cl();time=millis();w=1;w2=1;if(menu<0){menu=3;}}// меню кнопка вниз
  if(ir.value==IR_1&&menu==100){menu2++;gr1=0;gr2=0;cl();time=millis();w=1;w2=1;if(menu2>11){menu2=0;}}// меню2 кнопка вверх 
  if(ir.value==IR_2&&menu==100){menu2--;gr1=0;gr2=0;cl();time=millis();w=1;w2=1;if(menu2<0){menu2=11;}}// меню2 кнопка вниз

  if(ir.value==IR_5&&power==0&&menu2!=3&&mute==0){in++;gr1=0;gr2=0;cl();time=millis();w=1;w2=1;www=1;if(in>2){in=0;};lcd.setCursor(0,0);lcd.print("    INPUT ");lcd.print(in+1);audio();delay(2000);}// КНОПКА ВЫБОРА ВХОДА IN
    
  if(ir.value==IR_6&&mute==0){mute=1;gr1=0;gr2=0;cl();w=0;w2=1;lcd.print("      MUTE     ");menu=100;menu2=100;audio();}// mute on
  if(ir.value==IR_6&&mute==1){mute=0;gr1=0;gr2=0;cl();time=millis();w=1;w2=1;menu=0;myEnc.write(0);audio();}// mute off

  if(ir.value==IR_8&&menu<4){menu2=0;gr1=0;gr2=0;menu=100;cl();time=millis();w=1;w2=1;lcd.setCursor(0,0);lcd.print("     MENU 2   ");delay(2000);}// menu 2 on
  if(ir.value==IR_8&&menu>3){menu2=100;gr1=0;gr2=0;menu=0;cl();time=millis();w=1;w2=1;}// menu2 off
  }
  if(ir.value==IR_7&&power==0){power=1;mute=1;audio();gr1=0;gr2=0;cl();lcd.setCursor(0,0);lcd.print("   POWER OFF   ");w=0;menu=100;menu2=100;delay(3000);lcd.noBacklight();}// power off
  if(ir.value==IR_7&&power==1){power=0;mute=0;audio();gr1=0;gr2=0;lcd.backlight();cl();lcd.setCursor(0,0);lcd.print("   POWER  ON   ");menu=0;time=millis();w=1;w2=1;myEnc.write(0);delay(3000);lcd.clear();}// power on


  /////////////////////////////// VOLUME -79 ... +15 дБ ////////////////////////////////////////////////
 if(menu==0){
     if(ir.value==IR_3){vol++;gr1=1;gr2=0;cl1();w2=1;vol_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){vol++;gr2=0;cl1();w2=1;vol_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){vol--;gr1=0;gr2=1;cl1();w2=1;vol_func();audio();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){vol--;gr1=0;cl1();w2=1;vol_func();audio();}// кнопка <<<<<<
   
   if (newPosition != oldPosition){oldPosition = newPosition;
     vol=vol+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;vol_func();audio();} 
     lcd.setCursor(0,0);lcd.print("VOLUME  ");
     lcd.print(" ");lcd.print(vol);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");vol_d=vol/2+40;
   if(w2==1){
   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);}w2=0;}}

   ///////////////////////// TREBLE +/-20 dB /////////////////////////////////////////////////////////
   if(menu==1){
     if(ir.value==IR_3){treb++;gr1=1;gr2=0;cl1();w2=1;treb_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){treb++;gr2=0;cl1();w2=1;treb_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){treb--;gr1=0;gr2=1;cl1();w2=1;treb_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){treb--;gr1=0;cl1();w2=1;treb_func();audio();}// кнопка <<<<<<
    
     if (newPosition != oldPosition) {
    oldPosition = newPosition;
    treb=treb+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;treb_func();audio();} 
   lcd.setCursor(0,0);lcd.print("TREBLE  ");
   lcd.print(" ");lcd.print(treb);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");treb_d=treb+15;
   if(w2==1){
   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);}w2=0;}}

   /////////////////////////// MIDDLE +/-20 dB ////////////////////////////////////////////////////////
   if(menu==2){
     if(ir.value==IR_3){middle++;gr1=1;gr2=0;cl1();w2=1;middle_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){middle++;gr2=0;cl1();w2=1;middle_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){middle--;gr1=0;gr2=1;cl1();w2=1;middle_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){middle--;gr1=0;cl1();w2=1;middle_func();audio();}// кнопка <<<<<<
    
     if (newPosition != oldPosition) {
    oldPosition = newPosition;
    middle=middle+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;middle_func();audio();} 
   lcd.setCursor(0,0);lcd.print("MIDDLE  ");
   lcd.print(" ");lcd.print(middle);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");middle_d=middle+15;
   if(w2==1){
   for(z=0,z0=0,z1=0;z<=middle_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);}w2=0;}}

/////////////////////// BASS +/-20 dB ///////////////////////////////////////////////////////////
   if(menu==3){
     if(ir.value==IR_3){bass++;gr1=1;gr2=0;cl1();w2=1;bass_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){bass++;gr2=0;cl1();w2=1;bass_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){bass--;gr1=0;gr2=1;cl1();w2=1;bass_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){bass--;gr1=0;cl1();w2=1;bass_func();audio();}// кнопка <<<<<<  
    
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    bass=bass+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;bass_func();audio();} 
   lcd.setCursor(0,0);lcd.print("BASS    ");
   lcd.print(" ");lcd.print(bass);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");bass_d=bass+15;
   if(w2==1){
   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);}w2=0;}} 


//////////////////////////  MENU 2 //////////////////////////////////////////////////////////////////////

//////////////// IN + GAIN /////////////////////////////////////////////////////////////
   if(menu2==0){ 
       switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();w2=1;gain_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();w2=1;gain_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();w2=1;gain_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();w2=1;gain_func();audio();}// кнопка <<<<<<

    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;gain_func();audio();} 
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     } 
    if(www==1){audio();www=0;}
  lcd.setCursor(0,0);lcd.print("Gain IN ");lcd.print(in+1);
      lcd.setCursor(10,0);lcd.print(" ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(14,0);lcd.print("dB");gain_d=gain0*2;
   if(w2==1){
   for(z=0,z0=0,z1=0;z<=gain_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);}}w2=0;}

 ////////////////////////////// loudness ////////////////////////////////////////////////////
 if(menu2==1){  
     if(ir.value==IR_3){lon_f++;gr1=1;gr2=0;cl1();w2=1;lon_f_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){lon_f++;gr2=0;cl1();w2=1;lon_f_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){lon_f--;gr1=0;gr2=1;cl1();w2=1;lon_f_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){lon_f--;gr1=0;cl1();w2=1;lon_f_func();audio();}// кнопка <<<<<< 
  
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    lon_f=lon_f+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;lon_f_func();audio();} 

    lcd.setCursor(0,0);lcd.print("Loudness: ");
      switch(lon_f){
         case 0: lcd.print("400Hz ");break;
         case 1: lcd.print("800Hz ");break;
         case 2: lcd.print("2.4kHz");break;
         case 3: lcd.print("FLAT  ");break;}}

 //////////////////////////// loudness gain ////////////////////////////////////////////////
 if(menu2==2){
     if(ir.value==IR_3){lon++;gr1=1;gr2=0;cl1();w2=1;lon_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){lon++;gr2=0;cl1();w2=1;lon_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){lon--;gr1=0;gr2=1;cl1();w2=1;lon_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){lon--;gr1=0;cl1();w2=1;lon_func();audio();}// кнопка <<<<<< 
  
      if (newPosition != oldPosition) {
      oldPosition = newPosition;
      lon=lon+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;lon_func();audio();} 

   lcd.setCursor(0,0);lcd.print("Loud gain");
   lcd.print(" ");lcd.print(lon);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");lon_d=lon*2;
   if(w2==1){
   for(z=0,z0=0,z1=0;z<=lon_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);}w2=0;}}

////////////////////////////////////////// out /////////////////////////////////////////////////
 if(menu2==3){  
   if(digitalRead(2)==HIGH){out++;cl();time=millis();www=1;w=1;if(out>5){out=0;}audio();} // перебор выходов кнопкой IN
   if(ir.value==IR_5){out++;cl();time=millis();www=1;w=1;if(out>5){out=0;}audio();} // перебор выходов кнопкой IN
       switch(out){
          case 0:vol_out=rf;break;
          case 1:vol_out=lf;break;
          case 2:vol_out=rt;break;
          case 3:vol_out=lt;break;
          case 4:vol_out=sab1;break;
          case 5:vol_out=sab2;break;
          }

     if(ir.value==IR_3){vol_out++;gr1=1;gr2=0;cl1();w2=1;vol_out_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){vol_out++;gr2=0;cl1();w2=1;vol_out_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){vol_out--;gr1=0;gr2=1;cl1();w2=1;vol_out_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){vol_out--;gr1=0;cl1();w2=1;vol_out_func();audio();}// кнопка <<<<<< 
          
      if (newPosition != oldPosition) {
      oldPosition = newPosition;
      vol_out=vol_out+newPosition;myEnc.write(0);newPosition=0;time=millis();www=1;w=1;w2=1;vol_out_func();audio();} 
      
   lcd.setCursor(0,0);lcd.print("Volume OUT");lcd.setCursor(0,1);
      switch(out){
   case 0:rf=vol_out;lcd.print("RF:  ");lcd.print(rf);break;
   case 1:lf=vol_out;lcd.print("LF:  ");lcd.print(lf);break;
   case 2:rt=vol_out;lcd.print("RT:  ");lcd.print(rt);break;
   case 3:lt=vol_out;lcd.print("LT:  ");lcd.print(lt);break;
   case 4:sab1=vol_out;lcd.print("SUBW_1:  ");lcd.print(sab1);break;
   case 5:sab2=vol_out;lcd.print("SUBW_2:  ");lcd.print(sab2);break;
   }
    if(www==1){audio();www=0;}
  lcd.print(" dB      ");} 

 /////////////////////////////////treble center//////////////////////////////////////////////////
 if(menu2==4){ 
     if(ir.value==IR_3){treb_c++;gr1=1;gr2=0;cl1();w2=1;treb_c_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){treb_c++;gr2=0;cl1();w2=1;treb_c_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){treb_c--;gr1=0;gr2=1;cl1();w2=1;treb_c_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){treb_c--;gr1=0;cl1();w2=1;treb_c_func();audio();}// кнопка <<<<<< 
  
      if (newPosition != oldPosition) {
      oldPosition = newPosition;
      treb_c=treb_c+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;treb_c_func();audio();} 
  
  lcd.setCursor(0,0);lcd.print("Treble Center ");
  lcd.setCursor(1,6);
    switch(treb_c){
      case 0: lcd.print(" 7.5 kHz");break;
      case 1: lcd.print("10.0 kHz");break;
      case 2: lcd.print("12.5 kHz");break;
      case 3: lcd.print("15.0 kHz");break;}}

 /////////////////////////////////middle center//////////////////////////////////////////////////
 if(menu2==5){ 
     if(ir.value==IR_3){mid_c++;gr1=1;gr2=0;cl1();w2=1;mid_c_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){mid_c++;gr2=0;cl1();w2=1;mid_c_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){mid_c--;gr1=0;gr2=1;cl1();w2=1;mid_c_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){mid_c--;gr1=0;cl1();w2=1;mid_c_func();audio();}// кнопка <<<<<<  
     
      if (newPosition != oldPosition) {
      oldPosition = newPosition;
      mid_c=mid_c+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;mid_c_func();audio();}   
    lcd.setCursor(0,0);lcd.print("Middle Center ");
    lcd.setCursor(1,6);
      switch(mid_c){
        case 0: lcd.print("0.5 kHz");break;
        case 1: lcd.print("1.0 kHz");break;
        case 2: lcd.print("1.5 kHz");break;
        case 3: lcd.print("2.5 kHz");break;}} 
        
 ////////////////////////////////////bass center/////////////////////////////////////////// 
 if(menu2==6){ 
     if(ir.value==IR_3){bas_c++;gr1=1;gr2=0;cl1();w2=1;bas_c_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){bas_c++;gr2=0;cl1();w2=1;bas_c_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){bas_c--;gr1=0;gr2=1;cl1();w2=1;bas_c_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){bas_c--;gr1=0;cl1();w2=1;bas_c_func();audio();}// кнопка <<<<<<  
     
      if (newPosition != oldPosition) {
      oldPosition = newPosition;
      bas_c=bas_c+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;bas_c_func();audio();}   
    lcd.setCursor(0,0);lcd.print("Bass Center ");
    lcd.setCursor(1,6);
      switch(bas_c){
         case 0: lcd.print("60 Hz ");break;
         case 1: lcd.print("80 Hz ");break;
         case 2: lcd.print("100 Hz");break;
         case 3: lcd.print("120 Hz");break;}}

 //////////////////////////////////////subw//////////////////////////////////////////////// 
 if(menu2==7){ 
     if(ir.value==IR_3){sab_f++;gr1=1;gr2=0;cl1();w2=1;sab_f_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){sab_f++;gr2=0;cl1();w2=1;sab_f_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){sab_f--;gr1=0;gr2=1;cl1();w2=1;sab_f_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){sab_f--;gr1=0;cl1();w2=1;sab_f_func();audio();}// кнопка <<<<<<  
     
      if (newPosition != oldPosition) {
      oldPosition = newPosition;
      sab_f=sab_f+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;sab_f_func();audio();}   
    lcd.setCursor(0,0);lcd.print("Subwoofer Freq.");
    lcd.setCursor(1,6);
      switch(sab_f){
         case 0: lcd.print("FLAT  ");break;
         case 1: lcd.print("55 Hz ");break;
         case 2: lcd.print("85 Hz ");break;
         case 3: lcd.print("120 Hz");break; 
         case 4: lcd.print("160 Hz");break;}} 

  /////////////////////////////////treble Q//////////////////////////////////////////////////
 if(menu2==8){ 
     if(ir.value==IR_3){treb_q++;gr1=1;gr2=0;cl1();w2=1;treb_q_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){treb_q++;gr2=0;cl1();w2=1;treb_q_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){treb_q--;gr1=0;gr2=1;cl1();w2=1;treb_q_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){treb_q--;gr1=0;cl1();w2=1;treb_q_func();audio();}// кнопка <<<<<< 
  
      if (newPosition != oldPosition) {
      oldPosition = newPosition;
      treb_q=treb_q+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;treb_q_func();audio();} 
  
  lcd.setCursor(0,0);lcd.print("Treble Q ");
  lcd.setCursor(1,6);
    switch(treb_q){
      case 0: lcd.print("0.75");break;
      case 1: lcd.print("1.25");break;}}  

 /////////////////////////////////middle Q//////////////////////////////////////////////////
 if(menu2==9){ 
     if(ir.value==IR_3){mid_q++;gr1=1;gr2=0;cl1();w2=1;mid_q_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){mid_q++;gr2=0;cl1();w2=1;mid_q_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){mid_q--;gr1=0;gr2=1;cl1();w2=1;mid_q_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){mid_q--;gr1=0;cl1();w2=1;mid_q_func();audio();}// кнопка <<<<<<  
     
      if (newPosition != oldPosition) {
      oldPosition = newPosition;
      mid_q=mid_q+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;mid_q_func();audio();}   
    lcd.setCursor(0,0);lcd.print("Middle Q ");
    lcd.setCursor(1,6);
      switch(mid_q){
        case 0: lcd.print("0.75");break;
        case 1: lcd.print("1.00");break;
        case 2: lcd.print("1.25");break;
        case 3: lcd.print("1.50");break;}}    

 /////////////////////////////////bass Q//////////////////////////////////////////////////
 if(menu2==10){ 
     if(ir.value==IR_3){bas_q++;gr1=1;gr2=0;cl1();w2=1;bas_q_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){bas_q++;gr2=0;cl1();w2=1;bas_q_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){bas_q--;gr1=0;gr2=1;cl1();w2=1;bas_q_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){bas_q--;gr1=0;cl1();w2=1;bas_q_func();audio();}// кнопка <<<<<<  
     
      if (newPosition != oldPosition) {
      oldPosition = newPosition;
      bas_q=bas_q+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;bas_q_func();audio();}   
    lcd.setCursor(0,0);lcd.print("Bass Q ");
    lcd.setCursor(1,6);
      switch(bas_q){
        case 0: lcd.print("0.5");break;
        case 1: lcd.print("1.0");break;
        case 2: lcd.print("1.5");break;
        case 3: lcd.print("2.0");break;}}     

  /////////////////////////////////LPF Phase//////////////////////////////////////////////////
 if(menu2==11){ 
     if(ir.value==IR_3){faza++;gr1=1;gr2=0;cl1();w2=1;faza_func();audio();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){faza++;gr2=0;cl1();w2=1;faza_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){faza--;gr1=0;gr2=1;cl1();w2=1;faza_func();audio();}// кнопка < 
     if(ir.value==0xFFFFFFFF and gr2==1){faza--;gr1=0;cl1();w2=1;faza_func();audio();}// кнопка <<<<<<  
     
      if (newPosition != oldPosition) {
      oldPosition = newPosition;
      faza=faza+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;faza_func();audio();}   
    lcd.setCursor(0,0);lcd.print("LPF Phase ");
    lcd.setCursor(1,6);
      switch(faza){
        case 0: lcd.print("  0");break;
        case 1: lcd.print("180");break;}}
  

 ///////////////////// EEPROM ///////////////////////////////////////////////////////////////         
  if(millis()-time>10000 && w==1 && power==0){
     EEPROM.update(0,vol+79);EEPROM.update(1,treb+15);EEPROM.update(2,middle+15);EEPROM.update(3,bass+15);EEPROM.update(4,in);
     EEPROM.update(5,gain1);EEPROM.update(6,gain2);EEPROM.update(7,gain3);
     EEPROM.update(8,lon);EEPROM.update(9,lon_f);
     EEPROM.update(10,rf+79);EEPROM.update(11,lf+79);EEPROM.update(12,rt+79);EEPROM.update(13,lt+79);EEPROM.update(14,sab1+79);EEPROM.update(24,sab2+79);
     EEPROM.update(15,treb_c);EEPROM.update(16,mid_c);EEPROM.update(17,bas_c);EEPROM.update(18,sab_f);EEPROM.update(19,treb_q);
     EEPROM.update(20,mid_q);EEPROM.update(21,bas_q);EEPROM.update(22,faza);
     menu2=100;menu=0;w=0;w2=1;cl();}
  
}//loop

void faza_func(){if(faza>1){faza=0;}if(faza<0){faza=1;}}
void bas_q_func(){if(bas_q>3){bas_q=0;}if(bas_q<0){bas_q=3;}}
void mid_q_func(){if(mid_q>3){mid_q=0;}if(mid_q<0){mid_q=3;}}
void treb_q_func(){if(treb_q>1){treb_q=0;}if(treb_q<0){treb_q=1;}}
void sab_f_func(){if(sab_f>4){sab_f=0;}if(sab_f<0){sab_f=4;}}
void bas_c_func(){if(bas_c>3){bas_c=0;}if(bas_c<0){bas_c=3;}}
void mid_c_func(){if(mid_c>3){mid_c=0;}if(mid_c<0){mid_c=3;}}
void treb_c_func(){if(treb_c>3){treb_c=0;}if(treb_c<0){treb_c=3;}}
void vol_out_func(){if(vol_out>15){vol_out=15;}if(vol_out<-79){vol_out=-79;}}
void lon_func(){if(lon>15){lon=15;}if(lon<0){lon=0;}}
void lon_f_func(){if(lon_f>3){lon_f=0;}if(lon_f<0){lon_f=3;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>16){gain0=16;}}
void bass_func(){if(bass>15){bass=15;}if(bass<-15){bass=-15;}} 
void middle_func(){if(middle>15){middle=15;}if(middle<-15){middle=-15;}}
void treb_func(){if(treb>15){treb=15;}if(treb<-15){treb=-15;}}
void vol_func(){if(vol<-79){vol=-79;}if(vol>15){vol=15;}}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(100);}
void to_Timer(){newPosition = myEnc.read()/4;}

void audio(){
        tda.setInitial();
        tda.setSub_setup(sab_f,3,faza); // off 55hz 85hz 120hz 160hz pass = int sub_f(0...5) || LPF front rear sub = int sub_out(0...3) 0 - default || 0 180 = int faza(0...1)
        tda.setLoud_f(3,lon_f,1,1); // mix_in 0...3 (3=OFF) || 400hz 800hz 2400hz Prohibition = int loud_f(0...3) || MIXING 1ch 2ch -- on off = mix_ch1(0...1) mix_ch2 (0..1)
        tda.setIn(in); // in1 in2 in3 = int in(0...2)
        tda.setIn_gain(gain0,mute); // 0...16 dB = int in_gain(0...16) || off on = int mute(0...1)
        tda.setVol(vol); // -79...+15 dB = int vol(-79...15)
        tda.setFront_1(rf); // -79...+15 dB = int -79...15
        tda.setFront_2(lf); // -79...+15 dB = int -79...15
        tda.setRear_1(rt); // -79...+15 dB = int -79...15
        tda.setRear_2(lt); // -79...+15 dB = int -79...15
        tda.setSub1(sab1); // -79...+15 dB = int -79...15
        tda.setSub2(sab2); // -79...+15 dB = int -79...15
        tda.setBass_setup(bas_q,bas_c); // 0.5 1.0 1.5 2.0 --- int 0...3, 60Hz 80Hz 100Hz 120Hz --- int 0...3
        tda.setMiddle_setup(mid_q,mid_c); // 0.75 1.0 1.25 1.5 --- int 0...3, 500Hz 1kHz 1.5kHz 2.5kHz --- int 0...3
        tda.setTreble_setup(treb_q,treb_c); // 0.75 1.25  --- int 0...1, 7.5kHz 10kHz 12.5kHz 15kHz --- int 0...3
        tda.setBass_gain(bass); // --15 ... +15 dB = int -15 ... 15 
        tda.setMiddle_gain(middle); // --15 ... +15 dB = int -15 ... 15
        tda.setTreble_gain(treb); // --15 ... +15 dB = int -15 ... 15
        tda.setLoudness_gain(lon); // 0 ... 15 dB = int 0 ... 15 
  }

Re: BD37033FV - Sound Processors for Car Audio

хорошая работа .СПАСИБО! вопрос ,по теме цифрового шума,как победить ? как я понял вся проблема кроется в земле,если  не затруднит подскажите как правильно подключить,если можно в схеме,при увеличении громкости до верхнего предела,без сигнала,шум сильный соседей можно разбудить. до этого блока стояла тда 7419 без i2c lcd.шумов не было ,попробовал 7419. icd i2c тоже появился шум

4

Re: BD37033FV - Sound Processors for Car Audio

Посмотрите этот пост - http://forum.rcl-radio.ru/viewtopic.php?pid=1563#p1563
Возможно у Вас аналогичная проблема.

Re: BD37033FV - Sound Processors for Car Audio

Здравствуйте, собрал работает , вопрос такой, при включении и выключении питания , настройка усиления, Gain как бы сбивается, добравшись до этого пункта меню2 изменив значения звук становится громче, в какой строке кода нужно сделать изменения? Чтоб всё равномерно было,

6

Re: BD37033FV - Sound Processors for Car Audio

В void setup() перед audio(); добавьте следующий код:

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

Re: BD37033FV - Sound Processors for Car Audio

Я наверное не правильно объяснил, вы мне указали место исправления, когда я до него добрался, увидел 100% совпадение.Попробую ещё раз, дохожу пункт меню 2, звук тихий, если я изменю на единицу или+или-, звук становица громче в три раза. После отключения питания всё повторяется.

Re: BD37033FV - Sound Processors for Car Audio

Свист при увеличении громкости , оказалось наводка , от модуля дисплея pcf8574, причём свист такой , как будто работает генератор, а он работает, можно снизить чистоту, в какой строчке, можно посмотреть ,? Возможно убрать модуль pcf?

9

Re: BD37033FV - Sound Processors for Car Audio

Замените:

//////////////// IN + GAIN /////////////////////////////////////////////////////////////
   if(menu2==0){
       switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();w2=1;gain_func();audio();}// кнопка >
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();w2=1;gain_func();audio();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();w2=1;gain_func();audio();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();w2=1;gain_func();audio();}// кнопка <<<<<<

    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;gain_func();audio();}
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     }
    if(www==1){audio();www=0;}
  lcd.setCursor(0,0);lcd.print("Gain IN ");lcd.print(in+1);
      lcd.setCursor(10,0);lcd.print(" ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(14,0);lcd.print("dB");gain_d=gain0*2;
   if(w2==1){
   for(z=0,z0=0,z1=0;z<=gain_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);}}w2=0;}

на

//////////////// IN + GAIN /////////////////////////////////////////////////////////////
   if(menu2==0){
       switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();w2=1;gain_func();www=1;audio();}// кнопка >
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();w2=1;gain_func();www=1;audio();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();w2=1;gain_func();www=1;audio();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();w2=1;gain_func();www=1;audio();}// кнопка <<<<<<

    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;gain_func();www=1;audio();}
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     }
    if(www==1){audio();www=0;}
  lcd.setCursor(0,0);lcd.print("Gain IN ");lcd.print(in+1);
      lcd.setCursor(10,0);lcd.print(" ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(14,0);lcd.print("dB");gain_d=gain0*2;
   if(w2==1){
   for(z=0,z0=0,z1=0;z<=gain_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);}}w2=0;}

10

Re: BD37033FV - Sound Processors for Car Audio

Здраствуйте! Собрал проект на макетной плате но сразу после прошивки ардуини глюк-  режими на екране меняются по кругу, думал кнопка енкодера, подтянул к земле, не помогло, всю периферию отключал (енкодер ,датчик IR, кнопки) , аналогично. Енкодер работает, громкость на екране увеличивается.
Не пойму в чем проблема, может подскажете? Спасибо!
Видео тут

11

Re: BD37033FV - Sound Processors for Car Audio

Кнопка энкодера инверсная, при нажатой кнопке энкодера 0В, при отпущенной 5В. У Вас на выходе SW 0В, значит кнопка нажата. Проверьте подключение энкодера, наличие на плате энкодера 3-х подтягивающих резисторов к +5В .

12 (2021-05-23 16:40:11 отредактировано romanlylyk85)

Re: BD37033FV - Sound Processors for Car Audio

Спасибо огромное! Да подтянул  резистором к +5вольт (на плате енкодера запаял а то сэкономили на нем), теперь  все нормально. Тестирую дальше.

13

Re: BD37033FV - Sound Processors for Car Audio

Здраствуйте! А такой вопрос, переделать под другой дисплей сложно ?
OLED SSD1306128X64  I2C, работает с библиотекой  OLED_I2C.
Спасибо!

14

Re: BD37033FV - Sound Processors for Car Audio

У меня нет такого экрана.

15

Re: BD37033FV - Sound Processors for Car Audio

Понятно, 1602 не влезает по габаритам, а сам переделку и за месяц не осилю.

16

Re: BD37033FV - Sound Processors for Car Audio

Уважаемый liman324, смотрю у вас уже несколько проектов на OLED 1306, очень попрошу если несложно будет переписать под этот дисплей скетч roll. Там даже к комментариях просили под этот дисплей переделать.
Ну очень надо! Спасибо!

17

Re: BD37033FV - Sound Processors for Car Audio

Я могу переписать скетч по типу - http://rcl-radio.ru/?p=120519
Но Вам придется выполнить полное тестирование, так как у меня нет сейчас такого аудиопроцессора, я могу протестировать только экран и управление.

18 (2022-04-03 23:33:20 отредактировано romanlylyk85)

Re: BD37033FV - Sound Processors for Car Audio

Да как угодно на Ваше усмотрения,1602 ну просто огромен и никуда не лезет.
Потестить без проблем, все собрано вместе с усилителями на tpa3251, но пока не в корпусе.
Спасибо большое, что откликнулись!

19 (2022-04-03 17:22:30 отредактировано romanlylyk85)

Re: BD37033FV - Sound Processors for Car Audio

Если кому надо, то в архиве полностью проект для Kicad.

http://forum.rcl-radio.ru/uploads/images/2022/04/f5cf7c670b523025349c4a50f9e86991.png

Данный контент доступен только зарегистрированным пользователям.

20

Re: BD37033FV - Sound Processors for Car Audio

Скетч готов, нужно протестировать как на управление будет реагировать аудиопроцессор
После заливки скетча нужно пройти все меню и установить корректные значения.

Управление состоит из двух меню:
Основное: громкость и тембр, в нем работает ик пульт
Второе: все остальные параметры, в нем нет поддержки ИК пульта

Кнопки: MENU, INPUT, MUTE
Во втором меню, есть окна в которых регулируют 2 параметра, первый параметр регулируется поворотом энкодера, второй кнопкой INPUT

#define IR2    0x33B820DF // button encoder
#define IR3    0x33B8946B // mute
#define IR4    0x33B810EF // >>>
#define IR5    0x33B8E01F // <<<
#define IR6    0x33B844BB // INPUT
#define IR8    0x2FDB24D // Кнопка MENU2

#include <Wire.h>              // http://rcl-radio.ru/wp-content/uploads/2022/03/LC75342.zip
#include <MsTimer2.h>          // http://rcl-radio.ru/wp-content/uploads/2018/11/MsTimer2.zip 
#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 <BD37033FV.h>         // http://forum.rcl-radio.ru/misc.php?action=pan_download&item=134&download=1
#include <boarddefs.h>         // входит в состав библиотеки IRremote
#include <IRremote.h>          // http://rcl-radio.ru/wp-content/uploads/2019/06/IRremote.zip

  OLED  myOLED(SDA, SCL, 8);
  extern uint8_t SmallFont[],BigNumbers[];
  BD37033FV tda; 
  Encoder myEnc(9, 8);// DT, CLK
  IRrecv irrecv(12); // указываем вывод модуля IR приемника
  decode_results ir; 

long times,oldPosition  = -999,newPosition;
int vol_reg,bass_reg,mid_reg,treb_reg,menu,menu2=100,in_reg,gain0,gain1,gain2,gain3,lon_f,lon,lon_d;
int out,vol_out,rf,lf,rt,lt,sab1,sab2,treb_c,mid_c,bas_c,sab_f,treb_q,mid_q,bas_q,faza;
byte mute_reg,power,gr1,gr2,w,w2,www;

void setup(){
  Wire.begin();Wire.setClock(400000L);
  irrecv.enableIRIn();
  MsTimer2::set(1, to_Timer);MsTimer2::start();
  myOLED.begin();
  myOLED.setBrightness(100);
  Serial.begin(9600);
  myOLED.clrScr();
  myOLED.setFont(SmallFont);
  myOLED.print(F("Sound Processors"), CENTER, 10);
  myOLED.print(F("BD37033FV"), CENTER, 30);
  myOLED.update();
  pinMode(10,INPUT);        // encoder SW
  pinMode(7,INPUT_PULLUP);  // mute button
  pinMode(6,INPUT_PULLUP);  // input button 
  pinMode(5,INPUT_PULLUP);  // menu2 button 
  delay(2000);
  vol_reg = EEPROM.read(0)-79;treb_reg = EEPROM.read(1)-15;mid_reg = EEPROM.read(2)-15;bass_reg = EEPROM.read(3)-15;in_reg = EEPROM.read(4);
  gain1 = EEPROM.read(5);gain2 = EEPROM.read(6);gain3 = EEPROM.read(7);lon = EEPROM.read(8);lon_f = EEPROM.read(9);
  rf = EEPROM.read(10)-79;lf = EEPROM.read(11)-79;rt = EEPROM.read(12)-79;lt = EEPROM.read(13)-79;sab1 = EEPROM.read(14)-79;sab2 = EEPROM.read(24)-79;
  treb_c = EEPROM.read(15);mid_c = EEPROM.read(16);bas_c = EEPROM.read(17);sab_f = EEPROM.read(18);
  treb_q = EEPROM.read(19);mid_q = EEPROM.read(20);bas_q = EEPROM.read(21);faza = EEPROM.read(22);
    switch(in_reg){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
  audio();
  }

void loop(){
/// IR ////////////////////////////////////////
   if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();times=millis();w=1;w2=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
   if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта     

//////// BUTTON /////////////////////////////////////////////////////////////////////////////////////////////////////////////
 if(mute_reg==0){
   if((digitalRead(5)==LOW||ir.value==IR8)&&menu2==100){menu2=0;menu=100;gr1=0;gr2=0;cl();times=millis();w=1;w2=1;
     myOLED.clrScr();myOLED.setFont(SmallFont);myOLED.print(F("SECOND MENU"), CENTER, 25);myOLED.update();delay(2000);}
   if((digitalRead(5)==LOW||ir.value==IR8)&&menu==100){menu=0;menu2=100;gr1=0;gr2=0;cl();times=millis();w=1;w2=1;
     myOLED.clrScr();myOLED.setFont(SmallFont);myOLED.print(F("MAIN MENU"), CENTER, 25);myOLED.update();delay(2000);}
     
   if((digitalRead(10)==LOW||ir.value==IR2)&&menu2==100){menu++;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;if(menu>3){menu=0;}}
   if((digitalRead(6)==LOW||ir.value==IR6)&&menu2==100){in_reg++;menu=4;cl();times=millis();w=1;w2=1;www=1;if(in_reg>2){in_reg=0;}}

   if((digitalRead(10)==LOW||ir.value==IR2)&&menu==100){menu2++;gr1=0;gr2=0;cl();delay(200);times=millis();w=1;w2=1;if(menu2>5){menu2=0;}}
 }
   if((digitalRead(7)==LOW||ir.value==IR3)&&mute_reg==0){mute_reg=1;menu2=100;menu=100;cl();delay(200);audio();
       myOLED.clrScr();myOLED.setFont(SmallFont);myOLED.print(F("MUTE"), CENTER, 25);myOLED.update();}
   if((digitalRead(7)==LOW||ir.value==IR3)&&mute_reg==1){mute_reg=0;w=1;menu=0;cl();delay(200);audio();}
   
//////// VOLUME //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
  if(menu==0){
  if(newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
  vol_reg=vol_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;vol_func();audio();}
 
   if(ir.value==IR5){vol_reg++;gr1=1;gr2=0;cl();times=millis();w=1;w2=1;vol_func();audio();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){vol_reg++;gr2=0;cl();times=millis();w=1;w2=1;vol_func();audio();}// кнопка >>>>>>
   if(ir.value==IR4){vol_reg--;gr1=0;gr2=1;cl();times=millis();w=1;w2=1;vol_func();audio();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){vol_reg--;gr1=0;cl();times=millis();w=1;w2=1;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, 65, 0);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), RIGHT, 20);
  myOLED.setFont(SmallFont);myOLED.print(F("IN"), LEFT, 10);
  myOLED.printNumI(in_reg+1, 20, 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, 70, 35);myOLED.print(F("dB"), RIGHT, 35);
  myOLED.setFont(SmallFont);myOLED.print(F("MIDDLE"), LEFT, 45);myOLED.printNumI(mid_reg, 70, 45);myOLED.print(F("dB"), RIGHT, 45);
  myOLED.setFont(SmallFont);myOLED.print(F("BASS"), LEFT, 55);myOLED.printNumI(bass_reg, 70, 55);myOLED.print(F("dB"), RIGHT, 55);
  myOLED.update();
  }}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  

//////// TREBLE //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
  if(menu==1){
  if(newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
  treb_reg=treb_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;treb_func();audio();}
 
   if(ir.value==IR4){treb_reg++;gr1=1;gr2=0;cl();times=millis();w=1;w2=1;treb_func();audio();}// кнопка > 
   if(ir.value==IR5){treb_reg--;gr1=0;gr2=1;cl();times=millis();w=1;w2=1;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, 65, 0);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), RIGHT, 0);
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);myOLED.print(F("MIDDLE"), LEFT, 35);myOLED.printNumI(mid_reg, 70, 35);myOLED.print(F("dB"), RIGHT, 35);
  myOLED.setFont(SmallFont);myOLED.print(F("BASS"), LEFT, 45);myOLED.printNumI(bass_reg, 70, 45);myOLED.print(F("dB"), RIGHT, 45);
  myOLED.setFont(SmallFont);myOLED.print(F("VOLUME"), LEFT, 55);myOLED.printNumI(vol_reg, 70, 55);myOLED.print(F("dB"), RIGHT, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// MIDDLE //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
  if(menu==2){
  if(newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
  mid_reg=mid_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;mid_func();audio();}
 
   if(ir.value==IR4){mid_reg++;gr1=1;gr2=0;cl();times=millis();w=1;w2=1;mid_func();audio();}// кнопка > 
   if(ir.value==IR5){mid_reg--;gr1=0;gr2=1;cl();times=millis();w=1;w2=1;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, 65, 0);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), RIGHT, 0);
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);myOLED.print(F("BASS"), LEFT, 35);myOLED.printNumI(bass_reg, 70, 35);myOLED.print(F("dB"), RIGHT, 35);
  myOLED.setFont(SmallFont);myOLED.print(F("VOLUME"), LEFT, 45);myOLED.printNumI(vol_reg, 70, 45);myOLED.print(F("dB"), RIGHT, 45);
  myOLED.setFont(SmallFont);myOLED.print(F("TREBLE"), LEFT, 55);myOLED.printNumI(treb_reg, 70, 55);myOLED.print(F("dB"), RIGHT, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

//////// BASS //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
  if(menu==3){
  if(newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
  bass_reg=bass_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;bass_func();audio();}
 
   if(ir.value==IR4){bass_reg++;gr1=1;gr2=0;cl();times=millis();w=1;w2=1;bass_func();audio();}// кнопка > 
   if(ir.value==IR5){bass_reg--;gr1=0;gr2=1;cl();times=millis();w=1;w2=1;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, 65, 0);
  myOLED.setFont(SmallFont);myOLED.print(F("dB"), RIGHT, 0);
  myOLED.drawLine(0, 30, 128, 30);
  myOLED.setFont(SmallFont);myOLED.print(F("VOLUME"), LEFT, 35);myOLED.printNumI(vol_reg, 70, 35);myOLED.print(F("dB"), RIGHT, 35);
  myOLED.setFont(SmallFont);myOLED.print(F("TREBLE"), LEFT, 45);myOLED.printNumI(treb_reg, 70, 45);myOLED.print(F("dB"), RIGHT, 45);
  myOLED.setFont(SmallFont);myOLED.print(F("MIDDLE"), LEFT, 55);myOLED.printNumI(mid_reg, 70, 55);myOLED.print(F("dB"), RIGHT, 55);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

////////////// INPUT GAIN ///////////////////////////////////////////////////////////////////
 if(menu==4){
  switch(in_reg){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
 
  if (newPosition != oldPosition){oldPosition = newPosition;gain0=gain0+newPosition;myEnc.write(0);newPosition=0;times=millis();www=1;w=1;w2=1;gain_func();}
 
   if(ir.value==IR4){gain0++;gr1=1;gr2=0;cl();times=millis();w=1;w2=1;gain_func();audio();}// кнопка > 
   if(ir.value==IR5){gain0--;gr1=0;gr2=1;cl();times=millis();w=1;w2=1;gain_func();audio();}// кнопка <
 
  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.setFont(SmallFont);myOLED.print(F("dB"), RIGHT, 35);
  myOLED.update();
  }}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////// SECOND MENU /////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  

///////////////// loudness /////////////////////////////////////////////////////////////
 if(menu2==0){
  if(newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
   lon=lon+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;if(lon<0){lon=0;}if(lon>15){lon=15;}audio();}

  if(digitalRead(6)==LOW){lon_f++;cl();delay(200);times=millis();w=1;w2=1;if(lon_f<0){lon_f=3;}if(lon_f>3){lon_f=0;}audio();}// button IN

  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);
  myOLED.print(F("LOUDNESS"), CENTER, 0);
  myOLED.drawLine(0, 15, 128, 15);
  myOLED.print(F("FREQUENCY"), LEFT, 25);
  switch(lon_f){
         case 0: myOLED.print(F("400 "), 70, 25);break;
         case 1: myOLED.print(F("800 "), 70, 25);break;
         case 2: myOLED.print(F("2400"), 70, 25);break;
         case 3: myOLED.print(F("FLAT"), 70, 25);break;
         }
  if(lon_f<3){myOLED.print(F("Hz"), 100, 25);}
    else{myOLED.print(F("  "), 100, 25);}
  myOLED.print(F("GAIN"), LEFT, 40);
  myOLED.printNumI(lon, 70, 40);myOLED.print(F("dB"), 100, 40);
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////

////////////// OUTPUT GAIN ///////////////////////////////////////////////////////////////////
 if(menu2==1){
   
  if(digitalRead(6)==LOW){out++;cl();delay(200);times=millis();w=1;w2=1;if(out>5){out=0;}www=1;}// button IN
  
  switch(out){
          case 0:vol_out=rf;break;
          case 1:vol_out=lf;break;
          case 2:vol_out=rt;break;
          case 3:vol_out=lt;break;
          case 4:vol_out=sab1;break;
          case 5:vol_out=sab2;break;
          }
  
  if(newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
   vol_out=vol_out+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;vol_out_func();audio();}
  
  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);
  myOLED.print(F("OUTPUT ATT"), CENTER, 0);
  myOLED.drawLine(0, 15, 128, 15);
   
   switch(out){
     case 0:rf=vol_out; myOLED.print(F("FRONT R"), LEFT, 25);myOLED.printNumI(rf, 70, 25);break;
     case 1:lf=vol_out; myOLED.print(F("FRONT L"), LEFT, 25);myOLED.printNumI(lf, 70, 25);break;
     case 2:rt=vol_out; myOLED.print(F("REAR R "), LEFT, 25);myOLED.printNumI(rt, 70, 25);break;
     case 3:lt=vol_out; myOLED.print(F("REAR L "), LEFT, 25);myOLED.printNumI(lt, 70, 25);break;
     case 4:sab1=vol_out; myOLED.print(F("SUB_1 "), LEFT, 25);myOLED.printNumI(sab1, 70, 25);break;
     case 5:sab2=vol_out; myOLED.print(F("SUB_2 "), LEFT, 25);myOLED.printNumI(sab2, 70, 25);break;
   }
  myOLED.print(F("dB"), 100, 25);
  myOLED.update();
  if(www==1){audio();www=0;}
  }}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

///////////////// TREBLE SETUP /////////////////////////////////////////////////////////////
 if(menu2==2){
  if(newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
   treb_c=treb_c+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;treb_c_func();audio();}

  if(digitalRead(6)==LOW){treb_q++;cl();delay(200);times=millis();w=1;w2=1;treb_q_func();audio();}// button IN

  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);
  myOLED.print(F("TREBLE SETUP"), CENTER, 0);
  myOLED.drawLine(0, 15, 128, 15);
  myOLED.print(F("FREQUENCY"), LEFT, 25);
    switch(treb_c){
         case 0: myOLED.print(F("7.5 "), 70, 25);break;
         case 1: myOLED.print(F("10.0"), 70, 25);break;
         case 2: myOLED.print(F("12.5"), 70, 25);break;
         case 3: myOLED.print(F("15.0"), 70, 25);break;
         }
  myOLED.print(F("kHz"), 100, 25);       
  myOLED.print(F("TREBLE Q"), LEFT, 40);
    switch(treb_q){
         case 0: myOLED.print(F("0.75"), 70, 40);break;
         case 1: myOLED.print(F("1.25"), 70, 40);break;
         }
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////

///////////////// MIDDLE SETUP /////////////////////////////////////////////////////////////
 if(menu2==3){
  if(newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
   mid_c=mid_c+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;mid_c_func();audio();}

  if(digitalRead(6)==LOW){mid_q++;cl();delay(200);times=millis();w=1;w2=1;mid_q_func();audio();}// button IN

  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);
  myOLED.print(F("MIDDLE SETUP"), CENTER, 0);
  myOLED.drawLine(0, 15, 128, 15);
  myOLED.print(F("FREQUENCY"), LEFT, 25);
    switch(mid_c){
         case 0: myOLED.print(F("0.5"), 70, 25);break;
         case 1: myOLED.print(F("1.0"), 70, 25);break;
         case 2: myOLED.print(F("1.5"), 70, 25);break;
         case 3: myOLED.print(F("2.5"), 70, 25);break;
         }
  myOLED.print(F("kHz"), 100, 25);       
  myOLED.print(F("MIDDLE Q"), LEFT, 40);
    switch(mid_q){
         case 0: myOLED.print(F("0.75"), 70, 40);break;
         case 1: myOLED.print(F("1.00"), 70, 40);break;
         case 2: myOLED.print(F("1.25"), 70, 40);break;
         case 3: myOLED.print(F("1.50"), 70, 40);break;         
         }
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////

///////////////// BASS SETUP /////////////////////////////////////////////////////////////
 if(menu2==4){
  if(newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
   bas_c=bas_c+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;bas_c_func();audio();}

  if(digitalRead(6)==LOW){bas_q++;cl();delay(200);times=millis();w=1;w2=1;bas_q_func();audio();}// button IN

  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);
  myOLED.print(F("BASS SETUP"), CENTER, 0);
  myOLED.drawLine(0, 15, 128, 15);
  myOLED.print(F("FREQUENCY"), LEFT, 25);
    switch(bas_c){
         case 0: myOLED.print(F("60 "), 70, 25);break;
         case 1: myOLED.print(F("80 "), 70, 25);break;
         case 2: myOLED.print(F("100"), 70, 25);break;
         case 3: myOLED.print(F("120"), 70, 25);break;
         }
  myOLED.print(F("Hz"), 100, 25);       
  myOLED.print(F("BASS Q"), LEFT, 40);
    switch(bas_q){
         case 0: myOLED.print(F("0.75"), 70, 40);break;
         case 1: myOLED.print(F("1.00"), 70, 40);break;
         case 2: myOLED.print(F("1.25"), 70, 40);break;
         case 3: myOLED.print(F("1.50"), 70, 40);break;         
         }
  myOLED.update();
  }}
////////////////////////////////////////////////////////////////////////////////////////  

///////////////// SUBWOOFER SETUP /////////////////////////////////////////////////////////////
 if(menu2==5){
  if(newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
   sab_f=sab_f+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;sab_f_func();audio();}

  if(digitalRead(6)==LOW){faza++;cl();delay(200);times=millis();w=1;w2=1;faza_func();audio();}// button IN

  if(w==1){w=0;
  myOLED.clrScr();
  myOLED.setFont(SmallFont);
  myOLED.print(F("SUBWOOFER SETUP"), CENTER, 0);
  myOLED.drawLine(0, 15, 128, 15);
  myOLED.print(F("FREQUENCY"), LEFT, 25);
    switch(sab_f){
         case 0: myOLED.print(F("FLAT"), 70, 25);break;
         case 1: myOLED.print(F("55  "), 70, 25);break;
         case 2: myOLED.print(F("85  "), 70, 25);break;
         case 3: myOLED.print(F("120 "), 70, 25);break;
         case 4: myOLED.print(F("160 "), 70, 25);break;
         }
  if(sab_f>0){myOLED.print(F("Hz"), 100, 25);}
    else{myOLED.print(F("  "), 100, 25);}      
  myOLED.print(F("LPF PHASE"), LEFT, 40);
    switch(faza){
         case 0: myOLED.print(F("0  "), 70, 40);break;
         case 1: myOLED.print(F("180"), 70, 40);break;       
         }
  myOLED.update();
  }}
//////////////////////////////////////////////////////////////////////////////////////// 

////////////////// EEPROM //////////////////////////////////////////////////////////////
 if(millis()-times>10000 && w2==1 && mute_reg==0 && power==0){
     EEPROM.update(0,vol_reg+79);EEPROM.update(1,treb_reg+15);EEPROM.update(2,mid_reg+15);EEPROM.update(3,bass_reg+15);EEPROM.update(4,in_reg);
     EEPROM.update(5,gain1);EEPROM.update(6,gain2);EEPROM.update(7,gain3);EEPROM.update(8,lon);EEPROM.update(9,lon_f);
     EEPROM.update(10,rf+79);EEPROM.update(11,lf+79);EEPROM.update(12,rt+79);EEPROM.update(13,lt+79);EEPROM.update(14,sab1+79);EEPROM.update(24,sab2+79);
     EEPROM.update(15,treb_c);EEPROM.update(16,mid_c);EEPROM.update(17,bas_c);EEPROM.update(18,sab_f);EEPROM.update(19,treb_q);
     EEPROM.update(20,mid_q);EEPROM.update(21,bas_q);EEPROM.update(22,faza);
     if(menu!=0){menu=0;}menu2=100;w=1;w2=0;}     
  }// end loop 

void cl(){myOLED.clrScr();ir.value=0;delay(300);}
void to_Timer(){newPosition = myEnc.read()/4;} 
void vol_func(){if(vol_reg<-79){vol_reg=-79;}if(vol_reg>15){vol_reg=15;}}
void treb_func(){if(treb_reg>15){treb_reg=15;}if(treb_reg<-15){treb_reg=-15;}}
void mid_func(){if(mid_reg>15){mid_reg=15;}if(mid_reg<-15){mid_reg=-15;}}
void bass_func(){if(bass_reg>15){bass_reg=15;}if(bass_reg<-15){bass_reg=-15;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>16){gain0=16;}}
void vol_out_func(){if(vol_out>15){vol_out=15;}if(vol_out<-79){vol_out=-79;}}
void treb_c_func(){if(treb_c>3){treb_c=0;}if(treb_c<0){treb_c=3;}}
void treb_q_func(){if(treb_q>1){treb_q=0;}if(treb_q<0){treb_q=1;}}
void mid_c_func(){if(mid_c>3){mid_c=0;}if(mid_c<0){mid_c=3;}}
void mid_q_func(){if(mid_q>3){mid_q=0;}if(mid_q<0){mid_q=3;}}
void bas_c_func(){if(bas_c>3){bas_c=0;}if(bas_c<0){bas_c=3;}}
void bas_q_func(){if(bas_q>3){bas_q=0;}if(bas_q<0){bas_q=3;}}
void faza_func(){if(faza>1){faza=0;}if(faza<0){faza=1;}}
void sab_f_func(){if(sab_f>4){sab_f=0;}if(sab_f<0){sab_f=4;}}

void audio(){
        tda.setInitial();
        tda.setSub_setup(sab_f,3,faza); // off 55hz 85hz 120hz 160hz pass = int sub_f(0...5) || LPF front rear sub = int sub_out(0...3) 0 - default || 0 180 = int faza(0...1)
        tda.setLoud_f(3,lon_f,1,1); // mix_in 0...3 (3=OFF) || 400hz 800hz 2400hz Prohibition = int loud_f(0...3) || MIXING 1ch 2ch -- on off = mix_ch1(0...1) mix_ch2 (0..1)
        tda.setIn(in_reg); // in1 in2 in3 = int in_reg(0...2)
        tda.setIn_gain(gain0,mute_reg); // 0...16 dB = int in_gain(0...16) || off on = int mute(0...1)
        tda.setVol(vol_reg); // -79...+15 dB = int vol(-79...15)
        tda.setFront_1(rf); // -79...+15 dB = int -79...15
        tda.setFront_2(lf); // -79...+15 dB = int -79...15
        tda.setRear_1(rt); // -79...+15 dB = int -79...15
        tda.setRear_2(lt); // -79...+15 dB = int -79...15
        tda.setSub1(sab1); // -79...+15 dB = int -79...15
        tda.setSub2(sab2); // -79...+15 dB = int -79...15
        tda.setBass_setup(bas_q,bas_c); // 0.5 1.0 1.5 2.0 --- int 0...3, 60Hz 80Hz 100Hz 120Hz --- int 0...3
        tda.setMiddle_setup(mid_q,mid_c); // 0.75 1.0 1.25 1.5 --- int 0...3, 500Hz 1kHz 1.5kHz 2.5kHz --- int 0...3
        tda.setTreble_setup(treb_q,treb_c); // 0.75 1.25  --- int 0...1, 7.5kHz 10kHz 12.5kHz 15kHz --- int 0...3
        tda.setBass_gain(bass_reg); // --15 ... +15 dB = int -15 ... 15 
        tda.setMiddle_gain(mid_reg); // --15 ... +15 dB = int -15 ... 15
        tda.setTreble_gain(treb_reg); // --15 ... +15 dB = int -15 ... 15
        tda.setLoudness_gain(lon); // 0 ... 15 dB = int 0 ... 15 
  }   

21

Re: BD37033FV - Sound Processors for Car Audio

Хорошо, завтра займусь тестом. Спасибо!

22 (2022-04-05 16:40:08 отредактировано romanlylyk85)

Re: BD37033FV - Sound Processors for Car Audio

Потестил, и.... походу мой BD37033 как то умер иначе не назовешь, звук идет только  с RF , вход работает только 1 и то независимо какой выбран вход в настройках, при переключении входов только разное усиление входа влияет на звук.
По рабочему каналу когда меняешь настройки громкости тембра и т.д. то они меняются и влияют на звук как надо, и  даже во втором меню работают.
Думал с начало что код, загрузил старый для 1602 там все также, даже перекачал библиотеки и пере залил - не поменялось ничего.
Буду искать новий, а там уже полноценный тест.
liman324 - еще раз  спасибо за Ваш труд.

23

Re: BD37033FV - Sound Processors for Car Audio

Перелистайте все меню и покрутите все настройки.

24

Re: BD37033FV - Sound Processors for Car Audio

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

25

Re: BD37033FV - Sound Processors for Car Audio

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

Маловероятно что с аудиопроцессором что-то не то.

Загрузите тестовый скетч, тогда точно будет ясно исправен ли аудиопроцессор или нет.

Меняйте входы в :
tda.setIn(0); // in1 in2 in3 = int in(0...2)

#include <Wire.h> 
#include <BD37033FV.h>
BD37033FV tda; 

void setup(){
   Wire.begin();
   audio();
}

void loop(){}

void audio(){
        tda.setInitial();
        tda.setSub_setup(0,0,0); // off 55hz 85hz 120hz 160hz pass = int sub_f(0...5) || LPF front rear sub = int sub_out(0...3) 0 - default || 0 180 = int faza(0...1)
        tda.setLoud_f(3,0,0,0); // mix_in off || 400hz 800hz 2400hz Prohibition = int loud_f(0...3) || MIXING 1ch 2ch -- on off = mix_ch1(0...1) mix_ch2(0..1)
        tda.setIn(0); // in1 in2 in3 = int in(0...2)
        tda.setIn_gain(0,0); // 0...16 dB = int in_gain(0...16) || off on = int mute(0...1)
        tda.setVol(0); // -79...+15 dB = int vol(-79...15)
        tda.setFront_1(0); // -79...+15 dB = int -79...15
        tda.setFront_2(0); // -79...+15 dB = int -79...15
        tda.setRear_1(0); // -79...+15 dB = int -79...15
        tda.setRear_2(0); // -79...+15 dB = int -79...15
        tda.setSub1(0); // -79...+15 dB = int -79...15
        tda.setSub2(0); // -79...+15 dB = int -79...15
        tda.setBass_setup(0,0); // 0.5 1.0 1.5 2.0 --- int 0...3, 60Hz 80Hz 100Hz 120Hz --- int 0...3
        tda.setMiddle_setup(0,0); // 0.75 1.0 1.25 1.5 --- int 0...3, 500Hz 1kHz 1.5kHz 2.5kHz --- int 0...3
        tda.setTreble_setup(0,0); // 0.75 1.25  --- int 0...1, 7.5kHz 10kHz 12.5kHz 15kHz --- int 0...3
        tda.setBass_gain(0); // --15 ... +15 dB = int -15 ... 15 
        tda.setMiddle_gain(0); // --15 ... +15 dB = int -15 ... 15
        tda.setTreble_gain(0); // --15 ... +20 dB = int -15 ... 15
        tda.setLoudness_gain(0); // 0 ... 15 dB = int 0 ... 15 
  }