1

Тема: LC75342

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

LC75342.h

// liman324@yandex.ru rcl-radio.ru
// 15.01.2022

#ifndef LC75342_H
#define LC75342_H

#include <Arduino.h>
class LC75342
{
  public:
    LC75342(uint8_t ce, uint8_t di, uint8_t cl);

    void addr();
    void set_input(byte in);
    // input 1...4 = byte 0...3 (byte 4...7 = All switches off)
    void set_gain(byte gain); 
    // gain 0...30 dB step 2 dB = byte 0...15
    void set_volume(byte vol);
    // volume 0...-79 dB = byte 0...79
    void set_treble(int treb);
    // treble 10...-10 dB step 2 dB = int 5...-5 
    void set_bass(int bass);
    // bass 20...-20 dB step 2 dB = int 10...-10 
    void set_ch(byte ch);
    // Channel Selection RCH = byte 2, LCH = byte 1, Left and right together = byte 3
    void test();
    	
  private:
        uint8_t CE;
        uint8_t DI;
        uint8_t CL;
};
	
#endif //LC75342_H

LC75342.cpp

#include <Arduino.h>
#include "LC75342.h"

LC75342::LC75342(uint8_t ce, uint8_t di, uint8_t cl){
	CE = ce;
        DI = di;
        CL = cl;
        pinMode(CE,OUTPUT);
        pinMode(DI,OUTPUT);
        pinMode(CL,OUTPUT);
        digitalWrite(CL,LOW);
        digitalWrite(CE,LOW);
        digitalWrite(DI,LOW);
}

void LC75342::addr(){
       digitalWrite(CL,LOW);
       digitalWrite(CE,LOW);
       byte addr = 0b01000001; // 0x82
    for(int i = 7; i >= 0; i--){
       digitalWrite(CL,LOW);
       digitalWrite(DI, (addr >> i) & 0x01);
       digitalWrite(CL,HIGH);
       }  
       digitalWrite(CE,HIGH); 
}

void LC75342::set_input(byte in){
    for(int i = 0; i <= 3; i++){
       digitalWrite(CL,LOW);
    switch(i){
       case 0: digitalWrite(DI, (in & 0b0001)>>0);break;
       case 1: digitalWrite(DI, (in & 0b0010)>>1);break;
       case 2: digitalWrite(DI, (in & 0b0100)>>2);break;
       case 3: digitalWrite(DI, (in & 0b1000)>>3);break;
} 
       digitalWrite(CL,HIGH);
       }
}

void LC75342::set_gain(byte gain){
    for(int i = 0; i <= 3; i++){
       digitalWrite(CL,LOW);
    switch(i){
       case 0: digitalWrite(DI, (gain & 0b0001)>>0);break;
       case 1: digitalWrite(DI, (gain & 0b0010)>>1);break;
       case 2: digitalWrite(DI, (gain & 0b0100)>>2);break;
       case 3: digitalWrite(DI, (gain & 0b1000)>>3);break;
} 
       digitalWrite(CL,HIGH);
       }
}

void LC75342::set_volume(byte vol){
    for(int i = 0; i <= 7; i++){
       digitalWrite(CL,LOW);
    switch(i){
       case 0: digitalWrite(DI, (vol & 0b00000001)>>0);break;
       case 1: digitalWrite(DI, (vol & 0b00000010)>>1);break;
       case 2: digitalWrite(DI, (vol & 0b00000100)>>2);break;
       case 3: digitalWrite(DI, (vol & 0b00001000)>>3);break;
       case 4: digitalWrite(DI, (vol & 0b00010000)>>4);break;
       case 5: digitalWrite(DI, (vol & 0b00100000)>>5);break;
       case 6: digitalWrite(DI, (vol & 0b01000000)>>6);break;
       case 7: digitalWrite(DI, (vol & 0b10000000)>>7);break;
} 
       digitalWrite(CL,HIGH);
       }
}

void LC75342::set_treble(int treb){
      switch(treb){
        case 5:  treb = 0b1010;break;//10dB
        case 4:  treb = 0b0010;break;//8dB
        case 3:  treb = 0b1100;break;//6dB
        case 2:  treb = 0b0100;break;//4dB
        case 1:  treb = 0b1000;break;//2dB
        case 0:  treb = 0b0000;break;//0dB
        case -1: treb = 0b1001;break;//-2dB
        case -2: treb = 0b0101;break;//-4dB
        case -3: treb = 0b1101;break;//-6dB
        case -4: treb = 0b0011;break;//-8dB
        case -5: treb = 0b1011;break;//10dB
        }
      for(int i = 3; i >= 0; i--){
        digitalWrite(CL,LOW);
        digitalWrite(DI, (treb >> i) & 0x01);
        digitalWrite(CL,HIGH);
        }
}

void LC75342::set_bass(int bass){
      switch(bass){
        case 10:  bass = 0b010100;break;//20dB
        case 9 :  bass = 0b100100;break;//18dB
        case 8 :  bass = 0b000100;break;//16dB
        case 7 :  bass = 0b111000;break;//14dB
        case 6 :  bass = 0b011000;break;//12dB
        case 5 :  bass = 0b101000;break;//10dB   
        case 4 :  bass = 0b001000;break;//8dB  
        case 3 :  bass = 0b110000;break;//6dB 
        case 2 :  bass = 0b010000;break;//4dB  
        case 1 :  bass = 0b101000;break;//2dB
        case 0 :  bass = 0b000000;break;//0dB
        case -1:  bass = 0b100010;break;//-2dB
        case -2:  bass = 0b010010;break;//-4dB
        case -3:  bass = 0b110010;break;//-6dB
        case -4:  bass = 0b001010;break;//-8dB
        case -5:  bass = 0b101010;break;//-10dB
        case -6:  bass = 0b011010;break;//-12dB
        case -7:  bass = 0b111010;break;//-14dB
        case -8:  bass = 0b000110;break;//-16dB
        case -9:  bass = 0b100110;break;//-18dB
        case -10: bass = 0b010110;break;//-20dB
        }
      for(int i = 5; i >= 0; i--){
        digitalWrite(CL,LOW);
        digitalWrite(DI, (bass >> i) & 0x01);
        digitalWrite(CL,HIGH);
        }
}

void LC75342::set_ch(byte ch){
      switch(ch){
        case 1: ch = 0b01;break;
        case 2: ch = 0b10;break;
        case 3: ch = 0b11;break;
      }
      for(int i = 1; i >= 0; i--){
        digitalWrite(CL,LOW);
        digitalWrite(DI, (ch >> i) & 0x01);
        digitalWrite(CL,HIGH);
        }
}

void LC75342::test(){
      byte test = 0;
      for(int i = 3; i >= 0; i--){
        digitalWrite(CL,LOW);
        digitalWrite(DI, (test >> i) & 0x01);
        digitalWrite(CL,HIGH);
        }
      digitalWrite(CL,LOW);
      digitalWrite(CE,LOW); 
}

test.ino

#include <LC75342.h>

LC75342 lc(2,3,4);   // CE,DI,CL

void setup(){
  audio();
  }

void loop(){}

void audio(){
  lc.addr();
  lc.set_input(0);   // input 1...4 = byte 0...3 (byte 4...7 = All switches off)
  lc.set_gain(0);    // gain 0...30 dB step 2 dB = byte 0...15
  lc.set_volume(0);  // volume 0...-79 dB = byte 0...79
  lc.set_treble(0);  // treble 10...-10 dB step 2 dB = int 5...-5 
  lc.set_bass(0);    // bass 20...-20 dB step 2 dB = int 10...-10
  lc.set_ch(3);      // Channel Selection RCH = byte 2, LCH = byte 1, Left and right together = byte 3 
  lc.test();
  }

Скетч использует 1214 байт (3%) памяти устройства. Всего доступно 32256 байт.
Глобальные переменные используют 12 байт (0%) динамической памяти, оставляя 2036 байт для локальных переменных. Максимум: 2048 байт.

2

Re: LC75342

Добрый вечер, а как добавить сюда стенд бай? Помогите пожалуйста
Всех с новым годом

3

Re: LC75342

С st-by разобрался, а теперь у меня другой вопрос.. например когда включен вход 2 чтоб на каком-то из выводов поднимался лог уровень чтоб включилось реле и подало питание для блютуз модуля, как можно это реализовать?

4

Re: LC75342

Пример кода:

void setup(){
pinMode(2,OUTPUT);
}

void loop(){
if(in==1){digitalWrite(2,HIGH);}else{digitalWrite(2,LOW);}

}

5

Re: LC75342

#define IR2    0x4BB6E916  // button encoder
#define IR3    0x4BB6A05F // mute
#define IR4    0x4BB6A15E // >>>
#define IR5    0x4BB621DE // <<<
#define IR6    0x20DFD02F // INPUT
#define POWER  0x4B36D32C // STANDBY
#define BRIG_L 20
#define BRIG_H 250

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

LC75342 lc(3,4,2);   // CE,DI,CL 
LiquidCrystal_I2C lcd(0x27,16,2);  // Устанавливаем дисплей
Encoder myEnc(9, 8);// DT, CLK
IRrecv irrecv(12); // указываем вывод модуля IR приемника
decode_results ir; 

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;
byte a[6],d1,d2,d3,d4,d5,d6,e1,e2,e3,w,w2,x,gr1,gr2,www;
int menu,vol_reg,in_reg,mute_reg,treb_reg,menu0=100,treb_print,bass_reg,bass_print,gain0_print;
int chl,chr,i,gain0,gain1,gain2,gain3,gain4,gain5,ball,fun,vol_old;
bool power;



void setup(){
  irrecv.enableIRIn();lcd.init();lcd.backlight();Wire.begin();
  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(11,INPUT_PULLUP); // input button
  pinMode(7,INPUT_PULLUP);  // mute button
  pinMode(A0,INPUT_PULLUP); // POWER
  pinMode(6,OUTPUT);        // PWM output
  pinMode(13,OUTPUT);       // OUTPUT STANDBY
  pinMode(5,OUTPUT);        // OUTPUT ВТ
  analogWrite(6,BRIG_H);    
  delay(100);
  vol_reg = EEPROM.read(0);treb_reg = EEPROM.read(1)-5;bass_reg = EEPROM.read(2);gain1 = EEPROM.read(4);
  gain2 = EEPROM.read(5);gain3 = EEPROM.read(6);gain4 = EEPROM.read(7);gain5 = EEPROM.read(8);
  in_reg = EEPROM.read(9);ball = EEPROM.read(10)-4;
  switch(in_reg){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     case 3: gain0 = gain4;break;
     }
  audio_L();
  audio_R();
  }

void loop(){
/// IR ////////////////////////////////////////
   if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();times=millis();w=1;w2=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
   if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта  
   if(in==1){digitalWrite(5,HIGH);}
   else{digitalWrite(5,LOW);}
/// BUTTON ///////////////////////////////////
  if(power==0){
   if(mute_reg==0){   
     if(digitalRead(10)==LOW||ir.value==IR2){menu++;gr1=0;gr2=0;cl();times=millis();w=1;w2=1;if(menu>3){menu=0;}}
     if((digitalRead(11)==LOW||ir.value==IR6)){in_reg++;menu=4;cl();times=millis();w=1;w2=1;www=1;if(in_reg>3){in_reg=0;}}
     }
     if((digitalRead(7)==LOW||ir.value==IR3)&&mute_reg==0){mute_reg=1;menu=100;cl();vol_old=vol_reg;vol_reg=79;audio_R();audio_L();lcd.setCursor(6,0);lcd.print("MUTE");}
     if((digitalRead(7)==LOW||ir.value==IR3)&&mute_reg==1){mute_reg=0;menu=0;cl();vol_reg=vol_old;audio_R();audio_L();}
     }
 /// power ///
 if((digitalRead(A0)==LOW||ir.value==POWER)&&power==0){power=1;menu=100;analogWrite(6,BRIG_L);cl();myEnc.write(0);vol_old=vol_reg;vol_reg=79;
  lcd.setCursor(4,0);lcd.print("POWER OFF");audio_R();audio_L();delay(2000);cl();}
 if((digitalRead(A0)==LOW||ir.value==POWER)&&power==1&&digitalRead(10)==HIGH){power=0;menu=0;analogWrite(6,BRIG_H);cl();myEnc.write(0);vol_reg=vol_old;
  lcd.setCursor(4,0);lcd.print("POWER  ON");audio_R();audio_L();delay(2000);cl();}    
   // standby output
   if(power==0){digitalWrite(13,HIGH);}else{digitalWrite(13,LOW);}
////////////// VOLUME ///////////////////////////////////////////////////////////////////
 if(menu==0){
   if(ir.value==IR5){vol_reg++;gr1=1;gr2=0;cl1();times=millis();w=1;w2=1;vol_func();audio_R();audio_L();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){vol_reg++;gr2=0;cl1();times=millis();w=1;w2=1;vol_func();audio_R();audio_L();}// кнопка >>>>>>
   if(ir.value==IR4){vol_reg--;gr1=0;gr2=1;cl1();times=millis();w=1;w2=1;vol_func();audio_R();audio_L();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){vol_reg--;gr1=0;cl1();times=millis();w=1;w2=1;vol_func();audio_R();audio_L();}// кнопка <<<<<<
 
   if (newPosition != oldPosition){oldPosition = newPosition;vol_reg=vol_reg+newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;vol_func();audio_R();audio_L();}
   a[0]= (79-vol_reg)/10;a[1]=(79-vol_reg)%10;
   for(x=0;x<2;x++){switch(x){case 0: e1=10,e2=11,e3=12;break;case 1: e1=13,e2=14,e3=15;break;}digit();}
   if(mute_reg==0){lcd.setCursor(0,0);lcd.print("VOLUME");}else{lcd.setCursor(0,0);lcd.print("MUTE");}
   lcd.setCursor(7,0);lcd.print("IN");lcd.print(in_reg+1);
  }
////////////// TREBLE ///////////////////////////////////////////////////////////////////
 if(menu==1){
   if(ir.value==IR4){treb_reg++;gr1=1;gr2=0;cl1();delay(200);times=millis();w=1;w2=1;treb_func();audio_R();audio_L();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){treb_reg++;gr2=0;cl1();delay(200);times=millis();w=1;w2=1;treb_func();audio_R();audio_L();}// кнопка >>>>>>
   if(ir.value==IR5){treb_reg--;gr1=0;gr2=1;cl1();delay(200);times=millis();w=1;w2=1;treb_func();audio_R();audio_L();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){treb_reg--;gr1=0;cl1();delay(200);times=millis();w=1;w2=1;treb_func();audio_R();audio_L();}// кнопка <<<<<<
 
   if (newPosition != oldPosition){oldPosition = newPosition;treb_reg=treb_reg-newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;treb_func();
   audio_R();audio_L();}
   if(treb_reg<0){treb_print = abs(treb_reg)*2;lcd.setCursor(7,0);lcd.write((uint8_t)3);}else{treb_print = treb_reg*2;lcd.setCursor(7,0);lcd.print(" ");}
   a[0]= treb_print/10;a[1]=treb_print%10;
   for(x=0;x<2;x++){switch(x){case 0: e1=8,e2=9,e3=10;break;case 1: e1=11,e2=12,e3=13;break;}digit();}
   lcd.setCursor(0,0);lcd.print("TREBLE");lcd.setCursor(0,1);lcd.print("CONTROL");lcd.setCursor(14,0);lcd.print("dB");
   } 
////////////// BASS ///////////////////////////////////////////////////////////////////
 if(menu==2){
   if(ir.value==IR4){bass_reg++;gr1=1;gr2=0;cl1();delay(200);times=millis();w=1;w2=1;bass_func();audio_R();audio_L();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){bass_reg++;gr2=0;cl1();delay(200);times=millis();w=1;w2=1;bass_func();audio_R();audio_L();}// кнопка >>>>>>
   if(ir.value==IR5){bass_reg--;gr1=0;gr2=1;cl1();delay(200);times=millis();w=1;w2=1;bass_func();audio_R();audio_L();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){bass_reg--;gr1=0;cl1();delay(200);times=millis();w=1;w2=1;bass_func();audio_R();audio_L();}// кнопка <<<<<<
 
   if (newPosition != oldPosition){oldPosition = newPosition;bass_reg=bass_reg-newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;bass_func();
   audio_R();audio_L();}
   bass_print = abs(bass_reg)*2;
   a[0]= bass_print/10;a[1]=bass_print%10;
   for(x=0;x<2;x++){switch(x){case 0: e1=8,e2=9,e3=10;break;case 1: e1=11,e2=12,e3=13;break;}digit();}
   lcd.setCursor(0,0);lcd.print("BASS");lcd.setCursor(0,1);lcd.print("CONTROL");lcd.setCursor(14,0);lcd.print("dB");
   }    

//////// BALANCE /////////////////////////////////////////////////////////////// 
 if(menu==3){ 
   if(ir.value==IR4){ball++;gr1=1;gr2=0;cl1();times=millis();w=1;w2=1;ball_fun();audio_R();audio_L();}// кнопка > 
   if(ir.value==IR5){ball--;gr1=0;gr2=1;cl1();times=millis();w=1;w2=1;ball_fun();audio_R();audio_L();}// кнопка <
 
   if (newPosition != oldPosition){oldPosition = newPosition;
   ball=ball-newPosition;myEnc.write(0);newPosition=0;times=millis();w=1;w2=1;ball_fun();audio_R();audio_L();}
   lcd.setCursor(4,0);lcd.print(F("   <>   "));lcd.setCursor(4,1);lcd.print(F("CHL  CHR"));
   chl=(4+ball)-4;chr=(4-ball)-4;
   if(chl<0){lcd.setCursor(12,0);chl=abs(chl);lcd.write((uint8_t)3);}else{lcd.setCursor(12,0);lcd.print(" ");}
   if(chr<0){lcd.setCursor(0,0);chr=abs(chr);lcd.write((uint8_t)3);}else{lcd.setCursor(0,0);lcd.print(" ");}
   if(w2==1){w2=0;a[0]=chl;a[1]=chr;
   for(i=0;i<2;i++){
      switch(i){
        case 0: e1=1,e2=2,e3=3;break;
        case 1: e1=13,e2=14,e3=15;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);
 }}}  
 ////////////// INPUT GAIN ///////////////////////////////////////////////////////////////////
 if(menu==4){
  switch(in_reg){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     case 3: gain0 = gain4;break;
     }
   if(ir.value==IR4){gain0++;gr1=1;gr2=0;cl1();times=millis();w=1;w2=1;gain_func();audio_R();audio_L();}// кнопка > 
   if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();times=millis();w=1;w2=1;gain_func();audio_R();audio_L();}// кнопка >>>>>>
   if(ir.value==IR5){gain0--;gr1=0;gr2=1;cl1();times=millis();w=1;w2=1;gain_func();audio_R();audio_L();}// кнопка <
   if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();times=millis();w=1;w2=1;gain_func();audio_R();audio_L();}// кнопка <<<<<<
 
  if (newPosition != oldPosition){oldPosition = newPosition;gain0=gain0-newPosition;myEnc.write(0);newPosition=0;times=millis();www=1;w=1;w2=1;gain_func();}
  switch(in_reg){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     case 3: gain4 = gain0;break;
     }  
   gain0_print = gain0*2;
   a[0]= gain0_print/10;a[1]=gain0_print%10;
   for(x=0;x<2;x++){switch(x){case 0: e1=8,e2=9,e3=10;break;case 1: e1=11,e2=12,e3=13;break;}digit();}
   if(www==1){audio_R();audio_L();www=0;}
   lcd.setCursor(0,0);lcd.print("IN GAIN");lcd.setCursor(14,0);lcd.print("dB");
   lcd.setCursor(0,1);lcd.print("INPUT ");lcd.print(in_reg+1);}    
 
////////////////////////////////////////////////////////////////////////////////////////////   
////////////////// EEPROM //////////////////////////////////////////////////////////////
 if(millis()-times>10000 && w==1 && mute_reg==0 && power==0){
     EEPROM.update(0,vol_reg);EEPROM.update(1,treb_reg+5);EEPROM.update(2,bass_reg);EEPROM.update(4,gain1);
     EEPROM.update(5,gain2);EEPROM.update(6,gain3);EEPROM.update(7,gain4);EEPROM.update(8,gain5);
     EEPROM.update(9,in_reg);EEPROM.update(10,ball+4);
     if(menu!=0){lcd.clear();menu=0;}w=0;}                     
} // loop end


void gain_func(){{if(gain0<0){gain0=0;}if(gain0>15){gain0=15;}}}
void ball_fun(){if(ball>4){ball=4;}if(ball<-4){ball=-4;}}
void bass_func(){if(bass_reg<0){bass_reg=0;}if(bass_reg>10){bass_reg=10;}}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(300);}
void treb_func(){if(treb_reg<-5){treb_reg=-5;}if(treb_reg>5){treb_reg=5;}}
void vol_func(){if(vol_reg<4){vol_reg=4;}if(vol_reg>79){vol_reg=79;}}
void to_Timer(){newPosition = myEnc.read()/4;} 

void audio_L(){
  lc.addr();
  lc.set_input(in_reg);   // input 1...4 = byte 0...3 (byte 4...7 = All switches off)
  lc.set_gain(gain0);    // gain 0...30 dB step 2 dB = byte 0...15
  lc.set_volume(vol_reg-ball);  // volume 0...-79 dB = byte 0...79
  lc.set_treble(treb_reg);  // treble -10...10 dB step 2 dB = int -5...5 
  lc.set_bass(bass_reg);    // bass 0...20 dB step 2 dB = int 0...10
  lc.set_ch(1);      // Channel Selection RCH = byte 2, LCH = byte 1, Left and right together = byte 3 
  lc.test();
  }

void audio_R(){
  lc.addr();
  lc.set_input(in_reg);   // input 1...4 = byte 0...3 (byte 4...7 = All switches off)
  lc.set_gain(gain0);    // gain 0...30 dB step 2 dB = byte 0...15
  lc.set_volume(vol_reg+ball);  // volume 0...-79 dB = byte 0...79
  lc.set_treble(treb_reg);  // treble -10...10 dB step 2 dB = int -5...5 
  lc.set_bass(bass_reg);    // bass 0...20 dB step 2 dB = int 0...10
  lc.set_ch(2);      // Channel Selection RCH = byte 2, LCH = byte 1, Left and right together = byte 3 
  lc.test();
  }  

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);}

6

Re: LC75342

чтото не выходит(

7

Re: LC75342

Уточните.