1

Тема: TDA7448

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

TDA7448.h

// Александр Лиман
// liman324@yandex.ru

#ifndef TDA7448_H
#define TDA7448_H
// address 7 bit
#define TDA7448_address 0b1000100

//Sub addresses
#define TDA7448_1       0b00000000 
#define TDA7448_2       0b00000001 
#define TDA7448_3       0b00000010 
#define TDA7448_4       0b00000011 
#define TDA7448_5       0b00000100 
#define TDA7448_6       0b00000101

#include <Arduino.h>
class TDA7448
{
  public:
    TDA7448();        
        void setAtt(int spek, int att_spek); 

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

TDA7448.cpp

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

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

void TDA7448::setAtt(int spek, int att_spek){
      switch(spek){
        case 1: spek = TDA7448_1;break;
        case 2: spek = TDA7448_2;break;
        case 3: spek = TDA7448_3;break;  
        case 4: spek = TDA7448_4;break;
        case 5: spek = TDA7448_5;break;
        case 6: spek = TDA7448_6;break;   
}
       att_spek = abs(att_spek);
  writeWire(spek, att_spek);
}



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

test.ino

#include <Wire.h>
#include <TDA7448.h>
 TDA7448 tda;

 void setup(){Wire.begin();}

 void loop(){
  audio_tda();
  delay(1000);
  }
 void audio_tda(){
  tda.setAtt(1,0);// 0 макс громк, -79(79) мин громк
  tda.setAtt(2,0);
  tda.setAtt(3,0);
  tda.setAtt(4,0);
  tda.setAtt(5,0);
  tda.setAtt(6,0);
  }