<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[forum.rcl-radio.ru &mdash; TDA7303]]></title>
	<link rel="self" href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=296&amp;type=atom" />
	<updated>2021-04-09T17:52:22Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.rcl-radio.ru/viewtopic.php?id=296</id>
		<entry>
			<title type="html"><![CDATA[TDA7303]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=3407#p3407" />
			<content type="html"><![CDATA[<p>Digital controlled stereo audio processor with loudness</p><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2021/04/68ceb6de277e5cd86031bf3caa11856f.png" alt="http://forum.rcl-radio.ru/uploads/images/2021/04/68ceb6de277e5cd86031bf3caa11856f.png" /></span> </p><p>The TDA7303 is a volume, tone (bass and treble)<br />balance (left/right) and fader (front/rear)<br />processor for quality audio applications in car<br />radio, Hi-Fi and portable systems. </p><p><span class="attention-yellow"></span> </p><p>TDA7303.h</p><div class="codebox"><pre><code>// ALEXSANDER LIMAN
// liman324@yandex.ru
// rcl-radio.ru
// 09.04.21

#ifndef TDA7303_H
#define TDA7303_H

#define TDA7303_address 0b1000100 

#include &lt;Arduino.h&gt;
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</code></pre></div><p>TDA7303.cpp</p><div class="codebox"><pre><code>#include &lt;Arduino.h&gt;
#include &lt;Wire.h&gt;
#include &quot;TDA7303.h&quot;

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 &lt;&lt; 2) + (loud_gain &lt;&lt; 3));
}

void TDA7303::set_bass(char bass){
      if(bass &gt;= 0){writeWire(0b01100000 + 15 - bass);}
      if(bass &lt; 0){writeWire( 0b01100000 + 7 + bass);}
}

void TDA7303::set_treb(char treb){
      if(treb &gt;= 0){writeWire(0b01110000 + 15 - treb);}
      if(treb &lt; 0){writeWire( 0b01110000 + 7 + treb);}
}

void TDA7303::writeWire(byte a){
  Wire.beginTransmission(TDA7303_address);
  Wire.write (a);
  Wire.endTransmission();
}</code></pre></div><p>test.ino (протестировано)</p><div class="codebox"><pre><code>#include &lt;Wire.h&gt; 
#include &lt;TDA7303.h&gt;

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
}</code></pre></div><p><span class="attention-yellow"></span></p>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2021-04-09T17:52:22Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=3407#p3407</id>
		</entry>
</feed>
