<?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; PT2259]]></title>
		<link>http://forum.rcl-radio.ru/viewtopic.php?id=169</link>
		<atom:link href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=169&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «PT2259».]]></description>
		<lastBuildDate>Mon, 06 Jul 2020 05:19:40 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: PT2259]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=1855#p1855</link>
			<description><![CDATA[<p>кнопочное управление</p><div class="codebox"><pre><code>#include &lt;Wire.h&gt; // Входит в состав Arduino IDE
#include &lt;EEPROM.h&gt; // Входит в состав Arduino IDE
#include &lt;PT2259.h&gt; // https://github.com/liman324/PT2259.git
#include &lt;STM32_TM1637.h&gt; // http://forum.rcl-radio.ru/misc.php?action=pan_download&amp;item=452&amp;download=1
 
 STM32_TM1637 tm(2,3);// CLK, DIO
 PT2259 pt;
 
 
 int vol,w=1,w1,mute;
 unsigned long time;
  
 
void setup(){
  pinMode(10,INPUT_PULLUP);  // mute
  pinMode(6,INPUT_PULLUP);  // +
  pinMode(7,INPUT_PULLUP);  // -
  
  if(EEPROM.read(100)!=0){for(int i=0;i&lt;101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении 
  tm.brig(7); // ЯРКОСТЬ 0...7
  tm.print_float(0,0,  0b01000000,0b01110011,0b01111000,0b01000000);
  delay(2000);
  tm.print_float(2259,0,  0,0,0,0);
  delay(2000);
  vol = EEPROM.read(0);
  audio();
  }
 
void loop(){
////////// VOLUME //////////////
 if(digitalRead(6)==LOW&amp;&amp;mute==0){vol++;delay(300);time=millis();w=1;w1=1;vol_func();} 
 if(digitalRead(7)==LOW&amp;&amp;mute==0){vol--;delay(300);time=millis();w=1;w1=1;vol_func();} 
 if(w==1){w=0;audio();tm.print_float(vol,1,  0b00001000,0,0,0b00001000);}
 
///////// MUTE //////////// 
  if(digitalRead(10)==LOW&amp;&amp;mute==0){mute=1; audio();tm.print_float(0,0,  0b01000000,0b01000000,0b01000000,0b01000000);delay(500);}
  if(digitalRead(10)==LOW&amp;&amp;mute==1){mute=0; audio();w=1;delay(500);}
 
///////// EEPROM /////////////
   if(millis()-time&gt;5000 &amp;&amp; w1==1){w1=0;EEPROM.update(0,vol);}
   delay(10);
}// loop
 
void audio(){
 pt.setVol_ch2(mute, vol); // mute, vol
// mute on  === 1
// mute off === 0
// vol === -79...0 dB === int 0...79  
// channel-by-channel adjustment
// pt.setVol_left(0, 79);
// pt.setVol_right(0, 79);
  } 
 
void vol_func(){if(vol&lt;0){vol=0;}if(vol&gt;79){vol=79;}}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Mon, 06 Jul 2020 05:19:40 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=1855#p1855</guid>
		</item>
		<item>
			<title><![CDATA[PT2259]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=1704#p1704</link>
			<description><![CDATA[<p><strong>Протестировано!!!</strong></p><p>PT2259 is an 8-pin 2-channel volume controller which utilizes CMOS technology and incorporates the I2C interface control. The controller features an attenuation range of 0 to -79dB, low noise output, a high degree of stereo separation and requires only a small number of external components. PT2259 is an essential component for modern audio visual systems. </p><p><span class="attention-yellow"></span> </p><p>• Attenuation range: 0 to -79dB in 1dB steps<br />• Operating voltage: 4 to 10V<br />• Low power consumption<br />• Low signal noise: S/N &gt; 100dB (A-weighting)<br />• Stereo separation &gt; 100dB<br />• Requires few external components<br />• 2-channel volume individual adjust<br />• Available in 8 Pins DIP or SOP </p><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2020/06/123c4fb3c56bf97175cf257e26c1f8a0.png" alt="http://forum.rcl-radio.ru/uploads/images/2020/06/123c4fb3c56bf97175cf257e26c1f8a0.png" /></span> <br /><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2020/06/6a86956deb98d6be12d7772f8913bf1a.png" alt="http://forum.rcl-radio.ru/uploads/images/2020/06/6a86956deb98d6be12d7772f8913bf1a.png" /></span> </p><p>Библиотека - <a href="https://github.com/liman324/PT2259.git">https://github.com/liman324/PT2259.git</a></p><br /><p>PT2259.ino</p><div class="codebox"><pre><code>#include &lt;Wire.h&gt;
#include &lt;PT2259.h&gt;

 PT2259 pt;

void setup(){
  audio();
  }

void loop(){}

void audio(){
 pt.setVol_ch2(0, 79); // mute, vol
// mute on  === 1
// mute off === 0
// vol === -79...0 dB === int 0...79  

// channel-by-channel adjustment
// pt.setVol_left(0, 79);
// pt.setVol_right(0, 79);
  } </code></pre></div><p>PT2259.h</p><div class="codebox"><pre><code>#ifndef PT2259_H
#define PT2259_H
#define PT2259_address 0b1000100

//Sub addresses
#define CLEAR        0xF0
#define MUTE_OFF     0x74
#define MUTE_ON      0x77

#define MUTE_R      0x75
#define MUTE_L      0x76

#define CH2_1        0b11010000
#define CH2_10       0b11100000

#define LEFT_1       0b10100000
#define LEFT_10      0b10110000

#define RIGHT_1      0b00100000
#define RIGHT_10     0b00110000


#include &lt;Arduino.h&gt;
class PT2259{
public:
PT2259();

void setVol_ch2(bool mute, int vol_ch);
void setVol_left(bool mute, int vol_l);
void setVol_right(bool mute, int vol_r);
void clear();

private:
void writeWire(int8_t a, int8_t b, int8_t c);
};
#endif //PT2259_H</code></pre></div><p>PT2259.cpp</p><div class="codebox"><pre><code>#include &lt;Arduino.h&gt;
#include &lt;Wire.h&gt;
#include &quot;PT2259.h&quot;

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

void PT2259::setVol_ch2(bool mute, int vol_ch){
     vol_ch = 79 - vol_ch;
     byte vol_ch_10 = vol_ch/10;
     byte vol_ch_1 = vol_ch%10;

     if(mute==0){writeWire(MUTE_OFF, CH2_10+vol_ch_10, CH2_1+vol_ch_1);}	
     if(mute==1){writeWire(MUTE_ON, CH2_10+vol_ch_10, CH2_1+vol_ch_1);}
}

void PT2259::setVol_left(bool mute, int vol_l){
     vol_l = 79 - vol_l;
     byte vol_l_10 = vol_l/10;
     byte vol_l_1 = vol_l%10;

     if(mute==0){writeWire(MUTE_OFF, LEFT_10+vol_l_10, LEFT_1+vol_l_1);}	
     if(mute==1){writeWire(MUTE_L, LEFT_10+vol_l_10, LEFT_1+vol_l_1);}
}

void PT2259::setVol_right(bool mute, int vol_r){
     vol_r = 79 - vol_r;
     byte vol_r_10 = vol_r/10;
     byte vol_r_1 = vol_r%10;

     if(mute==0){writeWire(MUTE_OFF, RIGHT_10+vol_r_10, RIGHT_1+vol_r_1);}	
     if(mute==1){writeWire(MUTE_R, RIGHT_10+vol_r_10, RIGHT_1+vol_r_1);}
}

void PT2259::clear(){
  Wire.beginTransmission(PT2259_address);
  Wire.write (CLEAR);// clear
  Wire.endTransmission();	
}

void PT2259::writeWire(int8_t a, int8_t b, int8_t c){
  Wire.beginTransmission(PT2259_address);
  Wire.write (CLEAR);// clear	
  Wire.write (a);    // mute
  Wire.write (b);    // 10 dB
  Wire.write (c);    // 1 dB
  Wire.endTransmission();
}</code></pre></div><div class="quotebox"><blockquote><p>Скетч использует 2034 байт (6%) памяти устройства. Всего доступно 32256 байт.<br />Глобальные переменные используют 219 байт (10%) динамической памяти, оставляя 1829 байт для локальных переменных. Максимум: 2048 байт.</p></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Mon, 01 Jun 2020 17:51:17 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=1704#p1704</guid>
		</item>
	</channel>
</rss>
