51

Re: Темброблок 5.1 на PT2323 и PT2322 (Arduino)

Должно загружаться через теги code

[ code][ /code]

52

Re: Темброблок 5.1 на PT2323 и PT2322 (Arduino)

Я пробовал, выдаёт какую-то ошибку  code чего-то не нравится ему.


Посмотрите в режиме редактирования сообщения пример:

bool surr;

void setup() {
  //// -------------------
  vol = EEPROM.read(0)-79;in = EEPROM.read(1);bass = EEPROM.read(2)-7;mid = EEPROM.read(3)-7;treb = EEPROM.read(4)-7;
  attfl = EEPROM.read(5)-14;attcn = EEPROM.read(7)-14;attsub = EEPROM.read(8)-14;ddd = EEPROM.read(9);tembro = EEPROM.read(10);
  attfr = EEPROM.read(11)-14;atttl = EEPROM.read(12)-14;atttr = EEPROM.read(13)-14;

  surr = EEPROM.read(20);
  
  delay(500);
  audio();audio_in();

}

void loop() {

   if(ir.value==код_кнопки && surr==0){surr=1;g1=1;g2=0;cl1();time=millis();w=1;lcd.setCursor(0,0);lcd.print("Surround ON ");audio_in();delay(1000);}
   if(ir.value==код_кнопки && surr==1){surr=0;g1=1;g2=0;cl1();time=millis();w=1;lcd.setCursor(0,0);lcd.print("Surround OFF");audio_in();delay(1000);}



  //// -------------------------------
  if(millis()-time>10000&& w==1&&mute==0){
     EEPROM.update(0,vol+79);EEPROM.update(1,in);EEPROM.update(2,bass+7);EEPROM.update(3,mid+7);EEPROM.update(4,treb+7);
     EEPROM.update(5,attfl+14);EEPROM.update(7,attcn+14);EEPROM.update(8,attsub+14);EEPROM.update(9,ddd);EEPROM.update(10,tembro);
     EEPROM.update(11,attfr+14);EEPROM.update(12,atttl+14);EEPROM.update(13,atttr+14);

     EEPROM.update(20,surr);
     
     menu=0;w=0;cl();}
}

void audio_in(){
  pt0.setInput(in);
  pt0.setMute(0,0,0,0,0,0,0);
  pt0.setFeature(0,surr);
}

53

Re: Темброблок 5.1 на PT2323 и PT2322 (Arduino)

Вот окончательный код для меня, здесь используются все функции аудиопроцессоров
8 эквалайзеров (но это пульт у меня такой с надписями) под него и вводил данные.
Выше писАл что за аппарат. фото не могу прикрепить кого интересует в нете есть фото
комплекта.

#include <Wire.h>
#include <PT2322.h>
#include <PT2323.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <Encoder.h>
#include <MsTimer2.h>
#include <boarddefs.h>
#include <IRremote.h>
 PT2322 pt; PT2323 pt0; 
  Encoder myEnc(9, 8);//CLK, DT подключение энкодера
  IRrecv irrecv(10); // указываем вывод модуля IR приемника
   decode_results ir;
 LiquidCrystal lcd(7, 6, 2, 3, 4, 5);// RS,E,D4,D5,D6,D7 подключение LCD
   byte a1[8]={0b00000,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b00000};
   byte a2[8]={0b00000,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b00000};
   byte a3[8]={0b00000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b00000};
    unsigned long newPosition,time,oldPosition  = -999;
   int menu,menu2,w,vol,vol_d,z,z0,z1,in,bass,bass_d,mid,mid_d,treb,treb_d,attfl,attfl_d,attcn,attcn_d,attsub,attsub_d,ddd,tembro,x,attfr,attfr_d,atttl,atttl_d,atttr,atttr_d,mute;
   int g1,g2,inn;
   
bool surr;

void setup() {
  Wire.begin();Serial.begin(9600);irrecv.enableIRIn(); // запускаем модульIR
  lcd.begin(8, 2);lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);
  pinMode(A0,INPUT); // menu кнопка энкодера
  pinMode(12,INPUT); // MUTE
  pinMode(11,INPUT); // IN
  pinMode(A2, OUTPUT);
  pinMode(A1, OUTPUT);
  
 
  MsTimer2::set(2, to_Timer);MsTimer2::start();
   vol = EEPROM.read(0)-79;in = EEPROM.read(1);bass = EEPROM.read(2)-7;mid = EEPROM.read(3)-7;treb = EEPROM.read(4)-7;
  attfl = EEPROM.read(5)-14;attcn = EEPROM.read(7)-14;attsub = EEPROM.read(8)-14;ddd = EEPROM.read(9);tembro = EEPROM.read(10);
  attfr = EEPROM.read(11)-14;atttl = EEPROM.read(12)-14;atttr = EEPROM.read(13)-14;
  surr = EEPROM.read(14);
  delay(500);
  audio();audio_in();
}
 void to_Timer(){newPosition = myEnc.read()/4;}
 
 void loop(){delay(10);
  if(analogRead(A0)<900){menu++;cl1();myEnc.write(0);time=millis();w=1;if(menu>11){menu=0;}}// меню
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);time=millis();w=1;irrecv.resume();}// IR приемник  
  if(ir.value==0){g1=0;g2=0;}// запрет нажатий не активных кнопок пульта
  if(in==4){digitalWrite(13,HIGH);}else{digitalWrite(13,LOW);} //вкл\выкл AUX5.1
   if(ir.value==0x2FD609F){menu++;g1=0;g2=0;cl1();time=millis();w=1;if(menu>11){menu=0;}}// меню кнопка 5.1CH
   if(ir.value==0x2FDE01F){menu--;g1=0;g2=0;cl1();time=millis();w=1;if(menu<0){menu=11;}}// меню кнопка 2.1CH
   if(ir.value==0x2FDA05F){menu=0;g1=0;g2=0;cl1();time=millis();w=1;}// меню кнопка VSS (menu===0)
   if(ir.value==0x2FDC03F){inn=1;g1=0;g2=0;time=millis();w=1;audio();}//   кнопка AUX 
   if(ir.value==0x2FD807F && surr==0){surr=1;g1=1;g2=0;cl1();time=millis();w=1;lcd.setCursor(0,0);lcd.print("Surround ON ");audio_in();delay(1000);}//кнопка DVD
   if(ir.value==0x2FD807F && surr==1){surr=0;g1=1;g2=0;cl1();time=millis();w=1;lcd.setCursor(0,0);lcd.print("Surround OFF");audio_in();delay(1000);}//кнопка DVD
   if(ddd==0){digitalWrite(A2,HIGH);}else{digitalWrite(A2,LOW);}
   if(mute==1){digitalWrite(A1,HIGH);}else{digitalWrite(A1,LOW);}
 //////////////////////////////////////// volume -79...0 db //////////////////////////////////////
if(menu==0){   
     if(ir.value==0x2FD10EF){vol++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+ 
     if(ir.value==0xFFFFFFFF and g1==1){vol++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==0x2FD08F7){vol--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){vol--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
     if(vol>79){vol=79;}if(vol<0){vol=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    vol=vol+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(vol>79){vol=79;}if(vol<0){vol=0;}audio();}
  lcd.setCursor(0,0);lcd.print("Volume  ");
  lcd.print(" ");lcd.print(-79+vol);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");vol_d=vol-32;
   for(z=0,z0=0,z1=0;z<=vol_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0,1);lcd.write((uint8_t)2);}}
 //////////////////////////////////////// bass +-14 db //////////////////////////////////////
 if(menu==1){
     if(ir.value==0x2FD00FF){bass++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка R+
     if(ir.value==0xFFFFFFFF and g1==1){bass++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==0x2FD38C7){bass--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка L-
     if(ir.value==0xFFFFFFFF and g2==1){bass--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(bass<-7){bass=-7;}if(bass>7){bass=7;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    bass=bass+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(bass<-7){bass=-7;}if(bass>7){bass=7;}audio();}
  lcd.setCursor(0,0);lcd.print("Bass");
  lcd.print(" ");lcd.print(bass*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");bass_d=(bass+7)*2;
   for(z=0,z0=0,z1=0;z<=bass_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}   
 //////////////////////////////////////// MIDDLE +-14 db //////////////////////////////////////
 if(menu==2){
     if(ir.value==0x2FD20DF){mid++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка FRONT+
     if(ir.value==0xFFFFFFFF and g1==1){mid++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==0x2FD18E7){mid--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка FRONT-
     if(ir.value==0xFFFFFFFF and g2==1){mid--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(mid<-7){mid=-7;}if(mid>7){mid=7;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    mid=mid+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(mid<-7){mid=-7;}if(mid>7){mid=7;}audio();}
  lcd.setCursor(0,0);lcd.print("Middle  ");
  lcd.print(" ");lcd.print(mid*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("db");mid_d=(mid+7)*2;
   for(z=0,z0=0,z1=0;z<=mid_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("   ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}} 
 //////////////////////////////////////// treble +-14 db //////////////////////////////////////
 if(menu==3){
     if(ir.value==0x2FD6897){treb++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка TREBLE+
     if(ir.value==0xFFFFFFFF and g1==1){treb++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==0x2FDE817){treb--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка TREBLE-
     if(ir.value==0xFFFFFFFF and g2==1){treb--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(treb<-7){treb=-7;}if(treb>7){treb=7;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    treb=treb+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(treb<-7){treb=-7;}if(treb>7){treb=7;}audio();}
  lcd.setCursor(0,0);lcd.print("Treble  ");
  lcd.print(" ");lcd.print(treb*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");treb_d=(treb+7)*2;
   for(z=0,z0=0,z1=0;z<=treb_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}    
   //////////////////////////////////// rock pop classic //////////////////////      
  if(menu==4){
     if(ir.value==0x2FDD02F){tembro=0;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка LIVE
     if(ir.value==0x2FD906F){tembro=1;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка ROCK
     if(ir.value==0x2FD50AF){tembro=2;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DISCO
     if(ir.value==0x2FDF00F){tembro=3;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка MATR
     if(ir.value==0x2FDC837){tembro=4;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка POPS
     if(ir.value==0x2FD708F){tembro=5;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CLAS
     if(ir.value==0x2FD48B7){tembro=6;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DSP OFF
     if(ir.value==0x2FDB04F){tembro=7;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SIMUL
     if(ir.value==0x2FD8877){tembro=8;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка HAL
      if(tembro>9){tembro=0;}if(tembro<0){tembro=9;}
     if (newPosition != oldPosition) {
    oldPosition = newPosition;
    tembro=tembro+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(tembro>8){tembro=0;}if(tembro<0){tembro=8;}}
    lcd.setCursor(0,0);lcd.print(" Preset timbre  ");
    if(tembro==0){lcd.setCursor(0,1);lcd.print("     LIVE      ");bass=2,mid=0,treb=2;x=1;}
    if(tembro==1){lcd.setCursor(0,1);lcd.print("     ROCK      ");bass=4,mid=-2;treb=5;x=1;}
    if(tembro==2){lcd.setCursor(0,1);lcd.print("     DISCO     ");bass=10,mid=2;treb=14;x=1;}
    if(tembro==3){lcd.setCursor(0,1);lcd.print("     MATR      ");bass=-2,mid=0;treb=8;x=1;}
    if(tembro==4){lcd.setCursor(0,1);lcd.print("     POP       ");bass=4,mid=3;treb=4;x=1;}
    if(tembro==5){lcd.setCursor(0,1);lcd.print("    CLASSIC    ");bass=0,mid=0;treb=-2;x=1;}
    if(tembro==6){lcd.setCursor(0,1);lcd.print("    DSP OFF    ");bass=0,mid=0;treb=0;x=1;}
    if(tembro==7){lcd.setCursor(0,1);lcd.print("     SIMUL     ");}
    if(tembro==8){lcd.setCursor(0,1);lcd.print("     HAL       ");bass=-2,mid=5;treb=0;x=1;}
    if(x==1){audio();x=0;}
  }
   
  /////////////////////// ATT FL ///////////////////
   if(menu==5){
     if(ir.value==0x2FD20DF){attfl++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка FRONT+
     if(ir.value==0xFFFFFFFF and g1==1){attfl++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==0x2FD18E7){attfl--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка FRONT-
     if(ir.value==0xFFFFFFFF and g2==1){attfl--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(attfl<-14){attfl=-14;}if(attfl>0){attfl=0;}
     
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    attfl=attfl+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attfl<-14){attfl=-14;}if(attfl>0){attfl=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT FL   ");
  lcd.print(" ");lcd.print(attfl);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attfl_d=(attfl+14)*2;
   for(z=0,z0=0,z1=0;z<=attfl_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}  
  /////////////////////// ATT FR ///////////////////
   if(menu==6){
     if(ir.value==0x2FD20DF){attfr++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка FRONT+
     if(ir.value==0xFFFFFFFF and g1==1){attfr++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==0x2FD18E7){attfr--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка FRONT-
     if(ir.value==0xFFFFFFFF and g2==1){attfr--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(attfr<-14){attfr=-14;}if(attfr>0){attfr=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    attfr=attfr+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attfr<-14){attfr=-14;}if(attfr>0){attfr=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT FR   ");
  lcd.print(" ");lcd.print(attfr);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attfr_d=(attfr+14)*2;
   for(z=0,z0=0,z1=0;z<=attfr_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}  
  /////////////////////// ATT SL ///////////////////
  if(menu==7){
     if(ir.value==0x2FDD827){atttl++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SURR+
     if(ir.value==0xFFFFFFFF and g1==1){atttl++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==0x2FDF807){atttl--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка SURR-
     if(ir.value==0xFFFFFFFF and g2==1){atttl--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(atttl<-14){atttl=-14;}if(atttl>0){atttl=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    atttl=atttl+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(atttl<-14){atttl=-14;}if(atttl>0){atttl=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT TL   ");
  lcd.print(" ");lcd.print(atttl);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");atttl_d=(atttl+14)*2;
   for(z=0,z0=0,z1=0;z<=atttl_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}} 
 /////////////////////// ATT SR ///////////////////
  if(menu==8){
     if(ir.value==0x2FDD827){atttr++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SURR+
     if(ir.value==0xFFFFFFFF and g1==1){atttr++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==0x2FDF807){atttr--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка SURR-
     if(ir.value==0xFFFFFFFF and g2==1){atttr--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
   if(atttr<-14){atttr=-14;}if(atttr>0){atttr=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    atttr=atttr+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(atttr<-14){atttr=-14;}if(atttr>0){atttr=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT TR   ");
  lcd.print(" ");lcd.print(atttr);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");atttr_d=(atttr+14)*2;
   for(z=0,z0=0,z1=0;z<=atttr_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}} 
 /////////////////////// ATT CEN ///////////////////
    if(menu==9){
     if(ir.value==0x2FD9867){attcn++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CENTR+
     if(ir.value==0xFFFFFFFF and g1==1){attcn++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==0x2FDB847){attcn--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка CENTR-
     if(ir.value==0xFFFFFFFF and g2==1){attcn--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
      if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    attcn=attcn+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT CN   ");
  lcd.print(" ");lcd.print(attcn);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attcn_d=(attcn+14)*2;
   for(z=0,z0=0,z1=0;z<=attcn_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}  
  /////////////////////// ATT SUB ///////////////////
     if(menu==10){
     if(ir.value==0x2FD58A7){attsub++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SAB+
     if(ir.value==0xFFFFFFFF and g1==1){attsub++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==0x2FD7887){attsub--;g1=0;g2=1;cl();audio();}// кнопка SAB-
     if(ir.value==0xFFFFFFFF and g2==1){attsub--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
       if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;time=millis();}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    attsub=attsub+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT SUB  ");
  lcd.print("");lcd.print(attsub);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attsub_d=(attsub+14)*2;
   for(z=0,z0=0,z1=0;z<=attsub_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}  
   
  //////////////////////////// 3d ///////////////////////////////////////////////
 if(menu==11){
     if(ir.value==0x2FD40BF){ddd++;g1=1;g2=0;cl1();time=millis();w=1;audio();}// кнопка 3D MOD
     if(ir.value==0x2FD40BF){ddd--;g1=0;g2=1;cl1();audio();}// кнопка 3D MOD
   if(ddd<0){ddd=1;}if(ddd>1){ddd=0;}
   if (newPosition != oldPosition) {
    oldPosition = newPosition;
    ddd=ddd+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(ddd<0){ddd=1;}if(ddd>1){ddd=0;}audio();}
   lcd.setCursor(0,0); if(ddd==0){lcd.print("     3D  ON  ");}else{lcd.print("     3D  OFF  ");} }  

//////////// mute ////////////////////////
  if(mute==1&&(digitalRead(12)==HIGH||ir.value==0x2FD30CF)){mute=0;g1=1;g2=0;menu=0;audio();cl1();} 
  if(mute==0&&(digitalRead(12)==HIGH||ir.value==0x2FD30CF)){mute=1;g1=1;g2=0;menu=100;audio();cl1();}
  if(mute==1){lcd.setCursor(0,0);lcd.print("      MUTE      ");delay(300);}
   
  /////////////////// INPUT //////////////////////////////////////////////////////////////////////////////////////// 
   if(digitalRead(11)==HIGH||inn==1){
    in++;if(in>4){in=0;}audio_in();cl1();
   lcd.setCursor(0,0);lcd.print("");
   switch(in){ // 
     case 0: lcd.print("     AUX 2.1    "); break;
     case 1: lcd.print("   BLUETOOTH    "); break;
     case 2: lcd.print("   DVD  AS-3    "); break;
     case 3: lcd.print("     RADIO      "); break;
     case 4: lcd.print("     AUX 5.1    "); break;}
   delay(2000);time=millis();w=1;inn=0;}// in


   if(millis()-time>10000&& w==1&&mute==0){
     EEPROM.update(0,vol+79);EEPROM.update(1,in);EEPROM.update(2,bass+7);EEPROM.update(3,mid+7);EEPROM.update(4,treb+7);
     EEPROM.update(5,attfl+14);EEPROM.update(7,attcn+14);EEPROM.update(8,attsub+14);EEPROM.update(9,ddd);EEPROM.update(10,tembro);
     EEPROM.update(11,attfr+14);EEPROM.update(12,atttl+14);EEPROM.update(13,atttr+14);
     EEPROM.update(14,surr);
     menu=0;w=0;cl();}
 
   
 }//loop
 
 void cl(){ir.value=0;delay(100);}
 void cl1(){ir.value=0;delay(300);lcd.clear();}
 void audio_in(){
  pt0.setInput(in); 
  pt0.setMute(0,0,0,0,0,0,0); 
  pt0.setFeature(0,surr); 
}
 void audio(){
  pt.setFront_lk_att(abs(attfl));// att front L
  pt.setFront_rk_att(abs(attfr));// att front R
  pt.setCenter_att(abs(attcn));  // att center
  pt.setRear_lk_att(abs(atttl)); // att rear L
  pt.setRear_rk_att(abs(atttr)); // att rear R
  pt.setSub_att(abs(attsub));     // att sub
  pt.setFunc(mute,ddd,0); // mute,3d,����� on/off
  pt.setBass(bass);            // BASS    -14...0...14 dB (int -7...0...7)
  pt.setMiddle(mid);          // MIDDLE  -14...0...14 dB (int -7...0...7)
  pt.setTreble(treb);          // TREBLE  -14...0...14 dB (int -7...0...7)
  pt.setVol(abs(vol)); // -79...0
}

54

Re: Темброблок 5.1 на PT2323 и PT2322 (Arduino)

Вот такой вид. дисплей 16*2 маленького размера между фазоинвертором и панелью без подсветки,
поэтому не видно. Как-то так.
http://forum.rcl-radio.ru/uploads/images/2022/04/a05c16f94ea808043442fa48ee7f6a75.jpg
http://forum.rcl-radio.ru/uploads/images/2022/04/d7907a2a36f47fa934d97b9b5cb7f0e7.jpg

55

Re: Темброблок 5.1 на PT2323 и PT2322 (Arduino)

Доброго времени суток. Вот скетч который меня устраивает и работает, но регулировка ATT_Front и ATT_ Rear
не регулируется, хотя на индикаторе значения меняются как положено, что-то я не так сделал, когда было
по канально, то регулировалось, но это не совсем удобно было, центр и саб регулируются, фронт и тыл нет и как будто они находятся в минимальном положении. посмотрите пожалуйста что я не так сделал.

#include <Wire.h>
#include <PT2322.h>
#include <PT2323.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <Encoder.h>
#include <MsTimer2.h>
#include <boarddefs.h>
#include <IRremote.h>
 PT2322 pt; PT2323 pt0; 
  Encoder myEnc(9, 8);//CLK, DT подключение энкодера
  IRrecv irrecv(10); // указываем вывод модуля IR приемника
   decode_results ir;
 LiquidCrystal lcd(7, 6, 2, 3, 4, 5);// RS,E,D4,D5,D6,D7 подключение LCD
   byte a1[8]={0b00000,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b00000};
   byte a2[8]={0b00000,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b00000};
   byte a3[8]={0b00000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b00000};
    unsigned long newPosition,time,oldPosition  = -999;
   int menu,menu2,w,vol,vol_d,z,z0,z1,in,bass,bass_d,mid,mid_d,treb,treb_d,attfl,attfl_d,attcn,attcn_d,attsub,attsub_d,ddd,tembro,x,attfr,attfr_d,atttl,atttl_d,atttr,atttr_d,mute;
   int g1,g2,inn;
   int att_front, att_rear;
   bool surr;
   bool mix;
   bool w1=1;

void setup() {
  Wire.begin();Serial.begin(9600);irrecv.enableIRIn(); // запускаем модульIR
  lcd.begin(16, 2);lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3); 
  pinMode(A0,INPUT); // menu кнопка энкодера
  pinMode(12,INPUT); // MUTE
  pinMode(11,INPUT); // IN
  pinMode(A2, OUTPUT);
  pinMode(A1, OUTPUT);
  
 
  MsTimer2::set(2, 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;in = EEPROM.read(10);bass = EEPROM.read(1)-7;mid = EEPROM.read(2)-7;treb = EEPROM.read(3)-7;
  attfl = EEPROM.read(15)-14;attcn = EEPROM.read(7)-14;attsub = EEPROM.read(8)-14;ddd = EEPROM.read(9);tembro = EEPROM.read(10);
  attfr = EEPROM.read(13)-14;atttl = EEPROM.read(14)-14;atttr = EEPROM.read(16)-14;att_front = EEPROM.read(5)-14;att_rear = EEPROM.read(6)-14;
  surr = EEPROM.read(17); mix = EEPROM.read(18);
  delay(500);
  
  audio();audio_in();
}
 void to_Timer(){newPosition = myEnc.read()/4;}
 
 void loop(){delay(10);
  if(analogRead(A0)<900){menu++;cl1();myEnc.write(0);time=millis();w=1;w=1;if(menu>9){menu=0;}}// меню
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);time=millis();w=1;w=1;irrecv.resume();}// IR приемник  
  if(ir.value==0){g1=0;g2=0;}// запрет нажатий не активных кнопок пульта
  if(in==4){digitalWrite(13,HIGH);}else{digitalWrite(13,LOW);} //вкл\выкл AUX5.1
   if(ir.value==0x2FD609F){menu++;g1=0;g2=0;cl1();time=millis();w=1;if(menu>9){menu=0;}}// меню кнопка 5.1CH
   if(ir.value==0x2FDE01F){menu--;g1=0;g2=0;cl1();time=millis();w=1;if(menu<0){menu=9;}}// меню кнопка 2.1CH
   if(ir.value==0x2FDA05F && mix==1){mix=0;g1=1;g2=0;cl();time=millis();w=1;lcd.setCursor(0,0);lcd.print("   Mixed 0dB   ");audio_in();delay(2000);} //  кнопка VSS 
   if(ir.value==0x2FDA05F && mix==0){mix=1;g1=1;g2=0;cl();time=millis();w=1;lcd.setCursor(0,0);lcd.print("   Mixed +6dB  ");audio_in();delay(2000);} //  кнопка VSS 
   if(ir.value==0x2FDC03F){inn=1;g1=0;g2=0;time=millis();w=1;audio();}//   кнопка AUX 
   if(ir.value==0x2FD807F && surr==0){surr=1;g1=1;g2=0;cl();time=millis();w=1;lcd.setCursor(0,0);lcd.print("Surround ON ");audio_in();delay(2000);}//кнопка DVD
   if(ir.value==0x2FD807F && surr==1){surr=0;g1=1;g2=0;cl();time=millis();w=1;lcd.setCursor(0,0);lcd.print("Surround OFF");audio_in();delay(2000);}//кнопка DVD
   if(ir.value==0x2FD40BF){ddd++;menu=9;g1=1;g2=0;cl();time=millis();w=1;ddd_conf();audio();}//кнопка 3D mod
     if(ir.value==0x2FD6897){treb++;menu=3;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка TREBLE+
     if(ir.value==0x2FDE817){treb--;menu=3;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка TREBLE-
     if(ir.value==0x2FD20DF){att_front++;menu=5;g1=1;g2=0;cl();time=millis();w=1;att_front_conf();audio();}// кнопка FRONT+
     if(ir.value==0x2FD18E7){att_front--;menu=5;g1=0;g2=1;cl();time=millis();w=1;att_front_conf();audio();}// кнопка FRONT-
     if(ir.value==0x2FDD827){att_rear++;menu=6;g1=1;g2=0;cl();time=millis();w=1;att_rear_conf();audio();}// кнопка SURR+
     if(ir.value==0x2FDF807){att_rear--;menu=6;g1=0;g2=1;cl();time=millis();w=1;att_rear_conf();audio();}// кнопка SURR-
     if(ir.value==0x2FD9867){attcn++;menu=7;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CENTR+
     if(ir.value==0x2FDB847){attcn--;menu=7;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка CENTR-
     if(ir.value==0x2FD58A7){attsub++;menu=8;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SAB+
     if(ir.value==0x2FD7887){attsub--;menu=8;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка SAB-
     if(ir.value==0x2FDD02F){tembro=0;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка LIVE
     if(ir.value==0x2FD906F){tembro=1;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка ROCK
     if(ir.value==0x2FD50AF){tembro=2;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DISCO
     if(ir.value==0x2FDF00F){tembro=3;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка MATR
     if(ir.value==0x2FDC837){tembro=4;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка POPS
     if(ir.value==0x2FD708F){tembro=5;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CLAS
     if(ir.value==0x2FD48B7){tembro=6;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DSP OFF
     if(ir.value==0x2FDB04F){tembro=7;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SIMUL
     if(ir.value==0x2FD8877){tembro=8;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка HAL
    
   if(ddd==0){digitalWrite(A2,HIGH);}else{digitalWrite(A2,LOW);}
   if(mute==1){digitalWrite(A1,HIGH);}else{digitalWrite(A1,LOW);}
 //////////////////////////////////////// volume -79...0 db //////////////////////////////////////
if(menu==0){   
     if(ir.value==0x2FD10EF){vol++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+ 
     if(ir.value==0xFFFFFFFF and g1==1){vol++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==0x2FD08F7){vol--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){vol--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
     if(vol>79){vol=79;}if(vol<0){vol=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    vol=vol+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(vol>79){vol=79;}if(vol<0){vol=0;}audio();}
  lcd.setCursor(0,0);lcd.print("Volume  ");
  lcd.print(" ");lcd.print(-79+vol);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");vol_d=vol-32;
   for(z=0,z0=0,z1=0;z<=vol_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0,1);lcd.write((uint8_t)2);}}
 //////////////////////////////////////// bass +-14 db //////////////////////////////////////
 if(menu==1){
     if(ir.value==0x2FD00FF){bass++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка R+
     if(ir.value==0x2FD38C7){bass--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка L-
   if(bass<-7){bass=-7;}if(bass>7){bass=7;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    bass=bass+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(bass<-7){bass=-7;}if(bass>7){bass=7;}audio();}
  lcd.setCursor(0,0);lcd.print("Bass");
  lcd.print(" ");lcd.print(bass*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");bass_d=(bass+7)*2;
   for(z=0,z0=0,z1=0;z<=bass_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}   
 //////////////////////////////////////// MIDDLE +-14 db //////////////////////////////////////
 if(menu==2){
     if(ir.value==0x2FD00FF){mid++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка R+
     if(ir.value==0x2FD38C7){mid--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка L-
   if(mid<-7){mid=-7;}if(mid>7){mid=7;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    mid=mid+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(mid<-7){mid=-7;}if(mid>7){mid=7;}audio();}
  lcd.setCursor(0,0);lcd.print("Middle  ");
  lcd.print(" ");lcd.print(mid*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("db");mid_d=(mid+7)*2;
   for(z=0,z0=0,z1=0;z<=mid_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("   ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}} 
 //////////////////////////////////////// treble +-14 db //////////////////////////////////////
 if(menu==3){
     if(ir.value==0x2FD6897){treb++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка TREBLE+
     if(ir.value==0x2FDE817){treb--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка TREBLE-
   if(treb<-7){treb=-7;}if(treb>7){treb=7;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    treb=treb+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(treb<-7){treb=-7;}if(treb>7){treb=7;}audio();}
  lcd.setCursor(0,0);lcd.print("Treble  ");
  lcd.print(" ");lcd.print(treb*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");treb_d=(treb+7)*2;
   for(z=0,z0=0,z1=0;z<=treb_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}    
   //////////////////////////////////// equalizer //////////////////////      
  if(menu==4){
     if(ir.value==0x2FDD02F){tembro=0;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка LIVE
     if(ir.value==0x2FD906F){tembro=1;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка ROCK
     if(ir.value==0x2FD50AF){tembro=2;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DISCO
     if(ir.value==0x2FDF00F){tembro=3;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка MATR
     if(ir.value==0x2FDC837){tembro=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка POPS
     if(ir.value==0x2FD708F){tembro=5;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CLAS
     if(ir.value==0x2FD48B7){tembro=6;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DSP OFF
     if(ir.value==0x2FDB04F){tembro=7;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SIMUL
     if(ir.value==0x2FD8877){tembro=8;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка HAL
     if(tembro>9){tembro=0;}if(tembro<0){tembro=9;}
     if (newPosition != oldPosition) {
    oldPosition = newPosition;
    tembro=tembro+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(tembro>9){tembro=0;}if(tembro<0){tembro=9;}}
    lcd.setCursor(0,0);lcd.print("PRESS EQUALIZER ");
    if(tembro==0){lcd.setCursor(0,1);lcd.print("     LIVE      ");bass=-1,mid=3,treb=0;x=1;}
    if(tembro==1){lcd.setCursor(0,1);lcd.print("     ROCK      ");bass=3,mid=1;treb=4;x=1;}
    if(tembro==2){lcd.setCursor(0,1);lcd.print("     DISCO     ");bass=5,mid=1;treb=6;x=1;}
    if(tembro==3){lcd.setCursor(0,1);lcd.print("     MATR      ");bass=2,mid=1;treb=5;x=1;}
    if(tembro==4){lcd.setCursor(0,1);lcd.print("     POP       ");bass=0,mid=3;treb=0;x=1;}
    if(tembro==5){lcd.setCursor(0,1);lcd.print("    CLASSIC    ");bass=0,mid=0;treb=-2;x=1;}
    if(tembro==6){lcd.setCursor(0,1);lcd.print("  MANUAL MODE  ");}
    if(tembro==7){lcd.setCursor(0,1);lcd.print("     SIMUL     ");bass=0,mid=0;treb=0;x=1;}
    if(tembro==8){lcd.setCursor(0,1);lcd.print("     HAL       ");bass=3,mid=0;treb=3;x=1;}
    if(x==1){audio();x=0;}
  }
   
  /////////////////////// ATT FRONT ///////////////////
   if(menu==5){
     if(ir.value==0x2FD20DF){att_front++;g1=1;g2=0;cl();time=millis();w=1;att_front_conf();audio();}// кнопка FRONT+
     if(ir.value==0x2FD18E7){att_front--;g1=0;g2=1;cl();time=millis();w=1;att_front_conf();audio();}// кнопка FRONT-  
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
  att_front=att_front+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;att_front_conf();audio();}
  lcd.setCursor(3,0);lcd.print("ATT FRONT ");
  lcd.print(att_front);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attfl_d=(att_front+14)*2;
  
   for(z=0,z0=0,z1=0;z<=attfl_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}} 
   
  /////////////////////// ATT SURR ///////////////////
  if(menu==6){
     if(ir.value==0x2FDD827){att_rear++;g1=1;g2=0;cl();time=millis();w=1;att_rear_conf();audio();}// кнопка SURR+
     if(ir.value==0x2FDF807){att_rear--;g1=0;g2=1;cl();time=millis();w=1;att_rear_conf();audio();}// кнопка SURR-
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    att_rear=att_rear+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;att_rear_conf();audio();}
  lcd.setCursor(3,0);lcd.print("ATT REAR  ");
  lcd.print(att_rear);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");atttl_d=(att_rear+14)*2;
  
   for(z=0,z0=0,z1=0;z<=atttl_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}} 
 /////////////////////// ATT CEN ///////////////////
    if(menu==7){
     if(ir.value==0x2FD9867){attcn++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CENTR+
     if(ir.value==0x2FDB847){attcn--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка CENTR-
      if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    attcn=attcn+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT CN   ");
  lcd.print(" ");lcd.print(attcn);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attcn_d=(attcn+14)*2;
   for(z=0,z0=0,z1=0;z<=attcn_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}  
  /////////////////////// ATT SUB ///////////////////
     if(menu==8){
     if(ir.value==0x2FD58A7){attsub++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SAB+
     if(ir.value==0x2FD7887){attsub--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка SAB-
       if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;time=millis();}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    attsub=attsub+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT SUB  ");
  lcd.print("");lcd.print(attsub);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attsub_d=(attsub+14)*2;
   for(z=0,z0=0,z1=0;z<=attsub_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}  
   
  //////////////////////////// 3d ///////////////////////////////////////////////
 if(menu==9){
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    ddd=ddd+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;ddd_conf();audio();}
   lcd.setCursor(0,0);lcd.print("    Surround    "); 
   lcd.setCursor(0,1);if(ddd==0){lcd.print("     3D  ON  ");}else{lcd.print("     3D  OFF  ");}}  


//////////// mute ////////////////////////
  if(mute==1&&(digitalRead(12)==HIGH||ir.value==0x2FD30CF)){mute=0;g1=1;g2=0;menu=0;audio();cl1();} 
  if(mute==0&&(digitalRead(12)==HIGH||ir.value==0x2FD30CF)){mute=1;g1=1;g2=0;menu=100;audio();cl1();}
  if(mute==1){lcd.setCursor(0,0);lcd.print("      MUTE      ");delay(300);}
   
  /////////////////// INPUT //////////////////////////////////////////////////////////////////////////////////////// 
   if(digitalRead(11)==HIGH||inn==1){
    in++;if(in>4){in=0;}audio_in();cl1();
   lcd.setCursor(0,0);lcd.print("");
   switch(in){ // 
     case 0: lcd.print("     AUX 2.1    "); break;
     case 1: lcd.print("   BLUETOOTH    "); break;
     case 2: lcd.print("   DVD  AS-3    "); break;
     case 3: lcd.print("     RADIO      "); break;
     case 4: lcd.print("     AUX 5.1    "); break;}
   delay(2000);time=millis();w=1;inn=0;}// in


   if(millis()-time>10000&& w==1&&mute==0){
     EEPROM.update(0,vol+79);EEPROM.update(10,in);EEPROM.update(1,bass+7);EEPROM.update(2,mid+7);EEPROM.update(3,treb+7);
     EEPROM.update(15,attfl+14);EEPROM.update(7,attcn+14);EEPROM.update(8,attsub+14);EEPROM.update(9,ddd);EEPROM.update(10,tembro);
     EEPROM.update(13,attfr+14);EEPROM.update(14,atttl+14);EEPROM.update(16,atttr+14);
     EEPROM.update(17,surr); EEPROM.update(5,att_front+14);EEPROM.update(6,att_rear+14); EEPROM.update(18,mix);
     menu=0;w=0;cl();}
 
   
 }//loop
 void ddd_conf(){if(ddd<0){ddd=1;}if(ddd>1){ddd=0;}}
 void att_sub(){if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;}}
 void att_cn(){if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}}
 void att_rear_conf(){if(att_rear<-14){att_rear=-14;}if(att_rear>0){att_rear=0;}}
 void att_front_conf(){if(att_front<-14){att_front=-14;}if(att_front>0){att_front=0;}}
 void tembr(){if(tembro>8){tembro=0;}if(tembro<0){tembro=8;}}
 void treb_conf(){if(treb<-7){treb=-7;}if(treb>7){treb=7;}}
 void mid_conf(){if(mid<-7){mid=-7;}if(mid>7){mid=7;}}
 void bass_conf(){if(bass<-7){bass=-7;}if(bass>7){bass=7;}}
 void vol_conf(){if(vol>79){vol=79;}if(vol<0){vol=0;}}
 void cl(){ir.value=0;delay(100);}
 void cl1(){ir.value=0;delay(300);lcd.clear();}
 void audio_in(){
  pt0.setInput(in); 
  pt0.setMute(0,0,0,0,0,0,0); 
  pt0.setFeature(mix,surr); 
}
 void audio(){
  pt.setFront_lk_att(abs(attfl));// att front L
  pt.setFront_rk_att(abs(attfr));// att front R
  pt.setCenter_att(abs(attcn));  // att center
  pt.setRear_lk_att(abs(atttl)); // att rear L
  pt.setRear_rk_att(abs(atttr)); // att rear R
  pt.setSub_att(abs(attsub));     // att sub
  pt.setFunc(mute,ddd,tembro); // mute,3d,tembre on/off
  pt.setBass(bass);            // BASS    -14...0...14 dB (int -7...0...7)
  pt.setMiddle(mid);          // MIDDLE  -14...0...14 dB (int -7...0...7)
  pt.setTreble(treb);          // TREBLE  -14...0...14 dB (int -7...0...7)
  pt.setVol(abs(vol)); // -79...0
}

56

Re: Темброблок 5.1 на PT2323 и PT2322 (Arduino)

#include <Wire.h>
#include <PT2322.h>
#include <PT2323.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <Encoder.h>
#include <MsTimer2.h>
#include <boarddefs.h>
#include <IRremote.h>
 PT2322 pt; PT2323 pt0; 
  Encoder myEnc(9, 8);//CLK, DT подключение энкодера
  IRrecv irrecv(10); // указываем вывод модуля IR приемника
   decode_results ir;
 LiquidCrystal lcd(7, 6, 2, 3, 4, 5);// RS,E,D4,D5,D6,D7 подключение LCD
   byte a1[8]={0b00000,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b00000};
   byte a2[8]={0b00000,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b00000};
   byte a3[8]={0b00000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b00000};
    unsigned long newPosition,time,oldPosition  = -999;
   int menu,menu2,w,vol,vol_d,z,z0,z1,in,bass,bass_d,mid,mid_d,treb,treb_d,attfl,attfl_d,attcn,attcn_d,attsub,attsub_d,ddd,tembro,x,attfr,attfr_d,atttl,atttl_d,atttr,atttr_d,mute;
   int g1,g2,inn;
   int att_front, att_rear;
   bool surr;
   bool mix;
   bool w1=1;

void setup() {
  Wire.begin();Serial.begin(9600);irrecv.enableIRIn(); // запускаем модульIR
  lcd.begin(16, 2);lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3); 
  pinMode(A0,INPUT); // menu кнопка энкодера
  pinMode(12,INPUT); // MUTE
  pinMode(11,INPUT); // IN
  pinMode(A2, OUTPUT);
  pinMode(A1, OUTPUT);
  
 
  MsTimer2::set(2, 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;in = EEPROM.read(10);bass = EEPROM.read(1)-7;mid = EEPROM.read(2)-7;treb = EEPROM.read(3)-7;
  attfl = EEPROM.read(15)-14;attcn = EEPROM.read(7)-14;attsub = EEPROM.read(8)-14;ddd = EEPROM.read(9);tembro = EEPROM.read(10);
  attfr = EEPROM.read(13)-14;atttl = EEPROM.read(14)-14;atttr = EEPROM.read(16)-14;att_front = EEPROM.read(5)-14;att_rear = EEPROM.read(6)-14;
  surr = EEPROM.read(17); mix = EEPROM.read(18);
  delay(500);
  
  audio();audio_in();
}
 void to_Timer(){newPosition = myEnc.read()/4;}
 
 void loop(){delay(10);
  if(analogRead(A0)<900){menu++;cl1();myEnc.write(0);time=millis();w=1;w=1;if(menu>9){menu=0;}}// меню
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);time=millis();w=1;w=1;irrecv.resume();}// IR приемник  
  if(ir.value==0){g1=0;g2=0;}// запрет нажатий не активных кнопок пульта
  if(in==4){digitalWrite(13,HIGH);}else{digitalWrite(13,LOW);} //вкл\выкл AUX5.1
   if(ir.value==0x2FD609F){menu++;g1=0;g2=0;cl1();time=millis();w=1;if(menu>9){menu=0;}}// меню кнопка 5.1CH
   if(ir.value==0x2FDE01F){menu--;g1=0;g2=0;cl1();time=millis();w=1;if(menu<0){menu=9;}}// меню кнопка 2.1CH
   if(ir.value==0x2FDA05F && mix==1){mix=0;g1=1;g2=0;cl();time=millis();w=1;lcd.setCursor(0,0);lcd.print("   Mixed 0dB   ");audio_in();delay(2000);} //  кнопка VSS 
   if(ir.value==0x2FDA05F && mix==0){mix=1;g1=1;g2=0;cl();time=millis();w=1;lcd.setCursor(0,0);lcd.print("   Mixed +6dB  ");audio_in();delay(2000);} //  кнопка VSS 
   if(ir.value==0x2FDC03F){inn=1;g1=0;g2=0;time=millis();w=1;audio();}//   кнопка AUX 
   if(ir.value==0x2FD807F && surr==0){surr=1;g1=1;g2=0;cl();time=millis();w=1;lcd.setCursor(0,0);lcd.print("Surround ON ");audio_in();delay(2000);}//кнопка DVD
   if(ir.value==0x2FD807F && surr==1){surr=0;g1=1;g2=0;cl();time=millis();w=1;lcd.setCursor(0,0);lcd.print("Surround OFF");audio_in();delay(2000);}//кнопка DVD
   if(ir.value==0x2FD40BF){ddd++;menu=9;g1=1;g2=0;cl();time=millis();w=1;ddd_conf();audio();}//кнопка 3D mod
     if(ir.value==0x2FD6897){treb++;menu=3;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка TREBLE+
     if(ir.value==0x2FDE817){treb--;menu=3;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка TREBLE-
     if(ir.value==0x2FD20DF){att_front++;menu=5;g1=1;g2=0;cl();time=millis();w=1;att_front_conf();audio();}// кнопка FRONT+
     if(ir.value==0x2FD18E7){att_front--;menu=5;g1=0;g2=1;cl();time=millis();w=1;att_front_conf();audio();}// кнопка FRONT-
     if(ir.value==0x2FDD827){att_rear++;menu=6;g1=1;g2=0;cl();time=millis();w=1;att_rear_conf();audio();}// кнопка SURR+
     if(ir.value==0x2FDF807){att_rear--;menu=6;g1=0;g2=1;cl();time=millis();w=1;att_rear_conf();audio();}// кнопка SURR-
     if(ir.value==0x2FD9867){attcn++;menu=7;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CENTR+
     if(ir.value==0x2FDB847){attcn--;menu=7;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка CENTR-
     if(ir.value==0x2FD58A7){attsub++;menu=8;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SAB+
     if(ir.value==0x2FD7887){attsub--;menu=8;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка SAB-
     if(ir.value==0x2FDD02F){tembro=0;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка LIVE
     if(ir.value==0x2FD906F){tembro=1;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка ROCK
     if(ir.value==0x2FD50AF){tembro=2;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DISCO
     if(ir.value==0x2FDF00F){tembro=3;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка MATR
     if(ir.value==0x2FDC837){tembro=4;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка POPS
     if(ir.value==0x2FD708F){tembro=5;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CLAS
     if(ir.value==0x2FD48B7){tembro=6;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DSP OFF
     if(ir.value==0x2FDB04F){tembro=7;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SIMUL
     if(ir.value==0x2FD8877){tembro=8;menu=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка HAL
    
   if(ddd==0){digitalWrite(A2,HIGH);}else{digitalWrite(A2,LOW);}
   if(mute==1){digitalWrite(A1,HIGH);}else{digitalWrite(A1,LOW);}
 //////////////////////////////////////// volume -79...0 db //////////////////////////////////////
if(menu==0){   
     if(ir.value==0x2FD10EF){vol++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+ 
     if(ir.value==0xFFFFFFFF and g1==1){vol++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==0x2FD08F7){vol--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){vol--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
     if(vol>79){vol=79;}if(vol<0){vol=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    vol=vol+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(vol>79){vol=79;}if(vol<0){vol=0;}audio();}
  lcd.setCursor(0,0);lcd.print("Volume  ");
  lcd.print(" ");lcd.print(-79+vol);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");vol_d=vol-32;
   for(z=0,z0=0,z1=0;z<=vol_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0,1);lcd.write((uint8_t)2);}}
 //////////////////////////////////////// bass +-14 db //////////////////////////////////////
 if(menu==1){
     if(ir.value==0x2FD00FF){bass++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка R+
     if(ir.value==0x2FD38C7){bass--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка L-
   if(bass<-7){bass=-7;}if(bass>7){bass=7;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    bass=bass+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(bass<-7){bass=-7;}if(bass>7){bass=7;}audio();}
  lcd.setCursor(0,0);lcd.print("Bass");
  lcd.print(" ");lcd.print(bass*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");bass_d=(bass+7)*2;
   for(z=0,z0=0,z1=0;z<=bass_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}   
 //////////////////////////////////////// MIDDLE +-14 db //////////////////////////////////////
 if(menu==2){
     if(ir.value==0x2FD00FF){mid++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка R+
     if(ir.value==0x2FD38C7){mid--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка L-
   if(mid<-7){mid=-7;}if(mid>7){mid=7;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    mid=mid+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(mid<-7){mid=-7;}if(mid>7){mid=7;}audio();}
  lcd.setCursor(0,0);lcd.print("Middle  ");
  lcd.print(" ");lcd.print(mid*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("db");mid_d=(mid+7)*2;
   for(z=0,z0=0,z1=0;z<=mid_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("   ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}} 
 //////////////////////////////////////// treble +-14 db //////////////////////////////////////
 if(menu==3){
     if(ir.value==0x2FD6897){treb++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка TREBLE+
     if(ir.value==0x2FDE817){treb--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка TREBLE-
   if(treb<-7){treb=-7;}if(treb>7){treb=7;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    treb=treb+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(treb<-7){treb=-7;}if(treb>7){treb=7;}audio();}
  lcd.setCursor(0,0);lcd.print("Treble  ");
  lcd.print(" ");lcd.print(treb*2);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");treb_d=(treb+7)*2;
   for(z=0,z0=0,z1=0;z<=treb_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}    
   //////////////////////////////////// equalizer //////////////////////      
  if(menu==4){
     if(ir.value==0x2FDD02F){tembro=0;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка LIVE
     if(ir.value==0x2FD906F){tembro=1;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка ROCK
     if(ir.value==0x2FD50AF){tembro=2;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DISCO
     if(ir.value==0x2FDF00F){tembro=3;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка MATR
     if(ir.value==0x2FDC837){tembro=4;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка POPS
     if(ir.value==0x2FD708F){tembro=5;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CLAS
     if(ir.value==0x2FD48B7){tembro=6;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка DSP OFF
     if(ir.value==0x2FDB04F){tembro=7;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SIMUL
     if(ir.value==0x2FD8877){tembro=8;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка HAL
     if(tembro>9){tembro=0;}if(tembro<0){tembro=9;}
     if (newPosition != oldPosition) {
    oldPosition = newPosition;
    tembro=tembro+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(tembro>9){tembro=0;}if(tembro<0){tembro=9;}}
    lcd.setCursor(0,0);lcd.print("PRESS EQUALIZER ");
    if(tembro==0){lcd.setCursor(0,1);lcd.print("     LIVE      ");bass=-1,mid=3,treb=0;x=1;}
    if(tembro==1){lcd.setCursor(0,1);lcd.print("     ROCK      ");bass=3,mid=1;treb=4;x=1;}
    if(tembro==2){lcd.setCursor(0,1);lcd.print("     DISCO     ");bass=5,mid=1;treb=6;x=1;}
    if(tembro==3){lcd.setCursor(0,1);lcd.print("     MATR      ");bass=2,mid=1;treb=5;x=1;}
    if(tembro==4){lcd.setCursor(0,1);lcd.print("     POP       ");bass=0,mid=3;treb=0;x=1;}
    if(tembro==5){lcd.setCursor(0,1);lcd.print("    CLASSIC    ");bass=0,mid=0;treb=-2;x=1;}
    if(tembro==6){lcd.setCursor(0,1);lcd.print("  MANUAL MODE  ");}
    if(tembro==7){lcd.setCursor(0,1);lcd.print("     SIMUL     ");bass=0,mid=0;treb=0;x=1;}
    if(tembro==8){lcd.setCursor(0,1);lcd.print("     HAL       ");bass=3,mid=0;treb=3;x=1;}
    if(x==1){audio();x=0;}
  }
   
  /////////////////////// ATT FRONT ///////////////////
   if(menu==5){
     if(ir.value==0x2FD20DF){att_front++;g1=1;g2=0;cl();time=millis();w=1;att_front_conf();audio();}// кнопка FRONT+
     if(ir.value==0x2FD18E7){att_front--;g1=0;g2=1;cl();time=millis();w=1;att_front_conf();audio();}// кнопка FRONT-  
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
  att_front=att_front+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;att_front_conf();audio();}
  lcd.setCursor(3,0);lcd.print("ATT FRONT ");
  lcd.print(att_front);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attfl_d=(att_front+14)*2;
  
   for(z=0,z0=0,z1=0;z<=attfl_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}} 
   
  /////////////////////// ATT SURR ///////////////////
  if(menu==6){
     if(ir.value==0x2FDD827){att_rear++;g1=1;g2=0;cl();time=millis();w=1;att_rear_conf();audio();}// кнопка SURR+
     if(ir.value==0x2FDF807){att_rear--;g1=0;g2=1;cl();time=millis();w=1;att_rear_conf();audio();}// кнопка SURR-
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    att_rear=att_rear+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;att_rear_conf();audio();}
  lcd.setCursor(3,0);lcd.print("ATT REAR  ");
  lcd.print(att_rear);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");atttl_d=(att_rear+14)*2;
  
   for(z=0,z0=0,z1=0;z<=atttl_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}} 
 /////////////////////// ATT CEN ///////////////////
    if(menu==7){
     if(ir.value==0x2FD9867){attcn++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка CENTR+
     if(ir.value==0x2FDB847){attcn--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка CENTR-
      if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    attcn=attcn+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT CN   ");
  lcd.print(" ");lcd.print(attcn);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attcn_d=(attcn+14)*2;
   for(z=0,z0=0,z1=0;z<=attcn_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}  
  /////////////////////// ATT SUB ///////////////////
     if(menu==8){
     if(ir.value==0x2FD58A7){attsub++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка SAB+
     if(ir.value==0x2FD7887){attsub--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка SAB-
       if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;time=millis();}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    attsub=attsub+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;}audio();}
  lcd.setCursor(0,0);lcd.print("ATT SUB  ");
  lcd.print("");lcd.print(attsub);lcd.print(" ");lcd.setCursor(13,0);lcd.print("dB");attsub_d=(attsub+14)*2;
   for(z=0,z0=0,z1=0;z<=attsub_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1+3,1);lcd.print("    ");}}
   if(z1==3){lcd.setCursor(z0+3,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+3,1);lcd.write((uint8_t)2);}}  
   
  //////////////////////////// 3d ///////////////////////////////////////////////
 if(menu==9){
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    ddd=ddd+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;ddd_conf();audio();}
   lcd.setCursor(0,0);lcd.print("    Surround    "); 
   lcd.setCursor(0,1);if(ddd==0){lcd.print("     3D  ON  ");}else{lcd.print("     3D  OFF  ");}}  


//////////// mute ////////////////////////
  if(mute==1&&(digitalRead(12)==HIGH||ir.value==0x2FD30CF)){mute=0;g1=1;g2=0;menu=0;audio();cl1();} 
  if(mute==0&&(digitalRead(12)==HIGH||ir.value==0x2FD30CF)){mute=1;g1=1;g2=0;menu=100;audio();cl1();}
  if(mute==1){lcd.setCursor(0,0);lcd.print("      MUTE      ");delay(300);}
   
  /////////////////// INPUT //////////////////////////////////////////////////////////////////////////////////////// 
   if(digitalRead(11)==HIGH||inn==1){
    in++;if(in>4){in=0;}audio_in();cl1();
   lcd.setCursor(0,0);lcd.print("");
   switch(in){ // 
     case 0: lcd.print("     AUX 2.1    "); break;
     case 1: lcd.print("   BLUETOOTH    "); break;
     case 2: lcd.print("   DVD  AS-3    "); break;
     case 3: lcd.print("     RADIO      "); break;
     case 4: lcd.print("     AUX 5.1    "); break;}
   delay(2000);time=millis();w=1;inn=0;}// in


   if(millis()-time>10000&& w==1&&mute==0){
     EEPROM.update(0,vol+79);EEPROM.update(10,in);EEPROM.update(1,bass+7);EEPROM.update(2,mid+7);EEPROM.update(3,treb+7);
     EEPROM.update(15,attfl+14);EEPROM.update(7,attcn+14);EEPROM.update(8,attsub+14);EEPROM.update(9,ddd);EEPROM.update(10,tembro);
     EEPROM.update(13,attfr+14);EEPROM.update(14,atttl+14);EEPROM.update(16,atttr+14);
     EEPROM.update(17,surr); EEPROM.update(5,att_front+14);EEPROM.update(6,att_rear+14); EEPROM.update(18,mix);
     menu=0;w=0;cl();}
 
   
 }//loop
 void ddd_conf(){if(ddd<0){ddd=1;}if(ddd>1){ddd=0;}}
 void att_sub(){if(attsub<-14){attsub=-14;}if(attsub>0){attsub=0;}}
 void att_cn(){if(attcn<-14){attcn=-14;}if(attcn>0){attcn=0;}}
 void att_rear_conf(){if(att_rear<-14){att_rear=-14;}if(att_rear>0){att_rear=0;}}
 void att_front_conf(){if(att_front<-14){att_front=-14;}if(att_front>0){att_front=0;}}
 void tembr(){if(tembro>8){tembro=0;}if(tembro<0){tembro=8;}}
 void treb_conf(){if(treb<-7){treb=-7;}if(treb>7){treb=7;}}
 void mid_conf(){if(mid<-7){mid=-7;}if(mid>7){mid=7;}}
 void bass_conf(){if(bass<-7){bass=-7;}if(bass>7){bass=7;}}
 void vol_conf(){if(vol>79){vol=79;}if(vol<0){vol=0;}}
 void cl(){ir.value=0;delay(100);}
 void cl1(){ir.value=0;delay(300);lcd.clear();}
 void audio_in(){
  pt0.setInput(in); 
  pt0.setMute(0,0,0,0,0,0,0); 
  pt0.setFeature(mix,surr); 
}
 void audio(){
  pt.setFront_lk_att(abs(att_front));// att front L
  pt.setFront_rk_att(abs(att_front));// att front R
  pt.setCenter_att(abs(attcn));  // att center
  pt.setRear_lk_att(abs(att_rear)); // att rear L
  pt.setRear_rk_att(abs(att_rear)); // att rear R
  pt.setSub_att(abs(attsub));     // att sub
  pt.setFunc(mute,ddd,tembro); // mute,3d,tembre on/off
  pt.setBass(bass);            // BASS    -14...0...14 dB (int -7...0...7)
  pt.setMiddle(mid);          // MIDDLE  -14...0...14 dB (int -7...0...7)
  pt.setTreble(treb);          // TREBLE  -14...0...14 dB (int -7...0...7)
  pt.setVol(abs(vol)); // -79...0
}

57

Re: Темброблок 5.1 на PT2323 и PT2322 (Arduino)

Спасибо Вам, я не понял что вы сделали, но работает.