Тема: TDA7303
Digital controlled stereo audio processor with loudness
The TDA7303 is a volume, tone (bass and treble)
balance (left/right) and fader (front/rear)
processor for quality audio applications in car
radio, Hi-Fi and portable systems.
Данный контент доступен только зарегистрированным пользователям.
TDA7303.h
// ALEXSANDER LIMAN
// liman324@yandex.ru
// rcl-radio.ru
// 09.04.21
#ifndef TDA7303_H
#define TDA7303_H
#define TDA7303_address 0b1000100
#include <Arduino.h>
class TDA7303
{
public:
TDA7303();
void volume(byte vol); // byte 0...63 === 0...-78.75 dB (step 1.25 dB)
void att_lr(byte lr); // byte 0...30 === 0...-37.5 dB (step 1.25 dB), byte 31 === mute
void att_rr(byte rr); // byte 0...30 === 0...-37.5 dB (step 1.25 dB), byte 31 === mute
void att_lf(byte lf); // byte 0...30 === 0...-37.5 dB (step 1.25 dB), byte 31 === mute
void att_rf(byte rf); // byte 0...30 === 0...-37.5 dB (step 1.25 dB), byte 31 === mute
void audio_sw(byte in, bool loud, byte loud_gain);
// byte 0...2 === input 0...2, byte 3 === Not allowed
// bool 0...1 === loudness_on...loudness_off
// byte 0...3 === loudness_gain 11.25...0 dB
void set_bass(char bass); // int -7...7 === bass -14...+14 dB
void set_treb(char treb); // int -7...7 === treble -14...+14 dB
private:
void writeWire(byte a);
};
#endif //TDA7303_H
TDA7303.cpp
#include <Arduino.h>
#include <Wire.h>
#include "TDA7303.h"
TDA7303::TDA7303(){
Wire.begin();
}
void TDA7303::volume(byte vol){
writeWire(0b00000000 + vol);
}
void TDA7303::att_lr(byte lr){
writeWire(0b11000000 + lr);
}
void TDA7303::att_rr(byte rr){
writeWire(0b11100000 + rr);
}
void TDA7303::att_lf(byte lf){
writeWire(0b10000000 + lf);
}
void TDA7303::att_rf(byte rf){
writeWire(0b10100000 + rf);
}
void TDA7303::audio_sw(byte in, bool loud, byte loud_gain){
writeWire(0b01000000 + in + (loud << 2) + (loud_gain << 3));
}
void TDA7303::set_bass(char bass){
if(bass >= 0){writeWire(0b01100000 + 15 - bass);}
if(bass < 0){writeWire( 0b01100000 + 7 + bass);}
}
void TDA7303::set_treb(char treb){
if(treb >= 0){writeWire(0b01110000 + 15 - treb);}
if(treb < 0){writeWire( 0b01110000 + 7 + treb);}
}
void TDA7303::writeWire(byte a){
Wire.beginTransmission(TDA7303_address);
Wire.write (a);
Wire.endTransmission();
}
test.ino (протестировано)
#include <Wire.h>
#include <TDA7303.h>
TDA7303 tda;
void setup(){}
void loop(){
audio();
delay(1000);
}
void audio(){
tda.volume(0); // byte 0...63 === 0...-78.75 dB (step 1.25 dB)
tda.att_lr(0); // byte 0...30 === 0...-37.5 dB (step 1.25 dB), byte 31 === mute
tda.att_rr(0); // byte 0...30 === 0...-37.5 dB (step 1.25 dB), byte 31 === mute
tda.att_lf(0); // byte 0...30 === 0...-37.5 dB (step 1.25 dB), byte 31 === mute
tda.att_rf(0); // byte 0...30 === 0...-37.5 dB (step 1.25 dB), byte 31 === mute
tda.audio_sw(0, 1, 3);
// byte 0...2 === input 0...2, byte 3 === Not allowed
// bool 0...1 === loudness_on...loudness_off
// byte 0...3 === loudness_gain 11.25...0 dB
tda.set_bass(2); // char -7...7 === bass -14...+14 dB
tda.set_treb(0); // char -7...7 === treble -14...+14 dB
}
Данный контент доступен только зарегистрированным пользователям.