Hi,
stil newbie here..
but hope i finish before christmas with my prosject.
I manange to compile my arduino nano and tda7439,
but there is no sound out.
I can see that it responds in i2c scanner, with adress 0x44,
somebody how can se if the code is right, with wire address and so.
i put this in the main sketch.
also has lcd and remote control.
thanks for any ideas ??
//Sound Processor chip library
#include <TDA7439.h>
TDA7439 equ;
and
#ifndef TDA7439_H
#define TDA7439_H
//chip **7 bit** address
// Datasheet says 0x88 but that is the 8 bit
// address. Wire.h automatically appends the
// extra (lsb write) bit.
#define TDA7439_address 0x44
//Sub addresses
#define TDA7439_input_sel 0x00
#define TDA7439_input_gain 0x01
#define TDA7439_volume 0x02
#define TDA7439_bass 0x03
#define TDA7439_middle 0x04
#define TDA7439_trebble 0x05
#define TDA7439_ratt 0x06
#define TDA7439_latt 0x07
// Input selection
#define TDA7439_input_1 0x03
#define TDA7439_input_2 0x02
#define TDA7439_input_3 0x01
#define TDA7439_input_4 0x00
//TDA7439 input gain in db (x 2)
//0x00 -> 0x0F
//TDA7439 volume (-db)
//0x00 -> 0x2F
#define TDA7439_mute 0x38 //Mute main volume
#include <Arduino.h>
class TDA7439
{
public:
TDA7439();
void setInput(int input); // 1 to 4
void inputGain(int gain); // 0 to 30
void setVolume(int volume); // 0 to 48 ( 0 is mute)
void setSnd(int val, int range); //-7 to +7 , 1 - Bass | 2 - Mids | 3 - Trebble
void mute();
void spkAtt(int att); // Output attenuation 0 to 79 (db) can be used for balance but not enabled in this code.
private:
void writeWire(char a, char b);
};
#endif //TDA7439_H
and the .cpp file
#include <Arduino.h>
#include <Wire.h>
#include "TDA7439.h"
TDA7439::TDA7439(){
Wire.begin();
}
void TDA7439::setInput(int input){
switch (input) {
case 1: input = TDA7439_input_1;break;
case 2: input = TDA7439_input_2;break;
case 3: input = TDA7439_input_3;break;
case 4: input = TDA7439_input_4;break;
}
writeWire(TDA7439_input_sel,input);
}
void TDA7439::inputGain(int gain){
writeWire(TDA7439_input_gain,gain);
}
void TDA7439::setVolume(int volume){
if (volume == 0){
volume = TDA7439_mute;
}else{
volume = 48 - volume;
}
writeWire(TDA7439_volume,volume);
}
void TDA7439::setSnd(int val, int range){
switch (range){
case 1:range = TDA7439_bass;break;
case 2:range = TDA7439_middle;break;
case 3:range = TDA7439_trebble;break;
}
switch (val){
case -7:val = 0;break;
case -6:val = 1;break;
case -5:val = 2;break;
case -4:val = 3;break;
case -3:val = 4;break;
case -2:val = 5;break;
case -1:val = 6;break;
case 0 :val = 7;break;
case 1 :val = 14;break;
case 2 :val = 13;break;
case 3 :val = 12;break;
case 4 :val = 11;break;
case 5 :val = 10;break;
case 6 :val = 9;break;
case 7 :val = 8;break;
}
writeWire(range,val);
}
void TDA7439::mute(){
writeWire(TDA7439_volume,TDA7439_mute);
}
void TDA7439::spkAtt(int att){
// Mainly used to override the default attenuation of mute at power up
// can be used for balance with some simple code changes here.
writeWire(TDA7439_ratt,att);
writeWire(TDA7439_latt,att);
}
void TDA7439::writeWire(char a, char b){
Wire.beginTransmission(TDA7439_address);
Wire.write (a);
Wire.write (b);
Wire.endTransmission();
}