1

Тема: LC75421M

Данный контент доступен только зарегистрированным пользователям.
http://forum.rcl-radio.ru/uploads/images/2019/09/5b224c973ef47828e83db4eb5f0bb92a.png
http://forum.rcl-radio.ru/uploads/images/2019/09/e2d1d5406ccf1deafa9c98474c23e5be.png

///////////////////////// LC75421M D0...D43 ///////////////////////////
//// liman324@yandex.ru //// Alexander Liman //// rcl-radio.ru ////////
const byte CE = 10;
const byte DI = 11;
const byte CL = 12;
byte add[8]={1,0,0,0,0,0,0,1};// byte address 0b10000001
byte fader[16][4] = {{0,0,0,0},{1,0,0,0},{0,1,0,0},{1,1,0,0},{0,0,1,0},{1,0,1,0},{0,1,1,0},{1,1,1,0},{0,0,0,1},{1,0,0,1},{0,1,0,1},{1,1,0,1},{0,0,1,1},{1,0,1,1},{0,1,1,1},{1,1,1,1}};  
byte s_bass[11][4]= {{0,0,0,0},{1,0,0,0},{0,1,0,0},{1,1,0,0},{0,0,1,0},{1,0,1,0},{0,1,1,0},{1,1,1,0},{0,0,0,1},{1,0,0,1},{0,1,0,1}};
byte bass_con[15][4]={{1,1,1,0},{0,1,1,0},{1,0,1,0},{0,0,1,0},{1,1,0,0},{0,1,0,0},{1,0,0,0},{0,0,0,0},{1,0,0,1},{0,1,0,1},{1,1,0,1},{0,0,1,1},{1,0,1,1},{0,1,1,1},{1,1,1,1}};
byte treb_con[15][4]={{1,1,1,0},{0,1,1,0},{1,0,1,0},{0,0,1,0},{1,1,0,0},{0,1,0,0},{1,0,0,0},{0,0,0,0},{1,0,0,1},{0,1,0,1},{1,1,0,1},{0,0,1,1},{1,0,1,1},{0,1,1,1},{1,1,1,1}};
byte vol_con[80][8]={{0,0,1,0,0,1,0,1},{1,1,0,0,0,1,0,1},{0,0,1,0,0,0,0,1},{1,1,0,0,0,0,0,1},{0,1,0,0,0,0,0,1},{1,0,0,0,0,0,0,1},{0,0,1,1,1,1,1,0},{1,1,0,1,1,1,1,0},{0,1,0,1,1,1,1,0},
{1,0,0,1,1,1,1,0},{0,0,1,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0},{1,0,1,0},{0,1,1,0},{1,1,1,0},{0,0,0,1},{1,0,0,1},{0,1,0,1},{1,1,0,1},{0,0,1,1},{1,0,1,1},{0,1,1,1},{1,1,1,1}};
byte channel[4][2] = {{0,0},{1,0},{0,1},{1,1}};

void setup() { Serial.begin(9600);
  pinMode(CE,OUTPUT);//CE
  pinMode(DI,OUTPUT);//DI
  pinMode(CL,OUTPUT);//CL
  digitalWrite(CE,LOW); digitalWrite(DI,LOW); digitalWrite(CL,LOW);delay(500);
}

void loop() {
  audio(15,0,7,7,0,0,0,1,0,0);  // fader_step byte 0...15 === -80...0 dB ---- 4 bit
                                // super bass byte 0...10 === step0...step10(max) --- 4 bit
                                // bass byte 0...15 === step15...step0 --- 4 bit
                                // trerle byte 0...15 === step15...step0 --- 4 bit
                                // vol byte 0...80 === 0...-80 dB --- 8 bit
                                // in_gain byte 0...15 === 0...18.75 dB --- 4 bit
                                // in byte 0...4 === in1...in5 --- 3 bit
                                // r/f byte 0...1 === rear...front --- 1 bit
                                // channel
                                // mute
}// loop

 void audio(byte fader_step, byte sup_bass, byte bass, byte treb, byte vol, byte gain, byte in, byte rf, byte chan, byte mute){
   /// start 8 bit 0b10000001 ///
     digitalWrite(CE,LOW);
   for(int i=0;i<=7;i++){ 
     digitalWrite(CL,LOW);
     digitalWrite(DI,add[i]);
     digitalWrite(CL,HIGH);}
     digitalWrite(CE,HIGH);
    
    /// fader 4 bit D0...D3 ///
     digitalWrite(CL,LOW);
   for(int i=0;i<4;i++){
     digitalWrite(CL,LOW);
     digitalWrite(DI,fader[fader_step][i]);
     digitalWrite(CL,HIGH);} 
    /// super bass 4 bit D4...D7 ///
   for(int i=0;i<4;i++){
     digitalWrite(CL,LOW);
     digitalWrite(DI,s_bass[sup_bass][i]);
     digitalWrite(CL,HIGH);} 
    /// bass 4 bit D8...D11 ///
   for(int i=0;i<4;i++){
     digitalWrite(CL,LOW);
     digitalWrite(DI,bass_con[bass][i]);
     digitalWrite(CL,HIGH);} 
    /// treble 4 bit D12...D15 ///
   for(int i=0;i<4;i++){
     digitalWrite(CL,LOW);
     digitalWrite(DI,treb_con[treb][i]);
     digitalWrite(CL,HIGH);} 
    /// volume 8 bit D16...D23 ///
   for(int i=0;i<8;i++){
     digitalWrite(CL,LOW);
     digitalWrite(DI,vol_con[vol][i]);
     digitalWrite(CL,HIGH);}
    /// in_gain 4 bit D24...D27 ///
   for(int i=0;i<4;i++){
     digitalWrite(CL,LOW);
     digitalWrite(DI,in_gain[gain][i]);
     digitalWrite(CL,HIGH);}  

    switch(in){ // IN byte 3(2) D28...D29
      case 0:  digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);
               digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);break;
      case 1:  digitalWrite(CL,LOW);digitalWrite(DI,HIGH);digitalWrite(CL,HIGH);
               digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);break;
      case 2:  digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);
               digitalWrite(CL,LOW);digitalWrite(DI,HIGH);digitalWrite(CL,HIGH);break;    
      case 3:  digitalWrite(CL,LOW);digitalWrite(DI,HIGH);digitalWrite(CL,HIGH);
               digitalWrite(CL,LOW);digitalWrite(DI,HIGH);digitalWrite(CL,HIGH);break;  
      case 4:  digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);
               digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);break;}
   switch(rf){ // rear/front D30
      case 0:  digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);break;  
      case 1:  digitalWrite(CL,LOW);digitalWrite(DI,HIGH);digitalWrite(CL,HIGH);break;  
    }

     /// out_gain 0 db 2 bit (1) D31
     digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);  

    if(in<4){ // IN byte 3(3) D32
       digitalWrite(CL,LOW);digitalWrite(DI,HIGH);digitalWrite(CL,HIGH);}
    else{ digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);}

    /// Channel selection 2 bit D33...D34 ///
   for(int i=0;i<2;i++){
     digitalWrite(CL,LOW);
     digitalWrite(DI,channel[chan][i]);
     digitalWrite(CL,HIGH);} 

     switch(mute){ /// mute 0 off // 1 on 2 bit D35
      case 0:  digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);break;
      case 1:  digitalWrite(CL,LOW);digitalWrite(DI,HIGH);digitalWrite(CL,HIGH);break;
      }
        // 000 D36...D38 
       digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);
       digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);
       digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);
        /// output gain 0 D39
       digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);

        // 000 D40...D43 
       digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);
       digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);
       digitalWrite(CL,LOW);digitalWrite(DI,LOW);digitalWrite(CL,HIGH);
    
    }// audio