1

Тема: TDA7718

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

3 band car audio processor

http://forum.rcl-radio.ru/uploads/images/2020/07/f72c91bc02f47fdceef40ab4f8cb692e.png

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

https://github.com/liman324/TDA7718.git

TDA7718.h

#ifndef TDA7718_H
#define TDA7718_H

#define TDA7718_address 0b1000100 // 7 bit

#define MAIN            0b00000000
#define SOFT_MUTE       0b00000100
#define SOFT_STEP1      0b00000101
#define SOFT_STEP2      0b00000110
#define LOUNNESS        0b00000111
#define VOLUME_OUT      0b00001000
#define TERBLE          0b00001001
#define MIDDLE          0b00001010
#define BASS            0b00001011
#define SUB_MID_BASS    0b00001100
#define ATT_LF          0b00001101
#define ATT_RF          0b00001110
#define ATT_LR          0b00001111
#define ATT_RR          0b00010000
#define ATT_SL          0b00010001
#define ATT_SR          0b00010010

#include <Arduino.h>
class TDA7718
{
  public:
    TDA7718();
	void setMain(byte main_sel, byte fd_qd, byte main_gain, byte sub_flat); // 0,0,0,0
 // main_sel  - 0 SE1 / 1 SE3 / 2 QD1 / 3 QD2_FD1 / 4 SE2 / 5 SE4 / 6 SE5 / 7 MUTE === TDA7718N
 // main_sel  - 0 SE1 / 1 SE3 / 2 QD1 / 3 QD2_FD1 / 4 SE2 / 5 MUTE / 6 MUTE / 7 MUTE === TDA7718B
 // fd_qd - 0 FD / 1 QD2 
 // main_gain - 0 0dB / 1 3dB
 // sub_flat -  0 off / 1 on
        void setSoft_mute(byte soft_mute, byte pin_iic, byte soft_mute_time, byte sub_in, byte sub_eneble, byte fast_ch, byte anty_filter);// 0,0,1,0,0,0,0
 // soft_mute -  0 off / 1 on
 // pin_iic - 0 pin_and_iic / 1 iic 
 // soft_mute_time - 0 0.48ms / 1 0.96ms / 2 7.68ms / 3 15.63ms
 // sub_in - 0 input_mux / 1 bass_output  
 // sub_eneble - 0 on / 1 off
 // fast_ch - 0 on / 1 off
 // anty_filter - 0 on / off(bypass)
        void setSoft_step_1(byte loud_soft, byte vol_soft, byte treb_soft, byte mid_soft, byte bass_soft, byte lf_soft, byte rf_soft, byte lr_soft); // 0,0,0,0,0,0,0,0
 // all - 0 on / 1 off
        void setSoft_step_2(byte rr_soft, byte sub_l_soft, byte sub_r_soft, byte soft_time, byte zero, byte spike); // 0,0,0,0,1,1
 // rr_soft -  0 on / 1 off
 // sub_l_soft -  0 on / 1 off
 // sub_r_soft -  0 on / 1 off
 // soft_time - 0 5ms / 1 10ms
 // zero - 0 100mV / 1 75mV / 2 50mV / 3 25mV
 // spike - 0 11mkS / 1 22mkS / 2 33mkS / 3 44mkS
        void setLoudness(byte lon_att, byte lon_cen_f, byte lon_h_boost, byte lon_soft_step); // 0,0,0,0
 // lon_att - byte 0...15 = 0...-15dB 
 // lon_cen_f - 0 flat / 1 400Hz / 2 800Hz / 3 2400Hz
 // lon_h_boost - 0 on / 1 off
 // lon_soft_step - 0 act / 1 wait
        void setVolume_gain(int vol_gain, byte vol_out_gain, byte vol_soft_step); // 0,0,0
 // vol_gain - int -31...23 = -31...+23dB
 // vol_out_gain - 0 1dB / 1 0dB
 // vol_soft_step - 0 act / 1 wait
        void setTreble(int treb, byte treb_cen_f, byte treb_soft_step); // 0,0,0
 // treb - int -15...+15 = -15...+15dB 
 // treb_cen_f - 0 10.0kHz / 1 12.5kHz / 2 15.0kHz / 3 17.5 kHz
 // treb_soft_step - 0 act / 1 wait
        void setMiddle(int mid, byte mid_q, byte mid_soft_step); // 0,0,0
 // mid - int -15...+15 = -15...+15dB 
 // mid_q - 0 0.75 / 1 1.0 / 2 1.25 / 3 reserved 
 // mid_soft_step - 0 act / 1 wait
        void setBass(int bass, byte bass_q, byte bass_soft_step); // 0,0,0
 // bass - int -15...+15 = -15...+15dB 
 // bass_q - 0 1.0 / 1 1.25 / 2 1.5 / 3 2.0 
 // bass_soft_step - 0 act / 1 wait
        void setSub_Mid_Bass(byte sub_cen_f, byte sub_faza, byte mid_cen_f, byte bass_cen_f, byte bass_dc);
 // sub_cen_f - 0 55Hz / 1 85Hz / 2 120Hz / 3 160Hz
 // sub_faza - 0 180deg / 1 0deg
 // mid_cen_f - 0 500Hz / 1 1000Hz / 2 1500Hz / 3 2500Hz
 // bass_cen_f - 0 60Hz / 1 80Hz / 2 100Hz / 3 200Hz
 // bass_dc - 0 on / 1 off
        void setLF(int lf, byte lf_soft_step);
        void setRF(int rf, byte rf_soft_step);
        void setLR(int lr, byte lr_soft_step);
        void setRR(int rr, byte rr_soft_step);
        void setSL(int sl, byte sl_soft_step);
        void setSR(int sr, byte sr_soft_step);
 // all int -79...+15 = -79...+15dB
 // all - 0 act / 1 wait


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

TDA7718.cpp

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

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



void TDA7718::setMain(byte main_sel, byte fd_qd, byte main_gain, byte sub_flat){
        switch(main_sel){
           case 0: main_sel = 0b00000000;break; 
           case 1: main_sel = 0b00000001;break;
           case 2: main_sel = 0b00000010;break;
           case 3: main_sel = 0b00000011;break;
           case 4: main_sel = 0b00000100;break;
           case 5: main_sel = 0b00000101;break;
           case 6: main_sel = 0b00000110;break;
           case 7: main_sel = 0b00000111;break;
}
        switch(fd_qd){
           case 0: fd_qd = 0b00000000;break; 
           case 1: fd_qd = 0b00001000;break;
}
        switch(main_gain){
           case 0: main_gain = 0b00000000;break; 
           case 1: main_gain = 0b00010000;break;
}
        switch(sub_flat){
           case 0: sub_flat = 0b00000000;break; 
           case 1: sub_flat = 0b00100000;break;
}
   writeWire(MAIN, main_sel + fd_qd + main_gain + sub_flat);	
}


void TDA7718::setSoft_mute(byte soft_mute, byte pin_iic, byte soft_mute_time, byte sub_in, byte sub_eneble, byte fast_ch, byte anty_filter){
        switch(soft_mute){
           case 0: soft_mute = 0b00000000;break; 
           case 1: soft_mute = 0b00000001;break;      
}
        switch(pin_iic){
           case 0: pin_iic = 0b00000000;break; 
           case 1: pin_iic = 0b00000010;break;      
}
        switch(soft_mute_time){
           case 0: soft_mute_time = 0b00000000;break; 
           case 1: soft_mute_time = 0b00000100;break;
           case 2: soft_mute_time = 0b00001000;break;
           case 3: soft_mute_time = 0b00001100;break;      
}
        switch(sub_in){
           case 0: sub_in = 0b00000000;break; 
           case 1: sub_in = 0b00010000;break;      
}
        switch(sub_eneble){
           case 0: sub_eneble = 0b00000000;break; 
           case 1: sub_eneble = 0b00100000;break;      
}
      switch(fast_ch){
           case 0: fast_ch = 0b00000000;break; 
           case 1: fast_ch = 0b01000000;break;      
}
      switch(anty_filter){
           case 0: anty_filter = 0b00000000;break; 
           case 1: anty_filter = 0b10000000;break;      
}
   
   writeWire(SOFT_MUTE, soft_mute + pin_iic + soft_mute_time + sub_in + sub_eneble + fast_ch + anty_filter);	
}
         
void TDA7718::setSoft_step_1(byte loud_soft, byte vol_soft, byte treb_soft, byte mid_soft, byte bass_soft, byte lf_soft, byte rf_soft, byte lr_soft){
        switch(loud_soft){
           case 0: loud_soft = 0b00000000;break; 
           case 1: loud_soft = 0b00000001;break;      
}
        switch(vol_soft){
           case 0: vol_soft = 0b00000000;break; 
           case 1: vol_soft = 0b00000010;break;      
}
        switch(treb_soft){
           case 0: treb_soft = 0b00000000;break; 
           case 1: treb_soft = 0b00000100;break;      
}
        switch(mid_soft){
           case 0: mid_soft = 0b00000000;break; 
           case 1: mid_soft = 0b00001000;break;      
}
        switch(bass_soft){
           case 0: bass_soft = 0b00000000;break; 
           case 1: bass_soft = 0b00010000;break;      
}
        switch(lf_soft){
           case 0: lf_soft = 0b00000000;break; 
           case 1: lf_soft = 0b00100000;break;      
}
        switch(rf_soft){
           case 0: rf_soft = 0b00000000;break; 
           case 1: rf_soft = 0b01000000;break;      
}
        switch(lr_soft){
           case 0: lr_soft = 0b00000000;break; 
           case 1: lr_soft = 0b10000000;break;      
}
   writeWire(SOFT_STEP1, loud_soft + vol_soft + treb_soft + mid_soft + bass_soft + lf_soft + rf_soft + lr_soft);	
}


void TDA7718::setSoft_step_2(byte rr_soft, byte sub_l_soft, byte sub_r_soft, byte soft_time, byte zero, byte spike){
        switch(rr_soft){
           case 0: rr_soft = 0b00000000;break; 
           case 1: rr_soft = 0b00000001;break;      
}
        switch(sub_l_soft){
           case 0: sub_l_soft = 0b00000000;break; 
           case 1: sub_l_soft= 0b00000010;break;      
}
        switch(sub_r_soft){
           case 0: sub_r_soft = 0b00000000;break; 
           case 1: sub_r_soft = 0b00000100;break;      
}
        switch(soft_time){
           case 0: soft_time = 0b00000000;break; 
           case 1: soft_time = 0b00001000;break;      
}
        switch(zero){
           case 0: zero = 0b00000000;break; 
           case 1: zero = 0b00010000;break;
           case 2: zero = 0b00100000;break; 
           case 3: zero = 0b00110000;break;      
}
        switch(spike){
           case 0: spike = 0b00000000;break; 
           case 1: spike = 0b01000000;break;
           case 2: spike = 0b10000000;break; 
           case 3: spike = 0b11000000;break;      
}
   writeWire(SOFT_STEP2, rr_soft + sub_l_soft + sub_r_soft + soft_time + zero + spike);
}

void TDA7718::setLoudness(byte lon_att, byte lon_cen_f, byte lon_h_boost, byte lon_soft_step){
        switch(lon_cen_f){
           case 0: lon_cen_f = 0b00000000;break; 
           case 1: lon_cen_f = 0b00010000;break;
           case 2: lon_cen_f = 0b00100000;break; 
           case 3: lon_cen_f = 0b00110000;break;      
}
        switch(lon_h_boost){
           case 0: lon_h_boost = 0b00000000;break; 
           case 1: lon_h_boost = 0b01000000;break;
}
        switch(lon_soft_step){
           case 0: lon_soft_step = 0b00000000;break; 
           case 1: lon_soft_step = 0b10000000;break;
}
   writeWire(LOUNNESS, lon_att + lon_cen_f + lon_h_boost + lon_soft_step);
}

void TDA7718::setVolume_gain(int vol_gain, byte vol_out_gain, byte vol_soft_step){
          if(vol_gain<0){vol_gain = abs(vol_gain)+32;}
        switch(vol_out_gain){
           case 0: vol_out_gain = 0b00000000;break; 
           case 1: vol_out_gain = 0b01000000;break;
}
        switch(vol_soft_step){
           case 0: vol_soft_step = 0b00000000;break; 
           case 1: vol_soft_step = 0b10000000;break;
}
   writeWire(VOLUME_OUT, vol_gain + vol_out_gain + vol_soft_step);
}

void TDA7718::setTreble(int treb, byte treb_cen_f, byte treb_soft_step){
        if(treb >= 0){treb = 31 - treb;}
        if(treb < 0){treb = treb + 15;}
        switch(treb_cen_f){
           case 0: treb_cen_f = 0b00000000;break; 
           case 1: treb_cen_f = 0b00100000;break;
           case 2: treb_cen_f = 0b01000000;break; 
           case 3: treb_cen_f = 0b01100000;break;      
}
        switch(treb_soft_step){
           case 0: treb_soft_step = 0b00000000;break; 
           case 1: treb_soft_step = 0b10000000;break;
}
    writeWire(TERBLE, treb + treb_cen_f + treb_soft_step);
}

void TDA7718::setMiddle(int mid, byte mid_q, byte mid_soft_step){
        if(mid >= 0){mid = 31 - mid;}
        if(mid < 0){mid = mid + 15;}
        switch(mid_q){
           case 0: mid_q = 0b00000000;break; 
           case 1: mid_q = 0b00100000;break;
           case 2: mid_q = 0b01000000;break; 
           case 3: mid_q = 0b01100000;break;      
}
        switch(mid_soft_step){
           case 0: mid_soft_step = 0b00000000;break; 
           case 1: mid_soft_step = 0b10000000;break;
}
    writeWire(MIDDLE, mid + mid_q + mid_soft_step);
}

void TDA7718::setBass(int bass, byte bass_q, byte bass_soft_step){
        if(bass >= 0){bass = 31 - bass;}
        if(bass < 0){bass = bass + 15;}
        switch(bass_q){
           case 0: bass_q = 0b00000000;break; 
           case 1: bass_q = 0b00100000;break;
           case 2: bass_q = 0b01000000;break; 
           case 3: bass_q = 0b01100000;break;      
}
        switch(bass_soft_step){
           case 0: bass_soft_step = 0b00000000;break; 
           case 1: bass_soft_step = 0b10000000;break;
}
    writeWire(BASS, bass + bass_q + bass_soft_step);
}


void TDA7718::setSub_Mid_Bass(byte sub_cen_f, byte sub_faza, byte mid_cen_f, byte bass_cen_f, byte bass_dc){
        switch(sub_cen_f){
           case 0: sub_cen_f = 0b00000000;break; 
           case 1: sub_cen_f = 0b00000001;break;
           case 2: sub_cen_f = 0b00000010;break; 
           case 3: sub_cen_f = 0b00000011;break;      
}
        switch(sub_faza){
           case 0: sub_faza = 0b00000000;break; 
           case 1: sub_faza = 0b00000100;break;
}
        switch(mid_cen_f){
           case 0: mid_cen_f = 0b00000000;break; 
           case 1: mid_cen_f = 0b00001000;break;
           case 2: mid_cen_f = 0b00010000;break; 
           case 3: mid_cen_f = 0b00011000;break;      
}
        switch(bass_cen_f){
           case 0: bass_cen_f = 0b00000000;break; 
           case 1: bass_cen_f = 0b00100000;break;
           case 2: bass_cen_f = 0b01000000;break; 
           case 3: bass_cen_f = 0b01100000;break;      
}
        switch(bass_dc){
           case 0: bass_dc = 0b00000000;break; 
           case 1: bass_dc = 0b10000000;break;
}
    writeWire(SUB_MID_BASS, sub_cen_f + sub_faza + mid_cen_f + bass_cen_f + bass_dc);
}


void TDA7718::setLF(int lf, byte lf_soft_step){
            if(lf < 0){lf = abs(lf) + 16;}
            writeWire(ATT_LF, lf + (lf_soft_step << 7)); 
}

void TDA7718::setRF(int rf, byte rf_soft_step){
            if(rf < 0){rf = abs(rf) + 16;}
            writeWire(ATT_RF, rf + (rf_soft_step << 7)); 
}

void TDA7718::setLR(int lr, byte lr_soft_step){
            if(lr < 0){lr = abs(lr) + 16;}
            writeWire(ATT_LR, lr + (lr_soft_step << 7)); 
}

void TDA7718::setRR(int rr, byte rr_soft_step){
            if(rr < 0){rr = abs(rr) + 16;}
            writeWire(ATT_RR, rr + (rr_soft_step << 7)); 
}

void TDA7718::setSL(int sl, byte sl_soft_step){
            if(sl < 0){sl = abs(sl) + 16;}
            writeWire(ATT_SL, sl + (sl_soft_step << 7)); 
}

void TDA7718::setSR(int sr, byte sr_soft_step){
            if(sr < 0){sr = abs(sr) + 16;}
            writeWire(ATT_SR, sr + (sr_soft_step << 7)); 
}



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

test.ino

#include <TDA7718.h>

TDA7718 tda;

void setup(){
  delay(1000);
  audio();
  }
void loop(){}

void audio(){
       tda.setMain(0,0,0,0); // 0,0,0,0
 // main_sel  - 0 SE1 / 1 SE3 / 2 QD1 / 3 QD2_FD1 / 4 SE2 / 5 SE4 / 6 SE5 / 7 MUTE === TDA7718N
 // main_sel  - 0 SE1 / 1 SE3 / 2 QD1 / 3 QD2_FD1 / 4 SE2 / 5 MUTE / 6 MUTE / 7 MUTE === TDA7718B
 // fd_qd - 0 FD / 1 QD2 
 // main_gain - 0 0dB / 1 3dB
 // sub_flat -  0 off / 1 on
        tda.setSoft_mute(1,0,1,0,0,0,0);// 1,0,1,0,0,0,0
 // soft_mute -  0 on / 1 off
 // pin_iic - 0 pin_and_iic / 1 iic 
 // soft_mute_time - 0 0.48ms / 1 0.96ms / 2 7.68ms / 3 15.63ms
 // sub_in - 0 input_mux / 1 bass_output  
 // sub_eneble - 0 on / 1 off
 // fast_ch - 0 on / 1 off
 // anty_filter - 0 on / off(bypass)
        tda.setSoft_step_1(0,0,0,0,0,0,0,0); // 0,0,0,0,0,0,0,0
 // all - 0 on / 1 off
        tda.setSoft_step_2(0,0,0,0,1,1); // 0,0,0,0,1,1
 // rr_soft -  0 on / 1 off
 // sub_l_soft -  0 on / 1 off
 // sub_r_soft -  0 on / 1 off
 // soft_time - 0 5ms / 1 10ms
 // zero - 0 100mV / 1 75mV / 2 50mV / 3 25mV
 // spike - 0 11mkS / 1 22mkS / 2 33mkS / 3 44mkS
        tda.setLoudness(0,0,0,0); // 0,0,0,0
 // lon_att - byte 0...15 = 0...-15dB 
 // lon_cen_f - 0 flat / 1 400Hz / 2 800Hz / 3 2400Hz
 // lon_h_boost - 0 on / 1 off
 // lon_soft_step - 0 act / 1 wait
        tda.setVolume_gain(-20,1,0); // 0,0,0
 // vol_gain - int -31...23 = -31...+23dB
 // vol_out_gain - 0 1dB / 1 0dB
 // vol_soft_step - 0 act / 1 wait
        tda.setTreble(12,0,0); // 0,0,0
 // treb - int -15...+15 = -15...+15dB 
 // treb_cen_f - 0 10.0kHz / 1 12.5kHz / 2 15.0kHz / 3 17.5 kHz
 // treb_soft_step - 0 act / 1 wait
        tda.setMiddle(0,0,0); // 0,0,0
 // mid - int -15...+15 = -15...+15dB 
 // mid_q - 0 0.75 / 1 1.0 / 2 1.25 / 3 reserved 
 // mid_soft_step - 0 act / 1 wait
        tda.setBass(5,0,0); // 0,0,0
 // bass - int -15...+15 = -15...+15dB 
 // bass_q - 0 1.0 / 1 1.25 / 2 1.5 / 3 2.0 
 // bass_soft_step - 0 act / 1 wait
        tda.setSub_Mid_Bass(0,0,2,3,0); // 0,0,0,0,0
 // sub_cen_f - 0 55Hz / 1 85Hz / 2 120Hz / 3 160Hz
 // sub_faza - 0 180deg / 1 0deg
 // mid_cen_f - 0 500Hz / 1 1000Hz / 2 1500Hz / 3 2500Hz
 // bass_cen_f - 0 60Hz / 1 80Hz / 2 100Hz / 3 200Hz
 // bass_dc - 0 on / 1 off
        tda.setLF(0,0);
        tda.setRF(0,0);
        tda.setLR(0,0);
        tda.setRR(0,0);
        tda.setSL(0,0);
        tda.setSR(0,0);
 // all int -79...+15 = -79...+15dB
 // all - 0 act / 1 wait
  }

2

Re: TDA7718

http://forum.rcl-radio.ru/uploads/images/2020/07/624946bf9290b2f722951d978bf40090.png

Добавлена функция STANDBY. При активации режима STANDBY на выходе D7 появляется  лог. ноль для управления режимом STANDBY усилителя, а так же на экран выводится текущее время.Установка времени возможна по времени компиляции (см. setup) и ручная корректировка времени, для этого в режиме STANDBY нажмите и удерживайте кнопку MENU, для корректировки часов нажмите кнопку IN, для минут кнопку MUTE, для обнуления секунд кнопку STANDBY.

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

#include <Wire.h> // Входит в состав Arduino IDE
#include <LiquidCrystal_I2C.h> // http://forum.rcl-radio.ru/misc.php?action=pan_download&item=45&download=1
#include <TDA7718.h> // https://github.com/liman324/TDA7718.git
#include <Encoder.h> // http://rcl-radio.ru/wp-content/uploads/2019/05/Encoder.zip
#include <EEPROM.h> // Входит в состав Arduino IDE
#include <MsTimer2.h> // http://rcl-radio.ru/wp-content/uploads/2018/11/MsTimer2.zip
#include <boarddefs.h> // Входит в состав IRremote
#include <IRremote.h> // http://rcl-radio.ru/wp-content/uploads/2019/06/IRremote.zip
#include <DS3231.h>             //https://github.com/jarzebski/Arduino-DS3231/archive/master.zip
   TDA7718 tda;
   LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
   Encoder myEnc(8, 9);// DT, CLK
   IRrecv irrecv(12); // указываем вывод модуля IR приемника
   decode_results ir; 
   DS3231 clock;RTCDateTime DateTime;
   unsigned long time,times_in,oldPosition  = -999,newPosition; 
   int temp0,menu0,menu, bass,vol,mid,treb,vol_d,bass_d,treb_d,mid_d,hour,minut,secon;
   byte q,www,w,w2[4],z,z0,z1,i,menu_1,menu_2,w3,ch,mut=1,gr1,gr2,power;
   int gain0,gain1,gain2,gain3,gain_d;
   int bass_f,bass_q,treb_f,treb_q,mid_f,mid_q,loud_f,loud_g,sub_f,sl,sr,faza,in,in_x,lf,rf,lr,rr;
   byte mesto[8]={4,13,4,13,4,13,4,13};
   byte mesto1[8]={0,0,1,1,2,2,3,3};
   byte mesto2[8]={0,11,0,11,0,11,0,11};
   byte mesto3[8]={0,0,1,1,2,2,3,3};

   String bass_nam[4]={"60   Hz", "80   Hz", "100  Hz", "200  Hz"};
   String treb_nam[4]={"10  kHz", "12.5kHz", "15  kHz", "17.5kHz"};
   String mid_nam[4] ={"500  Hz", "1   kHz", "1.5 kHz", "2.5 kHz"};
   String lon_nam[4] ={"FLAT   ", "400  Hz", "800  Hz", "2.4 kHz"};
   String sub_nam[4] ={" 55Hz", " 85Hz", "120Hz", "160Hz"};
   float bass_nam_1[4]={1.0, 1.25, 1.5, 2.0};
   float mid_nam_1[3]={0.75, 1.0, 1.25};
  

void setup(){Serial.begin(9600);
  irrecv.enableIRIn();lcd.init();lcd.backlight();
  lcd.setCursor(0,1);lcd.print(" Sound Processor");lcd.setCursor(0,2);lcd.print(" TDA7718 "); delay(2000);lcd.clear();
  MsTimer2::set(1, to_Timer);MsTimer2::start();
  pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT_PULLUP);   // МЕНЮ НАСТРОЕК
  pinMode(3,INPUT_PULLUP);   // IN
  pinMode(4,INPUT_PULLUP);   // MUTE
  pinMode(5,INPUT_PULLUP);// КНОПКА STANDBY
  pinMode(7,OUTPUT);//  STANDBY
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении 
  vol = EEPROM.read(0)-59;treb = EEPROM.read(1)-15;mid = 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);
  bass_f = EEPROM.read(8);bass_q = EEPROM.read(9);treb_f = EEPROM.read(10);sr = 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;sl = EEPROM.read(20)-79;sub_f = EEPROM.read(21);
  faza = EEPROM.read(22);
  switch(in){case 0: gain0 = gain1;break;case 1: gain0 = gain2;break;case 2: gain0 = gain3;break;}   
  w2_arr();audio();
  // УСТАНОВКА ВРЕМЕНИ
  // clock.setDateTime(2016, 9, 15, 0, 0, 0);// Установка времени вручную (Год, Месяц, День, Час, Минута, Секунда)
  }
void loop(){
   DateTime = clock.getDateTime();hour = DateTime.hour;minut = DateTime.minute;secon = DateTime.second;
  
   if(digitalRead(10)==LOW&&menu0==0&&power==0){menu++;delay(200);time=millis();w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
   if(digitalRead(10)==LOW&&menu0==1&&power==0){menu_1++;delay(200);time=millis();w=1;if(menu_1>7){menu_1=0;}}// меню 1
   if(digitalRead(10)==LOW&&menu0==2&&power==0){menu_2++;delay(200);time=millis();w=1;if(menu_2>7){menu_2=0;}}// меню 2

   if(digitalRead(2)==LOW&&power==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||ir.value==IR_5)&&power==0){in++;cl();gr1=0;gr2=0;ir.value=0;times_in=millis();in_x=1;w3=1;www=1;menu0=100;if(in>2){in=0;}}

   if((digitalRead(4)==LOW&&mut==1||ir.value==IR_6&&mut==1)&&power==0){mut=0;gr1=0;gr2=0;menu0=100;cl();ir.value=0;audio();lcd.setCursor(7,1);lcd.print(" MUTE");delay(200);}
   if((digitalRead(4)==LOW&&mut==0||ir.value==IR_6&&mut==0)&&power==0){mut=1;gr1=0;gr2=0;menu0=0;cl();ir.value=0;w2_arr();delay(200);audio();}

   //// POWER //////////////////////

  if((digitalRead(5)==LOW||ir.value==IR_7)&&power==0&&digitalRead(2)==HIGH&&digitalRead(3)==HIGH&&digitalRead(4)==HIGH){cl();ir.value=0;
    power=1;mut=0;audio();lcd.clear();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);lcd.noBacklight();}// power off
  if((digitalRead(5)==LOW||ir.value==IR_7)&&power==1&&digitalRead(2)==HIGH&&digitalRead(3)==HIGH&&digitalRead(4)==HIGH){cl();ir.value=0;
    power=0;mut=1;audio();lcd.backlight();lcd.clear();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);audio();delay(3000);lcd.clear();}// power on


   if(power==0){digitalWrite(7,HIGH);
   byte a1[8] = {0b00000,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b00000};
   byte a2[8] = {0b00000,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b00000};
   byte a3[8] = {0b00000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b00000}; 
   byte a4[8] = {0b10000,0b11000,0b11100,0b11110,0b11100,0b11000,0b10000,0b00000}; 
   lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);lcd.createChar(3,a4);
  }
  if(power==1){digitalWrite(7,LOW);
      byte v1[8] = {7,7,7,7,7,7,7,7};
      byte v2[8] = {7,7,0, 0, 0, 0, 0, 0};      
      byte v3[8] = { 0, 0, 0, 0, 0,0,31,31};
      byte v4[8] = {31,31, 0, 0, 0, 0,31,31};
      byte v5[8] = { 28, 28, 0, 0, 0, 0, 28, 28};
      byte v6[8] = {28,28,28,28,28,28,28,28};
      byte v7[8] = { 0, 0, 0, 0, 0, 0,7,7};
      byte v8[8] = { 31, 31,0,0,0,0,0, 0};
   byte a[6];
   byte i0,d1,d2,d3,d4,d5,d6,e1,e2,e3;
  lcd.createChar(1, v1);lcd.createChar(2, v2);lcd.createChar(3, v3);lcd.createChar(4, v4);lcd.createChar(5, v5);lcd.createChar(6, v6);lcd.createChar(7, v7);lcd.createChar(8, v8);

     a[0]=DateTime.hour/10;
     a[1]=DateTime.hour%10;
     a[2]=DateTime.minute/10;
     a[3]=DateTime.minute%10;
     a[4]=DateTime.second/10;
     a[5]=DateTime.second%10;
    
 for(i=0;i<6;i++){
      switch(i){
        case 0: e1=0,e2=1,e3=2;break;
        case 1: e1=3,e2=4,e3=5;break;
        case 2: e1=7,e2=8,e3=9;break;
        case 3: e1=10,e2=11,e3=12;break;
        case 4: e1=14,e2=15,e3=16;break;
        case 5: e1=17,e2=18,e3=19;break;
        }
      switch(a[i]){
        case 0: d1=1,d2=8,d3=6,d4=1,d5=3,d6=6;break;
        case 1: d1=32,d2=2,d3=6,d4=32,d5=32,d6=6;break;
        case 2: d1=2,d2=8,d3=6,d4=1,d5=4,d6=5;break;
        case 3: d1=2,d2=4,d3=6,d4=7,d5=3,d6=6;break;
        case 4: d1=1,d2=3,d3=6,d4=32,d5=32,d6=6;break;
        case 5: d1=1,d2=4,d3=5,d4=7,d5=3,d6=6;break;
        case 6: d1=1,d2=4,d3=5,d4=1,d5=3,d6=6;break;
        case 7: d1=1,d2=8,d3=6,d4=32,d5=32,d6=6;break;
        case 8: d1=1,d2=4,d3=6,d4=1,d5=3,d6=6;break;
        case 9: d1=1,d2=4,d3=6,d4=7,d5=3,d6=6;break;
    }
     
      lcd.setCursor(e1,0);lcd.write((uint8_t)d1);lcd.setCursor(e2,0);lcd.write((uint8_t)d2);lcd.setCursor(e3,0);lcd.write((uint8_t)d3);
      lcd.setCursor(e1,1);lcd.write((uint8_t)d4);lcd.setCursor(e2,1);lcd.write((uint8_t)d5);lcd.setCursor(e3,1);lcd.write((uint8_t)d6);
  }
  lcd.setCursor(6,0);lcd.print(".");lcd.setCursor(13,0);lcd.print(".");lcd.setCursor(6,1);lcd.print(".");lcd.setCursor(13,1);lcd.print(".");
  lcd.setCursor(5,3);lcd.print("POWER  OFF");lcd.noBacklight();
  if(digitalRead(2)==LOW&&digitalRead(3)==LOW){hour++;if(hour>23){hour=0;} clock.setDateTime(2020, 9, 15, hour, minut, secon);delay(100);}
  if(digitalRead(2)==LOW&&digitalRead(4)==LOW){minut++;if(minut>59){minut=0;} clock.setDateTime(2020, 9, 15, hour, minut, secon);delay(100); }
  if(digitalRead(2)==LOW&&digitalRead(5)==LOW){secon=0; clock.setDateTime(2020, 9, 15, hour, minut, secon);delay(100); }
  } 

  

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

/////////////////////////////// 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.write((uint8_t)3);}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,-59,0,0,24);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print(" ");bass_d=map(bass,-15,15,0,24);
   lcd.setCursor(1,2);lcd.print("MIDDLE ");if(mid>=0){lcd.print(" ");}lcd.print(mid);lcd.print(" ");mid_d=map(mid,-15,15,0,24);
   lcd.setCursor(1,3);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print(" ");treb_d=map(treb,-15,15,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);if(bass<12){lcd.print("  ");}else{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);if(mid<12){lcd.print("  ");}else{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);if(treb<12){lcd.print("  ");}else{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: break;
      case 6: temp0 = loud_f;break;
      case 7: temp0 = loud_g;break;}
   
 
   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: 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.write((uint8_t)3);}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  N/A");
  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 = sl;break;
      case 5: temp0 = sr;break;
      case 6: temp0 = faza;break;
      case 7: temp0 = sub_f;break;}
      
 
   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: sl = temp0;sl_func();break;
      case 5: sr = temp0;sr_func();break;
      case 6: faza = temp0;faza_func();break;
      case 7: sub_f = temp0;sub_f_func();break;}
 
  au();
  for(i=0;i<8;i++){if(menu_2==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.write((uint8_t)3);}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
  lcd.setCursor(1,0);lcd.print("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(1,2);lcd.print("SL");lcd.setCursor(4,2);lcd.print(sl);lcd.print(" ");lcd.setCursor(7,2);lcd.print("dB ");lcd.setCursor(12,2);lcd.print("SR ");lcd.print(sr);lcd.print(" ");lcd.setCursor(18,2);lcd.print("dB");
  lcd.setCursor(1,3);lcd.print("Faza ");if(faza==0){lcd.print("  0");}else{lcd.print("180");}lcd.setCursor(12,3);lcd.print("Sf ");lcd.print(sub_nam[sub_f]);
 } // menu0 = 2


 ////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
   switch(in){
      case 0: ch=0;break;
      case 1: ch=4;break;
      case 2: ch=1;break;
      }
   switch(ch){
     case 0: gain0 = gain1;break;
     case 4: gain0 = gain2;break;
     case 1: gain0 = gain3;break;} 
 
    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(ch){
     case 0: gain1 = gain0;break;
     case 4: gain2 = gain0;break;
     case 1: 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=map(gain0, -31,23,0,20);
   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+59);EEPROM.update(1,treb+15);EEPROM.update(2,mid+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,bass_f);EEPROM.update(9,bass_q);EEPROM.update(10,treb_f);EEPROM.update(11,sr),
     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,sl+79);EEPROM.update(21,sub_f);
     EEPROM.update(22,faza);
     menu=0;menu_1=0;menu_2=0;w=0;w2_arr();}
  
  }//loop

void lf_func(){if(lf<0){lf=0;}if(lf>20){lf=20;}};
void rf_func(){if(rf<0){rf=0;}if(rf>20){rf=20;}};
void lr_func(){if(lr<0){lr=0;}if(lr>20){lr=20;}};
void rr_func(){if(rr<0){rr=0;}if(rr>20){rr=20;}};
void sl_func(){if(sl<0){sl=0;}if(sl>20){sl=20;}};
void sr_func(){if(sr<0){sr=0;}if(sr>20){sr=20;}};
void gain_func(){if(gain0<-31){gain0=-31;}if(gain0>23){gain0=23;}}
void faza_func(){if(faza>1){faza=0;}if(faza<0){faza=1;}}   
void sub_f_func(){if(sub_f>3){sub_f=0;}if(sub_f<0){sub_f=3;}}
void loud_g_func(){if(loud_g>15){loud_g=15;}if(loud_g<0){loud_g=0;}}
void mid_q_func(){if(mid_q>2){mid_q=0;}if(mid_q<0){mid_q=3;}}
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 loud_f_func(){if(loud_f>3){loud_f=0;}if(loud_f<0){loud_f=3;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void au(){if(www==1){audio();www=0;}}
void bass_func(){if(bass>15){bass=15;}if(bass<-15){bass=-15;}} 
void mid_func(){if(mid>15){mid=15;}if(mid<-15){mid=-15;}}
void treb_func(){if(treb>15){treb=15;}if(treb<-15){treb=-15;}}
void vol_func(){if(vol<-59){vol=-59;}if(vol>0){vol=0;}}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(200);} 
void to_Timer(){newPosition = myEnc.read()/4;}  
void audio(){
       tda.setMain(ch,0,0,0); // 0,0,0,0
 // main_sel  - 0 SE1 / 1 SE3 / 2 QD1 / 3 QD2_FD1 / 4 SE2 / 5 SE4 / 6 SE5 / 7 MUTE === TDA7718N
 // main_sel  - 0 SE1 / 1 SE3 / 2 QD1 / 3 QD2_FD1 / 4 SE2 / 5 MUTE / 6 MUTE / 7 MUTE === TDA7718B
 // fd_qd - 0 FD / 1 QD2 
 // main_gain - 0 0dB / 1 3dB
 // sub_flat -  0 off / 1 on
        tda.setSoft_mute(mut,0,1,0,0,0,0);// 1,0,1,0,0,0,0
 // soft_mute -  0 on / 1 off
 // pin_iic - 0 pin_and_iic / 1 iic 
 // soft_mute_time - 0 0.48ms / 1 0.96ms / 2 7.68ms / 3 15.63ms
 // sub_in - 0 input_mux / 1 bass_output  
 // sub_eneble - 0 on / 1 off
 // fast_ch - 0 on / 1 off
 // anty_filter - 0 on / off(bypass)
        tda.setSoft_step_1(0,0,0,0,0,0,0,0); // 0,0,0,0,0,0,0,0
 // all - 0 on / 1 off
        tda.setSoft_step_2(0,0,0,0,1,1); // 0,0,0,0,1,1
 // rr_soft -  0 on / 1 off
 // sub_l_soft -  0 on / 1 off
 // sub_r_soft -  0 on / 1 off
 // soft_time - 0 5ms / 1 10ms
 // zero - 0 100mV / 1 75mV / 2 50mV / 3 25mV
 // spike - 0 11mkS / 1 22mkS / 2 33mkS / 3 44mkS
        tda.setLoudness(loud_g,loud_f,0,0); // 0,0,0,0
 // lon_att - byte 0...15 = 0...-15dB 
 // lon_cen_f - 0 flat / 1 400Hz / 2 800Hz / 3 2400Hz
 // lon_h_boost - 0 on / 1 off
 // lon_soft_step - 0 act / 1 wait
        tda.setVolume_gain(gain0,1,0); // 0,0,0
 // vol_gain - int -31...23 = -31...+23dB
 // vol_out_gain - 0 1dB / 1 0dB
 // vol_soft_step - 0 act / 1 wait
        tda.setTreble(treb,treb_f,0); // 0,0,0
 // treb - int -15...+15 = -15...+15dB 
 // treb_cen_f - 0 10.0kHz / 1 12.5kHz / 2 15.0kHz / 3 17.5 kHz
 // treb_soft_step - 0 act / 1 wait
        tda.setMiddle(mid,mid_q,0); // 0,0,0
 // mid - int -15...+15 = -15...+15dB 
 // mid_q - 0 0.75 / 1 1.0 / 2 1.25 / 3 reserved 
 // mid_soft_step - 0 act / 1 wait
        tda.setBass(bass,bass_q,0); // 0,0,0
 // bass - int -15...+15 = -15...+15dB 
 // bass_q - 0 1.0 / 1 1.25 / 2 1.5 / 3 2.0 
 // bass_soft_step - 0 act / 1 wait
        tda.setSub_Mid_Bass(sub_f,faza,mid_f,bass_f,0); // 0,0,0,0,0
 // sub_cen_f - 0 55Hz / 1 85Hz / 2 120Hz / 3 160Hz
 // sub_faza - 0 180deg / 1 0deg
 // mid_cen_f - 0 500Hz / 1 1000Hz / 2 1500Hz / 3 2500Hz
 // bass_cen_f - 0 60Hz / 1 80Hz / 2 100Hz / 3 200Hz
 // bass_dc - 0 on / 1 off
        tda.setLF(vol-20+lf,0);
        tda.setRF(vol-20+rf,0);
        tda.setLR(vol-20+lr,0);
        tda.setRR(vol-20+rr,0);
        tda.setSL(vol-20+sl,0);
        tda.setSR(vol-20+sr,0);
 // all int -79...+15 = -79...+15dB
 // all - 0 act / 1 wait
  }

3

Re: TDA7718

Вот что получилось с LCD1604


http://forum.rcl-radio.ru/uploads/images/2021/11/c252a9c769cc5f5af911abbc48c64b94.jpg
http://forum.rcl-radio.ru/uploads/images/2021/11/6568c398b91aa82f27c7b65fd7fd63ef.jpg
http://forum.rcl-radio.ru/uploads/images/2021/11/67f8c03d995a7d02d8f63df3a6ea6c69.jpg
http://forum.rcl-radio.ru/uploads/images/2021/11/323f4ec560111fef01cf27807d0576c3.jpg
http://forum.rcl-radio.ru/uploads/images/2021/11/f5c033ff96c79a3c145dfca51eb2498a.jpg