<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[forum.rcl-radio.ru &mdash; TDA7317]]></title>
		<link>http://forum.rcl-radio.ru/viewtopic.php?id=465</link>
		<atom:link href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=465&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «TDA7317».]]></description>
		<lastBuildDate>Thu, 03 Mar 2022 07:11:15 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[TDA7317]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=5502#p5502</link>
			<description><![CDATA[<p><span class="attention-yellow"></span> </p><p>TDA7317.h<br /></p><div class="codebox"><pre><code>// liman324@yandex.ru rcl-radio.ru


#ifndef TDA7317_H
#define TDA7317_H


#define TDA7317_address 0x43 // 18 вывод ADDR не замкнут на землю

#include &lt;Arduino.h&gt;
class TDA7317
{
  public:
    TDA7317();
        void setVolume(int vol);        // 0...47   
        void setBand(int band, int db); // 0...4 (1...5 полоса) , -7...+7 (-14...+14 дБ)
	
  private:
	void writeWire(char a);
};
	
#endif //TDA7317_H</code></pre></div><p>TDA7317.cpp<br /></p><div class="codebox"><pre><code>#include &lt;Arduino.h&gt;
#include &lt;Wire.h&gt;
#include &quot;TDA7317.h&quot;

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

void TDA7317::setVolume(int vol){
  vol = 47 - vol;
  writeWire(vol);
}

void TDA7317::setBand(int band, int db){
  switch(band){
     case 0: band = 0b10000000; break;
     case 1: band = 0b10010000; break;
     case 2: band = 0b10100000; break;
     case 3: band = 0b10110000; break;
     case 4: band = 0b11000000; break;
  }
  switch(db){
     case -0: db = 0b00001000; break;
     case -1: db = 0b00001001; break;
     case -2: db = 0b00001010; break;
     case -3: db = 0b00001011; break;
     case -4: db = 0b00001100; break;
     case -5: db = 0b00001101; break;
     case -6: db = 0b00001110; break;
     case -7: db = 0b00001111; break;

     case 1: db = 0b00000001; break;
     case 2: db = 0b00000010; break;
     case 3: db = 0b00000011; break;
     case 4: db = 0b00000100; break;
     case 5: db = 0b00000101; break;
     case 6: db = 0b00000110; break;
     case 7: db = 0b00000111; break;
  }
    int ekv = band + db;
    writeWire(ekv);
}


void TDA7317::writeWire(char a){
  Wire.beginTransmission(TDA7317_address);
  Wire.write (a);
  Wire.endTransmission();
}</code></pre></div><p>TDA7317.ino<br /></p><div class="codebox"><pre><code>#include &lt;Wire.h&gt;
#include &lt;TDA7317.h&gt;
  TDA7317 tda;
  
void setup(){ 
  Serial.begin(9600);Wire.begin();
  audio();
}

void loop(){}

void audio(){
  tda.setVolume(35); // громкость 0...47
  /////////// номер полосы, дБ (-7...+7) //////////
  tda.setBand(0,0);  // 10000 Hz
  tda.setBand(1,0);  // 260   Hz
  tda.setBand(2,0);  // 1000  Hz
  tda.setBand(3,0);  // 3000  Hz
  tda.setBand(4,0);  // 60    Hz
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Thu, 03 Mar 2022 07:11:15 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=5502#p5502</guid>
		</item>
	</channel>
</rss>
