1

Тема: BD3702 Sound Processor for car audio

Данный контент доступен только зарегистрированным пользователям.
http://read.pudn.com/downloads317/doc/p … 3702FV.pdf

http://forum.rcl-radio.ru/uploads/images/2020/01/7bb3c7c369bec5ba326384fbdc4b9627.png


test.ino

#include <BD3702.h>
  BD3702 bd;

void setup() {
  audio();
}

void loop() {}

void audio(){
    // Advanced switch time of Mute === 0.6 1.0 1.4 3.2 ms = int 0...3
    // Advanced switch time of Input gain/Volume/Tone/Fader/Loudness === 4.7 7.1 11.2 14.4 ms = int 0...3
    // Advanced switch ON/OFF === OFF ON = int 0...1    
  bd.setInitial_1(0, 0, 0); // 0x01
    // Subwoofer LPF fc === OFF 55Hz 85 Hz 120Hz = int 0...3
    // Subwoofer Output Select === LPF Front Rear Prohibition = int 0...3
    // Level Meter RESET === HOLD RESET = int 0...1
  bd.setInitial_2(0, 0, 0); // 0x02  
    // Loudness fo === 250Hz 400Hz 800Hz Prohibition = int 0...3
  bd.setInitial_3(0); // 0x03
    // Input Selector === A B C D_single E1_single E2_single D_diff E_full_diff Input_SHORT = int 0...8 
  bd.setIn(0, 0); // 0x05
    // Input Gain === 0...20 dB = int 0...20
    // MUTE ON/OFF === OFF ON = int 0...1    
  bd.setIn_gain(0, 0); // 0x06
    // VOL === -79...+15 dB = int -79...15
  bd.setVol(0); // 0x20
    // FADER FRONT 1CH === -79...+15 dB = int -79...15
  bd.setFront_1(0); // 0x28
    // FADER FRONT 2CH === -79...+15 dB = int -79...15
  bd.setFront_2(0); // 0x29
    // FADER REAR 1CH === -79...+15 dB = int -79...15
  bd.setRear_1(0); // 0x2A
    // FADER REAR 2CH === -79...+15 dB = int -79...15
  bd.setRear_2(0); // 0x2B
    // FADER SUB === -79...+15 dB = int -79...15
  bd.setSub(0); // 0x2C
    // Mixing Gain === -79...+7 dB = int -79...7
  bd.setMix_gain(0); // 0x30
    // Bass Q factor === 0.5 1.0 1.5 2.0 = int 0...3
    // Bass fo === 60Hz 80Hz 100Hz 120Hz = int 0...3
  bd.setBass_setup(0, 0); // 0x41
    // Middle Q factor === 0.75 1.0 1.25 1.5 = int 0...3
    // Middle fo === 500Hz 1kHz 1.5kHz 2.5kHz = int 0...3
  bd.setMiddle_setup(0, 0); // 0x44
    // Treble Q factor === 0.75 1.25 = int 0...1
    // Treble fo === 7.5kHz 10kHz 12.5kHz 15kHz = int 0...3
  bd.setTreble_setup(0, 0); // 0x47
    // Bass Gain === -20...+20 dB = int -20...20
  bd.setBass_gain(0); // 0x51
    // Middle Gain === -20...+20 dB = int -20...20
  bd.setMiddle_gain(0); // 0x54
    // Treble Gain === -20...+20 dB = int -20...20
  bd.setTreble_gain(0); // 0x57
    // Loudness Gain === 0...20 dB = int 0...20
  bd.setLoudness_gain(0); // 0x75
    // Setup 4 = not param
  bd.setInitial_4();
  }

BD3702.h

// Александр Лиман
// liman324@yandex.ru
// rcl-radio.ru
// BD3702FV

#ifndef BD3702_H
#define BD3702_H

#define BD3702_address 0b1000000 

#define INITIAL_SETUP_1        0x01
#define INITIAL_SETUP_2        0x02
#define INITIAL_SETUP_3        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              0x2C
#define MIXING                 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
#define INITIAL_SETUP_4        0x90

#include <Arduino.h>
class BD3702
{
  public:
    BD3702();
    // Advanced switch time of Mute === 0.6 1.0 1.4 3.2 ms = int 0...3
    // Advanced switch time of Input gain/Volume/Tone/Fader/Loudness === 4.7 7.1 11.2 14.4 ms = int 0...3
    // Advanced switch ON/OFF === OFF ON = int 0...1    
    void setInitial_1(int sw1, int sw2, int sw3); // 0x01
    // Subwoofer LPF fc === OFF 55Hz 85 Hz 120Hz = int 0...3
    // Subwoofer Output Select === LPF Front Rear Prohibition = int 0...3
    // Level Meter RESET === HOLD RESET = int 0...1
        void setInitial_2(int sub_f, int sub_out, int l_metr); // 0x02    
    // Loudness fo === 250Hz 400Hz 800Hz Prohibition = int 0...3
        void setInitial_3(int loud_f); // 0x03
    // Input Selector === A B C D_single E1_single E2_single D_diff E_full_diff Input_SHORT = int 0...8 
        void setIn(int in, int in_type); // 0x05
    // Input Gain === 0...20 dB = int 0...20
    // MUTE ON/OFF === OFF ON = int 0...1    
        void setIn_gain(int in_gain, int mute); // 0x06
    // VOL === -79...+15 dB = int -79...15
        void setVol(int vol); // 0x20
    // FADER FRONT 1CH === -79...+15 dB = int -79...15
        void setFront_1(int front_1); // 0x28
    // FADER FRONT 2CH === -79...+15 dB = int -79...15
        void setFront_2(int front_2); // 0x29
    // FADER REAR 1CH === -79...+15 dB = int -79...15
        void setRear_1(int rear_1); // 0x2A
    // FADER REAR 2CH === -79...+15 dB = int -79...15
        void setRear_2(int rear_2); // 0x2B
    // FADER SUB === -79...+15 dB = int -79...15
        void setSub(int sub); // 0x2C
    // Mixing Gain === -79...+7 dB = int -79...7
        void setMix_gain(int mix_g); // 0x30
    // Bass Q factor === 0.5 1.0 1.5 2.0 = int 0...3
    // Bass fo === 60Hz 80Hz 100Hz 120Hz = int 0...3
        void setBass_setup(int bass_q, int bass_f); // 0x41
    // Middle Q factor === 0.75 1.0 1.25 1.5 = int 0...3
    // Middle fo === 500Hz 1kHz 1.5kHz 2.5kHz = int 0...3
        void setMiddle_setup(int mid_q, int mid_f); // 0x44
    // Treble Q factor === 0.75 1.25 = int 0...1
    // Treble fo === 7.5kHz 10kHz 12.5kHz 15kHz = int 0...3
        void setTreble_setup(int treb_q, int treb_f); // 0x47
    // Bass Gain === -20...+20 dB = int -20...20
        void setBass_gain(int bass_gain); // 0x51
    // Middle Gain === -20...+20 dB = int -20...20
        void setMiddle_gain(int mid_gain); // 0x54
    // Treble Gain === -20...+20 dB = int -20...20
        void setTreble_gain(int treb_gain); // 0x57
    // Loudness Gain === 0...20 dB = int 0...20
        void setLoudness_gain(int loud_gain); // 0x75
    // Setup 4 = not param
        void setInitial_4();

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

BD3702.cpp

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

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

void BD3702::setInitial_1(int sw1, int sw2, int sw3){
           switch(sw1){
              case 0: sw1 = 0b00000000;break;
              case 1: sw1 = 0b00000001;break;
              case 2: sw1 = 0b00000010;break;
              case 3: sw1 = 0b00000011;break;
}
           switch(sw2){
              case 0: sw2 = 0b00000000;break;
              case 1: sw2 = 0b00010000;break;
              case 2: sw2 = 0b00100000;break;
              case 3: sw2 = 0b00110000;break;
}
           switch(sw3){
              case 0: sw3 = 0b00000000;break;
              case 1: sw3 = 0b10000000;break;
}
           writeWire(INITIAL_SETUP_1, 0b01000100 + sw1 + sw2 + sw3); 
}


void BD3702::setInitial_2(int sub_f, int sub_out, int l_metr){
           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;
}
           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(l_metr){
              case 0: l_metr = 0b00000000;break;
              case 1: l_metr = 0b01000000;break;
}
           writeWire(INITIAL_SETUP_2, sub_f + sub_out + l_metr);
}


void BD3702::setInitial_3(int loud_f){
            switch(loud_f){
              case 0: loud_f = 0b00000001;break;
              case 1: loud_f = 0b00001001;break;
              case 2: loud_f = 0b00010001;break;
              case 3: loud_f = 0b00011001;break;
}                 
           writeWire(INITIAL_SETUP_3, loud_f);
}


void BD3702::setIn(int in, int in_type){
           switch(in){
             case 0: in = 0b00000000;break;  
             case 1: in = 0b00000001;break; 
             case 2: in = 0b00000010;break; 
             case 3: in = 0b00000011;break;
             case 4: in = 0b00001010;break;
             case 5: in = 0b00001011;break; 
             case 6: in = 0b00000110;break;
             case 7: in = 0b00001000;break;    
             case 8: in = 0b00001001;break;
}  
          switch(in_type){
             case 0: in_type = 0b00000000;break;
             case 1: in_type = 0b10000000;break;
} 
             writeWire(INPUT_SELECT, in + in_type); 
}


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


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


void BD3702::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 BD3702::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 BD3702::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 BD3702::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 BD3702::setSub(int sub){ 
            if(sub > 0){sub = 128 - sub;}
            if(sub <= 0){sub = abs(sub) + 128;}
            writeWire(FADER_SUB, sub); 
}


void BD3702::setMix_gain(int mix_g){
            if(mix_g > 0){mix_g = 128 - mix_g;}
            if(mix_g <= 0){mix_g = abs(mix_g) + 128;}
            writeWire(MIXING, mix_g); 
}


void BD3702::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;  
}
            writeWire(BASS_SETUP, bass_q + bass_f); 
}


void BD3702::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;  
}
            writeWire(MIDDLE_SETUP, mid_q + mid_f); 
}


void BD3702::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;  
}
            writeWire(TREBLE_SETUP, treb_q + treb_f); 
}


void BD3702::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 BD3702::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 BD3702::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 BD3702::setLoudness_gain(int loud_gain){
               writeWire(LOUDNESS_GAIN, loud_gain);  
}

void BD3702::setInitial_4(){
           writeWire(INITIAL_SETUP_4, 0b00110000);  
}

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

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

2

Re: BD3702 Sound Processor for car audio

BD3702 + LCD2004(I2C) + энкодер + ИК пульт

https://github.com/liman324/BD3702FV.git
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 // Кнопка MENU

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <BD3702.h>
#include <Encoder.h>
#include <EEPROM.h>
#include <MsTimer2.h>
#include <boarddefs.h>
#include <IRremote.h>
   BD3702 bd;
   LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
   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,times_in,oldPosition  = -999,newPosition; 
   byte in,in_x,w,w1,w2[4],w3,z,z0,z1,q,i,www,gr1,gr2;
   int menu,menu0,menu_1,menu_2,vol,bass,treb,mid,vol_d,bass_d,treb_d,mid_d;
   int temp0,gain0,gain1,gain2,gain3,gain_d;
   int bass_f,bass_q,treb_f,treb_q,mid_f,mid_q,loud_f,loud_g;
   int lf,rf,lr,rr,sub,sub_f;
   byte mesto[8]={4,13,4,13,4,13,4,13};
   byte mesto1[8]={0,0,1,1,2,2,3,3};
   byte mesto2[6]={0,11,0,11,0,11};
   byte mesto3[6]={0,0,1,1,3,3};
   String bass_nam[4]={"60   Hz", "80   Hz", "100  Hz", "120  Hz"};
   String treb_nam[4]={"7.5 kHz", "10  kHz", "12.5kHz", "15  kHz"};
   String mid_nam[4] ={"500  Hz", "1   kHz", "1.5 kHz", "2.5 kHz"};
   String lon_nam[4] ={"250  Hz", "400  Hz", "800  Hz", "disable"};
   String sub_nam[4] ={" OFF   ", " 55  Hz", " 85  Hz", " 120 Hz"};
   float bass_nam_1[4]={0.5, 1.0, 1.5, 2.0};
   float mid_nam_1[4]={0.75, 1.0, 1.25, 1.5};
   float treb_nam_1[2]={0.75, 1.25};

void setup() {
  irrecv.enableIRIn();lcd.init();lcd.backlight();
  lcd.setCursor(0,2);lcd.print("      BD3702FV   ");lcd.setCursor(0,1);lcd.print("  Sound  Processor  "); delay(2000);
  lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);
  pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT);   // МЕНЮ НАСТРОЕК
  pinMode(3,INPUT);   // IN
  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)-20;mid = EEPROM.read(2)-20;bass = EEPROM.read(3)-20;
  in = EEPROM.read(4);gain1 = EEPROM.read(5);gain2 = EEPROM.read(6);gain3 = EEPROM.read(7);
  bass_f = EEPROM.read(8);bass_q = EEPROM.read(9);treb_f = EEPROM.read(10);treb_q = EEPROM.read(11);
  mid_f = EEPROM.read(12);mid_q = EEPROM.read(13);loud_f = EEPROM.read(14);loud_g= EEPROM.read(15);
  lf = EEPROM.read(16)-79;rf = EEPROM.read(17)-79;lr = EEPROM.read(18)-79;rr = EEPROM.read(19)-79;sub = EEPROM.read(20)-79;sub_f = EEPROM.read(21);
  w2_arr();audio();cl();
}

void loop() {
  if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time=millis();w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu_1++;delay(200);time=millis();w=1;if(menu_1>7){menu_1=0;}}// меню 1
  if(digitalRead(10)==LOW&&menu0==2){menu_2++;delay(200);time=millis();w=1;if(menu_2>5){menu_2=0;}}// меню 2
    
  if(digitalRead(2)==HIGH){menu0++;cl();delay(200);time=millis();w=1;w2_arr();menu=0;menu_1;menu_2;if(menu0>2){menu0=0;}}// меню
  if(digitalRead(3)==HIGH){in++;cl();times_in=millis();in_x=1;w3=1;www=1;menu0=100;if(in>2){in=0;}}// IN

////////////////////// 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(ir.value==IR_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu>3){menu=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu<0){menu=3;}}//  кнопка вниз
   if(ir.value==IR_2&&menu0==1){menu_1++;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_1>7){menu_1=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==1){menu_1--;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_1<0){menu_1=7;}}//  кнопка вниз
   if(ir.value==IR_2&&menu0==2){menu_2++;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_2>5){menu_2=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==2){menu_2--;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_2<0){menu_2=5;}}//  кнопка вниз

   if(ir.value==IR_6){menu0++;gr1=0;gr2=0;cl();time=millis();w=1;w2_arr();menu=0;menu_1;menu_2;if(menu0>2){menu0=0;}}//  кнопка MENU
   if(ir.value==IR_5){in++;gr1=0;gr2=0;cl();times_in=millis();in_x=1;w3=1;www=1;menu0=100;if(in>2){in=0;}}//  кнопка IN
  
/////////////////////////////// MENU0 = VOLUME TERBLE MIDDLE BASS ///////////////////////////////////////////////////////////////////////
  if(menu0==0){
    switch(menu){
      case 0: temp0 = vol;q=0;break;
      case 1: temp0 = bass;q=1;break;
      case 2: temp0 = mid;q=2;break;
      case 3: temp0 = treb;q=3;break;}

     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time=millis();w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time=millis();;w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time=millis();;w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time=millis();w=1;w2[q]=1;www=1;}// кнопка <<<<<<   
     
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2[q]=1;www=1;} 

     switch(menu){
      case 0: vol = temp0;vol_func();break;
      case 1: bass = temp0;bass_func();break;
      case 2: mid = temp0;mid_func();break;
      case 3: treb = temp0;treb_func();break;}
      
   au();
   for(i=0;i<4;i++){if(menu==i){lcd.setCursor(0,i);lcd.print(">");}else{lcd.setCursor(0,i);lcd.print(" ");}}
   lcd.setCursor(1,0);lcd.print("VOLUME ");if(vol>=0){lcd.print(" ");}lcd.print(vol);lcd.print(" ");vol_d=map(vol,-79,15,0,24);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print(" ");bass_d=map(bass,-20,20,0,24);
   lcd.setCursor(1,2);lcd.print("MIDDLE ");if(mid>=0){lcd.print(" ");}lcd.print(mid);lcd.print(" ");mid_d=map(mid,-20,20,0,24);
   lcd.setCursor(1,3);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print(" ");treb_d=map(treb,-20,20,0,24);

   if(w2[0]==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+12,0);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,0);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,0);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,0);lcd.write((uint8_t)2);}w2[0]=0;}
   if(w2[1]==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+12,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,1);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,1);lcd.write((uint8_t)2);}w2[1]=0;}
   if(w2[2]==1){
   for(z=0,z0=0,z1=0;z<=mid_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,2);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,2);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,2);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,2);lcd.write((uint8_t)2);}w2[2]=0;}   
   if(w2[3]==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+12,3);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,3);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,3);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,3);lcd.write((uint8_t)2);}w2[3]=0;}
   }// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////

///////////////////// MENU 2 ////////////////////////////////////////////////////////
 if(menu0==1){
  switch(menu_1){
      case 0: temp0 = bass_f;break;
      case 1: temp0 = bass_q;break;
      case 2: temp0 = mid_f;break;
      case 3: temp0 = mid_q;break;
      case 4: temp0 = treb_f;break;
      case 5: temp0 = treb_q;break;
      case 6: temp0 = loud_f;break;
      case 7: temp0 = loud_g;break;}

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

     switch(menu_1){
      case 0: bass_f = temp0;bass_f_func();break;
      case 1: bass_q = temp0;bass_q_func();break;
      case 2: mid_f = temp0;mid_f_func();break;
      case 3: mid_q = temp0;mid_q_func();break;
      case 4: treb_f = temp0;treb_f_func();break;
      case 5: treb_q = temp0;treb_q_func();break;
      case 6: loud_f = temp0;loud_f_func();break;
      case 7: loud_g = temp0;loud_g_func();break;}
      
  au();
  for(i=0;i<8;i++){if(menu_1==i){lcd.setCursor(mesto[i],mesto1[i]);lcd.print(">");}else{lcd.setCursor(mesto[i],mesto1[i]);lcd.print(" ");}}
  lcd.setCursor(0,0);lcd.print("BASS");lcd.setCursor(5,0);lcd.print(bass_nam[bass_f]);lcd.setCursor(14,0);lcd.print("Q ");lcd.print(bass_nam_1[bass_q]);
  lcd.setCursor(0,1);lcd.print("MIDD");lcd.setCursor(5,1);lcd.print(mid_nam[mid_f]);lcd.setCursor(14,1);lcd.print("Q ");lcd.print(mid_nam_1[mid_q]);
  lcd.setCursor(0,2);lcd.print("TREB");lcd.setCursor(5,2);lcd.print(treb_nam[treb_f]);lcd.setCursor(14,2);lcd.print("Q ");lcd.print(treb_nam_1[treb_q]);
  lcd.setCursor(0,3);lcd.print("LOUD");lcd.setCursor(5,3);lcd.print(lon_nam[loud_f]);lcd.setCursor(14,3);lcd.print("G ");lcd.print(loud_g/10);lcd.print(loud_g%10);lcd.setCursor(18,3);lcd.print("dB");
  }// menu0 = 1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


 if(menu0==2){
     switch(menu_2){
      case 0: temp0 = lf;break;
      case 1: temp0 = rf;break;
      case 2: temp0 = lr;break;
      case 3: temp0 = rr;break;
      case 4: temp0 = sub;break;
      case 5: temp0 = sub_f;break;}

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

     switch(menu_2){
      case 0: lf = temp0;lf_func();break;
      case 1: rf = temp0;rf_func();break;
      case 2: lr = temp0;lr_func();break;
      case 3: rr = temp0;rr_func();break;
      case 4: sub = temp0;sub_func();break;
      case 5: sub_f = temp0;sub_f_func();break;}

  au();
  for(i=0;i<6;i++){if(menu_2==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(">");}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
  lcd.setCursor(1,0);lcd.print("LF");lcd.setCursor(4,0);lcd.print(lf);lcd.print(" ");lcd.setCursor(7,0);lcd.print("dB ");lcd.setCursor(12,0);lcd.print("RF ");lcd.print(rf);lcd.print(" ");lcd.setCursor(18,0);lcd.print("dB");
  lcd.setCursor(1,1);lcd.print("LR");lcd.setCursor(4,1);lcd.print(lr);lcd.print(" ");lcd.setCursor(7,1);lcd.print("dB ");lcd.setCursor(12,1);lcd.print("RR ");lcd.print(rr);lcd.print(" ");lcd.setCursor(18,1);lcd.print("dB");
  lcd.setCursor(0,2);lcd.print("  Subwoofer  setup  ");
  lcd.setCursor(1,3);lcd.print("G ");lcd.setCursor(4,3);lcd.print(sub);lcd.print(" ");lcd.setCursor(7,3);lcd.print("dB ");lcd.setCursor(12,3);lcd.print(sub_nam[sub_f]);
 } // menu0 = 2

////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
   switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;}

     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка <<<<<<  
     
    if (newPosition != oldPosition) {oldPosition = newPosition;
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();} 
    
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;}
      
  au();
  lcd.setCursor(2,1);lcd.print("Gain IN ");lcd.print(in+1);lcd.setCursor(12,1);lcd.print(" ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(16,1);lcd.print("dB");gain_d=gain0;
   if(w3==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+7,2);lcd.write((uint8_t)0);lcd.setCursor(z0+1+7,2);lcd.print("   ");}}
   if(z1==3){lcd.setCursor(z0+7,2);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+7,2);lcd.write((uint8_t)2);}} w3=0;
   if(millis()-times_in>3000){in_x=0;cl();menu0=0;w2_arr();}}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   

///////////////////// EEPROM ///////////////////////////////////////////////////////////////         
  if(millis()-time>10000 && w==1){
     EEPROM.update(0,vol+79);EEPROM.update(1,treb+20);EEPROM.update(2,mid+20);EEPROM.update(3,bass+20);
     EEPROM.update(4,in);EEPROM.update(5,gain1);EEPROM.update(6,gain2);EEPROM.update(7,gain3);
     EEPROM.update(8,bass_f);EEPROM.update(9,bass_q);EEPROM.update(10,treb_f);EEPROM.update(11,treb_q),
     EEPROM.update(12,mid_f);EEPROM.update(13,mid_q);EEPROM.update(14,loud_f);EEPROM.update(15,loud_g);
     EEPROM.update(16,lf+79);EEPROM.update(17,rf+79);EEPROM.update(18,lr+79);EEPROM.update(19,rr+79);EEPROM.update(20,sub+79);EEPROM.update(21,sub_f);
     menu=0;menu_1=0;menu_2=0;w=0;w2_arr();}
  
  }// loop

void sub_f_func(){if(sub_f>3){sub_f=0;}if(sub_f<0){sub_f=3;}}
void lf_func(){if(lf<-79){lf=-79;}if(lf>15){lf=15;}};
void rf_func(){if(rf<-79){rf=-79;}if(rf>15){rf=15;}};
void lr_func(){if(lr<-79){lr=-79;}if(lr>15){lr=15;}};
void rr_func(){if(rr<-79){rr=-79;}if(rr>15){rr=15;}};
void sub_func(){if(sub<-79){sub=-79;}if(sub>7){sub=7;}};
void au(){if(www==1){audio();www=0;}}
void loud_f_func(){if(loud_f>3){loud_f=0;}if(loud_f<0){loud_f=3;}}
void loud_g_func(){if(loud_g>20){loud_g=20;}if(loud_g<0){loud_g=0;}}
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 bass_q_func(){if(bass_q>3){bass_q=0;}if(bass_q<0){bass_q=3;}}
void mid_f_func(){if(mid_f>3){mid_f=0;}if(mid_f<0){mid_f=3;}}
void treb_f_func(){if(treb_f>3){treb_f=0;}if(treb_f<0){treb_f=3;}}
void bass_f_func(){if(bass_f>3){bass_f=0;}if(bass_f<0){bass_f=3;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>20){gain0=20;}}
void bass_func(){if(bass>20){bass=20;}if(bass<-20){bass=-20;}} 
void mid_func(){if(mid>20){mid=20;}if(mid<-20){mid=-20;}}
void treb_func(){if(treb>20){treb=20;}if(treb<-20){treb=-20;}}
void vol_func(){if(vol<-79){vol=-79;}if(vol>15){vol=15;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(200);}

void audio(){
    // Advanced switch time of Mute === 0.6 1.0 1.4 3.2 ms = int 0...3
    // Advanced switch time of Input gain/Volume/Tone/Fader/Loudness === 4.7 7.1 11.2 14.4 ms = int 0...3
    // Advanced switch ON/OFF === OFF ON = int 0...1    
  bd.setInitial_1(0, 0, 1); // 0x01
    // Subwoofer LPF fc === OFF 55Hz 85Hz 120Hz = int 0...3
    // Subwoofer Output Select === LPF Front Rear Prohibition = int 0...3
    // Level Meter RESET === HOLD RESET = int 0...1
  bd.setInitial_2(sub_f, 0, 0); // 0x02  
    // Loudness fo === 250Hz 400Hz 800Hz Prohibition = int 0...3
  bd.setInitial_3(loud_f); // 0x03
    // Input Selector === A B C D_single E1_single E2_single D_diff E_full_diff Input_SHORT = int 0...8 
    // Full-diff Bias Type Select === Negative_Input Bias = int 0...1
  bd.setIn(in, 0); // 0x05
    // Input Gain === 0...20 dB = int 0...20
    // MUTE ON/OFF === OFF ON = int 0...1    
  bd.setIn_gain(gain0, 0); // 0x06
    // VOL === -79...+15 dB = int -79...15
  bd.setVol(vol); // 0x20
    // FADER FRONT 1CH === -79...+15 dB = int -79...15
  bd.setFront_1(lf); // 0x28
    // FADER FRONT 2CH === -79...+15 dB = int -79...15
  bd.setFront_2(rf); // 0x29
    // FADER REAR 1CH === -79...+15 dB = int -79...15
  bd.setRear_1(lr); // 0x2A
    // FADER REAR 2CH === -79...+15 dB = int -79...15
  bd.setRear_2(rr); // 0x2B
    // FADER SUB === -79...+15 dB = int -79...15
  bd.setSub(sub); // 0x2C
    // Mixing Gain === -79...+7 dB = int -79...7
  bd.setMix_gain(-79); // 0x30
    // Bass Q factor === 0.5 1.0 1.5 2.0 = int 0...3
    // Bass fo === 60Hz 80Hz 100Hz 120Hz = int 0...3
  bd.setBass_setup(bass_q, bass_f); // 0x41
    // Middle Q factor === 0.75 1.0 1.25 1.5 = int 0...3
    // Middle fo === 500Hz 1kHz 1.5kHz 2.5kHz = int 0...3
  bd.setMiddle_setup(mid_q, mid_f); // 0x44
    // Treble Q factor === 0.75 1.25 = int 0...1
    // Treble fo === 7.5kHz 10kHz 12.5kHz 15kHz = int 0...3
  bd.setTreble_setup(treb_q, mid_f); // 0x47
    // Bass Gain === -20...+20 dB = int -20...20
  bd.setBass_gain(bass); // 0x51
    // Middle Gain === -20...+20 dB = int -20...20
  bd.setMiddle_gain(mid); // 0x54
    // Treble Gain === -20...+20 dB = int -20...20
  bd.setTreble_gain(treb); // 0x57
    // Loudness Gain === 0...20 dB = int 0...20
  bd.setLoudness_gain(loud_g); // 0x75
    // Setup 4 = not param
  bd.setInitial_4(); // 0x90
  }

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

3

Re: BD3702 Sound Processor for car audio

Здравствуйте.
Добавьте пожалуйста в скетч функцию MUTE.
Можно без кнопки, только управление с пульта.

4

Re: BD3702 Sound Processor for car audio

Не тестировал

#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 // Кнопка MENU
#define IR_7 0x2FDDDDD // Кнопка MUTE


#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <BD3702.h>
#include <Encoder.h>
#include <EEPROM.h>
#include <MsTimer2.h>
#include <boarddefs.h>
#include <IRremote.h>
   BD3702 bd;
   LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
   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,times_in,oldPosition  = -999,newPosition; 
   byte in,in_x,w,w1,w2[4],w3,z,z0,z1,q,i,www,gr1,gr2;
   int menu,menu0,menu_1,menu_2,vol,bass,treb,mid,vol_d,bass_d,treb_d,mid_d,mute;
   int temp0,gain0,gain1,gain2,gain3,gain_d;
   int bass_f,bass_q,treb_f,treb_q,mid_f,mid_q,loud_f,loud_g;
   int lf,rf,lr,rr,sub,sub_f;
   byte mesto[8]={4,13,4,13,4,13,4,13};
   byte mesto1[8]={0,0,1,1,2,2,3,3};
   byte mesto2[6]={0,11,0,11,0,11};
   byte mesto3[6]={0,0,1,1,3,3};
   String bass_nam[4]={"60   Hz", "80   Hz", "100  Hz", "120  Hz"};
   String treb_nam[4]={"7.5 kHz", "10  kHz", "12.5kHz", "15  kHz"};
   String mid_nam[4] ={"500  Hz", "1   kHz", "1.5 kHz", "2.5 kHz"};
   String lon_nam[4] ={"250  Hz", "400  Hz", "800  Hz", "disable"};
   String sub_nam[4] ={" OFF   ", " 55  Hz", " 85  Hz", " 120 Hz"};
   float bass_nam_1[4]={0.5, 1.0, 1.5, 2.0};
   float mid_nam_1[4]={0.75, 1.0, 1.25, 1.5};
   float treb_nam_1[2]={0.75, 1.25};

void setup() {
  irrecv.enableIRIn();lcd.init();lcd.backlight();
  lcd.setCursor(0,2);lcd.print("      BD3702FV   ");lcd.setCursor(0,1);lcd.print("  Sound  Processor  "); delay(2000);
  lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);
  pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT);   // МЕНЮ НАСТРОЕК
  pinMode(3,INPUT);   // IN
  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)-20;mid = EEPROM.read(2)-20;bass = EEPROM.read(3)-20;
  in = EEPROM.read(4);gain1 = EEPROM.read(5);gain2 = EEPROM.read(6);gain3 = EEPROM.read(7);
  bass_f = EEPROM.read(8);bass_q = EEPROM.read(9);treb_f = EEPROM.read(10);treb_q = EEPROM.read(11);
  mid_f = EEPROM.read(12);mid_q = EEPROM.read(13);loud_f = EEPROM.read(14);loud_g= EEPROM.read(15);
  lf = EEPROM.read(16)-79;rf = EEPROM.read(17)-79;lr = EEPROM.read(18)-79;rr = EEPROM.read(19)-79;sub = EEPROM.read(20)-79;sub_f = EEPROM.read(21);
  w2_arr();audio();cl();
}

void loop() {
  if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time=millis();w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu_1++;delay(200);time=millis();w=1;if(menu_1>7){menu_1=0;}}// меню 1
  if(digitalRead(10)==LOW&&menu0==2){menu_2++;delay(200);time=millis();w=1;if(menu_2>5){menu_2=0;}}// меню 2
    
  if(digitalRead(2)==HIGH){menu0++;cl();delay(200);time=millis();w=1;w2_arr();menu=0;menu_1;menu_2;if(menu0>2){menu0=0;}}// меню
  if(digitalRead(3)==HIGH){in++;cl();times_in=millis();in_x=1;w3=1;www=1;menu0=100;if(in>2){in=0;}}// IN

////////////////////// 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(ir.value==IR_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu>3){menu=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu<0){menu=3;}}//  кнопка вниз
   if(ir.value==IR_2&&menu0==1){menu_1++;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_1>7){menu_1=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==1){menu_1--;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_1<0){menu_1=7;}}//  кнопка вниз
   if(ir.value==IR_2&&menu0==2){menu_2++;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_2>5){menu_2=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==2){menu_2--;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_2<0){menu_2=5;}}//  кнопка вниз

   if(ir.value==IR_6){menu0++;gr1=0;gr2=0;cl();time=millis();w=1;w2_arr();menu=0;menu_1;menu_2;if(menu0>2){menu0=0;}}//  кнопка MENU
   if(ir.value==IR_5){in++;gr1=0;gr2=0;cl();times_in=millis();in_x=1;w3=1;www=1;menu0=100;if(in>2){in=0;}}//  кнопка IN

  if(ir.value==IR_7&&mute==0){mute=1;gr1=0;gr2=0;cl();lcd.setCursor(0,1);lcd.print("      MUTE     ");menu0=100;audio();}// mute on
  if(ir.value==IR_7&&mute==1){mute=0;gr1=0;gr2=0;cl();menu0=0;w2_arr();myEnc.write(0);audio();}// mute off
  
/////////////////////////////// MENU0 = VOLUME TERBLE MIDDLE BASS ///////////////////////////////////////////////////////////////////////
  if(menu0==0){
    switch(menu){
      case 0: temp0 = vol;q=0;break;
      case 1: temp0 = bass;q=1;break;
      case 2: temp0 = mid;q=2;break;
      case 3: temp0 = treb;q=3;break;}

     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time=millis();w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time=millis();;w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time=millis();;w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time=millis();w=1;w2[q]=1;www=1;}// кнопка <<<<<<   
     
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2[q]=1;www=1;} 

     switch(menu){
      case 0: vol = temp0;vol_func();break;
      case 1: bass = temp0;bass_func();break;
      case 2: mid = temp0;mid_func();break;
      case 3: treb = temp0;treb_func();break;}
      
   au();
   for(i=0;i<4;i++){if(menu==i){lcd.setCursor(0,i);lcd.print(">");}else{lcd.setCursor(0,i);lcd.print(" ");}}
   lcd.setCursor(1,0);lcd.print("VOLUME ");if(vol>=0){lcd.print(" ");}lcd.print(vol);lcd.print(" ");vol_d=map(vol,-79,15,0,24);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print(" ");bass_d=map(bass,-20,20,0,24);
   lcd.setCursor(1,2);lcd.print("MIDDLE ");if(mid>=0){lcd.print(" ");}lcd.print(mid);lcd.print(" ");mid_d=map(mid,-20,20,0,24);
   lcd.setCursor(1,3);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print(" ");treb_d=map(treb,-20,20,0,24);

   if(w2[0]==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+12,0);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,0);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,0);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,0);lcd.write((uint8_t)2);}w2[0]=0;}
   if(w2[1]==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+12,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,1);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,1);lcd.write((uint8_t)2);}w2[1]=0;}
   if(w2[2]==1){
   for(z=0,z0=0,z1=0;z<=mid_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,2);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,2);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,2);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,2);lcd.write((uint8_t)2);}w2[2]=0;}   
   if(w2[3]==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+12,3);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,3);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,3);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,3);lcd.write((uint8_t)2);}w2[3]=0;}
   }// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////

///////////////////// MENU 2 ////////////////////////////////////////////////////////
 if(menu0==1){
  switch(menu_1){
      case 0: temp0 = bass_f;break;
      case 1: temp0 = bass_q;break;
      case 2: temp0 = mid_f;break;
      case 3: temp0 = mid_q;break;
      case 4: temp0 = treb_f;break;
      case 5: temp0 = treb_q;break;
      case 6: temp0 = loud_f;break;
      case 7: temp0 = loud_g;break;}

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

     switch(menu_1){
      case 0: bass_f = temp0;bass_f_func();break;
      case 1: bass_q = temp0;bass_q_func();break;
      case 2: mid_f = temp0;mid_f_func();break;
      case 3: mid_q = temp0;mid_q_func();break;
      case 4: treb_f = temp0;treb_f_func();break;
      case 5: treb_q = temp0;treb_q_func();break;
      case 6: loud_f = temp0;loud_f_func();break;
      case 7: loud_g = temp0;loud_g_func();break;}
      
  au();
  for(i=0;i<8;i++){if(menu_1==i){lcd.setCursor(mesto[i],mesto1[i]);lcd.print(">");}else{lcd.setCursor(mesto[i],mesto1[i]);lcd.print(" ");}}
  lcd.setCursor(0,0);lcd.print("BASS");lcd.setCursor(5,0);lcd.print(bass_nam[bass_f]);lcd.setCursor(14,0);lcd.print("Q ");lcd.print(bass_nam_1[bass_q]);
  lcd.setCursor(0,1);lcd.print("MIDD");lcd.setCursor(5,1);lcd.print(mid_nam[mid_f]);lcd.setCursor(14,1);lcd.print("Q ");lcd.print(mid_nam_1[mid_q]);
  lcd.setCursor(0,2);lcd.print("TREB");lcd.setCursor(5,2);lcd.print(treb_nam[treb_f]);lcd.setCursor(14,2);lcd.print("Q ");lcd.print(treb_nam_1[treb_q]);
  lcd.setCursor(0,3);lcd.print("LOUD");lcd.setCursor(5,3);lcd.print(lon_nam[loud_f]);lcd.setCursor(14,3);lcd.print("G ");lcd.print(loud_g/10);lcd.print(loud_g%10);lcd.setCursor(18,3);lcd.print("dB");
  }// menu0 = 1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


 if(menu0==2){
     switch(menu_2){
      case 0: temp0 = lf;break;
      case 1: temp0 = rf;break;
      case 2: temp0 = lr;break;
      case 3: temp0 = rr;break;
      case 4: temp0 = sub;break;
      case 5: temp0 = sub_f;break;}

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

     switch(menu_2){
      case 0: lf = temp0;lf_func();break;
      case 1: rf = temp0;rf_func();break;
      case 2: lr = temp0;lr_func();break;
      case 3: rr = temp0;rr_func();break;
      case 4: sub = temp0;sub_func();break;
      case 5: sub_f = temp0;sub_f_func();break;}

  au();
  for(i=0;i<6;i++){if(menu_2==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(">");}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
  lcd.setCursor(1,0);lcd.print("LF");lcd.setCursor(4,0);lcd.print(lf);lcd.print(" ");lcd.setCursor(7,0);lcd.print("dB ");lcd.setCursor(12,0);lcd.print("RF ");lcd.print(rf);lcd.print(" ");lcd.setCursor(18,0);lcd.print("dB");
  lcd.setCursor(1,1);lcd.print("LR");lcd.setCursor(4,1);lcd.print(lr);lcd.print(" ");lcd.setCursor(7,1);lcd.print("dB ");lcd.setCursor(12,1);lcd.print("RR ");lcd.print(rr);lcd.print(" ");lcd.setCursor(18,1);lcd.print("dB");
  lcd.setCursor(0,2);lcd.print("  Subwoofer  setup  ");
  lcd.setCursor(1,3);lcd.print("G ");lcd.setCursor(4,3);lcd.print(sub);lcd.print(" ");lcd.setCursor(7,3);lcd.print("dB ");lcd.setCursor(12,3);lcd.print(sub_nam[sub_f]);
 } // menu0 = 2

////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
   switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;}

     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка <<<<<<  
     
    if (newPosition != oldPosition) {oldPosition = newPosition;
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();} 
    
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;}
      
  au();
  lcd.setCursor(2,1);lcd.print("Gain IN ");lcd.print(in+1);lcd.setCursor(12,1);lcd.print(" ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(16,1);lcd.print("dB");gain_d=gain0;
   if(w3==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+7,2);lcd.write((uint8_t)0);lcd.setCursor(z0+1+7,2);lcd.print("   ");}}
   if(z1==3){lcd.setCursor(z0+7,2);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+7,2);lcd.write((uint8_t)2);}} w3=0;
   if(millis()-times_in>3000){in_x=0;cl();menu0=0;w2_arr();}}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   

///////////////////// EEPROM ///////////////////////////////////////////////////////////////         
  if(millis()-time>10000 && w==1){
     EEPROM.update(0,vol+79);EEPROM.update(1,treb+20);EEPROM.update(2,mid+20);EEPROM.update(3,bass+20);
     EEPROM.update(4,in);EEPROM.update(5,gain1);EEPROM.update(6,gain2);EEPROM.update(7,gain3);
     EEPROM.update(8,bass_f);EEPROM.update(9,bass_q);EEPROM.update(10,treb_f);EEPROM.update(11,treb_q),
     EEPROM.update(12,mid_f);EEPROM.update(13,mid_q);EEPROM.update(14,loud_f);EEPROM.update(15,loud_g);
     EEPROM.update(16,lf+79);EEPROM.update(17,rf+79);EEPROM.update(18,lr+79);EEPROM.update(19,rr+79);EEPROM.update(20,sub+79);EEPROM.update(21,sub_f);
     menu=0;menu_1=0;menu_2=0;w=0;w2_arr();}
  
  }// loop

void sub_f_func(){if(sub_f>3){sub_f=0;}if(sub_f<0){sub_f=3;}}
void lf_func(){if(lf<-79){lf=-79;}if(lf>15){lf=15;}};
void rf_func(){if(rf<-79){rf=-79;}if(rf>15){rf=15;}};
void lr_func(){if(lr<-79){lr=-79;}if(lr>15){lr=15;}};
void rr_func(){if(rr<-79){rr=-79;}if(rr>15){rr=15;}};
void sub_func(){if(sub<-79){sub=-79;}if(sub>7){sub=7;}};
void au(){if(www==1){audio();www=0;}}
void loud_f_func(){if(loud_f>3){loud_f=0;}if(loud_f<0){loud_f=3;}}
void loud_g_func(){if(loud_g>20){loud_g=20;}if(loud_g<0){loud_g=0;}}
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 bass_q_func(){if(bass_q>3){bass_q=0;}if(bass_q<0){bass_q=3;}}
void mid_f_func(){if(mid_f>3){mid_f=0;}if(mid_f<0){mid_f=3;}}
void treb_f_func(){if(treb_f>3){treb_f=0;}if(treb_f<0){treb_f=3;}}
void bass_f_func(){if(bass_f>3){bass_f=0;}if(bass_f<0){bass_f=3;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>20){gain0=20;}}
void bass_func(){if(bass>20){bass=20;}if(bass<-20){bass=-20;}} 
void mid_func(){if(mid>20){mid=20;}if(mid<-20){mid=-20;}}
void treb_func(){if(treb>20){treb=20;}if(treb<-20){treb=-20;}}
void vol_func(){if(vol<-79){vol=-79;}if(vol>15){vol=15;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(200);}

void audio(){
    // Advanced switch time of Mute === 0.6 1.0 1.4 3.2 ms = int 0...3
    // Advanced switch time of Input gain/Volume/Tone/Fader/Loudness === 4.7 7.1 11.2 14.4 ms = int 0...3
    // Advanced switch ON/OFF === OFF ON = int 0...1    
  bd.setInitial_1(0, 0, 1); // 0x01
    // Subwoofer LPF fc === OFF 55Hz 85Hz 120Hz = int 0...3
    // Subwoofer Output Select === LPF Front Rear Prohibition = int 0...3
    // Level Meter RESET === HOLD RESET = int 0...1
  bd.setInitial_2(sub_f, 0, 0); // 0x02  
    // Loudness fo === 250Hz 400Hz 800Hz Prohibition = int 0...3
  bd.setInitial_3(loud_f); // 0x03
    // Input Selector === A B C D_single E1_single E2_single D_diff E_full_diff Input_SHORT = int 0...8 
    // Full-diff Bias Type Select === Negative_Input Bias = int 0...1
  bd.setIn(in, 0); // 0x05
    // Input Gain === 0...20 dB = int 0...20
    // MUTE ON/OFF === OFF ON = int 0...1    
  bd.setIn_gain(gain0, mute); // 0x06
    // VOL === -79...+15 dB = int -79...15
  bd.setVol(vol); // 0x20
    // FADER FRONT 1CH === -79...+15 dB = int -79...15
  bd.setFront_1(lf); // 0x28
    // FADER FRONT 2CH === -79...+15 dB = int -79...15
  bd.setFront_2(rf); // 0x29
    // FADER REAR 1CH === -79...+15 dB = int -79...15
  bd.setRear_1(lr); // 0x2A
    // FADER REAR 2CH === -79...+15 dB = int -79...15
  bd.setRear_2(rr); // 0x2B
    // FADER SUB === -79...+15 dB = int -79...15
  bd.setSub(sub); // 0x2C
    // Mixing Gain === -79...+7 dB = int -79...7
  bd.setMix_gain(-79); // 0x30
    // Bass Q factor === 0.5 1.0 1.5 2.0 = int 0...3
    // Bass fo === 60Hz 80Hz 100Hz 120Hz = int 0...3
  bd.setBass_setup(bass_q, bass_f); // 0x41
    // Middle Q factor === 0.75 1.0 1.25 1.5 = int 0...3
    // Middle fo === 500Hz 1kHz 1.5kHz 2.5kHz = int 0...3
  bd.setMiddle_setup(mid_q, mid_f); // 0x44
    // Treble Q factor === 0.75 1.25 = int 0...1
    // Treble fo === 7.5kHz 10kHz 12.5kHz 15kHz = int 0...3
  bd.setTreble_setup(treb_q, mid_f); // 0x47
    // Bass Gain === -20...+20 dB = int -20...20
  bd.setBass_gain(bass); // 0x51
    // Middle Gain === -20...+20 dB = int -20...20
  bd.setMiddle_gain(mid); // 0x54
    // Treble Gain === -20...+20 dB = int -20...20
  bd.setTreble_gain(treb); // 0x57
    // Loudness Gain === 0...20 dB = int 0...20
  bd.setLoudness_gain(loud_g); // 0x75
    // Setup 4 = not param
  bd.setInitial_4(); // 0x90
  }

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

5

Re: BD3702 Sound Processor for car audio

Загорается MUTE без ослабления звука. Режим  MUTE BD3702 включается командой с Arduino? Пин не используется?

6

Re: BD3702 Sound Processor for car audio

MUTE программный

Найдите строчку
  bd.setIn(in, mute); // 0x05

Вместо MUTE поставьте 1, загрузите скетч звука не должно быть.

Проверьте.

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

7

Re: BD3702 Sound Processor for car audio

с исправлением реакция таже

8

Re: BD3702 Sound Processor for car audio

Я обновил скетч. Загрузите по новой, должно заработать.

9

Re: BD3702 Sound Processor for car audio

Заработало, Благодарю

Re: BD3702 Sound Processor for car audio

Подскажите, как добавить в скетч кнопку "ВКЛ" для включения общего питания. Еще добавить функцию задержки подключения громкоговорителей и функцию подачи питания в зависимости от подключенного входа. Спасибо.

Re: BD3702 Sound Processor for car audio

Здравствуйте ,добавьте функцию станбай и вывод с Ардуино управляющий,спасибо

12 (2023-01-16 22:02:30 отредактировано www.aleksandrov74)

Re: BD3702 Sound Processor for car audio

Здравствуйте ! Загрузил скетч,но почему то не вижу коды пульта в мониторе  порта, при нажатии на кнопку пульта нет реакций ни кодов Подключил к 12 пину .Модуль 100 процентов исправен.Так как в других скетчах работает исправно коды вижу.Причем опробовал на разных скетчах связанных с аудиопроцессарами Собирал TDA7419 tda2313 и в этом сектче не работает пульт вернее приемник Ir.Подскажите что не так делаю.

13

Re: BD3702 Sound Processor for car audio

Библиотеку IRremote устанавливали с этого источника - http://rcl-radio.ru/wp-content/uploads/ … remote.zip  ?

14 (2023-01-16 22:03:57 отредактировано www.aleksandrov74)

Re: BD3702 Sound Processor for car audio

С шапки устанавливал библиотеки http://rcl-radio.ru/wp-content/uploads … remote.zip

15 (2023-01-16 22:06:26 отредактировано www.aleksandrov74)

Re: BD3702 Sound Processor for car audio

Уже вторую ардуину нано думал дело в ней пульт использую RC5  Да и пробовал LG

16

Re: BD3702 Sound Processor for car audio

Библиотека поддерживает только формат NEC

17 (2023-01-16 22:13:46 отредактировано www.aleksandrov74)

Re: BD3702 Sound Processor for car audio

Вытравил печатку под BD3207 Все четко работает ! И кнопки и энкодер. Про NEC  понял не знал извините ! Стандбая не хватает отдельной кнопкой и вывода И лично мне бы от энкодера избавится только кнопки и пульт.Можно вас попросить сделать это

18

Re: BD3702 Sound Processor for car audio

Ранее была установлена библиотека IRremote не с моего сайта? Если была то надо перед установкой удалить папку со старой библиотекой.

19

Re: BD3702 Sound Processor for car audio

Светодиод на платке ИК датчика мигает если нажать кнопку пульта?

20 (2023-01-16 22:16:00 отредактировано www.aleksandrov74)

Re: BD3702 Sound Processor for car audio

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

21

Re: BD3702 Sound Processor for car audio

Вытравил печатку под BD3207 Все четко работает ! И кнопки и энкодер. Про NEC  понял не знал извините ! Стандбая не хватает отдельной кнопкой и вывода И лично мне бы от энкодера избавится только кнопки и пульт.Можно вас попросить сделать это

Завтра постараюсь сделать.

22 (2023-01-16 22:22:43 отредактировано www.aleksandrov74)

Re: BD3702 Sound Processor for car audio

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

23

Re: BD3702 Sound Processor for car audio

Дисплей используете LCD2004 с модулем I2C?

24 (2023-01-16 23:01:34 отредактировано www.aleksandrov74)

Re: BD3702 Sound Processor for car audio

Для теста использую 16 2 с I2C но скоро приедет LCD2004 в принципе видно частично

25

Re: BD3702 Sound Processor for car audio

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

Mute только с пульта, STANDBY с пульта и кнопки. Выход для управления STANDBY D4.

Подсветку дисплея можно сделать от ШИМ выхода, то есть в режиме STANDBY будет гаснуть не полностью, а немного  подсвечивать, можно вывести надпись или время.



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


#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <BD3702.h>
#include <EEPROM.h>
#include <boarddefs.h>
#include <IRremote.h>
   BD3702 bd;
   LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
   IRrecv irrecv(12); // указываем вывод модуля IR приемника
   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,times_in,oldPosition  = -999,newPosition; 
   byte in,in_x,w,w1,w2[4],w3,z,z0,z1,q,i,www,gr1,gr2;
   int menu,menu0,menu_1,menu_2,vol,bass,treb,mid,vol_d,bass_d,treb_d,mid_d,mute;
   int temp0,gain0,gain1,gain2,gain3,gain_d;
   int bass_f,bass_q,treb_f,treb_q,mid_f,mid_q,loud_f,loud_g;
   int lf,rf,lr,rr,sub,sub_f;
   byte mesto[8]={4,13,4,13,4,13,4,13};
   byte mesto1[8]={0,0,1,1,2,2,3,3};
   byte mesto2[6]={0,11,0,11,0,11};
   byte mesto3[6]={0,0,1,1,3,3};
   String bass_nam[4]={"60   Hz", "80   Hz", "100  Hz", "120  Hz"};
   String treb_nam[4]={"7.5 kHz", "10  kHz", "12.5kHz", "15  kHz"};
   String mid_nam[4] ={"500  Hz", "1   kHz", "1.5 kHz", "2.5 kHz"};
   String lon_nam[4] ={"250  Hz", "400  Hz", "800  Hz", "disable"};
   String sub_nam[4] ={" OFF   ", " 55  Hz", " 85  Hz", " 120 Hz"};
   float bass_nam_1[4]={0.5, 1.0, 1.5, 2.0};
   float mid_nam_1[4]={0.75, 1.0, 1.25, 1.5};
   float treb_nam_1[2]={0.75, 1.25};
   bool power;

void setup() {
  irrecv.enableIRIn();lcd.init();lcd.backlight();
  Serial.begin(9600);
  lcd.setCursor(0,2);lcd.print("      BD3702FV   ");lcd.setCursor(0,1);lcd.print("  Sound  Processor  "); delay(2000);
  lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);
  pinMode(10,INPUT_PULLUP);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT_PULLUP);   // МЕНЮ НАСТРОЕК
  pinMode(3,INPUT_PULLUP);   // IN
  pinMode(A0,INPUT_PULLUP);  // UP
  pinMode(A1,INPUT_PULLUP);  // DW
  pinMode(A2,INPUT_PULLUP);  // POWER
  pinMode(4,OUTPUT);         // OUTPUT STANDBY
  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)-20;mid = EEPROM.read(2)-20;bass = EEPROM.read(3)-20;
  in = EEPROM.read(4);gain1 = EEPROM.read(5);gain2 = EEPROM.read(6);gain3 = EEPROM.read(7);
  bass_f = EEPROM.read(8);bass_q = EEPROM.read(9);treb_f = EEPROM.read(10);treb_q = EEPROM.read(11);
  mid_f = EEPROM.read(12);mid_q = EEPROM.read(13);loud_f = EEPROM.read(14);loud_g= EEPROM.read(15);
  lf = EEPROM.read(16)-79;rf = EEPROM.read(17)-79;lr = EEPROM.read(18)-79;rr = EEPROM.read(19)-79;sub = EEPROM.read(20)-79;sub_f = EEPROM.read(21);
  w2_arr();audio();cl();
}

void loop() {
if(power==0){
  if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time=millis();w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu_1++;delay(200);time=millis();w=1;if(menu_1>7){menu_1=0;}}// меню 1
  if(digitalRead(10)==LOW&&menu0==2){menu_2++;delay(200);time=millis();w=1;if(menu_2>5){menu_2=0;}}// меню 2
    
  if(digitalRead(2)==LOW && in_x==0){menu0++;cl();delay(200);time=millis();w=1;w2_arr();menu=0;menu_1=0;menu_2=0;if(menu0>2){menu0=0;}}// меню
  if(digitalRead(3)==LOW){in++;cl();times_in=millis();in_x=1;w3=1;www=1;menu0=100;if(in>2){in=0;}}// IN
}
////////////////////// 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_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu>3){menu=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu<0){menu=3;}}//  кнопка вниз
   if(ir.value==IR_2&&menu0==1){menu_1++;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_1>7){menu_1=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==1){menu_1--;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_1<0){menu_1=7;}}//  кнопка вниз
   if(ir.value==IR_2&&menu0==2){menu_2++;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_2>5){menu_2=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==2){menu_2--;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_2<0){menu_2=5;}}//  кнопка вниз

   if(ir.value==IR_6){menu0++;gr1=0;gr2=0;cl();time=millis();w=1;w2_arr();menu=0;menu_1;menu_2;if(menu0>2){menu0=0;}}//  кнопка MENU
   if(ir.value==IR_5){in++;gr1=0;gr2=0;cl();times_in=millis();in_x=1;w3=1;www=1;menu0=100;if(in>2){in=0;}}//  кнопка IN

  if(ir.value==IR_7&&mute==0){mute=1;gr1=0;gr2=0;cl();lcd.setCursor(0,1);lcd.print("        MUTE     ");menu0=100;audio();}// mute on
  if(ir.value==IR_7&&mute==1){mute=0;gr1=0;gr2=0;cl();menu0=0;w2_arr();audio();}// mute off

}

 if((ir.value==IR_8||digitalRead(A2)==LOW)&&power==0){power=1;in_x=0;mute=1;cl();audio();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);}// power off
 if((ir.value==IR_8||digitalRead(A2)==LOW)&&power==1){power=0;cl();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();
   menu0=0;mute=0;audio();delay(3000);cl();}// power on
 if(power==0){digitalWrite(4,HIGH);}else{digitalWrite(4,LOW);}  
  
/////////////////////////////// MENU0 = VOLUME TERBLE MIDDLE BASS ///////////////////////////////////////////////////////////////////////
  if(menu0==0){
    switch(menu){
      case 0: temp0 = vol;q=0;break;
      case 1: temp0 = bass;q=1;break;
      case 2: temp0 = mid;q=2;break;
      case 3: temp0 = treb;q=3;break;}

     if(ir.value==IR_3 || digitalRead(A0)==LOW){temp0++;gr1=1;gr2=0;cl1();time=millis();w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time=millis();;w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4 || digitalRead(A1)==LOW){temp0--;gr1=0;gr2=1;cl1();time=millis();;w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time=millis();w=1;w2[q]=1;www=1;}// кнопка <<<<<<   

     switch(menu){
      case 0: vol = temp0;vol_func();break;
      case 1: bass = temp0;bass_func();break;
      case 2: mid = temp0;mid_func();break;
      case 3: treb = temp0;treb_func();break;}
      
   au();
   for(i=0;i<4;i++){if(menu==i){lcd.setCursor(0,i);lcd.print(">");}else{lcd.setCursor(0,i);lcd.print(" ");}}
   lcd.setCursor(1,0);lcd.print("VOLUME ");if(vol>=0){lcd.print(" ");}lcd.print(vol);lcd.print(" ");vol_d=map(vol,-79,15,0,24);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print(" ");bass_d=map(bass,-20,20,0,24);
   lcd.setCursor(1,2);lcd.print("MIDDLE ");if(mid>=0){lcd.print(" ");}lcd.print(mid);lcd.print(" ");mid_d=map(mid,-20,20,0,24);
   lcd.setCursor(1,3);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print(" ");treb_d=map(treb,-20,20,0,24);

   if(w2[0]==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+12,0);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,0);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,0);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,0);lcd.write((uint8_t)2);}w2[0]=0;}
   if(w2[1]==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+12,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,1);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,1);lcd.write((uint8_t)2);}w2[1]=0;}
   if(w2[2]==1){
   for(z=0,z0=0,z1=0;z<=mid_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,2);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,2);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,2);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,2);lcd.write((uint8_t)2);}w2[2]=0;}   
   if(w2[3]==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+12,3);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,3);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,3);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,3);lcd.write((uint8_t)2);}w2[3]=0;}
   }// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////

///////////////////// MENU 2 ////////////////////////////////////////////////////////
 if(menu0==1){
  switch(menu_1){
      case 0: temp0 = bass_f;break;
      case 1: temp0 = bass_q;break;
      case 2: temp0 = mid_f;break;
      case 3: temp0 = mid_q;break;
      case 4: temp0 = treb_f;break;
      case 5: temp0 = treb_q;break;
      case 6: temp0 = loud_f;break;
      case 7: temp0 = loud_g;break;}

     if(ir.value==IR_3 || digitalRead(A0)==LOW){temp0++;gr1=1;gr2=0;cl1();time=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4 || digitalRead(A1)==LOW){temp0--;gr1=0;gr2=1;cl1();time=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time=millis();w=1;www=1;}// кнопка <<<<<<     
     

     switch(menu_1){
      case 0: bass_f = temp0;bass_f_func();break;
      case 1: bass_q = temp0;bass_q_func();break;
      case 2: mid_f = temp0;mid_f_func();break;
      case 3: mid_q = temp0;mid_q_func();break;
      case 4: treb_f = temp0;treb_f_func();break;
      case 5: treb_q = temp0;treb_q_func();break;
      case 6: loud_f = temp0;loud_f_func();break;
      case 7: loud_g = temp0;loud_g_func();break;}
      
  au();
  for(i=0;i<8;i++){if(menu_1==i){lcd.setCursor(mesto[i],mesto1[i]);lcd.print(">");}else{lcd.setCursor(mesto[i],mesto1[i]);lcd.print(" ");}}
  lcd.setCursor(0,0);lcd.print("BASS");lcd.setCursor(5,0);lcd.print(bass_nam[bass_f]);lcd.setCursor(14,0);lcd.print("Q ");lcd.print(bass_nam_1[bass_q]);
  lcd.setCursor(0,1);lcd.print("MIDD");lcd.setCursor(5,1);lcd.print(mid_nam[mid_f]);lcd.setCursor(14,1);lcd.print("Q ");lcd.print(mid_nam_1[mid_q]);
  lcd.setCursor(0,2);lcd.print("TREB");lcd.setCursor(5,2);lcd.print(treb_nam[treb_f]);lcd.setCursor(14,2);lcd.print("Q ");lcd.print(treb_nam_1[treb_q]);
  lcd.setCursor(0,3);lcd.print("LOUD");lcd.setCursor(5,3);lcd.print(lon_nam[loud_f]);lcd.setCursor(14,3);lcd.print("G ");lcd.print(loud_g/10);lcd.print(loud_g%10);lcd.setCursor(18,3);lcd.print("dB");
  }// menu0 = 1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


 if(menu0==2){
     switch(menu_2){
      case 0: temp0 = lf;break;
      case 1: temp0 = rf;break;
      case 2: temp0 = lr;break;
      case 3: temp0 = rr;break;
      case 4: temp0 = sub;break;
      case 5: temp0 = sub_f;break;}

     if(ir.value==IR_3 || digitalRead(A0)==LOW){temp0++;gr1=1;gr2=0;cl1();time=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4 || digitalRead(A1)==LOW){temp0--;gr1=0;gr2=1;cl1();time=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time=millis();w=1;www=1;}// кнопка <<<<<<     

     switch(menu_2){
      case 0: lf = temp0;lf_func();break;
      case 1: rf = temp0;rf_func();break;
      case 2: lr = temp0;lr_func();break;
      case 3: rr = temp0;rr_func();break;
      case 4: sub = temp0;sub_func();break;
      case 5: sub_f = temp0;sub_f_func();break;}

  au();
  for(i=0;i<6;i++){if(menu_2==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(">");}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
  lcd.setCursor(1,0);lcd.print("LF");lcd.setCursor(4,0);lcd.print(lf);lcd.print(" ");lcd.setCursor(7,0);lcd.print("dB ");lcd.setCursor(12,0);lcd.print("RF ");lcd.print(rf);lcd.print(" ");lcd.setCursor(18,0);lcd.print("dB");
  lcd.setCursor(1,1);lcd.print("LR");lcd.setCursor(4,1);lcd.print(lr);lcd.print(" ");lcd.setCursor(7,1);lcd.print("dB ");lcd.setCursor(12,1);lcd.print("RR ");lcd.print(rr);lcd.print(" ");lcd.setCursor(18,1);lcd.print("dB");
  lcd.setCursor(0,2);lcd.print("  Subwoofer  setup  ");
  lcd.setCursor(1,3);lcd.print("G ");lcd.setCursor(4,3);lcd.print(sub);lcd.print(" ");lcd.setCursor(7,3);lcd.print("dB ");lcd.setCursor(12,3);lcd.print(sub_nam[sub_f]);
 } // menu0 = 2

////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
   switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;}

     if(ir.value==IR_3 || digitalRead(A0)==LOW){gain0++;gr1=1;gr2=0;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка >>>>>>
     if(ir.value==IR_4 || digitalRead(A1)==LOW){gain0--;gr1=0;gr2=1;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка <<<<<<  
     
    
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;}
      
  au();
  lcd.setCursor(2,1);lcd.print("Gain IN ");lcd.print(in+1);lcd.setCursor(12,1);lcd.print(" ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(16,1);lcd.print("dB");gain_d=gain0;
   if(w3==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+7,2);lcd.write((uint8_t)0);lcd.setCursor(z0+1+7,2);lcd.print("   ");}}
   if(z1==3){lcd.setCursor(z0+7,2);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+7,2);lcd.write((uint8_t)2);}} w3=0;
   if(millis()-times_in>3000){in_x=0;cl();menu0=0;w2_arr();}}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   

///////////////////// EEPROM ///////////////////////////////////////////////////////////////         
  if(millis()-time>10000 && w==1){
     EEPROM.update(0,vol+79);EEPROM.update(1,treb+20);EEPROM.update(2,mid+20);EEPROM.update(3,bass+20);
     EEPROM.update(4,in);EEPROM.update(5,gain1);EEPROM.update(6,gain2);EEPROM.update(7,gain3);
     EEPROM.update(8,bass_f);EEPROM.update(9,bass_q);EEPROM.update(10,treb_f);EEPROM.update(11,treb_q),
     EEPROM.update(12,mid_f);EEPROM.update(13,mid_q);EEPROM.update(14,loud_f);EEPROM.update(15,loud_g);
     EEPROM.update(16,lf+79);EEPROM.update(17,rf+79);EEPROM.update(18,lr+79);EEPROM.update(19,rr+79);EEPROM.update(20,sub+79);EEPROM.update(21,sub_f);
     menu=0;menu_1=0;menu_2=0;w=0;w2_arr();}
  
  }// loop

void sub_f_func(){if(sub_f>3){sub_f=0;}if(sub_f<0){sub_f=3;}}
void lf_func(){if(lf<-79){lf=-79;}if(lf>15){lf=15;}};
void rf_func(){if(rf<-79){rf=-79;}if(rf>15){rf=15;}};
void lr_func(){if(lr<-79){lr=-79;}if(lr>15){lr=15;}};
void rr_func(){if(rr<-79){rr=-79;}if(rr>15){rr=15;}};
void sub_func(){if(sub<-79){sub=-79;}if(sub>7){sub=7;}};
void au(){if(www==1){audio();www=0;}}
void loud_f_func(){if(loud_f>3){loud_f=0;}if(loud_f<0){loud_f=3;}}
void loud_g_func(){if(loud_g>20){loud_g=20;}if(loud_g<0){loud_g=0;}}
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 bass_q_func(){if(bass_q>3){bass_q=0;}if(bass_q<0){bass_q=3;}}
void mid_f_func(){if(mid_f>3){mid_f=0;}if(mid_f<0){mid_f=3;}}
void treb_f_func(){if(treb_f>3){treb_f=0;}if(treb_f<0){treb_f=3;}}
void bass_f_func(){if(bass_f>3){bass_f=0;}if(bass_f<0){bass_f=3;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>20){gain0=20;}}
void bass_func(){if(bass>20){bass=20;}if(bass<-20){bass=-20;}} 
void mid_func(){if(mid>20){mid=20;}if(mid<-20){mid=-20;}}
void treb_func(){if(treb>20){treb=20;}if(treb<-20){treb=-20;}}
void vol_func(){if(vol<-79){vol=-79;}if(vol>15){vol=15;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(200);}

void audio(){
    // Advanced switch time of Mute === 0.6 1.0 1.4 3.2 ms = int 0...3
    // Advanced switch time of Input gain/Volume/Tone/Fader/Loudness === 4.7 7.1 11.2 14.4 ms = int 0...3
    // Advanced switch ON/OFF === OFF ON = int 0...1    
  bd.setInitial_1(0, 0, 1); // 0x01
    // Subwoofer LPF fc === OFF 55Hz 85Hz 120Hz = int 0...3
    // Subwoofer Output Select === LPF Front Rear Prohibition = int 0...3
    // Level Meter RESET === HOLD RESET = int 0...1
  bd.setInitial_2(sub_f, 0, 0); // 0x02  
    // Loudness fo === 250Hz 400Hz 800Hz Prohibition = int 0...3
  bd.setInitial_3(loud_f); // 0x03
    // Input Selector === A B C D_single E1_single E2_single D_diff E_full_diff Input_SHORT = int 0...8 
    // Full-diff Bias Type Select === Negative_Input Bias = int 0...1
  bd.setIn(in, 0); // 0x05
    // Input Gain === 0...20 dB = int 0...20
    // MUTE ON/OFF === OFF ON = int 0...1    
  bd.setIn_gain(gain0, mute); // 0x06
    // VOL === -79...+15 dB = int -79...15
  bd.setVol(vol); // 0x20
    // FADER FRONT 1CH === -79...+15 dB = int -79...15
  bd.setFront_1(lf); // 0x28
    // FADER FRONT 2CH === -79...+15 dB = int -79...15
  bd.setFront_2(rf); // 0x29
    // FADER REAR 1CH === -79...+15 dB = int -79...15
  bd.setRear_1(lr); // 0x2A
    // FADER REAR 2CH === -79...+15 dB = int -79...15
  bd.setRear_2(rr); // 0x2B
    // FADER SUB === -79...+15 dB = int -79...15
  bd.setSub(sub); // 0x2C
    // Mixing Gain === -79...+7 dB = int -79...7
  bd.setMix_gain(-79); // 0x30
    // Bass Q factor === 0.5 1.0 1.5 2.0 = int 0...3
    // Bass fo === 60Hz 80Hz 100Hz 120Hz = int 0...3
  bd.setBass_setup(bass_q, bass_f); // 0x41
    // Middle Q factor === 0.75 1.0 1.25 1.5 = int 0...3
    // Middle fo === 500Hz 1kHz 1.5kHz 2.5kHz = int 0...3
  bd.setMiddle_setup(mid_q, mid_f); // 0x44
    // Treble Q factor === 0.75 1.25 = int 0...1
    // Treble fo === 7.5kHz 10kHz 12.5kHz 15kHz = int 0...3
  bd.setTreble_setup(treb_q, mid_f); // 0x47
    // Bass Gain === -20...+20 dB = int -20...20
  bd.setBass_gain(bass); // 0x51
    // Middle Gain === -20...+20 dB = int -20...20
  bd.setMiddle_gain(mid); // 0x54
    // Treble Gain === -20...+20 dB = int -20...20
  bd.setTreble_gain(treb); // 0x57
    // Loudness Gain === 0...20 dB = int 0...20
  bd.setLoudness_gain(loud_g); // 0x75
    // Setup 4 = not param
  bd.setInitial_4(); // 0x90
  }