Тема: pt2322 pt2323

Какие команды надо изменять для lcd 2004 i2c

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


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

2

Re: pt2322 pt2323

http://rcl-radio.ru/?p=66506

3

Re: pt2322 pt2323

как исправит это мерцание

4

Re: pt2322 pt2323

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


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

5

Re: pt2322 pt2323

Можно сделать так(на примере громкости):

 //////////////////////////////////////// Громкость -79...0 дБ //////////////////////////////////////
 if(menu==0){   
     if(ir.value==VOL_UP){vol++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+  0xFFA857
     if(ir.value==0xFFFFFFFF and g1==1){vol++;g2=0;cl();time=millis();w=1;audio();}// кнопка >>>>>>
     if(ir.value==VOL_DW){vol--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){vol--;g1=0;cl();time=millis();w=1;audio();}// кнопка <<<<<<
     if(vol>79){vol=79;}if(vol<0){vol=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    vol=vol+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(vol>79){vol=79;}if(vol<0){vol=0;}audio();}
if(w==1){  
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);}}}

6

Re: pt2322 pt2323

Нет не помогло  а можно сделать такой функционал

#include <Wire.h> 
#include <LiquidCrystal_I2C.h> // http://forum.rcl-radio.ru/misc.php?action=pan_download&item=45&download=1
#include <Encoder.h>           // http://rcl-radio.ru/wp-content/uploads/2019/05/Encoder.zip       
#include <EEPROM.h>
#include <MsTimer2.h>          // http://rcl-radio.ru/wp-content/uploads/2018/11/MsTimer2.zip 
#include <boarddefs.h>         // входит в состав библиотеки IRremote
#include <IRremote.h>          // http://rcl-radio.ru/wp-content/uploads/2019/06/IRremote.zip
#include <PT2258.h> // https://github.com/liman324/PT2258.git
#include <DS3231.h>

 PT2258 pt;
 LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
 Encoder myEnc(9, 8);// DT, CLK
 IRrecv irrecv(12); // указываем вывод модуля IR приемника
 decode_results ir; 
 DS3231 clock;RTCDateTime DateTime;

 
byte v1[8] = {0b00111,0b00111,0b00111,0b00111,0b00111,0b00111,0b00111,0b00111};
byte v2[8] = {0b00111,0b00111,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000};      
byte v3[8] = {0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b11111,0b11111};
byte v4[8] = {0b11111,0b11111,0b00000,0b00000,0b00000,0b00000,0b11111,0b11111};
byte v5[8] = {0b11100,0b11100,0b00000,0b00000,0b00000,0b00000,0b11100,0b11100};
byte v6[8] = {0b11100,0b11100,0b11100,0b11100,0b11100,0b11100,0b11100,0b11100};
byte v7[8] = {0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00111,0b00111};
byte v8[8] = {0b11111,0b11111,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000}; 
unsigned long times,oldPosition  = -999,newPosition; 
int vol,ch1,ch2,ch3,ch4,ch5,ch6,menu,brig=250;
bool mute,power,w,w1,gr1,gr2;
byte a[6],d1,d2,d3,d4,d5,d6,e1,e2,e3,x;
int hour,minut,secon,data,mon,year;


void setup(){
  irrecv.enableIRIn();lcd.init();lcd.backlight();Wire.begin();clock.begin();Serial.begin(9600);
  MsTimer2::set(1, to_Timer);MsTimer2::start();
  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);
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении  
  pinMode(10,INPUT);        // encoder SW
  pinMode(6,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ ПОДСВЕТКОЙ
  analogWrite(6, brig);
   //  clock.setDateTime(__DATE__, __TIME__); // Устанавливаем время на часах, основываясь на времени компиляции скетча

  delay(500);
  audio();
  
  }

void loop(){
/// READ TIME /////////////////////////////////
DateTime = clock.getDateTime();hour = DateTime.hour;minut = DateTime.minute;secon = DateTime.second;
  data = DateTime.day;mon = DateTime.month;year = DateTime.year;
/// IR ////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();times=millis();w=1;w1=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта  

////////////// VOLUME ///////////////////////////////////////////////////////////////////
 if(menu==0){
 
   if (newPosition != oldPosition){oldPosition = newPosition;vol=vol+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w1=1;vol_func();audio();}
   a[0]= (64-vol)/10;a[1]=(64-vol)%10;
   for(x=0;x<2;x++){switch(x){case 0: e1=11,e2=12,e3=13;break;case 1: e1=14,e2=15,e3=16;break;}digit();}
   lcd.setCursor(0,0);lcd.print("VOLUME");
   lcd.setCursor(0,1);lcd.print("CONTROL");
   lcd.setCursor(0,2);lcd.print("--------------------");
   lcd.setCursor(0,3);
     lcd.print(hour/10);lcd.print(hour%10);lcd.print(":");
     lcd.print(minut/10);lcd.print(minut%10);lcd.print(":");
     lcd.print(secon/10);lcd.print(secon%10);lcd.print(" ");

     lcd.print(data/10);lcd.print(data%10);lcd.print("-");
     lcd.print(mon/10);lcd.print(mon%10);lcd.print("-");
     lcd.print(year);
     
  }  
  
  }  

void audio(){
        pt.clear(); 
      //  pt.setVolume(75); //  int 0...79     
        pt.setVol1(vol+ch1); //  int 0...79       
        pt.setVol2(vol+ch2); //  int 0...79 
        pt.setVol3(vol+ch3); //  int 0...79 
        pt.setVol4(vol+ch4); //  int 0...79 
        pt.setVol5(vol+ch5); //  int 0...79 
        pt.setVol6(vol+ch6); //  int 0...79 
        pt.setMute(mute); // mute 0 - off / 1 - on
  }

void to_Timer(){newPosition = myEnc.read()/4;} 
void vol_func(){if(vol<0){vol=0;}if(vol>64){vol=64;}}

void digit(){switch(a[x]){
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);}
 

7

Re: pt2322 pt2323

брат помогите создать на дисплей 2004 скетч

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

#include <Wire.h> 
#include <PT2322.h>
#include <PT2323.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h> 
#include <Encoder.h>            
#include <EEPROM.h>
#include <MsTimer2.h>           
#include <boarddefs.h>
#include <IRremote.h>  
#include <DS3231.h>
   DS3231 clock;RTCDateTime DateTime;
   PT2322 pt; PT2323 pt0; 
   LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
   IRrecv irrecv(12); // указываем вывод модуля IR приемника
   Encoder myEnc(9, 8);// DT, CLK
   decode_results ir; 
      int menu,menu0,menu1,temp0,par,hour,minut,secon,z_old,gain0;
      int brig0,brig1;
       int vol,vol_d,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;
   int g1,g2,inn; 

 
      byte w2[4],z,z0,z1,n,q,gr1,gr2,www,i,w,mute,power,in_x,save,i1;
      unsigned long time0,oldPosition  = -999,newPosition,times_in;
      byte mesto2[5]={0,11,6,0,11};
      byte mesto3[5]={0,0,1,3,3};


void setup() {
  irrecv.enableIRIn();lcd.init();lcd.backlight();clock.begin();Serial.begin(9600);
  pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT_PULLUP);   // КНОПКА SET
  pinMode(3,INPUT_PULLUP);   // КНОПКА IN
  pinMode(4,INPUT_PULLUP);   // КНОПКА MUTE
  pinMode(5,INPUT_PULLUP);   // КНОПКА STANDBY
  pinMode(7,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ STANDBY
  pinMode(6,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ ПОДСВЕТКОЙ
  analogWrite(6, 200);// больше 200 не делать
  lcd.setCursor(1,1);lcd.print("Sound Processor");lcd.setCursor(1,2);lcd.print("PT2314"); delay(2000);lcd.clear();
  MsTimer2::set(3, to_Timer);MsTimer2::start();
  //  clock.setDateTime(__DATE__, __TIME__); // Устанавливаем время на часах, основываясь на времени компиляции скетча
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении  
   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;brig0 = EEPROM.read(14);brig1 = EEPROM.read(15);
  w2_arr();audio();cl();
  analogWrite(6, 25*brig0);
}
void to_Timer(){newPosition = myEnc.read()/4;}  

void loop() {
  DateTime = clock.getDateTime();hour = DateTime.hour;minut = DateTime.minute;secon = DateTime.second;

/////////////////////////////// УПРАВЛЕНИЕ //////////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();time0=millis();w=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта  

  if(mute==0&&power==0){ 
  if(ir.value==IR_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time0=millis();w=1;w2_arr();if(menu>2){menu=0;}}//меню 1
  if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time0=millis();w=1;w2_arr();if(menu<0){menu=2;}}//меню 1
 
  if(ir.value==IR_2&&menu0==1){menu1++;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu1>4){menu1=0;}}//меню 2
  if(ir.value==IR_1&&menu0==1){menu1--;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu1<0){menu1=4;}}//меню 2
    
  if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time0=millis();w=1;w2_arr();if(menu>2){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu1++;delay(200);time0=millis();w=1;if(menu1>4){menu1=0;}}// меню 1
  
  if((ir.value==IR_6||digitalRead(2)==LOW)&&menu0==0){menu0=1;cl();time0=millis();w=1;lcd.setCursor(6,1);lcd.print("SETTING"); delay(300);lcd.clear();}
  if((ir.value==IR_6||digitalRead(2)==LOW)&&menu0==1){menu0=0;menu=0;cl();w2_arr();time0=millis();w=1;lcd.setCursor(8,1);lcd.print("MENU"); delay(300);lcd.clear();}
  if(ir.value==IR_5||digitalRead(3)==LOW||inn==1){inn++;cl();times_in=millis();in_x=1;www=1;menu0=100;if(in>4){in=0;}}// IN
  }
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==0&&power==0){mute=1; pt.setVol(31); pt.setVol(31);menu0=100;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");delay(300);}// mute on
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==1&&power==0){mute=0;cl();time0=millis();w=1;w2_arr();menu0=0;myEnc.write(0);audio();}// mute off

   if((ir.value==IR_8||digitalRead(5)==LOW)&&power==0){power=1;save=1; pt.setVol(31); pt.setVol(31);cl();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);analogWrite(6, brig1*25);}// power off
  if((ir.value==IR_8||digitalRead(5)==LOW)&&power==1){power=0;analogWrite(6, brig0*25);lcd.clear();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);audio();delay(3000);cl();}// 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}; //>
   byte a5[8] = {0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000};
   lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);lcd.createChar(3,a4);lcd.createChar(4,a5);
  }
  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");
  if(digitalRead(10)==LOW&&digitalRead(2)==LOW){hour++;if(hour>23){hour=0;} clock.setDateTime(2020, 9, 15, hour, minut, secon);delay(100);}
  if(digitalRead(10)==LOW&&digitalRead(3)==LOW){minut++;if(minut>59){minut=0;} clock.setDateTime(2020, 9, 15, hour, minut, secon);delay(100); }
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW){secon=0; clock.setDateTime(2020, 9, 15, hour, minut, secon);delay(100); }
  } 

 /////////////////////////////// MENU0 = VOLUME TERBLE BASS BALANCE ///////////////////////////////////////////////////////////////////////
  if(menu0==0){
    switch(menu){
      case 0: temp0 = vol;q=0;break;
      case 1: temp0 = bass;q=1;break;
      case 2: temp0 = treb;q=2;break;}
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();;w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка <<<<<<   
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=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: treb = temp0;treb_func();break;}
 
   au();
   for(i=0;i<3;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,0,79,1,24);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print(" ");bass_d=map(bass,-14,14,1,1);
   lcd.setCursor(1,2);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print(" ");treb_d=map(treb,-14,14,1,1);
   lcd.setCursor(1,3);lcd.print("INPUT   ");lcd.print(in+1);lcd.print("  ");
   lcd.print(DateTime.hour/10);lcd.print(DateTime.hour%10);lcd.print(":");lcd.print(DateTime.minute/10);lcd.print(DateTime.minute%10);lcd.print(":");
   lcd.print(DateTime.second/10);lcd.print(DateTime.second%10);

   for(n=0;n<3;n++){if(w2[n]==1){
   switch(n){
    case 0: par = vol_d;break;
    case 1: par = bass_d;break;
    case 2: par = treb_d;break;} 
   
   for(z=0,z0=0,z1=0;z<=par;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,n);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,n);Serial.println(z0);z_old=7-par/3;while(z_old>0){z_old=z_old-1;lcd.write((uint8_t)4);}}}
   if(z1==3){lcd.setCursor(z0+12,n);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,n);lcd.write((uint8_t)2);}w2[n]=0;}
   }}// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////

 if(menu0==1){
     switch(menu1){
      case 0: temp0 = attfl;break;
      case 1: temp0 = attfr;break;
      case 2: temp0 = ddd;break;
      case 3: temp0 = brig0;break;
      case 4: temp0 = brig1;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu1){
      case 0: attfl = temp0;attfl_func();break;
      case 1: attfr = temp0;attfr_func();break;
      case 2: ddd  = temp0;ddd_func();break;
      case 3: brig0  = temp0;brig0_func();break;
      case 4: brig1  = temp0;brig1_func();break;
      }
 
  au();analogWrite(6, brig0*25);
  for(i=0;i<5;i++){if(menu1==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("ATTFL ");lcd.print(attfl);lcd.print(" ");lcd.setCursor(12,0);lcd.print("ATTFR ");lcd.print(attfr);lcd.print(" ");
  lcd.setCursor(7,1);lcd.print("3D   ");if(ddd==0){lcd.print("ON ");}else{lcd.print("OFF");}
  lcd.setCursor(0,2);lcd.print("-------------------");
  lcd.setCursor(1,3);lcd.print("BRIG_1 ");lcd.print(brig0);lcd.print(" ");lcd.setCursor(12,3);lcd.print("BRIG_2 ");lcd.print(brig1);
  
 } // menu0 = 1


////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
 // switch(in){
    // case 0: gain0 = gain1;break;
   //  case 1: gain0 = gain2;break;
   //  case 2: gain0 = gain3;break;
   //  case 3: gain0 = gain4;break;}
 
    if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();time0=millis();times_in=millis();www=1;w=1;gain_func();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();time0=millis();times_in=millis();www=1;w=1;gain_func();}// кнопка >>>>>>
    if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();time0=millis();times_in=millis();www=1;w=1;gain_func();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();time0=millis();times_in=millis();www=1;w=1;gain_func();}// кнопка <<<<<<  
 
    if (newPosition != oldPosition) {oldPosition = newPosition;
   gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time0=millis();times_in=millis();www=1;w=1;gain_func();} 
 
  // switch(in){
   //  case 0: gain1 = gain0;break;
    // case 1: gain2 = gain0;break;
    // case 2: gain3 = gain0;break;
    // case 3: gain4 = gain0;break;}
 
  au();
  lcd.setCursor(5,1);lcd.print("Gain IN ");lcd.print(in+1);lcd.setCursor(6,2);//lcd.print(float(gain0*3.75));lcd.print(" ");lcd.print("dB ");
   }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   

if(millis()-time0>10000&&w==1&&mute==0&&power==0){if(menu0==1){cl();}w=0;menu0=0;menu=0;w2_arr();}
if(millis()-times_in>3000&&w==1&&in_x==1&&mute==0&&power==0){cl();w=0;in_x=0;menu0=0;menu=0;w2_arr();}

if(save==1){save=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,brig0);EEPROM.update(15,brig1);}
            
}// loop

void brig1_func(){if(brig1>8){brig1=8;}if(brig1<0){brig1=0;}}
void brig0_func(){if(brig0>8){brig0=8;}if(brig0<0){brig0=0;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void au(){if(www==1){audio();www=0;}}
void inn_func(){if(in>3){in=3;}if(in<0){in=0;}}
void ddd_func(){if(ddd<0){ddd=0;}if(ddd>1){ddd=1;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>3){gain0=3;}}
void attfr_func(){if(attfr<0){attfr=0;}if(attfr>14){attfr=14;}}
void attfl_func(){if(attfl<0){attfl=0;}if(attfl>14){attfl=14;}}
void treb_func(){if(treb<-14){treb=-14;}if(treb>14){treb=14;}}
void bass_func(){if(bass<-14){bass=-14;}if(bass>14){bass=14;}}
void vol_func(){if(vol<0){vol=0;}if(vol>79){vol=79;}}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(200);}  
 void audio_in(){
  pt0.setInput(in); 
  pt0.setMute(0,0,0,0,0,0,0); 
  pt0.setFeature(1,1); 
}
 void audio(){
  
  pt.setFront_lk_att(abs(attfl));// att front L
  pt.setFront_rk_att(abs(attfr));// att front R
  pt.setCenter_att(abs(attcn));  // att center
  pt.setRear_lk_att(abs(atttl)); // att rear L
  pt.setRear_rk_att(abs(atttr)); // att rear R
  pt.setSub_att(abs(attsub));     // att sub
  pt.setFunc(mute,ddd,0); // mute,3d,тембр on/off
  pt.setBass(bass);            // BASS    -14...0...14 dB (int -7...0...7)
  pt.setMiddle(mid);          // MIDDLE  -14...0...14 dB (int -7...0...7)
  pt.setTreble(treb);          // TREBLE  -14...0...14 dB (int -7...0...7)
  pt.setVol(abs(vol)); // -79...0
  }

8

Re: pt2322 pt2323

привет брат помогите мене написать скетч я не могу добавить остальные функцию и не сохраняет настройку

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

#include <Wire.h> 
#include <PT2322.h>
#include <PT2323.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h> 
#include <Encoder.h>            
#include <EEPROM.h>
#include <MsTimer2.h>           
#include <boarddefs.h>
#include <IRremote.h>  
#include <DS3231.h>
   DS3231 clock;RTCDateTime DateTime;
   PT2322 pt; PT2323 pt0; 
   LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
   IRrecv irrecv(12); // указываем вывод модуля IR приемника
   Encoder myEnc(9, 8);// DT, CLK
   decode_results ir; 
        int menu,menu0,menu1,times1,temp0,in_time,par,year,date,mont,hour,minut,secon,korr,z_old,gain0;
        int brig0,brig1;
        int vol,vol_d,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;
        int g1,g2,inn; 
        String dn[]={"   ","DUWANBA","SEWANBA","CHORWANBA","PAYWANBA","JUMA","WANBA","YAKWANBA"};
        byte wesk;
        
   
 
      byte w2[4],z,z0,z1,n,q,gr1,gr2,www,i,w,mute,power,in_x,save,i1;
      unsigned long time0,oldPosition  = -999,newPosition,times_in;
      byte mesto2[5]={0,11,6,0,11};
      byte mesto3[5]={0,0,1,3,3};


void setup() {
  irrecv.enableIRIn();lcd.init();lcd.backlight();clock.begin();Serial.begin(9600);
  pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT_PULLUP);   // КНОПКА SET
  pinMode(3,INPUT_PULLUP);   // КНОПКА IN
  pinMode(4,INPUT_PULLUP);   // КНОПКА MUTE
  pinMode(5,INPUT_PULLUP);   // КНОПКА STANDBY
  pinMode(7,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ STANDBY
  pinMode(6,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ ПОДСВЕТКОЙ
  analogWrite(6, 200);// больше 200 не делать
  lcd.setCursor(1,1);lcd.print("Sound Processor");lcd.setCursor(1,2);lcd.print("PT2314"); delay(2000);lcd.clear();
  MsTimer2::set(3, to_Timer);MsTimer2::start();
  //  clock.setDateTime(__DATE__, __TIME__); // Устанавливаем время на часах, основываясь на времени компиляции скетча
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении  
   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;brig0 = EEPROM.read(14);brig1 = EEPROM.read(15);
  audio();audio_in();
  analogWrite(6, 25*brig0);
}
void to_Timer(){newPosition = myEnc.read()/4;}  

void loop() {
   DateTime = clock.getDateTime();hour = DateTime.hour;minut = DateTime.minute;secon = DateTime.second;
 date = DateTime.day;mont = DateTime.month;year = DateTime.year;wesk = DateTime.dayOfWeek;

/////////////////////////////// УПРАВЛЕНИЕ //////////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();time0=millis();w=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта  

{ 
 if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time0=millis();times1=millis();in_x=0;w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu1++;delay(200);time0=millis();times1=millis();in_x=0;w=1;if(menu1>4){menu1=0;}}// меню 1
 
  if(ir.value==IR_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time0=millis();times1=millis();in_x=0;w=1;w2_arr();if(menu>3){menu=0;}}//меню 0
  if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time0=millis();times1=millis();in_x=0;w=1;w2_arr();if(menu<0){menu=3;}}//меню 0
 
  if(ir.value==IR_2&&menu0==1){menu1++;gr1=0;gr2=0;cl1();time0=millis();times1=millis();in_x=0;w=1;w2_arr();if(menu1>4){menu1=0;}}//меню 1
  if(ir.value==IR_1&&menu0==1){menu1--;gr1=0;gr2=0;cl1();time0=millis();times1=millis();in_x=0;w=1;w2_arr();if(menu1<0){menu1=4;}}//меню 1
    
  if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time0=millis();w=1;w2_arr();if(menu>2){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu1++;delay(200);time0=millis();w=1;if(menu1>4){menu1=0;}}// меню 1

  if((ir.value==IR_6||digitalRead(2)==LOW)&&menu0==0){menu0=1 ;cl();time0=millis();w=1;lcd.setCursor(6,1);lcd.print("SETTING"); delay(300);lcd.clear();}
  if((ir.value==IR_6||digitalRead(2)==LOW)&&menu0==1){menu0=0;menu=0;cl();w2_arr();time0=millis();w=1;lcd.setCursor(8,1);lcd.print("MENU"); delay(300);lcd.clear();}
  if(ir.value==IR_5||digitalRead(3)==LOW||inn==1){in++;if(in>4){in=0;}audio_in();cl1();lcd.setCursor(0,3);delay(500);time0=millis();w=1;inn=0;}// inIN
  }
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==0&&power==0){mute=1; pt.setVol(31); pt.setVol(31);menu0=100;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");delay(300);}// mute on
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==1&&power==0){mute=0;cl();time0=millis();w=1;w2_arr();menu0=0;myEnc.write(0);audio();}// mute off

   if((ir.value==IR_8||digitalRead(5)==LOW)&&power==0){power=1;save=1; pt.setVol(31); pt.setVol(31);cl();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);analogWrite(6, brig1*25);}// power off
  if((ir.value==IR_8||digitalRead(5)==LOW)&&power==1){power=0;analogWrite(6, brig0*25);lcd.clear();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);audio();delay(3000);cl();}// 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}; //>
   byte a5[8] = {0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000};
   lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);lcd.createChar(3,a4);lcd.createChar(4,a5);
  }
  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(0,3);lcd.print(date/10);lcd.print(date%10),lcd.print(".");lcd.print(mont/10);lcd.print(mont%10);lcd.print(".");lcd.print(year);lcd.print(" ");
  lcd.print(dn[wesk]);
  
  if(digitalRead(10)==LOW&&digitalRead(2)==LOW){korr++;if(korr>6){korr=0;}delay(100);} // SET
 
  if(digitalRead(10)==LOW&&digitalRead(3)==LOW&&korr==1){hour++;if(hour>23){hour=23;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);} // IN
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW&&korr==1){hour--;if(hour<0){hour=0;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}  // MUTE

  if(digitalRead(10)==LOW&&digitalRead(3)==LOW&&korr==2){minut++;if(minut>59){minut=59;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW&&korr==2){minut--;if(minut<0){minut=0;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  
  if(digitalRead(10)==LOW&&digitalRead(3)==LOW&&korr==3){secon=0;clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW&&korr==3){secon=0;clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}

  if(digitalRead(10)==LOW&&digitalRead(3)==LOW&&korr==4){date++;if(date>31){date=31;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW&&korr==4){date--;if(date<1){date=1;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}

  if(digitalRead(10)==LOW&&digitalRead(3)==LOW&&korr==5){mont++;if(mont>12){mont=12;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW&&korr==5){mont--;if(mont<1){mont=1;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}

  if(digitalRead(10)==LOW&&digitalRead(3)==LOW&&korr==6){year++;if(year>2050){year=2050;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW&&korr==6){year--;if(year<2022){year=2022;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  
  lcd.setCursor(0,2);
  switch(korr){
    case 0 : lcd.print("                ");lcd.print("    ");break;
    case 1 : lcd.print("Time correction ");lcd.print("HOUR");break;
    case 2 : lcd.print("Time correction ");lcd.print("MIN ");break;
    case 3 : lcd.print("Time correction ");lcd.print("SEC ");break;
    case 4 : lcd.print("Time correction ");lcd.print("DATE");break;
    case 5 : lcd.print("Time correction ");lcd.print("MON ");break;
    case 6 : lcd.print("Time correction ");lcd.print("YEAR");break;
    }
  } 

 /////////////////////////////// MENU0 = VOLUME TERBLE BASS BALANCE ///////////////////////////////////////////////////////////////////////
  if(menu0==0){
    switch(menu){
      case 0: temp0 = vol;q=0;break;
      case 1: temp0 = bass;q=1;break;
      case 2: temp0 = mid;q=1;break;
      case 3: temp0 = treb;q=2;break;}
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();;w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка <<<<<<   
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=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("VOL(");lcd.print(in+1);lcd.print(") ");if(vol>=0){lcd.print(" ");}lcd.print(vol);lcd.print("     ");lcd.print(year);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print("     ");lcd.print(date/10);lcd.print(date%10),lcd.print(".");lcd.print(mont/10);lcd.print(mont%10);
    lcd.setCursor(1,2);lcd.print("MIDLE  ");if(mid>=0){lcd.print(" ");}lcd.print(mid);lcd.print("  ");lcd.print(dn[wesk]); 
    lcd.setCursor(1,3);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print("  "); lcd.print(DateTime.hour/10);lcd.print(DateTime.hour%10);lcd.print(":");lcd.print(DateTime.minute/10);lcd.print(DateTime.minute%10);lcd.print(":");
    lcd.print(DateTime.second/10);lcd.print(DateTime.second%10);
  
   for(n=0;n<4;n++){if(w2[n]==1){
   switch(n){
    case 0: par = vol_d;break;
    case 1: par = bass_d;break;
    case 2: par = mid_d;break;
    case 3: par = treb_d;break;} 
   
 for(z=0,z0=0,z1=0;z<=par;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,n);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,n);Serial.println(z0);z_old=7-par/3;while(z_old>0){z_old=z_old-1;lcd.write((uint8_t)4);}}}
   if(z1==3){lcd.setCursor(z0+12,n);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,n);lcd.write((uint8_t)2);}w2[n]=0;}
   }}// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////

 if(menu0==1){
     switch(menu1){
      case 0: temp0 = attfl;break;
      case 1: temp0 = attfr;break;
      case 2: temp0 = ddd;break;
      case 3: temp0 = brig0;break;
      case 4: temp0 = brig1;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu1){
      case 0: attfl = temp0;attfl_func();break;
      case 1: attfr = temp0;attfr_func();break;
      case 2: ddd  = temp0;ddd_func();break;
      case 3: brig0  = temp0;brig0_func();break;
      case 4: brig1  = temp0;brig1_func();break;
      }
 
  au();analogWrite(6, brig0*25);
  for(i=0;i<5;i++){if(menu1==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("ATTFL ");lcd.print(attfl);lcd.print(" ");lcd.setCursor(12,0);lcd.print("ATTFR ");lcd.print(attfr);lcd.print(" ");
  lcd.setCursor(7,1);lcd.print("3D   ");if(ddd==0){lcd.print("ON ");}else{lcd.print("OFF");}
  lcd.setCursor(0,2);lcd.print("-------------------");
  lcd.setCursor(1,3);lcd.print("BRIG_1 ");lcd.print(brig0);lcd.print(" ");lcd.setCursor(12,3);lcd.print("BRIG_2 ");lcd.print(brig1);
  
 } // menu0 = 1


////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   

if(millis()-time0>10000&&w==1&&mute==0&&power==0){if(menu0==1){cl();}w=0;menu0=0;menu=0;w2_arr();}
if(millis()-times_in>3000&&w==1&&in_x==1&&mute==0&&power==0){cl();w=0;in_x=0;menu0=0;menu=0;w2_arr();}

if(save==1){save=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,brig0);EEPROM.update(15,brig1);}

             
}// loop

void brig1_func(){if(brig1>8){brig1=8;}if(brig1<0){brig1=0;}}
void brig0_func(){if(brig0>8){brig0=8;}if(brig0<0){brig0=0;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void au(){if(www==1){audio();www=0;}}
//void inn_func(){if(in>3){in=3;}if(in<0){in=0;}}
void ddd_func(){if(ddd<0){ddd=0;}if(ddd>1){ddd=1;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>3){gain0=3;}}
void attfr_func(){if(attfr<0){attfr=0;}if(attfr>14){attfr=14;}}
void attfl_func(){if(attfl<0){attfl=0;}if(attfl>14){attfl=14;}}
void treb_func(){if(treb<-7){treb=-7;}if(treb>7){treb=7;}}
void bass_func(){if(bass<-7){bass=-7;}if(bass>7){bass=7;}}
void mid_func(){if(mid<-7){mid=-7;}if(mid>7){mid=7;}}
void vol_func(){if(vol<-0){vol=-0;}if(vol>79){vol=79;}}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(200);}  
 void audio_in(){
  pt0.setInput(in); 
  pt0.setMute(0,0,0,0,0,0,0); 
  pt0.setFeature(1,1); 
}
 void audio(){
  
  pt.setFront_lk_att(abs(attfl));// att front L
  pt.setFront_rk_att(abs(attfr));// att front R
  pt.setCenter_att(abs(attcn));  // att center
  pt.setRear_lk_att(abs(atttl)); // att rear L
  pt.setRear_rk_att(abs(atttr)); // att rear R
  pt.setSub_att(abs(attsub));     // att sub
  pt.setFunc(mute,ddd,0); // mute,3d,тембр on/off
  pt.setBass(bass);            // BASS    -14...0...14 dB (int -7...0...7)
  pt.setMiddle(mid);          // MIDDLE  -14...0...14 dB (int -7...0...7)
  pt.setTreble(treb);          // TREBLE  -14...0...14 dB (int -7...0...7)
  pt.setVol(abs(vol)); // -79...0
  }

9

Re: pt2322 pt2323

привет брат помогите пожалуйста когда отключаю звук есть а когда включаю звука нет

#define IR_1 0x33B8A05F // Кнопка вверх
#define IR_2 0x33B8609F // Кнопка вниз
#define IR_3 0x33B810EF // Кнопка >
#define IR_4 0x33B8E01F // Кнопка <
#define IR_5 0x33B850AF // Кнопка IN
#define IR_6 0x33B844BB // Кнопка SET
#define IR_7 0x33B8946B // Кнопка MUTE
#define IR_8 0x33B800FF // Кнопка STANDBY (POWER)
 
#define BRIG_H 200      // Яркость 0...255 POWER ON
#define BRIG_L 50       // Яркость 0...255 POWER OFF
 
#include <PT2322.h>
#include <PT2323.h>            // http://rcl-radio.ru/wp-content/uploads/2019/07/TDA7719.zip
#include <Wire.h>
#include <LiquidCrystal_I2C.h>  // http://forum.rcl-radio.ru/misc.php?action=pan_download&item=45&download=1
#include <Encoder.h>            // http://rcl-radio.ru/wp-content/uploads/2019/05/Encoder.zip    
#include <EEPROM.h>
#include <MsTimer2.h>           // http://rcl-radio.ru/wp-content/uploads/2018/11/MsTimer2.zip       
#include <boarddefs.h>          // входит в состав библиотеки IRremote
#include <IRremote.h>           // http://rcl-radio.ru/wp-content/uploads/2019/06/IRremote.zip
#include <DS3231.h>             // http://rcl-radio.ru/wp-content/uploads/2022/10/DS3231.zip
 PT2322 pt; PT2323 pt0;
 DS3231 clock;RTCDateTime DateTime;
 LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
 IRrecv irrecv(11); // указываем вывод модуля IR приемника
 Encoder myEnc(9, 8);// DT, CLK
 decode_results ir; 
 int in,ddd,loun_f,vol_att,treb,treb_f,mid,mid_q,bass,bass_q,sub_f,faza=0,mid_f,bass_f;
 int vol,attfl,attfr,attcn,attsub,atttl,atttr;
 long time0,oldPosition  = -999,newPosition,times1;
 int menu0,menu,temp0,vol_d,bass_d,treb_d,par,z_old,z1,z0,z,menu1,in_time;
 byte q,gr1,gr2,w,w2[4],www,power,in_x,mute=1;
 int hour,minut,secon,mid_d,menu2,gain0,gain1,gain2,gain3,date,mont,year,korr;
 byte mesto2[8]={0,10,0,10,0,10,0,10};
 byte mesto3[8]={0,0,1,1,2,2,3,3};
 bool power_off=1;
 String dn[]={"   ","MON","TUE","WED","THU","FRI","SAT","SUN"};
 byte wesk,zast;
 
void setup() {
  irrecv.enableIRIn();lcd.init();lcd.backlight();clock.begin();Serial.begin(9600);
  pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT_PULLUP);   // КНОПКА SET
  pinMode(3,INPUT_PULLUP);   // КНОПКА IN
  pinMode(4,INPUT_PULLUP);   // КНОПКА MUTE
  pinMode(5,INPUT_PULLUP);   // КНОПКА STANDBY
  pinMode(7,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ STANDBY
  pinMode(6,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ ПОДСВЕТКОЙ
  pinMode(12,OUTPUT);  // ВЫХОД УПРАВЛЕНИЯ Bluetooth
  analogWrite(6, BRIG_H);// больше 200 не делать
  lcd.setCursor(3,1);lcd.print("Sound Processor");lcd.setCursor(7,2);lcd.print("TDA7719"); delay(2000);lcd.clear();
  MsTimer2::set(4, to_Timer);MsTimer2::start();
  // clock.setDateTime(__DATE__, __TIME__); // Устанавливаем время на часах, основываясь на времени компиляции скетча
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении  
  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(10);
  attfr = EEPROM.read(11)-14;atttl = EEPROM.read(12)-14;atttr = EEPROM.read(13)-14;
 // switch(in)
  {
    // case 0: gain0 = gain1;break;
    // case 1: gain0 = gain2;break;
    // case 2: gain0 = gain3;break;
     }
  w2_arr();audio();audio_in();cl();
}
 
void to_Timer(){newPosition = myEnc.read()/4;}
 
void loop() { 
 DateTime = clock.getDateTime();hour = DateTime.hour;minut = DateTime.minute;secon = DateTime.second;
 date = DateTime.day;mont = DateTime.month;year = DateTime.year;wesk = DateTime.dayOfWeek;

   /////////////////////////////// УПРАВЛЕНИЕ //////////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта  

  if((digitalRead(10)==LOW||digitalRead(2)==LOW||digitalRead(3)==LOW||digitalRead(4)==LOW||digitalRead(5)==LOW)&& zast==1){cl();w=0;times1=millis();zast=0;menu0=0;menu=0;menu1=0;menu2=0;in_x=0;w2_arr();} 
  if((ir.value==IR_1||ir.value==IR_2||ir.value==IR_3||ir.value==IR_4||ir.value==IR_5||ir.value==IR_6||ir.value==IR_7||ir.value==IR_8)&&zast==1){
  cl();w=0;times1=millis();zast=0;menu0=0;menu=0;menu1=0;menu2=0;in_x=0;w2_arr();} 
 
  if(power==0){
    if(mute==1){
  if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time0=millis();times1=millis();zast=0;in_x=0;w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu1++;delay(200);time0=millis();times1=millis();zast=0;in_x=0;w=1;if(menu1>7){menu1=0;}}// меню 1
  if(digitalRead(10)==LOW&&menu0==2){menu2++;delay(200);time0=millis();times1=millis();zast=0;in_x=0;w=1;if(menu2>5){menu2=0;}}// меню 2
 
  if(ir.value==IR_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time0=millis();times1=millis();zast=0;in_x=0;w=1;w2_arr();if(menu>3){menu=0;}}//меню 0
  if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time0=millis();times1=millis();zast=0;in_x=0;w=1;w2_arr();if(menu<0){menu=3;}}//меню 0
 
  if(ir.value==IR_2&&menu0==1){menu1++;gr1=0;gr2=0;cl1();time0=millis();times1=millis();zast=0;in_x=0;w=1;w2_arr();if(menu1>7){menu1=0;}}//меню 1
  if(ir.value==IR_1&&menu0==1){menu1--;gr1=0;gr2=0;cl1();time0=millis();times1=millis();zast=0;in_x=0;w=1;w2_arr();if(menu1<0){menu1=7;}}//меню 1
 
  if(ir.value==IR_2&&menu0==2){menu2++;gr1=0;gr2=0;cl1();time0=millis();times1=millis();zast=0;in_x=0;w=1;w2_arr();if(menu2>5){menu2=0;}}//меню 2
  if(ir.value==IR_1&&menu0==2){menu2--;gr1=0;gr2=0;cl1();time0=millis();times1=millis();zast=0;in_x=0;w=1;w2_arr();if(menu2<0){menu2=5;}}//меню 2
 
  if(ir.value==IR_6||digitalRead(2)==LOW){menu0++;if(menu0>2){menu0=0;}cl();in_x=0;w2_arr();time0=millis();times1=millis();zast=0;w=1;lcd.setCursor(5,1);
     lcd.print("SETTING_");lcd.print(menu0);delay(500);lcd.clear();} 
 
  if(ir.value==IR_5||digitalRead(3)==LOW){in++;cl();time0=millis();times1=millis();zast=0;in_x=1;w=1;www=1;menu0=100;menu=100;if(in>2){in=0;}}// IN   
    } // mute off
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==1&&power==0){zast=0;mute=0;in_x=0;mute=0;menu0=100;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");audio();delay(300);}// mute on
  if((ir.value==IR_7||digitalRead(4)==LOW)&&mute==0&&power==0){mute=1;cl();time0=millis();times1=millis();zast=0;w=1;w2_arr();menu0=0;menu=0;myEnc.write(0);audio();}// mute off
  }// power on
 
  if((ir.value==IR_8||digitalRead(5)==LOW||power_off==1)&&power==0){times1=millis();zast=0;power_off=0;power=1;in_x=0;mute=0;cl();audio();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);analogWrite(6,BRIG_L);}// power off
  if((ir.value==IR_8||digitalRead(5)==LOW)&&power==1){times1=millis();zast=0;power=0;analogWrite(6, BRIG_H);cl();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);mute=1;audio();delay(3000);cl();}// power on

if(power==0){digitalWrite(7,HIGH);if(in==2){digitalWrite(12,HIGH);}else{digitalWrite(12,LOW);}}
if(power==1){digitalWrite(7,LOW);digitalWrite(12,LOW);}
 
if(power==0&&zast==0){
   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}; //>
   byte a5[8] = {0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000};
   lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);lcd.createChar(3,a4);lcd.createChar(4,a5);
  }
  if(power==1||zast==1){
      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(int 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(0,3);lcd.print(date/10);lcd.print(date%10),lcd.print(".");lcd.print(mont/10);lcd.print(mont%10);lcd.print(".");lcd.print(year);lcd.print(" ");
  lcd.print(clock.readTemperature(),1);lcd.print((char)223);lcd.print(" ");
  lcd.print(dn[wesk]); 
  
  //lcd.setCursor(5,3);lcd.print("POWER  OFF");
  
  if(digitalRead(10)==LOW&&digitalRead(2)==LOW){korr++;if(korr>6){korr=0;}delay(100);} // SET
 
  if(digitalRead(10)==LOW&&digitalRead(3)==LOW&&korr==1){hour++;if(hour>23){hour=23;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);} // IN
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW&&korr==1){hour--;if(hour<0){hour=0;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}  // MUTE

  if(digitalRead(10)==LOW&&digitalRead(3)==LOW&&korr==2){minut++;if(minut>59){minut=59;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW&&korr==2){minut--;if(minut<0){minut=0;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  
  if(digitalRead(10)==LOW&&digitalRead(3)==LOW&&korr==3){secon=0;clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW&&korr==3){secon=0;clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}

  if(digitalRead(10)==LOW&&digitalRead(3)==LOW&&korr==4){date++;if(date>31){date=31;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW&&korr==4){date--;if(date<1){date=1;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}

  if(digitalRead(10)==LOW&&digitalRead(3)==LOW&&korr==5){mont++;if(mont>12){mont=12;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW&&korr==5){mont--;if(mont<1){mont=1;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}

  if(digitalRead(10)==LOW&&digitalRead(3)==LOW&&korr==6){year++;if(year>2050){year=2050;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  if(digitalRead(10)==LOW&&digitalRead(4)==LOW&&korr==6){year--;if(year<2022){year=2022;} clock.setDateTime(year, mont, date, hour, minut, secon);delay(100);}
  
  lcd.setCursor(0,2);
  switch(korr){
    case 0 : lcd.print("                ");lcd.print("    ");break;
    case 1 : lcd.print("Time correction ");lcd.print("HOUR");break;
    case 2 : lcd.print("Time correction ");lcd.print("MIN ");break;
    case 3 : lcd.print("Time correction ");lcd.print("SEC ");break;
    case 4 : lcd.print("Time correction ");lcd.print("DATE");break;
    case 5 : lcd.print("Time correction ");lcd.print("MON ");break;
    case 6 : lcd.print("Time correction ");lcd.print("YEAR");break;
    }
  } 
/////////////////////////////// MENU0 = VOLUME TERBLE BASS MIDDLE ///////////////////////////////////////////////////////////////////////
  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();time0=millis();times1=millis();zast=0;w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();times1=millis();zast=0;w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();times1=millis();zast=0;w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();times1=millis();zast=0;w=1;w2[q]=1;www=1;}// кнопка <<<<<<   
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>2){newPosition=2;}if(newPosition<-2){newPosition=-2;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();times1=millis();zast=0;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(int 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("VOL(");lcd.print(in+1);lcd.print(") ");if(vol>=0){lcd.print(" ");}lcd.print(-79+vol);lcd.print(" ");vol_d=map(vol,-63,0,1,24);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print(" ");bass_d=map(bass,-15,15,1,24);
   lcd.setCursor(1,2);lcd.print("MIDDLE ");if(mid>=0){lcd.print(" ");}lcd.print(mid);lcd.print(" ");mid_d=map(mid,-15,15,1,24);
   lcd.setCursor(1,3);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print(" ");treb_d=map(treb,-15,15,1,24);
 
 
   for(int n=0;n<4;n++){if(w2[n]==1){
   switch(n){
    case 0: par = vol_d;break;
    case 1: par = bass_d;break;
    case 2: par = mid_d;break;
    case 3: par = treb_d;break; 
    } 
 
   for(z=0,z0=0,z1=0;z<=par;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,n);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,n);Serial.println(z0);z_old=7-par/3;while(z_old>0){z_old=z_old-1;lcd.write((uint8_t)4);}}}
   if(z1==3){lcd.setCursor(z0+12,n);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,n);lcd.write((uint8_t)2);}w2[n]=0;}
   }}// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////////////////////
 if(menu0==1){
     switch(menu1){
      case 0: temp0 = atttl;break;
      case 1: temp0 = atttr;break;
      case 2: temp0 = attfl;break;
      case 3: temp0 = attfr;break;
      case 4: temp0 = attsub;break;
      case 5: temp0 = attcn;break;
      case 6: temp0 = ddd;break;
      case 7: temp0 = loun_f;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();times1=millis();zast=0;w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();times1=millis();zast=0;w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();times1=millis();zast=0;;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();times1=millis();zast=0;w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();times1=millis();zast=0;w=1;www=1;} 
 
     switch(menu1){
      case 0: atttl = temp0;atttl_func();break;
      case 1: atttr = temp0;atttr_func();break;
      case 2: attfl = temp0;attfl_func();break;
      case 3: attfr = temp0;attfr_func();break;      
      case 4: attsub  = temp0;attsub_func();break;
      case 5: attcn  = temp0;attcn_func();break;
      case 6: ddd  = temp0;ddd_func();break;
      case 7: loun_f  = temp0;loun_f_func();break;
      }
 
  au();
  for(int i=0;i<8;i++){if(menu1==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("ATTL ");lcd.print(atttl);lcd.print(" ");lcd.setCursor(11,0);lcd.print("ATTR ");lcd.print(atttr);lcd.print(" ");
  lcd.setCursor(1,1);lcd.print("AT_FL ");lcd.print(attfl);lcd.print(" ");lcd.setCursor(11,1);lcd.print("AT_FR ");lcd.print(attfr);lcd.print(" ");
  lcd.setCursor(1,2);lcd.print("ATSUB ");lcd.print(attsub);lcd.print(" ");lcd.setCursor(11,2);lcd.print("AT_CN ");lcd.print(attcn);lcd.print(" ");
  lcd.setCursor(1,3);lcd.print("3D    ");lcd.print(abs(ddd));lcd.print(" ");lcd.setCursor(11,3);
  switch(loun_f){
    case 0: lcd.print("FLAT   ");break;
    case 1: lcd.print("400  Hz");break;
    case 2: lcd.print("800  Hz");break;
    case 3: lcd.print("2.4 kHz");break;}
 
 } // menu0 = 1
 
 
///////////////////////////////////////////////////////////////////////////////////////////////
 
 if(menu0==2){
     switch(menu2){
      case 0: temp0 = bass_f;break;
      case 1: temp0 = mid_f;break;
      case 2: temp0 = treb_f;break;
      case 3: temp0 = sub_f;break;
      case 4: temp0 = bass_q;break;
      case 5: temp0 = mid_q;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();times1=millis();zast=0;w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();times1=millis();zast=0;w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();times1=millis();zast=0;;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();times1=millis();zast=0;w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();times1=millis();zast=0;w=1;www=1;} 
 
     switch(menu2){
//      case 0: bass_f = temp0;bass_f_func();break;
     // case 1: mid_f = temp0;mid_f_func();break;
     // case 2: treb_f = temp0;treb_f_func();break;
     // case 3: sub_f = temp0;sub_f_func();break;      
    //  case 4: bass_q  = temp0;bass_q_func();break;
    //  case 5: mid_q  = temp0;mid_q_func();break;
      }
 
  au();
  for(int i=0;i<6;i++){if(menu2==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("BF ");
    switch(bass_f){
    case 0: lcd.print(" 60 Hz");break;
    case 1: lcd.print(" 80 Hz");break;
    case 2: lcd.print("100 Hz");break;
    case 3: lcd.print("200 Hz");break;}
  lcd.setCursor(11,0);lcd.print("MF ");
    switch(mid_f){
      case 0: lcd.print("0.5kHz");break;
      case 1: lcd.print("1.0kHz");break;
      case 2: lcd.print("1.5kHz");break;
      case 3: lcd.print("2.5kHz");break;}
 
  lcd.setCursor(1,1);lcd.print("TF");
    switch(treb_f){
      case 0: lcd.print("10.0kHz");break;
      case 1: lcd.print("12.5kHz");break;
      case 2: lcd.print("15.0kHz");break;
      case 3: lcd.print("17.5kHz");break;}
 
  lcd.setCursor(11,1);lcd.print("SF ");
    switch(sub_f){
      case 0: lcd.print("FLAT  ");break;
      case 1: lcd.print("400 Hz");break;
      case 2: lcd.print("800 Hz");break;
      case 3: lcd.print("2.4kHz");break;}
 
  lcd.setCursor(1,2);lcd.print("BQ ");
    switch(bass_q){
      case 0: lcd.print("1.0 ");break;
      case 1: lcd.print("1.25");break;
      case 2: lcd.print("1.5 ");break;
      case 3: lcd.print("2.0 ");break;}
 
  lcd.setCursor(11,2);lcd.print("MQ ");
    switch(mid_q){
      case 0: lcd.print("0.5 ");break;
      case 1: lcd.print("0.75");break;
      case 2: lcd.print("1.0 ");break;
      case 3: lcd.print("1.25");break;}
 
 } // menu0 = 2 
 
 
////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
   switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     }
 
     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();time0=millis();times1=millis();zast=0;www=1;w=1;gain_func();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();time0=millis();times1=millis();zast=0;www=1;w=1;gain_func();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();time0=millis();times1=millis();zast=0;www=1;w=1;gain_func();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();time0=millis();times1=millis();zast=0;www=1;w=1;gain_func();}// кнопка <<<<<<  
 
    if (newPosition != oldPosition) {oldPosition = newPosition;if(newPosition>1){newPosition=1;}if(newPosition<-1){newPosition=-1;}
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time0=millis();times1=millis();zast=0;www=1;w=1;gain_func();} 
 
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     }
 
  au();
  lcd.setCursor(7,1);lcd.print("INPUT ");lcd.print(in+1);lcd.setCursor(5,2);lcd.print("GAIN ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(14,2);lcd.print("dB ");
   }
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){in_time=3000;}else{in_time=10000;}
if(millis()-time0>in_time&&w==1&&mute==1&&power==0&&zast==0){if(menu0==1){cl();}w=0;if(menu0!=0){cl();}menu0=0;menu=0;menu1=0;menu2=0;in_x=0;w2_arr();
    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(11,attfr+14);EEPROM.update(12,atttl+14);EEPROM.update(13,atttr+14);
   }
if(millis()-times1>60000&&zast==0&&mute==1){zast=1;menu0=100;}   
if(w==1&&zast==1){cl2();w=0;times1=millis();zast=0;menu0=0;menu=0;menu1=0;menu2=0;in_x=0;w2_arr();}  

}
 
 
void gain_func(){if(gain0<-15){gain0=-15;}if(gain0>15){gain0=15;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void loun_f_func(){if(loun_f>3){loun_f=3;}if(loun_f<0){loun_f=0;}}
void ddd_func(){if(ddd<0){ddd=0;}if(ddd>1){ddd=1;}}
void atttl_func(){if(atttl>14){atttl=14;}if(atttl<0){atttl=0;}}
void atttr_func(){if(atttr>14){atttr=14;}if(atttr<0){atttr=0;}}
void attfl_func(){if(attfl>14){attfl=14;}if(attfl<0){attfl=0;}}
void attfr_func(){if(attfr>14){attfr=14;}if(attfr<0){attfr=0;}}
void attsub_func(){if(attsub>14){attsub=14;}if(attsub<0){attsub=0;}}
void attcn_func(){if(attcn>14){attcn=14;}if(attcn<0){attcn=0;}}
void vol_func(){if(vol<0){vol=0;}if(vol>79){vol=79;}}
void treb_func(){if(treb<-15){treb=-15;}if(treb>15){treb=15;}}
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 cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(50);}  
void cl2(){ir.value=0;lcd.clear();}  
void au(){if(www==1){audio();www=0;}}
//void bass_f_func(){if(bass_f>3){bass_f=3;}if(bass_f<0){bass_f=0;}}
//void mid_f_func(){if(mid_f>3){mid_f=3;}if(mid_f<0){mid_f=0;}}
//void treb_f_func(){if(treb_f>3){treb_f=3;}if(treb_f<0){treb_f=0;}}
//void sub_f_func(){if(sub_f>3){sub_f=3;}if(sub_f<0){sub_f=0;}}
//void bass_q_func(){if(bass_q>3){bass_q=3;}if(bass_q<0){bass_q=0;}}
//void mid_q_func(){if(mid_q>3){mid_q=3;}if(mid_q<0){mid_q=0;}}
 
 void audio_in(){
  pt0.setInput(in); 
  pt0.setMute(0,0,0,0,0,0,0); 
  pt0.setFeature(1,1); 
}
 void audio(){
  pt.setFront_lk_att(abs(attfl));// att front L
  pt.setFront_rk_att(abs(attfr));// att front R
  pt.setCenter_att(abs(attcn));  // att center
  pt.setRear_lk_att(abs(atttl)); // att rear L
  pt.setRear_rk_att(abs(atttr)); // att rear R
  pt.setSub_att(abs(attsub));     // att sub
  pt.setFunc(mute,ddd,0); // mute,3d,тембр on/off
  pt.setBass(bass);            // BASS    -14...0...14 dB (int -7...0...7)
  pt.setMiddle(mid);          // MIDDLE  -14...0...14 dB (int -7...0...7)
  pt.setTreble(treb);          // TREBLE  -14...0...14 dB (int -7...0...7)
  pt.setVol(abs(vol)); // -79...0
}