<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[forum.rcl-radio.ru &mdash; PT2257]]></title>
	<link rel="self" href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=460&amp;type=atom" />
	<updated>2022-03-03T05:30:16Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.rcl-radio.ru/viewtopic.php?id=460</id>
		<entry>
			<title type="html"><![CDATA[PT2257]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=5497#p5497" />
			<content type="html"><![CDATA[<p><span class="attention-yellow"></span> </p><p>PT2257.h<br /></p><div class="codebox"><pre><code>// PT2257 | rcl-radio.ru | liman324@yandex.ru | Автор: Лиман А.А.
#ifndef  PT2257_H
#define  PT2257_H

#define  PT2257_address 0x44 // адрес

#include &lt;Arduino.h&gt;
class  PT2257
{
  public:
     PT2257();
        void setLeft(int left);      // 0...-79 дБ  int 0...79
        void setRight(int right);    // 0...-79 дБ  int 0...79
        void setMute(int mute);      // int 1 - on mute  | int 0 - off mute
  private:
	void writeWire(char a);
};
	
#endif // PT2257_H</code></pre></div><p>PT2257.cpp<br /></p><div class="codebox"><pre><code>#include &lt;Arduino.h&gt;
#include &lt;Wire.h&gt;
#include &quot;PT2257.h&quot;

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

void PT2257::setLeft(int left){
        left = 78 - left;
    int left10 = left / 10;
    int left01 = left - left10 * 10;

  writeWire(left10+0b10110000);
  writeWire(left01+0b10100000);
}

void PT2257::setRight(int right){
        right = 78 - right;
    int right10 = right / 10;
    int right01 = right - right10 * 10;

  writeWire(right10+0b00110000);
  writeWire(right01+0b00100000);
}

void PT2257::setMute(int mute){
 if(mute == 1){
  writeWire(0b01111001);}
 else{
  writeWire(0b01111000);}
}

void PT2257::writeWire(char a){
  Wire.beginTransmission(PT2257_address);
  Wire.write (a);
  Wire.endTransmission();
}</code></pre></div><p>PT2257.ino<br /></p><div class="codebox"><pre><code>#include &lt;Wire.h&gt;
#include &lt;PT2257.h&gt;
PT2257 rt;

void setup() {
  Wire.begin();
}

void loop() {
  rt.setLeft(33); // int 0...79 
  rt.setRight(33);// int 0...79
  rt.setMute(0);  // int 0...1
  delay(1000);
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2022-03-03T05:30:16Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=5497#p5497</id>
		</entry>
</feed>
