<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[forum.rcl-radio.ru &mdash; Проблемы с загрузками скетча]]></title>
	<link rel="self" href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;fid=4&amp;type=atom" />
	<updated>2025-06-03T13:10:21Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.rcl-radio.ru/index.php</id>
		<entry>
			<title type="html"><![CDATA[YoRadio нужна помощь!!!!]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=706&amp;action=new" />
			<summary type="html"><![CDATA[<p>Несколько дней не могу загрузить скетч ,спросить пытался все молчат или отправляют к первоисточнику там все прочитал ответа не нашел помогите разобраться?<span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2025/06/3fd2fc76d44358f1b98a218b6489af50.jpg" alt="http://forum.rcl-radio.ru/uploads/images/2025/06/3fd2fc76d44358f1b98a218b6489af50.jpg" /></span></p><p>чего не хватает и как исправить. Всем спасибо заранее.</p><p>Весь код на всякий случай</p><div class="codebox"><pre><code>/* ============================================================================================================
 *    ёRadio
 * ============================================================================================================
 *    Web-radio based on
 *    ESP32-audioI2S     [url]https://github.com/schreibfaul1/ESP32-audioI2S[/url]  
 *    or/and
 *    ESP32-vs1053_ext   [url]https://github.com/schreibfaul1/ESP32-vs1053_ext[/url]
 *    libraries
 * ============================================================================================================
 *    Project home       [url]https://github.com/e2002/yoradio[/url]
 *    Wiki               [url]https://github.com/e2002/yoradio/wiki[/url]
 *    Описание на 4PDA   [url]https://4pda.to/forum/index.php?s=&amp;showtopic=1010378&amp;view=findpost&amp;p=112992611[/url]
 *    Как это прошить?   [url]https://4pda.to/forum/index.php?act=findpost&amp;pid=112992611&amp;anchor=Spoil-112992611-2[/url]
 * ============================================================================================================
 *    Here goes!
 * ============================================================================================================
 */
#include &quot;Arduino.h&quot;
#include &quot;src/core/options.h&quot;
#include &quot;src/core/config.h&quot;
#include &quot;src/core/telnet.h&quot;
#include &quot;src/core/player.h&quot;
#include &quot;src/core/display.h&quot;
#include &quot;src/core/network.h&quot;
#include &quot;src/core/netserver.h&quot;
#include &quot;src/core/controls.h&quot;
#include &quot;src/core/mqtt.h&quot;
#include &quot;src/core/optionschecker.h&quot;

extern __attribute__((weak)) void yoradio_on_setup();

void setup() {
  Serial.begin(115200);
  if(LED_BUILTIN!=255) pinMode(LED_BUILTIN, OUTPUT);
  if (yoradio_on_setup) yoradio_on_setup();
  config.init();
  display.init();
  player.init();
  network.begin();
  if (network.status != CONNECTED) {
    netserver.begin();
    display.putRequest(DSP_START);
    while(!display.ready()) delay(10);
    return;
  }
  if(SDC_CS!=255) {
    display.putRequest(WAITFORSD, 0);
    Serial.print(&quot;##[BOOT]#\tSD search\t&quot;);
  }
  config.initPlaylistMode();
  netserver.begin();
  telnet.begin();
  initControls();
  display.putRequest(DSP_START);
  while(!display.ready()) delay(10);
  #ifdef MQTT_ROOT_TOPIC
    mqttInit();
  #endif
  if (config.getMode()==PM_SDCARD) player.initHeaders(config.station.url);
  player.lockOutput=false;
  if (config.store.smartstart == 1) player.sendCommand({PR_PLAY, config.store.lastStation});
}

void loop() {
  telnet.loop();
  if (network.status == CONNECTED) {
    player.loop();
    loopControls();
  }
  netserver.loop();
}

#include &quot;src/core/audiohandlers.h&quot;</code></pre></div>]]></summary>
			<author>
				<name><![CDATA[Fox57]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=1627</uri>
			</author>
			<updated>2025-06-03T13:10:21Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=706&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[TDA8425]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=680&amp;action=new" />
			<summary type="html"><![CDATA[<p>Код</p>]]></summary>
			<author>
				<name><![CDATA[Tomm]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2908</uri>
			</author>
			<updated>2024-11-02T17:25:49Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=680&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Генератор AD9833]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=665&amp;action=new" />
			<summary type="html"><![CDATA[<p>Подключил библиотеку для работы с генератором AD9833: #include &lt;AD9833.h&gt;&nbsp; </p><p>При выполнении команды gen.EnableOutput(btn_state); // включаем / отключаем выход генератора </p><p>выдается сообщение об ошибке: &#039;class AD9833&#039; has no member named &#039;EnableOutput&#039;.</p><p>В чем причина?</p>]]></summary>
			<author>
				<name><![CDATA[Gennady_r]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2779</uri>
			</author>
			<updated>2024-09-05T22:17:13Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=665&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Анализатор спектра на SH1106 OLED 1.3″ (Arduino)]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=588&amp;action=new" />
			<summary type="html"><![CDATA[<p>Ошибка (&nbsp; analogReadResolution(10);// АЦП 10 БИТ )<span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2023/10/ce14b5b50ecebb35ad700bfbc243caf8.png" alt="http://forum.rcl-radio.ru/uploads/images/2023/10/ce14b5b50ecebb35ad700bfbc243caf8.png" /></span></p>]]></summary>
			<author>
				<name><![CDATA[senior.vovchenko]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2211</uri>
			</author>
			<updated>2023-10-29T12:28:44Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=588&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Часы (DS3231) с будильником (Arduino)]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=582&amp;action=new" />
			<summary type="html"><![CDATA[<div class="codebox"><pre><code>#include &lt;Wire.h&gt;
#include &lt;TM1637Display.h&gt;
#include &lt;DS3231.h&gt;
#include &lt;EEPROM.h&gt;  //#include &lt;EEPROMex.h&gt;
DS3231 clock; // ПОДКЛЮЧЕНИЕ DS3231 SDA, SCL, SQW / A4, A5, D6
RTCDateTime DateTime;
TM1637Display display(4, 5);// ПОДКЛЮЧЕНИЕ TM1637 CLK,DIO / 4, 5
// https://github.com/avishorp/TM1637/tree/master
 
int k,alarm_m,alarm_h;
byte w = 1,x,y,z,menu,ton,on=1;
uint8_t date_s[]{0,0,0,0};// second
uint8_t date_t[]{0x78,0,0,0};// t
uint8_t date_on[]{0,0,0x3f,0x37};// ON
uint8_t date_off[]{0,0x3f,0x71,0x71};// OFF
 
void setup() {
  clock.begin();
  // clock.setDateTime(__DATE__, __TIME__);
   display.setBrightness(1);// яркость TM1637 0-7
   Wire.begin(); 
   pinMode(6,INPUT);pinMode(10,INPUT);pinMode(11,INPUT);pinMode(12,INPUT);
   alarm_m = EEPROM.read(0);alarm_h = EEPROM.read(1);z = EEPROM.read(3);// ЧТЕНИЕ EEPROM
}
 
void loop() {
     DateTime = clock.getDateTime(); // ОПРОС ВРЕМЕНИ
     k = DateTime.hour*100+DateTime.minute; // ВРЕМЯ КАК ЧИСЛО ННММ
 
if(digitalRead(6) == HIGH){x = 0x40;}else{x = 0x00;} // МИГАНИЕ ДВОЕТОЧИЯ 
if(digitalRead(10) == HIGH){menu++;delay(300);if(menu &gt; 6){menu = 0;}} // ПЕРЕБОР МЕНЮ
 
if(menu == 0){y = true;if(w == 0){EEPROM.update(0,alarm_m);EEPROM.update(1,alarm_h);EEPROM.update(3,z);}
w = 1;}  // ПРИ ВЫХОДЕ ИЗ МЕНЮ ОБНОВЛЕНИЕ EEPROM
 
if(menu == 1){k = DateTime.second;date_s[2] = display.encodeDigit((k/10)%10);
date_s[3] = display.encodeDigit((k%10)%10);display.setSegments(date_s);
} // ВЫВОД СЕКУНД
 
if(menu == 2){k = DateTime.day*100 + DateTime.month;x = 0x40;} // ВЫВОД ДАТЫ И МЕСЯЦА
 
if(menu == 3){k = clock.readTemperature();date_t[2] = display.encodeDigit((k/10)%10);
date_t[3] = display.encodeDigit((k%10)%10);display.setSegments(date_t);} // ВЫВОД ТЕМПЕРАТУРЫ
 
if(menu == 4){y = true;x = 0x40;k = alarm_h*100+alarm_m; // УСТАНОВКА БУДИЛЬНИКА
if(digitalRead(12) == HIGH){alarm_m++;delay(300);}if(alarm_m &gt; 59){alarm_m = 0;} // МИНУТЫ БУДИЛЬНИКА
if(digitalRead(11) == HIGH){alarm_h++;delay(500);}if(alarm_h &gt; 23){alarm_h = 0;} // ЧАСЫ БУДИЛЬНИКА
w = 0;}
 
if(menu == 5){
if(digitalRead(11) == HIGH){on=1;delay(300);}if(on==1){display.setSegments(date_on);} // БУДИЛЬНИК ВКЛЮЧЕН
if(digitalRead(12) == HIGH){on=0;delay(300);}if(on==0){display.setSegments(date_off);} // БУДИЛЬНИК ВЫКЛЮЧЕН
}
 
if(menu == 6){y = false;x = 0x00;k = z; // НАСТРОЙКА ЯРКОСТИ ИНДИКАТОРА
if(digitalRead(11) == HIGH){z++;delay(500);}if(z &gt; 7){z = 0;}
if(digitalRead(12) == HIGH){z--;delay(500);}if(z &gt; 8){z = 7;}
w = 0;}
 
if(digitalRead(11)==HIGH||digitalRead(12)==HIGH){ton=1;} // ПРИ НАЖАТИИ НА КНОПУ + ИЛИ - ПРЕРЫВАЕТСЯ СИГНАЛ БУДИЛНИКА
if(DateTime.hour*100+DateTime.minute!=alarm_h*100+alarm_m){ton=0;}
if(on==1){pic();}
 
display.setBrightness(z);
if(menu == 3 || menu == 5 || menu == 1){}else{display.showNumberDecEx(k,x,y);}
 
}
void pic(){if(ton==0&amp;&amp;(DateTime.hour*100+DateTime.minute==alarm_h*100+alarm_m)){tone(7,1000,500);delay(1000);}} // СИГНАЛ БУДИЛЬНИКА, 7 ЦИФРОВОЙ ВЫХОД</code></pre></div><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2023/09/6862ad627b32a5ebd2eceaca21da4870.png" alt="http://forum.rcl-radio.ru/uploads/images/2023/09/6862ad627b32a5ebd2eceaca21da4870.png" /></span></p>]]></summary>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2023-09-26T11:22:06Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=582&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Импульсный генератор + частотомер (Arduino)]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=579&amp;action=new" />
			<summary type="html"><![CDATA[<div class="codebox"><pre><code>#include &lt;LiquidCrystal.h&gt;
#include &lt;Encoder.h&gt;
#include &lt;TimerOne.h&gt;
#include &lt;FreqCount.h&gt;
LiquidCrystal lcd(6, 7, 8, 11, 12, 13);// RS,E,D4,D5,D6,D7
Encoder myEnc(4, 3);// CLK, DT
 
void setup() {
  pinMode(2,INPUT); // КНОПКА ЭНКОДЕРА
  pinMode(A5,INPUT); // КНОПКА ПРИНУДИТЕЛЬНОГО ВКЛЮЧЕНИЯ ГЕНЕРАЦИИ
  pinMode(A4,INPUT); // ЧАСТОТОМЕР/ГЕНЕРАТОР
  lcd.begin(16, 2);// LCD 16X2
}
 
unsigned long f_sum,time;
long f[8]{0,0,0,0,0,0,0,512};
int i,x,y,cursor,h_g;
long oldPosition  = -999,newPosition;
float t;
const float popravka = 1.0004502;// поправочный коэффициент для повышения точности генератора (если нет эталона то коэффициент = 1.0000000)
 
unsigned long f_0;float f0;
int x1,n=3,r;
 
void loop() {
  if(digitalRead(A4)==HIGH){h_g++;y=0;delay(300);if(h_g&gt;1){h_g=0;}}// ГЕНЕРАТОР/ЧАСТОТОМЕР (ПО УМОЛЧАНИЮ ПЕРВЫЙ ГЕНЕРАТОР)
 
  if(h_g==1){ i=0; // ЧАСТОТОМЕР ////////////////////////////////////////////////////////////////////
  if(y==1){FreqCount.begin(1000);}
 
  if(digitalRead(2)==LOW){n++;x1=0;delay(100);}// ВЫБОР ВРЕМЕНИ ИЗМЕРЕНИЯ ПРИ ПОМОЩИ КНОПКИ ЭНКОДЕРА
    lcd.setCursor(0,1);
  if(n==1){x1++;if(x1==1){FreqCount.begin(100);}r=-1;lcd.print(&quot;T = 0.1 s &quot;);}
  if(n==2){x1++;if(x1==1){FreqCount.begin(10000);}r=1;lcd.print(&quot;T = 10 s &quot;);}
  if(n==3){x1++;if(x1==1){FreqCount.begin(1000);}r=0;lcd.print(&quot;T = 1 s  &quot;);}
  if(n&gt;3){n=1;} 
    lcd.setCursor(0,0);
    lcd.print(&quot;F = &quot;); // ВЫВОД ЧАСТОТЫ 
  if(f_0&gt;=1000000 &amp;&amp; n==3){f0=f_0/1000000.0;lcd.print(f0,6+r);lcd.print(&quot; MHz&quot;);}
  if(f_0&lt;1000000 &amp;&amp; n==3){f0=f_0/1000.0;lcd.print(f0,3+r);lcd.print(&quot; kHz&quot;);}
  if(f_0&gt;=100000 &amp;&amp; n==1){f0=f_0/100000.0;lcd.print(f0,6+r);lcd.print(&quot; MHz&quot;);}
  if(f_0&lt;100000 &amp;&amp; n==1){f0=f_0/100.0;lcd.print(f0,3+r);lcd.print(&quot; kHz&quot;);}
  if(f_0&gt;=10000000 &amp;&amp; n==2){f0=f_0/10000000.0;lcd.print(f0,6+r);lcd.print(&quot;MHz&quot;);}
  if(f_0&lt;10000000 &amp;&amp; n==2){f0=f_0/10000.0;lcd.print(f0,3+r);lcd.print(&quot; kHz&quot;);}
 
  if (FreqCount.available()) { 
 
    f_0 = FreqCount.read(); // ИЗМЕРЕНИЕ ЧАСТОТЫ
 
   lcd.setCursor(10,1);lcd.print(&quot;***&quot;);// ИНДИКАЦИЯ ИЗМЕРЕНИЯ
  }
   delay(200);
   lcd.clear();
}
 
  if(h_g==0){// ГЕНЕРАТОР //////////////////////////////////////////////////////////////////
 
   if(i==8){   lcd.setCursor(10,1); lcd.print(&quot;ON &quot;);// ГЕНЕРАЦИЯ ВКЛЮЧЕНА
   if(y==1){ Timer1.initialize(f_sum * popravka); // период  - запускаем только один раз после выхода из режима изминения параметров 
   Timer1.pwm(9, f[7]);} // k - коэффициент заполнения 0-1023. Сигнал снимаем с выхода 9
   delay(100);
 }
 
  if(digitalRead(2)==LOW){delay(300);i++;if(i&gt;8){i=0;} myEnc.write(f[i]*4);// ОПРОС КНОПКИ ЭНКОДЕРА
  if(i==8){y=0;cursor=0;}}
  if(digitalRead(A5)==HIGH){delay(300);i=8;y=0;}// КНОПКА ПРИНУДИТЕЛЬНОГО ВКЛЮЧЕНИЯ ГЕНЕРАЦИИ
 
  if(i&lt;8||cursor==1){ // В РЕЖИМЕ ИЗМЕНЕНИЯ ПЕРИОДА И ЗАПОЛНЕНИЯ ШИМ ГЕНЕРАЦИЯ ОТКЛЮЧЕНА
  lcd.setCursor(10,1); lcd.print(&quot;OFF&quot;);// ГЕНЕРАЦИЯ ВЫКЛЮЧЕНА
 
 long newPosition = myEnc.read()/4; // ОПРОС ЭНКОДЕРА
 
  if (newPosition != oldPosition) {
    oldPosition = newPosition;
    f[i]=newPosition;
 
    if(i&lt;7){ // ОГРАНИЧЕНИЕ ПРИ ИЗМЕНЕНИИ ПЕРИОДА ОТ 0 ДО 9
    if(f[i]&gt;9){myEnc.write(0);}
    if(f[i]&lt;0){myEnc.write(9*4);}}
    else{// ОГРАНИЧЕНИЕ ПРИ ИЗМЕНЕНИИ ЗАПОЛНЕНИЯ ШИМ ОТ 0 ДО 1023
    if(f[7]&gt;1023){f[7]=1023;}
    if(f[7]&lt;0){f[7]=0;}}
  }
   f_sum=f[6]*1000000+f[5]*100000+f[4]*10000+f[3]*1000+f[2]*100+f[1]*10+f[0];// ПЕРИОД
   lcd.setCursor(0,0);// ВЫВОД ИНФОРМАЦИИ НА LCD 
   lcd.print(&quot;T = &quot;);
   for(x=6;x&gt;=0;x--){
   if(x==5||x==2){lcd.print(&quot;.&quot;);}// ВСТАВЛЯЕМ РАЗДЕЛИТЬ РАЗРЯДА
   if(cursor==1&amp;&amp;i==x){lcd.print(&quot; &quot;);}else{lcd.print(f[x]);}
   }
   lcd.print(&quot; uS&quot;);
 
     // МИГАНИЕ КУРСОРА ПРИ ИЗМЕНЕНИИ ПАРАМЕТРОВ 
 
   if(millis()-time&lt;200){cursor=1;}// 200 МС ПРОБЕЛ ВМЕСТО ЦИФРЫ
   if(millis()-time&gt;200){cursor=0;}// 800 МС ПОКАЗЫВАЕМ ЦИФРУ
   if(millis()-time&gt;1000){time=millis();}// ОТСЧЕТ 1 СЕКУНДЫ
  }
 
   // ВЫВОД НА LCD % ЗАПОЛНЕНИЯ ШИМ
   t=f[7]*100.0/1023;
   lcd.setCursor(0,1);lcd.print(t,1);if(cursor==1&amp;&amp;i==7){lcd.print(&quot;    &quot;);}else{ lcd.print(&quot; %   &quot;);}
  }
y++;
}</code></pre></div>]]></summary>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2023-09-17T17:11:41Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=579&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Отказ  в выводе информации от OBD на дисплеи]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=553&amp;action=new" />
			<summary type="html"><![CDATA[<p>Всем привет <br />может кто в теме случившегося или доводилось с подобным сталкиваться<br />Скетч залит на мегу 2560 про мини отработал с OLED 1.3″ I2C 128х64 некое время ,пока пытался его подредактировать с выводом режимов спидометр тахометр и режим инфо по данным ТТ<br />Сначала ни стого сего отказал TCA 9548 наличием питания по портам, переключив на один лед, все работало с ним , но потом отказал выводом информации (данных) сам дисплей рабочий. пытался залить исходник ,но и это не помогло инфо данных не выводит , а Меню 4х дисплеев выводит.<br />Пропал вывод инфо на лед при чтения данных ,хотя лед диод сигнализирует о прохождении сигнала OBD морганием как на начальном&nbsp; этапе до оптопары,так и после обработки мегой на лед морганием<br />может кто сможет подсказать ,исправить<br /></p><div class="codebox"><pre><code>// ToyotaOBD1_Reader
// In order to read the data from the OBD connector, short E1 + TE2. then to read the data connect to VF1.
// Note the data line output is 12V - connecting it directly to one of the arduino pins might damage (proabably) the board
// This is made for diaply with an OLED display using the U8glib - which allow wide range of display types with minor adjusments.
// Many thanks to GadgetFreak for the greate base code for the reasding of the data.
// If you want to use invert line - note the comments on the MY_HIGH and the INPUT_PULLUP in the SETUP void.
////////////////////////////////////////////////////////////////////////////////////////////
// Modified version to support two displays using a TCA 9548.
// 30 June 2022            by jkl
//******* Warning!!! I have no way to test this code. Once it is tested and verified, this
//*******     warning can be removed.     -jkl    ******************
//   1 July 2022   Rev.1 adds include of Wire.h                -jkl
// Adds support for a4988 driver for VID2905 stepper motor. Provides Tachometer reading.
//   12 November 2022       by jkl
////////////////////////////////////////////////////////////////////////////////////////////


#include &quot;U8glib.h&quot;
//#include &quot;SdFat.h&quot;
#include &lt;SPI.h&gt;
#include &lt;Wire.h&gt;
#include &lt;EEPROM.h&gt;
#include &lt;MD_KeySwitch.h&gt;
// Include the AccelStepper Library
#include &lt;AccelStepper.h&gt;

#define VREF_MEASURED 3.32      //Измеренное опорное напряжение с 3.3В стабилизатора

// выбрать один вариант логирования
#define LOGGING_MINIMAL   // Запись минимума данных
//#define LOGGING_FULL    // Запись на SD всех данных
//#define LOGGING_DEBUG   // Запись на SD всех данных + статистику расхода и пробега
//#define SECOND_O2SENS   // Включение 2го сенсора кислорода для V движков
#define DEBUG_OUTPUT false // for debug option - swith output to Serial

//DEFINE пинов под входы-выходы
#define LED_PIN         6
#define OX_PIN          0 // A0 для сенсора кислорода
#define TT_PIN          1 // A1 для сенсора ТТ АКПП
#define ENGINE_DATA_PIN 2 // D2 VF1 PIN
#define TOGGLE_BTN_PIN  7 // D7 batton A PIN
#define TOGGLE_BTN_PINb 6 // D6 batton B PIN
#define INJECTOR_PIN    3 // D3 Номер ноги для форсунки
#define SS              5 // D5 Номер ноги SS SD модуля

//DEFINE констант расходомера
#define Ls 0.055         // производительсность форсунки литров в секунду // базовый 0.004 или 240cc
#define Ncyl 4           // кол-во цилиндров

//DEFINE модуля записи на SD карту
//#define FILE_BASE_NAME &quot;Data&quot;   //шаблон имени файла
//#define error(msg) sd.errorHalt(&amp;Serial,F(msg)) //ошибки при работе с SD

//DEFINE OBD READER
#define  MY_HIGH  HIGH //LOW    //Инвертировать линию Eng с помощью оптосоединителя, если у вас нет, то измените эти определения low &amp; high на противоположные.
#define  MY_LOW   LOW //HIGH
#define  TOYOTA_MAX_BYTES  24
#define OBD_INJ 1      //Injector pulse width (INJ)   Длительность импульса инжектора
#define OBD_IGN 2      //Ignition timing angle (IGN)  Угол опережения зажигания
#define OBD_IAC 3      //Idle Air Control (IAC)       Контроль холостого хода Воздуха
#define OBD_RPM 4      //Engine speed (RPM)           Частота вращения двигателя
#define OBD_MAP 5      //Manifold Absolute Pressure (MAP)  Абсолютное давление в коллекторе
#define OBD_ECT 6      //Engine Coolant Temperature (ECT)  Температура охлаждающей жидкости двигателя
#define OBD_TPS 7      //Throttle Position Sensor (TPS)    Датчик положения дроссельной заслонки
#define OBD_SPD 8      //Speed (SPD)                       Скорость
#define OBD_OXSENS 9   // Лямбда 1
#ifdef SECOND_O2SENS
#define OBD_OXSENS2 10 // Лямбда 2 на V-образных движка. У меня ее нету.
#endif

// I2C address of the TCA 9548
#define TCAADDR 0x70
// display channels on TCA 9548
#define DISPLAY_0  
#define DISPLAY_1  

// For each display, create a separate instance.

U8GLIB_SSD1306_128X64 u8g_0(U8G_I2C_OPT_NONE);    // Display #0
U8GLIB_SSD1306_128X64 u8g_1(U8G_I2C_OPT_NONE);    // Display #1

// Установка выводов
const int dirPin = 28;
const int stepPin = 26;
const int en = 30;          // this connection is not needed. 
const int stepsperevolution = 300;

// modified for tach stepper and controller
AccelStepper tachStepper(AccelStepper::DRIVER, stepPin, dirPin);           // works for a4988 (Bipolar, constant current, step/direction driver)
const long STEPS_PER_REVOLUTION = 315;     // for the VID2905 stepper
// Set this value based on a4988 configuration. 
// 1 = full step, 2 = 1/2 step, 4 = 1/4 step, 8 = 1/8 step  
const int uSteps = 2;   // micro step rate
const int MAX_RPM_RANGE = 7000;      // Maximum RPM range to display for your car

//SdFat sd;
//SdFile file;

MD_KeySwitch S(TOGGLE_BTN_PIN, HIGH);
byte CurrentDisplayIDX = 1, TT_last = 0, TT_curr = 0;
float total_fuel_consumption = 0, trip_fuel_consumption = 0;
float trip_avg_fuel_consumption;
float cycle_obd_inj_dur = 0;
float cycle_trip = 0;
float trip_inj_dur = 0;
float total_inj_dur_ee = 0;
float current_trip = 0;
float total_trip = 0;
float all_trip_b = 0;
float all_fuel_b = 0;
float total_avg_consumption;
float total_avg_speed;
float trip_avg_speed;

unsigned long current_time = 0;
unsigned long total_time = 0;
unsigned long t;
unsigned long last_log_time = 0;
unsigned long odometer;
bool flagNulSpeed = true;
unsigned int OX, TT;

volatile uint8_t ToyotaNumBytes, ToyotaID, ToyotaData[TOYOTA_MAX_BYTES];
volatile uint16_t ToyotaFailBit = 0;
boolean LoggingOn = false; // dfeine connection flag and last success packet - for lost connection function.

void setup() {
//  char fileName[13] = FILE_BASE_NAME &quot;00.csv&quot;;
//  const uint8_t BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;
//  noInterrupts();
  Serial.begin(115200);
  delay(100);
  
  //EEPROM.put(200, odometer); запись значения одометра
  EEPROM.get(104, total_trip);
  EEPROM.get(108, total_time);
  EEPROM.get(200, odometer);
  EEPROM.get(204, total_inj_dur_ee);
  EEPROM.get(50, all_trip_b);
  EEPROM.get(58, all_fuel_b);
  analogReference(EXTERNAL);

// NOTE!!! VERY IMPORTANT!!!
// Must call this once manually before first call to TCAselect()
  Wire.begin();
  
// Call TCAselect to set the channel.
  TCAselect(DISPLAY_0); // TCA channel for display 0
  u8g_0.begin();        // use the default values
  u8g_0.setFont(u8g_font_profont15r);    // I am guessing about this initialization????!!!!!

  TCAselect(DISPLAY_1); // TCA channel for display 1
  u8g_1.begin();        // use the default values
  u8g_1.setFont(u8g_font_profont15r);    // I am guessing about this initialization????!!!!!

  S.begin();
  S.enableDoublePress(true);
  S.enableLongPress(true);
  S.enableRepeat(false);
  S.enableRepeatResult(false);
  S.setDoublePressTime(300);
  S.setLongPressTime(2000);
//u8g.setFont(u8g_font_profont15r);
  if (DEBUG_OUTPUT) {
    Serial.println(&quot;system Started&quot;);
    Serial.println(&quot;Read float from EEPROM: &quot;);
    Serial.print(&quot;total_trip &quot;);
    Serial.println(total_trip, 3);
    Serial.print(&quot;total_time &quot;);
    Serial.println(total_time, 3);
    Serial.print(&quot;odometer &quot;);
    Serial.println(odometer, 1);
    Serial.print(&quot;total_inj_dur_ee &quot;);
    Serial.println(total_inj_dur_ee, 3);
    Serial.print(&quot;all_fuel_b &quot;);
    Serial.println(all_fuel_b, 3);
    Serial.print(&quot;all_trip_b &quot;);
    Serial.println(all_trip_b, 3);
    }

/*
  if (!sd.begin(SS, SPI_FULL_SPEED )) {
    sd.initErrorHalt(&amp;Serial);
  }
  if (BASE_NAME_SIZE &gt; 6) {
    error(&quot;FILE_BASE_NAME too long&quot;);
  }
  if (sd.exists(&quot;Data99.csv&quot;)) //очистка SD карты если логов более 99 штук
  {
    u8g.setFont(u8g_font_profont15r);
    u8g.firstPage();
    do {
      u8g.drawStr( 0, 17, &quot;WIPE DATA!&quot; );
    } while ( u8g.nextPage() );

    if (!sd.wipe()) {
      sd.errorHalt(&quot;Wipe failed.&quot;);
    }
    if (!sd.begin(SS, SPI_FULL_SPEED )) {
      sd.initErrorHalt();
    }
  }

  while (sd.exists(fileName)) {
    if (fileName[BASE_NAME_SIZE + 1] != &#039;9&#039;) {
      fileName[BASE_NAME_SIZE + 1]++;
    } else if (fileName[BASE_NAME_SIZE] != &#039;9&#039;) {
      fileName[BASE_NAME_SIZE + 1] = &#039;0&#039;;
      fileName[BASE_NAME_SIZE]++;
    } else {
      error(&quot;Can&#039;t create file name&quot;);
    }
  }

  if (!file.open(fileName, O_CREAT | O_WRITE  | O_EXCL)) {
    error(&quot;file.open&quot;);
  }
  writeHeader();
*/
  tachStepper.setMaxSpeed(250 * uSteps);          // these valuses seem to work for VID2905
  tachStepper.setAcceleration(250 * uSteps);
  tachStepper.runToNewPosition(-300 * uSteps);    // move to zero position
 //tachStepper.setCurrentPosition(0);              // set as 0 rpm reference
 //tachStepper.runToNewPosition(300 * uSteps);     // move needle full scale
  tachStepper.runToNewPosition(10 * uSteps);      // now move needle almost to zero  -- tach is ready to use.
  delay(1000);
  
  pinMode(ENGINE_DATA_PIN, INPUT); // VF1 PIN
  pinMode(LED_PIN, OUTPUT);
  attachInterrupt(digitalPinToInterrupt(ENGINE_DATA_PIN), ChangeState, CHANGE); //setup Interrupt for data line  Настройка прерывания для линии передачи данных
  pinMode(TOGGLE_BTN_PIN, INPUT);           // кнопка СЛЕД. ЭКРАН
  CurrentDisplayIDX = 1; // set to display 1
  drawScreenSelector();
  //Расходомер
  t = millis();
  last_log_time = millis();
  interrupts();
  delay(1000);
} // END VOID SETUP

void loop(void) {
  unsigned long new_t;
  unsigned int diff_t;
  switch (S.read())
  {
    case MD_KeySwitch::KS_NULL:  break;
    case MD_KeySwitch::KS_PRESS: ent(); break;
    case MD_KeySwitch::KS_DPRESS:break;
    //{
    //  if (LoggingOn == false) LoggingOn = true; else LoggingOn = false;
    //  } break;
    case MD_KeySwitch::KS_LONGPRESS: {
        if (CurrentDisplayIDX == 5) cleardataB(); else cleardata();
         } break; 
      
    case MD_KeySwitch::KS_RPTPRESS: break;
  }

  if (ToyotaNumBytes &gt; 0)  {    // if found bytes
    new_t = millis();
    tachStepper.moveTo((long)(map(getOBDdata(OBD_RPM), 0, MAX_RPM_RANGE, 1, STEPS_PER_REVOLUTION * uSteps * 2)));
    if (new_t &gt; t &amp;&amp; getOBDdata(OBD_RPM) &gt; 100 ) {// выполняем только когда на работающем двигателе
      diff_t = new_t - t;
      cycle_obd_inj_dur = getOBDdata(OBD_RPM) / 60000 * Ncyl * (float)diff_t  * getOBDdata(OBD_INJ); //Время открытых форсунок за 1 такт данных. В МС
      //ОБ/М           ОБ/С
      //форсунка срабатывает раз в 2 оборота КВ
      //6форсунок в с
      //время цикла мс в с. Получаем кол-во срабатываний за время цикла. Умножаем на время открытия форсунки, получаем время открытия 6 форсунок В МИЛЛИСЕКУНДАХ
        
         
      trip_inj_dur += cycle_obd_inj_dur;           //Время открытых форсунок за поездку        В МС
      total_inj_dur_ee += cycle_obd_inj_dur;       //Время открытых форсунок за все время. EEPROM    В МС

      trip_fuel_consumption = trip_inj_dur / 1000 * Ls;       //потребление топлива за поездку в литрах
      total_fuel_consumption = total_inj_dur_ee / 1000 * Ls;  //потребление топлива за все время. Из ЕЕПРОМ в литрах


      cycle_trip = (float)diff_t / 3600000 * getOBDdata(OBD_SPD);   //расстояние пройденное за такт обд данных
      current_trip += cycle_trip;  //Пройденное расстояние с момента включения. В КМ
      total_trip += cycle_trip;    //Полное пройденное расстояние. EEPROM. В КМ
      odometer += cycle_trip;      //электронный одометр. Хранится в еепром и не стирается кнопкой
      current_time += diff_t;      //Время в пути в миллисекундах с момента включения
      total_time += diff_t;        //полное пройденное время в миллисекундах лимит ~49 суток. EEPROM

      trip_avg_speed = current_trip / (float)current_time * 3600000 ;       //средняя скорость за поездку
      total_avg_speed = total_trip / (float)total_time * 3600000;           // средняя скорость за все время. км\ч
      trip_avg_fuel_consumption = 100 * trip_fuel_consumption / current_trip; //средний расход за поездку
      total_avg_consumption = 100 * total_fuel_consumption / total_trip;      //среднее потребление за все время - Л на 100км
      
      all_trip_b += cycle_trip ;        //Полное пройденное расстояние. EEPROM. В КМ
      all_fuel_b += cycle_obd_inj_dur;  //Время открытых форсунок за все время. EEPROM    В МС
     
      t = new_t;//тест

    //  if (LoggingOn == true) logData(); //запись в лог данных по двоному нажатию на кнопку

      updateEepromData();   //запись данных при остановке

      if (millis() - last_log_time &gt; 180000) {  //Запись данных в EEPROM каждые 3 минуты. Чтобы не потерять данные при движении на трассе
        EEPROM.put(104, total_trip);
        EEPROM.put(108, total_time);
        EEPROM.put(200, odometer);
        EEPROM.put(204, total_inj_dur_ee);
        EEPROM.put(50, all_trip_b);
        EEPROM.put(58, all_fuel_b);
        
        last_log_time = millis();
      }
    }
    drawScreenSelector();   // draw screen
    ToyotaNumBytes = 0;     // reset the counter.
  } // end if (ToyotaNumBytes &gt; 0)
  tachStepper.run();
 /* if (millis() % 50 == 0 &amp;&amp; LoggingOn == true &amp;&amp; CurrentDisplayIDX == 6) { //каждые 50мс, когда включено логирование и выбран экран с флагами(!)
    OX = analogRead(OX_PIN);
    if (OX &lt; 400) { //исключаю ложные показание &gt; ~1.3В
      file.write(&#039;;&#039;);
      file.print(((float)OX * VREF_MEASURED) / 1024, 3 );
      file.println();
    }
  }
  if (millis() % 500 == 0) {  //каждые пол секунды читаем состояние АКПП
    TT = analogRead(TT_PIN);
    TT_curr = (int)(TT * VREF_MEASURED / 1024 * 3.13 + 0.5);
    if (TT_last != TT_curr) {
      drawScreenSelector();
      TT_last = TT_curr;
    }
    //Serial.println((float)TT * VREF_MEASURED / 1024 * 3.13, 3);
    // Serial.println((int)(TT * VREF_MEASURED / 1024 * 3.13+0.5));
  }
*/
//if (millis() % 5000 &lt; 50) autoscreenchange();      // ротация экранов
}

void updateEepromData() {
  if (getOBDdata(OBD_SPD) == 0 &amp;&amp; flagNulSpeed == false)  {   //Запись данных в еепром когда остановка авто
    EEPROM.put(104, total_trip);
    EEPROM.put(108, total_time);
    EEPROM.put(200, odometer);
    EEPROM.put(204, total_inj_dur_ee);
    EEPROM.put(50, all_trip_b);
    EEPROM.put(58, all_fuel_b);
    flagNulSpeed = true;                                  //запрет повторной записи
    last_log_time = millis();                             //чтобы не писать лишний раз
  }
  if (getOBDdata(OBD_SPD) != 0) flagNulSpeed = false;     //начали двигаться - разрешаем запись
}

void cleardata() {
  int i;
  for (i = 104; i &lt;= 112; i++) {
  EEPROM.update(i, 0);
  }
  for (i = 200; i &lt;= 208; i++) {
  EEPROM.update(i, 0);
  }
  EEPROM.get(104, total_trip);
  EEPROM.get(108, total_time);
  EEPROM.get(204, total_inj_dur_ee);

}

void cleardataB () {
  int i;
  for (i = 50; i &lt;= 62; i++) {
  EEPROM.update(i, 0);
  }

  EEPROM.get(50, all_trip_b);
  EEPROM.get(58, all_fuel_b);
  
}

/*void writeHeader() {
#ifdef LOGGING_FULL
  file.print(F(&quot;;OX_RAW;INJ TIME;IGN;IAC;RPM;MAP;ECT;TPS;SPD;VF1;OX;ASE;COLD;KNOCK;OPEN LOOP;Acceleration Enrichment;STARTER;IDLE;A/C;NEUTRAL;AVG SPD;LPK_OBD;LPH_OBD;TOTAL_OBD;AVG_OBD;CURR_OBD;CURR_RUN;total_trip&quot;));
#endif
#ifdef LOGGING_DEBUG
  file.print(F(&quot;;OX_RAW;INJ TIME;IGN;IAC;RPM;MAP;ECT;TPS;SPD;VF1;OX;AVG SPD;LPK_OBD;LPH_OBD;TOTAL_OBD;AVG_OBD;CURR_OBD;CURR_RUN;total_trip&quot;));
#endif
#ifdef LOGGING_MINIMAL
  file.print(F(&quot;;OX_RAW;INJ TIME;IGN;IAC;RPM;MAP;ECT;TPS;SPD;VF1;OX;LPH_OBD&quot;));
#endif
  file.println();
  file.sync();
}
*/
//обнуление данных


/*void logData() {
  file.print(float(millis()) / 60000, 3); file.write(&#039;;&#039;)   ; file.write(&#039;;&#039;);
  file.print(getOBDdata(OBD_INJ)); file.write(&#039;;&#039;); file.print(getOBDdata(OBD_IGN));  file.write(&#039;;&#039;);  file.print(getOBDdata(OBD_IAC));  file.write(&#039;;&#039;);
  file.print(getOBDdata(OBD_RPM)); file.write(&#039;;&#039;); file.print(getOBDdata(OBD_MAP));  file.write(&#039;;&#039;); file.print(getOBDdata(OBD_ECT));  file.write(&#039;;&#039;);
  file.print(getOBDdata(OBD_TPS)); file.write(&#039;;&#039;);  file.print(getOBDdata(OBD_SPD));  file.write(&#039;;&#039;); file.print(getOBDdata(OBD_OXSENS)); file.write(&#039;;&#039;); file.print(getOBDdata(20)); file.write(&#039;;&#039;);
#ifdef LOGGING_FULL
  file.print(getOBDdata(11)); file.write(&#039;;&#039;); file.print(getOBDdata(12)); file.write(&#039;;&#039;); file.print(getOBDdata(13)); file.write(&#039;;&#039;); file.print(getOBDdata(14)); file.write(&#039;;&#039;);
  file.print(getOBDdata(15)); file.write(&#039;;&#039;); file.print(getOBDdata(16)); file.write(&#039;;&#039;); file.print(getOBDdata(17)); file.write(&#039;;&#039;); file.print(getOBDdata(18)); file.write(&#039;;&#039;);
  file.print(getOBDdata(19)); file.write(&#039;;&#039;);
#endif
#ifdef  LOGGING_DEBUG
  // file.print(total_avg_speed); file.write(&#039;;&#039;);                                                                   //AVG_SPD       ok
  // file.print(100 / getOBDdata(OBD_SPD) * (getOBDdata(OBD_INJ) * getOBDdata(OBD_RPM)*Ls * 0.18)); file.write(&#039;;&#039;);  //LPK_OBD      ok
#endif
  file.print(getOBDdata(OBD_INJ) * getOBDdata(OBD_RPM)*Ls * 0.18); file.write(&#039;;&#039;);                                //LPH_OBD    ok
#ifdef LOGGING_DEBUG
  //file.print(total_fuel_consumption); file.write(&#039;;&#039;);   //TOTAL_OBD     ok
  //file.print(trip_avg_fuel_consumption); file.write(&#039;;&#039;);   //!AVG_OBD
  //file.print(trip_fuel_consumption); file.write(&#039;;&#039;);  //!CURR_OBD
  //file.print(current_trip);   file.write(&#039;;&#039;);    //CURR_RUN ok
  //file.print(total_trip); file.write(&#039;;&#039;);//RUN_TOTAL      ok
#endif
  file.println();
  file.sync();
}
*/
void drawScreenSelector(void) {
  if (CurrentDisplayIDX == 1) DrawCurrentFuelConsuption();
  else if (CurrentDisplayIDX == 2) drawTripTimeDistance();
  else if (CurrentDisplayIDX == 3) drawTimeDistance();
  else if (CurrentDisplayIDX == 4) DrawTotalFuelConsuption();
  else if (CurrentDisplayIDX == 5) drawTotalFuelDistanceB();
  else if (CurrentDisplayIDX == 6) drawAllData();
  else if (CurrentDisplayIDX == 7) drawExtraData();
} // end drawScreenSelector()

void DrawCurrentFuelConsuption(void) {
  TCAselect(DISPLAY_0);   // this will be displayed on display 0
  u8g_0.setFont(u8g_font_profont15r);
  u8g_0.firstPage();
  do {
  u8g_0.setFont(u8g_font_profont15r);
  u8g_0.drawStr( 0, 15, &quot;TRIP&quot; );
  u8g_0.drawStr( 74, 15, &quot;L&quot; );
  u8g_0.setPrintPos(35, 15) ;
  u8g_0.print(trip_fuel_consumption, 1);
  if (LoggingOn == true)  u8g_0.drawHLine(20, 24, 88);
  //  u8g.setPrintPos(90, 20) ;
  //  u8g.print((float)TT * VREF_MEASURED / 1024 * 3.13, 2);
/*
    u8g.setFont(u8g_font_profont22r);
    switch (TT_curr) { //для делителя 10k + 4.7k
      case 0: u8g.drawStr( 95, 20, &quot;1&quot; );   break;
      case 2: u8g.drawStr( 95, 20, &quot;2&quot; ); break;
      case 4: u8g.drawStr( 95, 20, &quot;3&quot; ); break;
      case 5: u8g.drawStr( 95, 20, &quot;3L&quot; ); break;
      case 6: u8g.drawStr( 95, 20, &quot;4&quot; ); break;
      case 7: u8g.drawStr( 95, 20, &quot;4L&quot; ); break;
    }*/
    if (getOBDdata(OBD_SPD) &gt; 1)
    {
      u8g_0.setFont(u8g_font_profont15r);
      u8g_0.drawStr( 0, 42, &quot;L/100Km&quot; );
      u8g_0.setFont(u8g_font_profont22r);
      u8g_0.setPrintPos(0, 60) ;
   // u8g.print( 100 / getOBDdata(OBD_SPD) * (getOBDdata(OBD_INJ) * getOBDdata(OBD_RPM)*Ls * 0.18), 1);
      u8g_0.print( 100 / getOBDdata(OBD_SPD) * (getOBDdata(OBD_INJ)/1000 *Ls*4* getOBDdata(OBD_RPM)*60), 1);
    } else {
      u8g_0.setFont(u8g_font_profont15r);
      u8g_0.drawStr( 0, 42, &quot;L/Hour&quot; );
      u8g_0.setFont(u8g_font_profont22r);
      u8g_0.setPrintPos(0, 60) ;
   // u8g.print(getOBDdata(OBD_INJ) * getOBDdata(OBD_RPM)*Ls * 0.18, 1);
      u8g_0.print(getOBDdata(OBD_INJ)/1000 *Ls*4* getOBDdata(OBD_RPM)*60, 1);
    }
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.drawStr( 60, 42, &quot;Average&quot; );
    u8g_0.setFont(u8g_font_profont22r);
    u8g_0.setPrintPos(60, 60) ;
    if (trip_avg_fuel_consumption &lt; 100)
      u8g_0.print( trip_avg_fuel_consumption, 1);
    else u8g_0.drawStr( 60, 60, &quot;---&quot; );
  }
  while ( u8g_0.nextPage() );
}

void DrawTotalFuelConsuption(void) {
  TCAselect(DISPLAY_1);   // this will be displayed on display 1
  u8g_1.setFont(u8g_font_profont15r);
  u8g_1.firstPage();
  do {
    u8g_1.setFont(u8g_font_profont15r);
    u8g_1.drawStr( 0, 15, &quot;TOTAL&quot; );
 // u8g.drawStr( 74, 15, &quot;L&quot; );
    u8g_1.drawStr( 42, 15, &quot;Liters&quot; );
   
  //  u8g.setPrintPos(42, 15) ;
  //  u8g.print(total_fuel_consumption, 1);
      if (LoggingOn == true)  u8g_1.drawHLine(20, 24, 88);
   // u8g.setFont(u8g_font_profont22r);
   // switch (TT_curr) { //для делителя 10k + 4.7k
    // case 0: u8g.drawStr( 95, 20, &quot;1&quot; ); break;
    // case 2: u8g.drawStr( 95, 20, &quot;2&quot; ); break;
    // case 4: u8g.drawStr( 95, 20, &quot;3&quot; ); break;
    // case 5: u8g.drawStr( 95, 20, &quot;3L&quot; ); break;
    // case 6: u8g.drawStr( 95, 20, &quot;4&quot; ); break;
    // case 7: u8g.drawStr( 95, 20, &quot;4L&quot; ); break;
    // }
   
   // if (getOBDdata(OBD_SPD) &gt; 1)
   // {
      u8g_1.setFont(u8g_font_profont15r);
  //  u8g.drawStr( 0, 42, &quot;L/100Km&quot; );
      u8g_1.drawStr( 0, 42, &quot;All&quot; );
      u8g_1.setFont(u8g_font_profont22r);
      u8g_1.setPrintPos(0, 60) ;
      u8g_1.print(total_fuel_consumption, 1);
     // u8g.print( 100 / getOBDdata(OBD_SPD) * (getOBDdata(OBD_INJ) * getOBDdata(OBD_RPM)*Ls * 0.18), 1);
     // u8g.print( 100 / getOBDdata(OBD_SPD) * (getOBDdata(OBD_INJ) *Ls*4* getOBDdata(OBD_RPM)*60), 1);
     // } else {
     // u8g.setFont(u8g_font_profont15r);
     // u8g.drawStr( 0, 42, &quot;L/Hour&quot; );
     // u8g.setFont(u8g_font_profont22r);
     // u8g.setPrintPos(0, 60) ;
     // u8g.print(getOBDdata(OBD_INJ) * getOBDdata(OBD_RPM)*Ls * 0.18, 1);
     // u8g.print(getOBDdata(OBD_INJ) *Ls*4* getOBDdata(OBD_RPM)*60, 1);
     // }
    
    u8g_1.setFont(u8g_font_profont15r);
    u8g_1.drawStr( 60, 42, &quot;Average&quot; );
    u8g_1.setFont(u8g_font_profont22r);
    u8g_1.setPrintPos(60, 60) ;
    if (total_avg_consumption &lt; 100)
    u8g_1.print( total_avg_consumption, 1);
    else u8g_1.drawStr( 60, 60, &quot;---&quot; );
  }
  while ( u8g_1.nextPage() );
}

void drawTimeDistance(void) {
  TCAselect(DISPLAY_0);   // this will be displayed on display 0
  u8g_0.setFont(u8g_font_profont15r);
  u8g_0.firstPage();
  do {
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.drawStr( 0, 15, &quot;TOTAL&quot; );
    u8g_0.drawStr( 90, 15, &quot;KM&quot; );
    u8g_0.setPrintPos(44, 15) ;
    u8g_0.print(total_trip, 1);
    if (LoggingOn == true)  u8g_0.drawHLine(20, 24, 88);
    u8g_0.setFont(u8g_font_profont22r);
   //  switch (TT_curr) { //для делителя 10k + 4.7k
   //  case 0: u8g.drawStr( 95, 20, &quot;1&quot; ); break;
   //  case 2: u8g.drawStr( 95, 20, &quot;2&quot; ); break;
   //  case 4: u8g.drawStr( 95, 20, &quot;3&quot; ); break;
   //  case 5: u8g.drawStr( 95, 20, &quot;3L&quot; ); break;
   //  case 6: u8g.drawStr( 95, 20, &quot;4&quot; ); break;
   //  case 7: u8g.drawStr( 95, 20, &quot;4L&quot; ); break;
   // }
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.drawStr( 0, 42, &quot;Avg SPD&quot; );
    u8g_0.setFont(u8g_font_profont22r);
    u8g_0.setPrintPos(0, 60) ;
    u8g_0.print(total_avg_speed, 1);
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.drawStr( 60, 42, &quot;Time (M)&quot; );
    u8g_0.setFont(u8g_font_profont22r);
    u8g_0.setPrintPos(60, 60) ;
    u8g_0.print( float(total_time) / 60000, 1);
  }
  while ( u8g_0.nextPage() );
}

void drawTripTimeDistance(void) {
  TCAselect(DISPLAY_0);   // this will be displayed on display 0
  u8g_0.setFont(u8g_font_profont15r);
  u8g_0.firstPage();
  do {
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.drawStr( 0, 15, &quot;TRIP&quot; );
    u8g_0.drawStr( 90, 15, &quot;KM&quot; );
    u8g_0.setPrintPos(44, 15) ;
    u8g_0.print(current_trip, 1);
    if (LoggingOn == true)  u8g_0.drawHLine(20, 24, 88);
    u8g_0.setFont(u8g_font_profont22r);
   // switch (TT_curr) { //для делителя 10k + 4.7k
   // case 0: u8g.drawStr( 95, 20, &quot;1&quot; ); break;
   // case 2: u8g.drawStr( 95, 20, &quot;2&quot; ); break;
   // case 4: u8g.drawStr( 95, 20, &quot;3&quot; ); break;
   // case 5: u8g.drawStr( 95, 20, &quot;3L&quot; ); break;
   // case 6: u8g.drawStr( 95, 20, &quot;4&quot; ); break;
   // case 7: u8g.drawStr( 95, 20, &quot;4L&quot; ); break;
   //  }
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.drawStr( 0, 42, &quot;Avg SPD&quot; );
    u8g_0.setFont(u8g_font_profont22r);
    u8g_0.setPrintPos(0, 60) ;
    u8g_0.print(trip_avg_speed, 1);
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.drawStr( 60, 42, &quot;Time (M)&quot; );
    u8g_0.setFont(u8g_font_profont22r);
    u8g_0.setPrintPos(60, 60) ;
    u8g_0.print( float(current_time) / 60000, 1);
  }
  while ( u8g_0.nextPage() );
}

void drawTotalFuelDistanceB(void)  //-----------TRIP B
{
  TCAselect(DISPLAY_0);   // this will be displayed on display 0
  u8g_0.setFont(u8g_font_profont15r);
  u8g_0.firstPage();
  do {
  u8g_0.setFont(u8g_font_profont15r);
  //u8g.drawStr( 0, 6, &quot;TOTAL&quot; );
  //u8g.drawStr( 74, 15, &quot;L&quot; );
  //u8g.drawStr( 20, 15, &quot;All Trip B&quot; );
   
 
    if (LoggingOn == true)  u8g_0.drawHLine(20, 24, 88);
  
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.drawStr( 0, 47, &quot;Km&quot; );
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.setPrintPos(40, 47) ;
    u8g_0.print(all_trip_b, 1);
    
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.drawStr( 0, 63, &quot;Lit&quot; );
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.setPrintPos(40, 63) ;
    u8g_0.print( all_fuel_b/ 1000 * Ls, 1);
    
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.drawStr( 0, 30, &quot;L/100&quot; );
    u8g_0.setFont(u8g_font_profont15r);
    u8g_0.setPrintPos(40, 30) ;
    u8g_0.print(  all_fuel_b / 1000 * Ls * 100 / all_trip_b , 1);
  }
  while ( u8g_0.nextPage() );
}
//}


void drawAllData(void) {
  // graphic commands to redraw the complete screen should be placed here
  TCAselect(DISPLAY_0);   // this will be displayed on display 0
  u8g_0.setFont(u8g_font_profont15r);
  u8g_0.firstPage();
  do {
    u8g_0.drawStr( 0, 17, &quot;INJ&quot; );
    u8g_0.setPrintPos(25, 17) ;
    u8g_0.print(getOBDdata(OBD_INJ));

    u8g_0.drawStr( 0, 32, &quot;IGN&quot;);
    u8g_0.setPrintPos(25, 32) ;
    u8g_0.print( int(getOBDdata(OBD_IGN)));

    u8g_0.drawStr( 0, 47, &quot;IAC&quot;);
    u8g_0.setPrintPos(25, 47) ;
    u8g_0.print( int(getOBDdata(OBD_IAC)));

    u8g_0.drawStr( 0, 62, &quot;RPM&quot;);
    u8g_0.setPrintPos(25, 62) ;
    u8g_0.print( int(getOBDdata(OBD_RPM)));

    u8g_0.drawStr( 65, 17, &quot;MAP&quot; );
    u8g_0.setPrintPos(92, 17) ;
    u8g_0.print( int(getOBDdata(OBD_MAP)));

    u8g_0.drawStr( 65, 32, &quot;ECT&quot;);
    u8g_0.setPrintPos(92, 32) ;
    u8g_0.print( int(getOBDdata(OBD_ECT)));

    u8g_0.drawStr( 65, 47, &quot;TPS&quot;);
    u8g_0.setPrintPos(92, 47) ;
    u8g_0.print( int(getOBDdata(OBD_TPS)));

    u8g_0.drawStr( 65, 62, &quot;SPD&quot;);
    u8g_0.setPrintPos(92, 62) ;
    u8g_0.print( int(getOBDdata(OBD_SPD)));

    u8g_0.drawVLine(63, 0, 64);
  } while ( u8g_0.nextPage() ); // end picture loop
} // end void drawalldata

void autoscreenchange() {
  CurrentDisplayIDX++;
  if (CurrentDisplayIDX &gt; 3) CurrentDisplayIDX = 1;
  drawScreenSelector();
}
void ent() {//ПЕРЕКЛЮЧЕНИЕ ЭКРАНОВ
  CurrentDisplayIDX++;
  if (CurrentDisplayIDX &gt; 7) CurrentDisplayIDX = 1;
  drawScreenSelector();
}

float getOBDdata(byte OBDdataIDX) {
  float returnValue;
  switch (OBDdataIDX) {
    case 0:// UNKNOWN
      returnValue = ToyotaData[0];
      break;
    case OBD_INJ: //  Время впрыска форсунок  =X*0.125 (мс) (x / 8)
      returnValue = ToyotaData[OBD_INJ] / 8 ;  //* 0.125; //Время впрыска форсунок x/10
      break;
    case OBD_IGN: // Угол опережения зажигания X*0.47-30 (град)
      returnValue = ToyotaData[OBD_IGN] * 0.47 - 30;
      break;
    case OBD_IAC: //  Состояние клапана ХХ Для разных типов КХХ разные формулы: X/255*100 (%)
      //  X (шаг)
      returnValue = ToyotaData[OBD_IAC] * 0.39215; ///optimize divide
      break;
    case OBD_RPM: //Частота вращения коленвала X*25(об/мин)
      returnValue = ToyotaData[OBD_RPM] * 25;
      break;
    case OBD_MAP: //Расходомер воздуха (MAP/MAF)
      //  X*0.6515 (кПа)
      //  X*4.886 (мм.ртут.столба)
      //  X*0.97 (кПа) (для турбомоторов)
      //  X*7.732 (мм.рт.ст) (для турбомоторов)
      //  x*2(гр/сек) (данная формула для MAF так и не найдена)
      //  X/255*5 (Вольт) (напряжение на расходомере)
      returnValue = ToyotaData[OBD_MAP] * 4.886; //MAF
      break;
    case OBD_ECT: // Температура двигателя (ECT)
      // В зависимости от величины Х разные формулы:
      // 0..14:          =(Х-5)*2-60
      // 15..38:        =(Х-15)*0.83-40
      // 39..81:        =(Х-39)*0.47-20
      // 82..134:      =(Х-82)*0.38
      // 135..179:    =(Х-135)*0.44+20
      // 180..209:    =(Х-180)*0.67+40
      // 210..227:    =(Х-210)*1.11+60
      // 228..236:    =(Х-228)*2.11+80
      // 237..242:    =(Х-237)*3.83+99
      // 243..255:    =(Х-243)*9.8+122
      // Температура в градусах цельсия.
      if (ToyotaData[OBD_ECT] &gt;= 243)
        returnValue = ((float)(ToyotaData[OBD_ECT] - 243) * 9.8) + 122;
      else if (ToyotaData[OBD_ECT] &gt;= 237)
        returnValue = ((float)(ToyotaData[OBD_ECT] - 237) * 3.83) + 99;
      else if (ToyotaData[OBD_ECT] &gt;= 228)
        returnValue = ((float)(ToyotaData[OBD_ECT] - 228) * 2.11) + 80.0;
      else if (ToyotaData[OBD_ECT] &gt;= 210)
        returnValue = ((float)(ToyotaData[OBD_ECT] - 210) * 1.11) + 60.0;
      else if (ToyotaData[OBD_ECT] &gt;= 180)
        returnValue = ((float)(ToyotaData[OBD_ECT] - 180) * 0.67) + 40.0;
      else if (ToyotaData[OBD_ECT] &gt;= 135)
        returnValue = ((float)(ToyotaData[OBD_ECT] - 135) * 0.44) + 20.0;
      else if (ToyotaData[OBD_ECT] &gt;= 82)
        returnValue = ((float)(ToyotaData[OBD_ECT] - 82) * 0.38);
      else if (ToyotaData[OBD_ECT] &gt;= 39)
        returnValue = ((float)(ToyotaData[OBD_ECT] - 39) * 0.47) - 20.0;
      else if (ToyotaData[OBD_ECT] &gt;= 15)
        returnValue = ((float)(ToyotaData[OBD_ECT] - 15) * 0.83) - 40.0;
      else
        returnValue = ((float)(ToyotaData[OBD_ECT] - 15) * 2.0) - 60.0;
      break;
    case OBD_TPS: // Положение дроссельной заслонки
      // X/2(градусы)
      // X/1.8(%)
      returnValue = ToyotaData[OBD_TPS] / 1.8;
      break;
    case OBD_SPD: // Скорость автомобиля (км/час)
      returnValue = ToyotaData[OBD_SPD];
      break;
  //  Коррекция для рядных/ коррекция первой половины
    case OBD_OXSENS:
      returnValue = (float)ToyotaData[OBD_OXSENS] * 0.01953125;
      break;

#ifdef SECOND_O2SENS
    case OBD_OXSENS2:// Lambda2 tst
      returnValue = (float)ToyotaData[OBD_OXSENS2] * 0.01953125;
      break;
#endif

    //  читаем Байты флагов побитно
    case 11:
      returnValue = bitRead(ToyotaData[11], 0); //Переобогащение после запуска 1-Вкл
      break;
    case 12:
      returnValue = bitRead(ToyotaData[11], 1); //Холодный двигатель 1-Да
      break;
    case 13:
      returnValue = bitRead(ToyotaData[11], 4); //Детонация 1-Да
      break;
    case 14:
      returnValue = bitRead(ToyotaData[11], 5); //Обратная связь по лямбда зонду 1-Да
      break;
    case 15:
      returnValue = bitRead(ToyotaData[11], 6); //Дополнительное обогащение 1-Да
      break;
    case 16:
      returnValue = bitRead(ToyotaData[12], 0); //Стартер 1-Да
      break;
    case 17:
      returnValue = bitRead(ToyotaData[12], 1); //Признак ХХ (Дроссельная заслонка) 1-Да(Закрыта)
      break;
    case 18:
      returnValue = bitRead(ToyotaData[12], 2); //Кондиционер 1-Да
      break;
    case 19:
      returnValue = bitRead(ToyotaData[12], 3); //Нейтраль 1-Да
      break;
    case 20:
      returnValue = bitRead(ToyotaData[12], 4); //Смесь  первой половины 1-Богатая, 0-Бедная
      break;

#ifdef SECOND_O2SENS //Вторая лябмда для Vобразных движков
    case 21:
      returnValue = bitRead(ToyotaData[12], 5); //Смесь второй половины 1-Богатая, 0-Бедная
      break;
#endif

    default: // DEFAULT CASE (in no match to number)
   // send &quot;error&quot; value
      returnValue =  9999.99;
  } // end switch
  // send value back
  return returnValue;
} // end void getOBDdata


void ChangeState() {
  static uint8_t ID, EData[TOYOTA_MAX_BYTES];
  static boolean InPacket = false;
  static unsigned long StartMS;
  static uint16_t BitCount;
  int state = digitalRead(ENGINE_DATA_PIN);
  digitalWrite(LED_PIN, state);
    if (InPacket == false)  {
    if (state == MY_HIGH)   {
      StartMS = millis();
    }   else   { // else  if (state == MY_HIGH)
    if ((millis() - StartMS) &gt; (15 * 8))   {
        StartMS = millis();
        InPacket = true;
        BitCount = 0;
      } // end if  ((millis() - StartMS) &gt; (15 * 8))
    } // end if  (state == MY_HIGH)
  }  else   { // else  if (InPacket == false)
    uint16_t bits = ((millis() - StartMS) + 1 ) / 8; // The +1 is to cope with slight time errors
    StartMS = millis();
    // process bits
    while (bits &gt; 0)  {
    if (BitCount &lt; 4)  {
    if (BitCount == 0)
          ID = 0;
        ID &gt;&gt;= 1;
    if (state == MY_LOW)  // inverse state as we are detecting the change!
          ID |= 0x08;
      }   else    { // else    if (BitCount &lt; 4)
        uint16_t bitpos = (BitCount - 4) % 11;
        uint16_t bytepos = (BitCount - 4) / 11;
    if (bitpos == 0)      {
          // Start bit, should be LOW
    if ((BitCount &gt; 4) &amp;&amp; (state != MY_HIGH))  { // inverse state as we are detecting the change!
            ToyotaFailBit = BitCount;
            InPacket = false;
            break;
          } // end if ((BitCount &gt; 4) &amp;&amp; (state != MY_HIGH))
        }  else if (bitpos &lt; 9)  { //else TO  if (bitpos == 0)
          EData[bytepos] &gt;&gt;= 1;
    if (state == MY_LOW)  // inverse state as we are detecting the change!
            EData[bytepos] |= 0x80;
        } else { // else if (bitpos == 0)
          // Stop bits, should be HIGH
    if (state != MY_LOW)  { // inverse state as we are detecting the change!
            ToyotaFailBit = BitCount;
            InPacket = false;
            break;
          } // end if (state != MY_LOW)
    if ( (bitpos == 10) &amp;&amp; ((bits &gt; 1) || (bytepos == (TOYOTA_MAX_BYTES - 1))) ) {
            ToyotaNumBytes = 0;
            ToyotaID = ID;
            for (uint16_t i = 0; i &lt;= bytepos; i++)
              ToyotaData[i] = EData[i];
            ToyotaNumBytes = bytepos + 1;
    if (bits &gt;= 16)  // Stop bits of last byte were 1&#039;s so detect preamble for next packet
              BitCount = 0;
            else  {
              ToyotaFailBit = BitCount;
              InPacket = false;
            }
            break;
          }
        }
      }
      ++BitCount;
      --bits;
    } // end while
  } // end (InPacket == false)
} // end void change

void drawExtraData(void) {
  TCAselect(DISPLAY_0);   // this will be displayed on display 0
  u8g_0.setFont(u8g_font_profont15r);
  u8g_0.firstPage();
  do {
    u8g_0.drawStr( 0, 15, &quot;VF&quot; );
    u8g_0.setPrintPos(25, 15) ;
    u8g_0.print(getOBDdata(OBD_OXSENS), 1);
    if (int(getOBDdata(11)) == 1) {
    u8g_0.drawStr( 0, 30, &quot;ASE&quot;);
    }
    if (int(getOBDdata(12)) == 1) {
    u8g_0.drawStr( 0, 45, &quot;CLD&quot;);
    }
    if (int(getOBDdata(13)) == 1) {
    u8g_0.drawStr( 0, 60, &quot;KNK&quot;);
    }
    if (int(getOBDdata(14)) == 1) {
    u8g_0.drawStr( 40, 30, &quot;OL&quot;);
    }
    if (int(getOBDdata(15)) == 1) {
    u8g_0.drawStr( 40, 45, &quot;AE&quot;);
    }
    if (int(getOBDdata(16)) == 1) {
    u8g_0.drawStr( 40, 60, &quot;STA&quot;);
    }
    if (int(getOBDdata(17)) == 1) {
    u8g_0.drawStr( 70, 30, &quot;IDL&quot;);
    }
    if (int(getOBDdata(18)) == 1) {
    u8g_0.drawStr( 70, 45, &quot;A/C&quot;);
    }
    if (int(getOBDdata(19)) == 1) {
    u8g_0.drawStr( 70, 60, &quot;NSW&quot;);
    }
    if (int(getOBDdata(20)) == 0) {
    u8g_0.drawStr(70, 15, &quot;LEAN&quot;);
    } else  {
    u8g_0.drawStr(70, 15, &quot;RICH&quot;);
    }
  }
  while ( u8g_0.nextPage() );
}

// Helper function for changing TCA output channel
// Call this function whenever changing displays.
void TCAselect(uint8_t channel) {
  if (channel &gt; 7) return;
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 &lt;&lt; channel);
  Wire.endTransmission();  
}</code></pre></div>]]></summary>
			<author>
				<name><![CDATA[brat4791]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2065</uri>
			</author>
			<updated>2023-04-13T20:32:51Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=553&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Помогите с приёмником!!!]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=552&amp;action=new" />
			<summary type="html"><![CDATA[<p>Здравствуйте, случилась следующая беда. По данной ссылке ( <a href="http://rcl-radio.ru/?p=53149">http://rcl-radio.ru/?p=53149</a> ) я решил собрать приёмник на чипе RDA5807, Arduino Pro MIni и дисплее 1602. Собираю дисплей и приёмник вместе, загружаю: на экране ничего не выводится, он также мерцает. С монтажом проблем нет, дисплей и приёмник проверял - работают. Если кто - нибудь сталкивался с данной проблемой, помогите пожалуйста с ней.</p><div class="codebox"><pre><code>#include &lt;Wire.h&gt;
#include &lt;radio.h&gt;
#include &lt;RDA5807M.h&gt;
#include &lt;LiquidCrystal.h&gt;
#include &lt;EEPROM.h&gt;//#include &lt;EEPROMex.h&gt;
#include &lt;RDSParser.h&gt;
 LiquidCrystal lcd(7, 6, 2, 3, 4, 5);// RS,E,D4,D5,D6,D7
 byte a1[8]={0b00000,0b11011,0b11011,0b11011,0b11011,0b11011,0b11011,0b00000};
#define FIX_BAND    RADIO_BAND_FM   
 
RDA5807M radio; 
RADIO_INFO info;
RDSParser rds;
char s[12];
int menu,k,f_scan[10],f,i1=8700;
byte vol,bass,z,w,start,start1,t;
unsigned long time;
void DisplayServiceName(char *name){lcd.setCursor(0,1);lcd.print(&quot;    &quot;);lcd.print(name);lcd.print(&quot;           &quot;);} 
void RDS_process(uint16_t block1, uint16_t block2, uint16_t block3, uint16_t block4) {rds.processData(block1, block2, block3, block4);}
 
void setup() {
  vol=EEPROM.read(0);
  for(int c=0;c&lt;10;c++){f_scan[c]=EEPROM.read(10+c)*100+EEPROM.read(100+c);}
  k=EEPROM.read(3);
  f=EEPROM.read(1)*100+EEPROM.read(2);start=0;
  lcd.begin(16, 2);
  Serial.begin(9600);
  radio.init();
  radio.debugEnable();
  pinMode(12,INPUT);// меню
  pinMode(11,INPUT);// плюс
  pinMode(10,INPUT);// минус
 lcd.createChar(0,a1);
  radio.setBandFrequency(FIX_BAND, f);
  radio.setVolume(vol);
  radio.setMono(false);
  radio.setMute(false);
  radio.attachReceiveRDS(RDS_process);
  rds.attachServiceNameCallback(DisplayServiceName);
delay(400);
} 
 
void loop() {
  radio.formatFrequency(s, sizeof(s));
 
  if(start==0){radio.setBandFrequency(FIX_BAND, f);delay(400);radio.getRadioInfo(&amp;info);start=1;}
  if(digitalRead(12)==HIGH){menu++;lcd.clear();time=millis();radio.getRadioInfo(&amp;info);start=0;w=1;delay(300);if(menu&gt;3){menu=0;}}
 
   if(menu==0){// ГРОМКОСТЬ
   if(digitalRead(11)==HIGH){vol++;if(vol&gt;15){vol=15;}w=1;time=millis();radio.setVolume(vol);delay(200);lcd.clear();}
   if(digitalRead(10)==HIGH){vol--;if(vol&gt;16){vol=0;}w=1;time=millis();radio.setVolume(vol);delay(200);lcd.clear();}
    lcd.setCursor(0,0);lcd.print(&quot;   &quot;);lcd.print(s);
    lcd.setCursor(0,1);
  if(millis()-time&lt;5000){for(z=0;z&lt;=vol;z++){lcd.setCursor(z,1);lcd.write((uint8_t)0);}}
  if(millis()-time&gt;5000 and millis()-time&lt;10000){
    lcd.print(info.tuned  ? &quot;  TUNED&quot;  : &quot;  -----&quot;);
    lcd.print(info.stereo ? &quot; STEREO  &quot; : &quot;  MONO   &quot;);}
  if(millis()-time&gt;10000){radio.checkRDS();}  // RDS
   }
 
   if(menu==1){// КАНАЛЫ
       if(start1==0){f=f_scan[k];start=0;start1=1;}
    if(digitalRead(11)==HIGH){k++;if(k&gt;9){k=9;}delay(200);f=f_scan[k];w=1;time=millis();start=0;lcd.clear();}
    if(digitalRead(10)==HIGH){k--;if(k&lt;0){k=0;}delay(200);f=f_scan[k];w=1;time=millis();start=0;lcd.clear();}
      lcd.setCursor(0,0);lcd.print(&quot;K&quot;);lcd.print(k);
    if(f_scan[k]!=0){lcd.print(&quot; &quot;);lcd.print((float)f_scan[k]/100);lcd.print(&quot; MHz   &quot;);}else{lcd.print(&quot; N/A            &quot;);}
      radio.getRadioInfo(&amp;info);
      lcd.setCursor(0,1);lcd.print(info.tuned  ? &quot;TUNED&quot;  : &quot;-----&quot;);
      lcd.print(&quot;  SIGNAL &quot;);lcd.print(info.rssi);
   }   
 
    if(menu==2){// АВТО ПОИСК КАНАЛОВ
      lcd.setCursor(0,0);lcd.print(&quot;AUTOSCAN&quot;);  
    if(digitalRead(11)==HIGH || digitalRead(10)==HIGH){
    for(int i=0;i&lt;10;i++){
    for(i1;i1&lt;=10800;i1=i1+10){
      radio.setBandFrequency(FIX_BAND, i1);delay(300);
      radio.getRadioInfo(&amp;info);delay(500);
    if(info.tuned==1 and info.rssi&gt;26){f_scan[i]=i1;i1=f_scan[i]+10;if(i1&gt;=10800){f_scan[i]=0;}break;} 
      lcd.setCursor(9,0); lcd.print((float)i1/100);
  }
 lcd.setCursor(0,1);lcd.print(i);lcd.print(&quot; &quot;);lcd.print((float)f_scan[i]/100);lcd.print(&quot; MHz   &quot;);
  }delay(1000);time=millis();i1=8700;eeprom();k=0;start1=0;menu=1;}}   
 
 
  if(menu==3){// ПОДСТРОЙКА ЧАСТОТЫ КАНАЛА
    if(digitalRead(11)==HIGH){f=f+10;t=1;if(f&lt;8700){f=8700;}start=0;time=millis();delay(200);lcd.clear();}
    if(digitalRead(10)==HIGH){f=f-10;t=1;if(f&gt;10800){f=10800;}start=0;time=millis();delay(200);lcd.clear();}
    lcd.setCursor(0,0);lcd.print(&quot;&lt;  &quot;);lcd.print((float)f/100);lcd.print(&quot; MHz  &gt;&quot;);
    radio.getRadioInfo(&amp;info);
    lcd.setCursor(0,1);lcd.print(info.tuned  ? &quot;TUNED&quot;  : &quot;-----&quot;);
    lcd.print(&quot;  SIGNAL &quot;);lcd.print(info.rssi);
    if(millis()-time&gt;10000 and t==1){f_scan[k]=f;t=0;EEPROM.update(10+k,f_scan[k]/100);EEPROM.update(100+k,f_scan[k]-(f_scan[k]/100)*100);
    if(millis()-time&lt;11000){lcd.setCursor(0,1);lcd.print(&quot;      SAVE      &quot;);delay(1000);}}
  }
 
 if(millis()-time&gt;60000 &amp;&amp; w==1){EEPROM.update(0,vol);EEPROM.update(3,k);EEPROM.update(1,f_scan[k]/100);EEPROM.update(2,f_scan[k]-(f_scan[k]/100)*100);w=0;}
 if(millis()-time&gt;10000 and menu==1){menu=0;time=millis();lcd.clear();}
 
} // LOOP
 
void eeprom(){for(int b=0;b&lt;10;b++){EEPROM.update(10+b,f_scan[b]/100);EEPROM.update(100+b,f_scan[b]-(f_scan[b]/100)*100);}}</code></pre></div>]]></summary>
			<author>
				<name><![CDATA[r_shkurko]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2064</uri>
			</author>
			<updated>2023-04-13T17:13:32Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=552&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Часы на ИВЛ1-7/5 на Atmega8]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=547&amp;action=new" />
			<summary type="html"><![CDATA[<p>Собрал часы на атмега8. При прошивке столкнулся с проблемой, скетч не компилировался выдавало ошибку. После замены переменной min на minute скетч компилируется часы идут. Хотелось бы расширить функционал часов и добавить в эти часы датчик температуры на ds18b20 с отображением градусов, будильник с зажиганием одного сегмента на индикаторе будильник. Часы запустил на индикаторе ИЛЦ7-4/7Л.</p>]]></summary>
			<author>
				<name><![CDATA[klerik77]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2044</uri>
			</author>
			<updated>2023-03-26T18:48:54Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=547&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Минималистичное переключение меню TDA7419]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=546&amp;action=new" />
			<summary type="html"><![CDATA[<p>Здравствуйте, использую данный скетч. Могли бы Вы сделать так чтобы второе меню открывалось при долгом нажатии на кнопку энкодера. Делаю усилитель в небольшом корпусе и хочется сделать панель без кнопок, только дисплей и энкодер. Буду благодарен, если можно что-то тут изменить.</p><p>#include &lt;Wire.h&gt; <br />#include &lt;TDA7419.h&gt;<br />#include &lt;EEPROM.h&gt;//#include &lt;EEPROMex.h&gt;<br />#include &lt;LiquidCrystal.h&gt;<br />#include &lt;Encoder.h&gt;<br />#include &lt;MsTimer2.h&gt;<br />Encoder myEnc(9, 8);//CLK, DT<br />TDA7419 tda; LiquidCrystal lcd(7, 6, 2, 3, 4, 5);// RS,E,D4,D5,D6,D7<br />&nbsp; int menu,vol,bas,w,w1,vol_d,bass_d,treb,treble_d,middle,middle_d,z,in,gain0,gain1,gain2,gain3,gain_d,set;<br />&nbsp; int lon, lon_f, lon_d,out,vol_out,rf,lf,rt,lt,sab,treb_c,mid_c,bas_c,sab_f,mute=1,vol_ram;<br />&nbsp; unsigned long time, oldPosition&nbsp; = -999,time1;<br />&nbsp; byte a1[8]={0b00000,0b11011,0b11011,0b11011,0b11011,0b11011,0b11011,0b00000};<br />&nbsp; byte a2[8]={0b00000,0b11000,0b11000,0b11000,0b11000,0b11000,0b11000,0b00000};</p><p>void setup(){<br /> lcd.begin(16, 2);lcd.createChar(0,a1); lcd.createChar(1,a2);Wire.begin();Serial.begin(9600);<br />&nbsp; pinMode(13,INPUT);// set<br />&nbsp; pinMode(12,INPUT);// меню<br />&nbsp; pinMode(11,INPUT);// плюс<br />&nbsp; pinMode(10,INPUT);// минус<br />&nbsp; pinMode(A0,INPUT);// КНОПКА ЭНКОДЕРА<br />&nbsp; &nbsp;vol = EEPROM.read(0);treb = EEPROM.read(1)-15;middle = EEPROM.read(3)-15;bas = EEPROM.read(3)-15;<br />&nbsp; &nbsp;in = EEPROM.read(4);gain1 = EEPROM.read(5);gain2 = EEPROM.read(6);gain3 = EEPROM.read(7);<br />&nbsp; &nbsp;lon = EEPROM.read(8);lon_f = EEPROM.read(9);rf = EEPROM.read(10);lf = EEPROM.read(11);<br />&nbsp; &nbsp;rt = EEPROM.read(12);lt = EEPROM.read(13);sab = EEPROM.read(14);treb_c = EEPROM.read(15);<br />&nbsp; &nbsp;mid_c = EEPROM.read(16);bas_c = EEPROM.read(17);sab_f = EEPROM.read(18);<br />&nbsp; &nbsp; MsTimer2::set(1, to_Timer);MsTimer2::start();<br />&nbsp; &nbsp;audio();<br />}<br />long newPosition;</p><p>void to_Timer(){ //функция таймера<br /> newPosition = myEnc.read()/4;</p><p>}<br />void loop(){<br />&nbsp; if((analogRead(A0)&lt;900||digitalRead(12)==HIGH)&amp;&amp;menu&lt;4){menu++;cl();myEnc.write(0);time=millis();w1=1;if(menu&gt;3){menu=0;}}// меню<br />&nbsp; if(digitalRead(12)==HIGH&amp;&amp;menu&gt;=4){menu++;cl();myEnc.write(0);time=millis();w1=1;if(menu&gt;10){menu=0;}}// меню 2<br />&nbsp; if(digitalRead(12)==HIGH&amp;&amp;digitalRead(13)==HIGH){menu=4;cl();}<br />&nbsp; &nbsp;if(digitalRead(10)==HIGH&amp;&amp;digitalRead(11)==HIGH){mute++;w=1;if(mute&gt;1){mute=0;}}<br />//////////////////////////////////////// Volume -80 ... 0 дБ //////////////////////////////////////<br /> if(menu==0){<br />&nbsp; &nbsp; if (newPosition != oldPosition) {<br />&nbsp; &nbsp; oldPosition = newPosition;<br />&nbsp; &nbsp; vol=vol+newPosition;myEnc.write(0);newPosition=0;audio();lcd.clear();time=millis();w1=1;if(vol&gt;80){vol=80;}if(vol&lt;0){vol=0;}}</p><p>&nbsp; &nbsp;if(digitalRead(11)==HIGH){vol++;w=1;if(vol&gt;80){vol=80;}}// 80 максимальная громкость&nbsp; <br />&nbsp; &nbsp;if(digitalRead(10)==HIGH){vol--;w=1;if(vol&lt;0){vol=0;}}// 0 минимум громкости <br />&nbsp; &nbsp;if(w==1){audio();cl();time=millis();w=0;w1=1;}<br />&nbsp; lcd.setCursor(0,0);if(mute==1){lcd.print(&quot;Volume&nbsp; &nbsp;&quot;);}else{lcd.print(&quot;MUTE&nbsp; &nbsp; &nbsp;&quot;);}<br />&nbsp; lcd.print(-80+vol);lcd.setCursor(13,0);lcd.print(&quot;dB&quot;);vol_d=vol/2-17;<br />&nbsp; &nbsp;if(vol_d&gt;=0){for(z=0;z&lt;=vol_d;z++){lcd.setCursor(z/2,1);lcd.write((uint8_t)0);}}<br />&nbsp; &nbsp;if((vol_d)%2==0){lcd.setCursor(z/2,1);lcd.write((uint8_t)1);}<br />&nbsp; lcd.setCursor(13,1);lcd.print(vol);}<br /> /////////////////////////////////////////////////////////////////////////////////////<br />&nbsp; /////////////////////// индикация тембр ВЧ + управление кнопками -15...15 дБ ///////////////////<br />&nbsp; &nbsp;if(menu==1){<br />&nbsp; &nbsp; &nbsp;if (newPosition != oldPosition) {<br />&nbsp; &nbsp; oldPosition = newPosition;<br />&nbsp; &nbsp; treb=treb+newPosition;myEnc.write(0);newPosition=0;audio();lcd.clear();time=millis();w1=1;if(treb&gt;15){treb=15;}if(treb&lt;-15){treb=-15;}} </p><p>&nbsp; &nbsp;if(digitalRead(11)==HIGH){treb++;w=1;if(treb&gt;15){treb=15;}} <br />&nbsp; &nbsp;if(digitalRead(10)==HIGH){treb--;w=1;if(treb&lt;-15){treb=-15;}}<br />&nbsp; &nbsp;if(w==1){audio();cl();time=millis();w1=1;w=0;}<br />&nbsp; lcd.setCursor(0,0);lcd.print(&quot;Treble&nbsp; &nbsp;&quot;);<br />&nbsp; lcd.print(treb);lcd.setCursor(13,0);lcd.print(&quot;dB&quot;);treble_d=treb+15;<br />&nbsp; &nbsp;if(treble_d&gt;=0){for(z=0;z&lt;=treble_d;z++){lcd.setCursor(z/2,1);lcd.write((uint8_t)0);}}<br />&nbsp; &nbsp;if((treble_d)%2==0){lcd.setCursor(z/2,1);lcd.write((uint8_t)1);}}<br />/////////////////////////////////////////////////////////////////////////////////////<br /> /////////////////////// индикация тембр CЧ + управление кнопками -15...15 дБ ///////////////////<br />&nbsp; &nbsp;if(menu==2){<br />&nbsp; &nbsp; &nbsp; if (newPosition != oldPosition) {<br />&nbsp; &nbsp; oldPosition = newPosition;<br />&nbsp; &nbsp; middle=middle+newPosition;myEnc.write(0);newPosition=0;audio();lcd.clear();time=millis();w1=1;if(middle&gt;15){middle=15;}if(middle&lt;-15){middle=-15;}} </p><p>&nbsp; &nbsp;if(digitalRead(11)==HIGH){middle++;w=1;if(middle&gt;15){middle=15;}} <br />&nbsp; &nbsp;if(digitalRead(10)==HIGH){middle--;w=1;if(middle&lt;-15){middle=-15;}}<br />&nbsp; &nbsp;if(w==1){audio();cl();time=millis();w1=1;w=0;}<br />&nbsp; lcd.setCursor(0,0);lcd.print(&quot;Middle&nbsp; &nbsp;&quot;);<br />&nbsp; lcd.print(middle);lcd.setCursor(13,0);lcd.print(&quot;dB&quot;);middle_d=middle+15;<br />&nbsp; &nbsp;if(middle_d&gt;=0){for(z=0;z&lt;=middle_d;z++){lcd.setCursor(z/2,1);lcd.write((uint8_t)0);}}<br />&nbsp; &nbsp;if((middle_d)%2==0){lcd.setCursor(z/2,1);lcd.write((uint8_t)1);}}<br />/////////////////////////////////////////////////////////////////////////////////////<br /> /////////////////////// индикация тембр НЧ + управление кнопками -15...15 дБ ///////////////////<br />&nbsp; &nbsp;if(menu==3){<br />&nbsp; &nbsp; if (newPosition != oldPosition) {<br />&nbsp; &nbsp; oldPosition = newPosition;<br />&nbsp; &nbsp; bas=bas+newPosition;myEnc.write(0);newPosition=0;audio();lcd.clear();time=millis();w1=1;if(bas&gt;15){bas=15;}if(bas&lt;-15){bas=-15;}}&nbsp; &nbsp;</p><p>&nbsp; &nbsp;if(digitalRead(11)==HIGH){bas++;w=1;if(bas&gt;15){bas=15;}} <br />&nbsp; &nbsp;if(digitalRead(10)==HIGH){bas--;w=1;if(bas&lt;-15){bas=-15;}}<br />&nbsp; &nbsp;if(w==1){audio();cl();time=millis();w1=1;w=0;}<br />&nbsp; lcd.setCursor(0,0);lcd.print(&quot;Bass&nbsp; &nbsp; &nbsp; &quot;);<br />&nbsp; lcd.print(bas);lcd.setCursor(13,0);lcd.print(&quot;dB&quot;);bass_d=bas+15;<br />&nbsp; &nbsp;if(bass_d&gt;=0){for(z=0;z&lt;=bass_d;z++){lcd.setCursor(z/2,1);lcd.write((uint8_t)0);}}<br />&nbsp; &nbsp;if((bass_d)%2==0){lcd.setCursor(z/2,1);lcd.write((uint8_t)1);}}<br /> ////////////////////////////////////////////////////////////////////////////////////<br /> ///////////////////////////// вход 1...3 + предусилитель 0...15 дБ //////////////////////////////<br />&nbsp; &nbsp;if(menu==4){&nbsp; //рег. предусилителя - нажать и удерживать кнопку set, рег. кнопки плюс и минус<br />&nbsp; &nbsp;if(digitalRead(11)==HIGH&amp;&amp;digitalRead(13)==LOW){in++;w=1;if(in&gt;3){in=3;}} <br />&nbsp; &nbsp;if(digitalRead(10)==HIGH&amp;&amp;digitalRead(13)==LOW){in--;w=1;if(in&lt;1){in=1;}}<br />&nbsp; &nbsp;if(in==1){gain0=gain1;}if(in==2){gain0=gain2;}if(in==3){gain0=gain3;}<br />&nbsp; &nbsp;if(digitalRead(13)==HIGH&amp;&amp;digitalRead(11)==HIGH){gain0++;w=1;if(gain0&gt;15){gain0=15;}}<br />&nbsp; &nbsp;if(digitalRead(13)==HIGH&amp;&amp;digitalRead(10)==HIGH){gain0--;w=1;if(gain0&lt;0){gain0=0;}}<br />&nbsp; &nbsp;if(w==1){audio();cl();time=millis();w1=1;w=0;}<br />&nbsp; lcd.setCursor(0,0);lcd.print(&quot;Input: &quot;);lcd.print(in);gain_d=gain0;<br />&nbsp; &nbsp;if(gain_d&gt;=0){for(z=0;z&lt;=gain_d;z++){lcd.setCursor(z/2,1);lcd.write((uint8_t)0);}}<br />&nbsp; &nbsp;if((gain_d)%2==0){lcd.setCursor(z/2,1);lcd.write((uint8_t)1);}<br />&nbsp; &nbsp;if(in==1){gain1=gain0;}if(in==2){gain2=gain0;}if(in==3){gain3=gain0;}<br />&nbsp; &nbsp;lcd.setCursor(11,1);lcd.print(gain0);lcd.print(&quot; dB&nbsp; &quot;);} <br />/////////////////////////////////////////////////////////////////////////////////////////////<br />////////////////////////////// loudness ////////////////////////////////////////////////////<br /> if(menu==5){&nbsp; <br />&nbsp; &nbsp;if(digitalRead(11)==HIGH&amp;&amp;digitalRead(13)==LOW){lon_f++;w=1;if(lon_f&gt;3){lon_f=3;}} <br />&nbsp; &nbsp;if(digitalRead(10)==HIGH&amp;&amp;digitalRead(13)==LOW){lon_f--;w=1;if(lon_f&lt;0){lon_f=0;}}<br />&nbsp; &nbsp;if(digitalRead(13)==HIGH&amp;&amp;digitalRead(11)==HIGH){lon++;w=1;if(lon&gt;15){lon=15;}}<br />&nbsp; &nbsp;if(digitalRead(13)==HIGH&amp;&amp;digitalRead(10)==HIGH){lon--;w=1;if(lon&lt;0){lon=0;}}<br />&nbsp; &nbsp;if(w==1){audio();cl();time=millis();w1=1;w=0;}lon_d=lon;<br />&nbsp; lcd.setCursor(0,0);lcd.print(&quot;Loudness: &quot;);<br />&nbsp; &nbsp;switch(lon_f){case 0: lcd.print(&quot;FLAT&quot;);break;case 1: lcd.print(&quot;400Hz&quot;);break;<br />&nbsp; &nbsp;case 2: lcd.print(&quot;800Hz&quot;);break;case 3: lcd.print(&quot;2400Hz&quot;);break;} <br />&nbsp; &nbsp;lcd.setCursor(0,1);<br />&nbsp; &nbsp; if(lon_d&gt;=0){for(z=0;z&lt;=lon_d;z++){lcd.setCursor(z/2,1);lcd.write((uint8_t)0);}}<br />&nbsp; &nbsp;if((lon_d)%2==0){lcd.setCursor(z/2,1);lcd.write((uint8_t)1);}<br />&nbsp; &nbsp;lcd.setCursor(9,1);lcd.print(&quot;-&quot;);lcd.print(lon);lcd.print(&quot; dB&nbsp; &quot;);} <br />////////////////////////////////////////// out /////////////////////////////////////////////////<br /> if(menu==6){&nbsp; <br />&nbsp; &nbsp;if(digitalRead(11)==HIGH&amp;&amp;digitalRead(13)==LOW){out++;w=1;if(out&gt;4){out=4;}} <br />&nbsp; &nbsp;if(digitalRead(10)==HIGH&amp;&amp;digitalRead(13)==LOW){out--;w=1;if(out&lt;0){out=0;}}<br />&nbsp; &nbsp; switch(out){case 0:vol_out=rf;break;case 1:vol_out=lf;break;case 2:vol_out=rt;break;<br />&nbsp; &nbsp;case 3:vol_out=lt;break;case 4:vol_out=sab;break;}<br />&nbsp; &nbsp;if(digitalRead(13)==HIGH&amp;&amp;digitalRead(11)==HIGH){vol_out++;w=1;if(vol_out&gt;15){vol_out=15;}}<br />&nbsp; &nbsp;if(digitalRead(13)==HIGH&amp;&amp;digitalRead(10)==HIGH){vol_out--;w=1;if(vol_out&lt;0){vol_out=0;}}<br />&nbsp; &nbsp;lcd.setCursor(0,0);lcd.print(&quot;Volume OUT&quot;);lcd.setCursor(0,1);<br />&nbsp; &nbsp; switch(out){<br />&nbsp; &nbsp;case 0:rf=vol_out;lcd.print(&quot;RF:&nbsp; +&quot;);lcd.print(rf);break;<br />&nbsp; &nbsp;case 1:lf=vol_out;lcd.print(&quot;LF:&nbsp; +&quot;);lcd.print(lf);break;<br />&nbsp; &nbsp;case 2:rt=vol_out;lcd.print(&quot;RT:&nbsp; +&quot;);lcd.print(rt);break;<br />&nbsp; &nbsp;case 3:lt=vol_out;lcd.print(&quot;LT:&nbsp; +&quot;);lcd.print(lt);break;<br />&nbsp; &nbsp;case 4:sab=vol_out;lcd.print(&quot;SUBW:&nbsp; +&quot;);lcd.print(sab);break;}<br />&nbsp; lcd.print(&quot; dB&nbsp; &nbsp; &nbsp; &quot;);if(w==1){audio();cl();time=millis();w1=1;w=0;}}<br />&nbsp; &nbsp;/////////////////////////////////treble center//////////////////////////////////////////////////<br /> if(menu==7){ <br /> if(digitalRead(11)==HIGH){treb_c++;w=1;if(treb_c&gt;3){treb_c=3;}} <br />&nbsp; &nbsp;if(digitalRead(10)==HIGH){treb_c--;w=1;if(treb_c&lt;0){treb_c=0;}}<br />&nbsp; &nbsp;if(w==1){audio();cl();time=millis();w1=1;w=0;}<br />&nbsp; lcd.setCursor(0,0);lcd.print(&quot;Treble Center &quot;);<br />&nbsp; lcd.setCursor(1,6);switch(treb_c){<br />&nbsp; case 0: lcd.print(&quot;10.0 kHz&quot;);break;case 1: lcd.print(&quot;12.5 kHz&quot;);break;<br />&nbsp; case 2: lcd.print(&quot;15.0 kHz&quot;);break;case 3: lcd.print(&quot;17.5 kHz&quot;);break;}}&nbsp; <br />&nbsp; &nbsp;/////////////////////////////////middle center//////////////////////////////////////////////////<br /> if(menu==8){ <br /> if(digitalRead(11)==HIGH){mid_c++;w=1;if(mid_c&gt;3){mid_c=3;}} <br />&nbsp; &nbsp;if(digitalRead(10)==HIGH){mid_c--;w=1;if(mid_c&lt;0){mid_c=0;}}<br />&nbsp; &nbsp;if(w==1){audio();cl();time=millis();w1=1;w=0;}<br />&nbsp; lcd.setCursor(0,0);lcd.print(&quot;Middle Center &quot;);<br />&nbsp; lcd.setCursor(1,6);switch(mid_c){<br />&nbsp; case 0: lcd.print(&quot;0.5 kHz&quot;);break;case 1: lcd.print(&quot;1.0 kHz&quot;);break;<br />&nbsp; case 2: lcd.print(&quot;1.5 kHz&quot;);break;case 3: lcd.print(&quot;2.5 kHz&quot;);break;}}<br />////////////////////////////////////bass center/////////////////////////////////////////// <br /> if(menu==9){ <br /> if(digitalRead(11)==HIGH){bas_c++;w=1;if(bas_c&gt;3){bas_c=3;}} <br />&nbsp; &nbsp;if(digitalRead(10)==HIGH){bas_c--;w=1;if(bas_c&lt;0){bas_c=0;}}<br />&nbsp; &nbsp;if(w==1){audio();cl();time=millis();w1=1;w=0;}<br />&nbsp; lcd.setCursor(0,0);lcd.print(&quot;Bass Center &quot;);<br />&nbsp; lcd.setCursor(1,6);switch(bas_c){<br />&nbsp; case 0: lcd.print(&quot;60 Hz&quot;);break;case 1: lcd.print(&quot;80 Hz&quot;);break;<br />&nbsp; case 2: lcd.print(&quot;100 Hz&quot;);break;case 3: lcd.print(&quot;200 Hz&quot;);break;}}<br />//////////////////////////////////////subw//////////////////////////////////////////////// <br /> if(menu==10){ <br /> if(digitalRead(11)==HIGH){sab_f++;w=1;if(sab_f&gt;3){sab_f=3;}} <br />&nbsp; &nbsp;if(digitalRead(10)==HIGH){sab_f--;w=1;if(sab_f&lt;0){sab_f=0;}}<br />&nbsp; &nbsp;if(w==1){audio();cl();time=millis();w1=1;w=0;}<br />&nbsp; lcd.setCursor(0,0);lcd.print(&quot;Subwoofer Freq.&quot;);<br />&nbsp; lcd.setCursor(1,6);switch(sab_f){<br />&nbsp; case 0: lcd.print(&quot;FLAT&quot;);break;case 1: lcd.print(&quot;80 Hz&quot;);break;<br />&nbsp; case 2: lcd.print(&quot;120 Hz&quot;);break;case 3: lcd.print(&quot;160 Hz&quot;);break;}}<br />//////////////////////////////////////////////////////////////////////////////////////</p><p>Serial.println(time);</p><p> if(millis()-time&gt;10000 &amp;&amp; w1==1){<br />&nbsp; &nbsp; &nbsp;EEPROM.update(0,vol);EEPROM.update(1,treb+15);EEPROM.update(2,middle+15);EEPROM.update(3,bas+15);<br />&nbsp; &nbsp; &nbsp;EEPROM.update(4,in);EEPROM.update(5,gain1);EEPROM.update(6,gain2);EEPROM.update(7,gain3);<br />&nbsp; &nbsp; &nbsp;EEPROM.update(8,lon);EEPROM.update(9,lon_f);<br />&nbsp; &nbsp; &nbsp;EEPROM.update(10,rf);EEPROM.update(11,lf);EEPROM.update(12,rt);EEPROM.update(13,lt);<br />&nbsp; &nbsp; &nbsp;EEPROM.update(14,sab);EEPROM.update(15,treb_c);EEPROM.update(16,mid_c);EEPROM.update(17,bas_c);<br />&nbsp; &nbsp; &nbsp;EEPROM.update(18,sab_f);<br />&nbsp; &nbsp; &nbsp;menu=0;w1=0; myEnc.write(0);cl();}<br />}//loop<br /> void cl(){delay(300);lcd.clear();}<br /> void audio(){<br />tda.setInput(in,gain0,0);&nbsp; &nbsp; //вх1=1, вх2=2, вх3=3<br />tda.setInput2(0,0,0);&nbsp; &nbsp;// не используется<br />tda.setAtt_loudness(lon,lon_f,0,0);<br />tda.setSoft(mute,0,0,0,0);//mute off (не менять)<br />tda.setVolume(vol-79,0);&nbsp; &nbsp;// общая громкость от 0 до 79 макс<br />tda.setAtt_LF(64+lf,0);&nbsp; &nbsp;// гром. лк фронт<br />tda.setAtt_RF(64+rf,0);&nbsp; &nbsp;// гром. пк фронт<br />tda.setAtt_LT(64+lt,0);&nbsp; &nbsp;// гром. лк тыл<br />tda.setAtt_RT(64+rt,0);&nbsp; &nbsp;// гром. пк тыл<br />tda.setAtt_SUB(64+sab,0);&nbsp; // гром. савбуфер<br />tda.setAtt_Mix(79,0);&nbsp; &nbsp;// не использует<br />tda.setFilter_Treble(treb,treb_c,0); <br />tda.setFilter_Middle(middle,0,0);<br />tda.setFilter_Bass(bas,0,0);<br />tda.setSub_M_B(sab_f,mid_c,bas_c,0,0);<br />tda.setMix_Gain_Eff(1,0,0,0,0); // не используется<br />tda.setSpektor(0,0,1,0,1,0,0);<br />}</p>]]></summary>
			<author>
				<name><![CDATA[zhikovpavlik2003]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2048</uri>
			</author>
			<updated>2023-03-26T14:03:45Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=546&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[7318]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=542&amp;action=new" />
			<summary type="html"><![CDATA[<p>Здравствуйте! парни подскажите где косяк.Произвольно идет переключение с громкости на басс на вч и так по кругу.<br /><a href="https://cloud.mail.ru/public/rzGc/WEZZzWpPL">https://cloud.mail.ru/public/rzGc/WEZZzWpPL</a></p>]]></summary>
			<author>
				<name><![CDATA[rv9uu]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2023</uri>
			</author>
			<updated>2023-03-12T05:16:22Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=542&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Темброблок 5.1 на PT2323 и PT2322 (Arduino)]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=530&amp;action=new" />
			<summary type="html"><![CDATA[<p>Создайте новую переменную w2</p><p>bool w2;</p><p>Вот пример кода для регулировки громкости:</p><div class="codebox"><pre><code>if(menu==0){   
     if(ir.value==0x2FD906F){vol++;g1=1;g2=0;cl();time=millis();w=1;audio();}// кнопка VOL+  0xFFA857
     if(ir.value==0xFFFFFFFF and g1==1){vol++;g2=0;cl();time=millis();w=1;audio();}// кнопка &gt;&gt;&gt;&gt;&gt;&gt;
     if(ir.value==0x2FDF20D){vol--;g1=0;g2=1;cl();time=millis();w=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){vol--;g1=0;cl();time=millis();w=1;audio();}// кнопка &lt;&lt;&lt;&lt;&lt;&lt;
     if(vol&gt;79){vol=79;}if(vol&lt;0){vol=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    vol=vol+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;if(vol&gt;79){vol=79;}if(vol&lt;0){vol=0;}audio();}
  lcd.setCursor(0,0);lcd.print(&quot;Volume  &quot;);
  lcd.print(&quot; &quot;);lcd.print(-79+vol);lcd.print(&quot; &quot;);lcd.setCursor(13,0);lcd.print(&quot;dB&quot;);vol_d=vol-32;
   for(z=0,z0=0,z1=0;z&lt;=vol_d;z++,z1++){if(z1&gt;2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1,1);lcd.print(&quot;    &quot;);}}
   if(z1==3){lcd.setCursor(z0,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0,1);lcd.write((uint8_t)2);}}</code></pre></div><p>после w=1 используйте новую переменную w2=1;</p><p>После изменения параметра громкости w2 станет равна 1</p><p>Пример ниже:</p><div class="codebox"><pre><code> if(menu==0){   
     if(ir.value==0x2FD906F){vol++;g1=1;g2=0;cl();time=millis();w=1;w2=1;audio();}// кнопка VOL+  0xFFA857
     if(ir.value==0xFFFFFFFF and g1==1){vol++;g2=0;cl();time=millis();w=1;w2=1;audio();}// кнопка &gt;&gt;&gt;&gt;&gt;&gt;
     if(ir.value==0x2FDF20D){vol--;g1=0;g2=1;cl();time=millis();w=1;w2=1;audio();}// кнопка VOL-
     if(ir.value==0xFFFFFFFF and g2==1){vol--;g1=0;cl();time=millis();w=1;w2=1;audio();}// кнопка &lt;&lt;&lt;&lt;&lt;&lt;
     if(vol&gt;79){vol=79;}if(vol&lt;0){vol=0;}
    if (newPosition != oldPosition) {
    oldPosition = newPosition;
    vol=vol+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;if(vol&gt;79){vol=79;}if(vol&lt;0){vol=0;}audio();}
  lcd.setCursor(0,0);lcd.print(&quot;Volume  &quot;);
  lcd.print(&quot; &quot;);lcd.print(-79+vol);lcd.print(&quot; &quot;);lcd.setCursor(13,0);lcd.print(&quot;dB&quot;);vol_d=vol-32;
  if(w2==1){ w2=0;
   for(z=0,z0=0,z1=0;z&lt;=vol_d;z++,z1++){if(z1&gt;2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1,1);lcd.print(&quot;    &quot;);}}
   if(z1==3){lcd.setCursor(z0,1);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0,1);lcd.write((uint8_t)2);}}
 }</code></pre></div><p>Добавьте условие в код вывода строки уровня громкости</p><p><strong>if(w2==1){ w2=0;</strong><br />&nbsp; &nbsp;for(z=0,z0=0,z1=0;z&lt;=vol_d;z++,z1++){if(z1&gt;2){z1=0;z0++;}<br />&nbsp; &nbsp;if(z1==1){lcd.setCursor(z0,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1,1);lcd.print(&quot;&nbsp; &nbsp; &quot;);}}<br />&nbsp; &nbsp;if(z1==3){lcd.setCursor(z0,1);lcd.write((uint8_t)1);}<br />&nbsp; &nbsp;if(z1==2){lcd.setCursor(z0,1);lcd.write((uint8_t)2);}}</p><p>После исполнения кода вывода строки уровня громкости переменная w2 станет равной 0, запрещая по новой запускать код вывода строки уровня громкости, мерцания&nbsp; строки уровня громкости должно исчезнуть</p>]]></summary>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2022-12-28T05:14:55Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=530&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Темброблок на ис. TDA8425]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=527&amp;action=new" />
			<summary type="html"><![CDATA[<p>При проверке скетча, выдает ошибку во второй строке: #include &lt;TDA 8425.h&gt;&nbsp; &nbsp;<br />No sucf file or directory.</p><p>&nbsp; #include &lt;Wire.h&gt;<br />&nbsp; #include &lt;TDA8425.h&gt;<br />&nbsp; #include &lt;Encoder.h&gt;<br />&nbsp; #include &lt;LiquidCrystal.h&gt;<br />&nbsp; #include &lt;EEPROM.h&gt;<br />&nbsp; #include &lt;MsTimer2.h&gt;<br />&nbsp; #include &lt;boarddefs.h&gt;<br />&nbsp; #include &lt;IRremote.h&gt;<br />&nbsp; &nbsp;IRrecv irrecv(9); // указываем вывод модуля IR приемника<br />&nbsp; &nbsp;Encoder myEnc(11, 10);//CLK, DT<br />&nbsp; &nbsp;decode_results ir;<br />&nbsp; &nbsp;TDA8425 tda;<br />&nbsp; &nbsp;LiquidCrystal lcd(7, 6, 2, 3, 4, 5);// RS,E,D4,D5,D6,D7<br />&nbsp; &nbsp; byte a1[8]={0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101};<br />&nbsp; &nbsp; byte a2[8]={0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100};<br />&nbsp; &nbsp; byte a3[8]={0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000};<br />&nbsp; &nbsp;int menu,vol,vol_d,balans,bass,bass_d,treb,treb_d,in,mute,sss;<br />&nbsp; &nbsp;byte w,w2,standby=1,www,z,z0,z1,gr1,gr2;<br />&nbsp; &nbsp;unsigned long time,oldPosition&nbsp; = -999,newPosition;</p><p>void setup() {<br />&nbsp; &nbsp;Serial.begin(9600);lcd.begin(16, 2);<br />&nbsp; &nbsp;irrecv.enableIRIn(); // запускаем модуль IR<br />&nbsp; &nbsp;pinMode(12,INPUT);// меню кнопка энкодера SW<br />&nbsp; &nbsp;pinMode(A0,INPUT);// кнопка POWER<br />&nbsp; &nbsp;pinMode(8,OUTPUT);// выход управления STANDBY<br />&nbsp; &nbsp;pinMode(A1,INPUT);// MUTE<br />&nbsp; &nbsp;digitalWrite(8,LOW);<br />&nbsp; &nbsp;lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);<br />&nbsp; &nbsp;vol = EEPROM.read(0);// vol eeprom<br />&nbsp; &nbsp;bass = EEPROM.read(1);// bass eeprom<br />&nbsp; &nbsp;treb = EEPROM.read(2);// treb eeprom<br />&nbsp; &nbsp;in = EEPROM.read(3);// in eeprom<br />&nbsp; &nbsp;balans = EEPROM.read(4)-4;// balans eeprom<br />&nbsp; &nbsp;lcd.setCursor(4,0);lcd.print(&quot;TDA8425&quot;);delay(1000);<br />&nbsp; &nbsp;MsTimer2::set(3, to_Timer);MsTimer2::start();<br />&nbsp; &nbsp;audio();<br />}</p><p>void loop() {delay(10);<br />&nbsp; &nbsp;if(standby==1){menu=100;lcd.setCursor(0,0);lcd.print(&quot;&nbsp; &nbsp;POWER OFF&nbsp; &nbsp; &quot;);}<br />&nbsp; &nbsp;if(analogRead(A0)&gt;900&amp;&amp;standby==1){standby=0;lcd.clear();lcd.setCursor(0,0);lcd.print(&quot;&nbsp; &nbsp;POWER ON&nbsp; &nbsp; &nbsp;&quot;);digitalWrite(8,HIGH);delay(2000);menu=0;w2=1;}<br />&nbsp; &nbsp;if(analogRead(A0)&gt;900&amp;&amp;standby==0){standby=1;lcd.clear();digitalWrite(8,LOW);delay(500);menu=100;}</p><p>&nbsp; &nbsp;if(analogRead(A1)&gt;900&amp;&amp;mute==0&amp;&amp;standby==0){mute=1;cl();menu=100;lcd.setCursor(0,0);lcd.print(&quot;&nbsp; &nbsp; &nbsp; MUTE&nbsp; &nbsp; &nbsp; &quot;);delay(500);}<br />&nbsp; &nbsp;if(analogRead(A1)&gt;900&amp;&amp;mute==1&amp;&amp;standby==0){mute=0;cl();delay(100);menu=0;w2=1;}<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;if ( irrecv.decode( &amp;ir )) {Serial.print(&quot;0x&quot;);Serial.println( ir.value,HEX);time=millis();w=1;w2=1;irrecv.resume();}// IR приемник<br />&nbsp; &nbsp;if(digitalRead(12)==LOW&amp;&amp;standby==0){menu++;cl();myEnc.write(0);time=millis();w=1;w2=1;if(menu&gt;4){menu=0;}}// меню</p><p>&nbsp; &nbsp; if(ir.value==0x2FDD02F&amp;&amp;standby==0){menu++;gr1=0;gr2=0;cl1();time=millis();w=1;w2=1;if(menu&gt;4){menu=0;}}// IR меню кнопка вверх<br />&nbsp; &nbsp; if(ir.value==0x2FD32CD&amp;&amp;standby==0){menu--;gr1=0;gr2=0;cl1();time=millis();w=1;w2=1;if(menu&lt;0){menu=4;}}// IR меню кнопка вниз<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; if(ir.value==0x2FD00FF&amp;&amp;standby==1){standby=0;gr1=0;gr2=0;cl();lcd.setCursor(0,0);lcd.print(&quot;&nbsp; &nbsp;POWER ON&nbsp; &nbsp; &nbsp;&quot;);digitalWrite(8,HIGH);delay(2000);menu=0;w2=1;}//IR power on<br />&nbsp; &nbsp; if(ir.value==0x2FD00FF&amp;&amp;standby==0){standby=1;gr1=0;gr2=0;cl();digitalWrite(8,LOW);delay(500);menu=100;}//IR power off</p><p>&nbsp; &nbsp; if(ir.value==0x2FD708F&amp;&amp;mute==0&amp;&amp;standby==0){mute=1;cl();menu=100;lcd.setCursor(0,0);lcd.print(&quot;&nbsp; &nbsp; &nbsp; MUTE&nbsp; &nbsp; &nbsp; &quot;);delay(500);}// IR MUTE<br />&nbsp; &nbsp; if(ir.value==0x2FD708F&amp;&amp;mute==1&amp;&amp;standby==0){mute=0;cl();menu=0;w2=1;}//IR MUTE</p><p>&nbsp; &nbsp; <br />/////////////////////// VOLUME ///////////////////////////////////<br />&nbsp; if(menu==0){ <br />&nbsp; &nbsp; &nbsp;if(ir.value==0x2FD906F){vol++;gr1=1;gr2=0;cl();w2=1;ogr_vol();audio();}// кнопка &gt; <br />&nbsp; &nbsp; &nbsp;if(ir.value==0xFFFFFFFF and gr1==1){vol++;gr2=0;cl();w2=1;ogr_vol();audio();}// кнопка &gt;&gt;&gt;&gt;&gt;&gt;<br />&nbsp; &nbsp; &nbsp;if(ir.value==0x2FDF20D){vol--;gr1=0;gr2=1;cl();w2=1;ogr_vol();audio();}// кнопка &lt;<br />&nbsp; &nbsp; &nbsp;if(ir.value==0xFFFFFFFF and gr2==1){vol--;gr1=0;cl();w2=1;ogr_vol();audio();}// кнопка &lt;&lt;&lt;&lt;&lt;&lt;<br />&nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; if (newPosition != oldPosition){oldPosition = newPosition;<br />&nbsp; &nbsp; vol=vol+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;ogr_vol();audio();} <br />&nbsp; &nbsp; <br />&nbsp; &nbsp;lcd.setCursor(0,0);lcd.print(&quot;VOLUME&nbsp; &quot;);<br />&nbsp; &nbsp;lcd.print(&quot; &quot;);lcd.print((-60+vol)*2);lcd.print(&quot; &quot;);lcd.setCursor(13,0);lcd.print(&quot;dB&quot;);vol_d=vol-15;<br />&nbsp; &nbsp;if(w2==1){<br />&nbsp; &nbsp;for(z=0,z0=0,z1=0;z&lt;=vol_d;z++,z1++){if(z1&gt;2){z1=0;z0++;}<br />&nbsp; &nbsp;if(z1==1){lcd.setCursor(z0,1);lcd.write((uint8_t)0);lcd.setCursor(z0+1,1);lcd.print(&quot;&nbsp; &nbsp;&quot;);}}<br />&nbsp; &nbsp;if(z1==3){lcd.setCursor(z0,1);lcd.write((uint8_t)1);}<br />&nbsp; &nbsp;if(z1==2){lcd.setCursor(z0,1);lcd.write((uint8_t)2);}w2=0;}}</p><p>//////////////// BASS /////////////////////////////////////<br />&nbsp; if(menu==1){ <br />&nbsp; &nbsp; &nbsp;if(ir.value==0x2FD906F){bass++;gr1=1;gr2=0;cl();w2=1;ogr_bass();audio();}// кнопка &gt; <br />&nbsp; &nbsp; &nbsp;if(ir.value==0xFFFFFFFF and gr1==1){bass++;gr2=0;cl();w2=1;ogr_bass();audio();}// кнопка &gt;&gt;&gt;&gt;&gt;&gt;<br />&nbsp; &nbsp; &nbsp;if(ir.value==0x2FDF20D){bass--;gr1=0;gr2=1;cl();w2=1;ogr_bass();audio();}// кнопка &lt;<br />&nbsp; &nbsp; &nbsp;if(ir.value==0xFFFFFFFF and gr2==1){bass--;gr1=0;cl();w2=1;ogr_bass();audio();}// кнопка &lt;&lt;&lt;&lt;&lt;&lt;<br />&nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; if (newPosition != oldPosition){oldPosition = newPosition;<br />&nbsp; &nbsp; bass=bass+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;ogr_bass();audio();} </p><p>&nbsp; &nbsp; &nbsp;lcd.setCursor(0,0);lcd.print(&quot;BASS&nbsp; &nbsp; &nbsp; &quot;);<br />&nbsp; switch(bass){<br />&nbsp; &nbsp; case 11: bass_d=15;break;<br />&nbsp; &nbsp; case 10: bass_d=12;break;<br />&nbsp; &nbsp; case 9:&nbsp; bass_d=9;break;<br />&nbsp; &nbsp; case 8:&nbsp; bass_d=6;break;<br />&nbsp; &nbsp; case 7:&nbsp; bass_d=3;break;<br />&nbsp; &nbsp; case 6:&nbsp; bass_d=0;break;<br />&nbsp; &nbsp; case 5:&nbsp; bass_d=-3;break;<br />&nbsp; &nbsp; case 4:&nbsp; bass_d=-6;break;<br />&nbsp; &nbsp; case 3:&nbsp; bass_d=-9;break;<br />&nbsp; &nbsp; case 2:&nbsp; bass_d=-12;break;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp;if(bass_d&gt;=0){lcd.print(&quot;+&quot;);}else{lcd.print(&quot;-&quot;);}<br />&nbsp; &nbsp;if(bass_d&gt;-10&amp;&amp;bass_d&lt;=0||bass_d&lt;10&amp;&amp;bass_d&gt;0){{lcd.print(&quot; &quot;);}}<br />&nbsp; lcd.print(abs(bass_d));lcd.print(&quot; dB&nbsp; &nbsp;&quot;);<br />&nbsp; &nbsp; if(w2==1){bass_d=bass_d+12;<br />&nbsp; &nbsp; for(z=0,z0=0,z1=0;z&lt;=bass_d;z++,z1++){if(z1&gt;2){z1=0;z0++;}<br />&nbsp; &nbsp; if(z1==1){lcd.setCursor(z0+3,1);lcd.write((uint8_t)0);lcd.setCursor(z0+3+1,1);lcd.print(&quot;&nbsp; &nbsp;&quot;);}}<br />&nbsp; &nbsp; if(bass_d==0){lcd.setCursor(0,1);lcd.print(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;);}w2=0;}}</p><p>/////////////////////// TREBLE //////////////////////////////////////////////////////<br />&nbsp; if(menu==2){ <br />&nbsp; &nbsp; &nbsp;if(ir.value==0x2FD906F){treb++;gr1=1;gr2=0;cl();w2=1;ogr_treb();audio();}// кнопка &gt; <br />&nbsp; &nbsp; &nbsp;if(ir.value==0xFFFFFFFF and gr1==1){treb++;gr2=0;cl();w2=1;ogr_treb();audio();}// кнопка &gt;&gt;&gt;&gt;&gt;&gt;<br />&nbsp; &nbsp; &nbsp;if(ir.value==0x2FDF20D){treb--;gr1=0;gr2=1;cl();w2=1;ogr_treb();audio();}// кнопка &lt;<br />&nbsp; &nbsp; &nbsp;if(ir.value==0xFFFFFFFF and gr2==1){treb--;gr1=0;cl();w2=1;ogr_treb();audio();}// кнопка &lt;&lt;&lt;&lt;&lt;&lt;<br />&nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; if (newPosition != oldPosition){oldPosition = newPosition;<br />&nbsp; &nbsp; treb=treb+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;ogr_treb();audio();} </p><p>&nbsp; &nbsp; &nbsp;lcd.setCursor(0,0);lcd.print(&quot;TREBLE&nbsp; &nbsp; &quot;);<br />&nbsp; switch(treb){<br />&nbsp; &nbsp; case 10: treb_d=12;break;<br />&nbsp; &nbsp; case 9:&nbsp; treb_d=9;break;<br />&nbsp; &nbsp; case 8:&nbsp; treb_d=6;break;<br />&nbsp; &nbsp; case 7:&nbsp; treb_d=3;break;<br />&nbsp; &nbsp; case 6:&nbsp; treb_d=0;break;<br />&nbsp; &nbsp; case 5:&nbsp; treb_d=-3;break;<br />&nbsp; &nbsp; case 4:&nbsp; treb_d=-6;break;<br />&nbsp; &nbsp; case 3:&nbsp; treb_d=-9;break;<br />&nbsp; &nbsp; case 2:&nbsp; treb_d=-12;break;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp;if(treb_d&gt;=0){lcd.print(&quot;+&quot;);}else{lcd.print(&quot;-&quot;);}<br />&nbsp; &nbsp;if(treb_d&gt;-10&amp;&amp;treb_d&lt;=0||treb_d&lt;10&amp;&amp;treb_d&gt;0){{lcd.print(&quot; &quot;);}}<br />&nbsp; lcd.print(abs(treb_d));lcd.print(&quot; dB&nbsp; &nbsp;&quot;);<br />&nbsp; &nbsp; if(w2==1){treb_d=treb_d+12;<br />&nbsp; &nbsp; for(z=0,z0=0,z1=0;z&lt;=treb_d;z++,z1++){if(z1&gt;2){z1=0;z0++;}<br />&nbsp; &nbsp; if(z1==1){lcd.setCursor(z0+4,1);lcd.write((uint8_t)0);lcd.setCursor(z0+4+1,1);lcd.print(&quot;&nbsp; &nbsp;&quot;);}}<br />&nbsp; &nbsp; if(treb_d==0){lcd.setCursor(0,1);lcd.print(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;);}w2=0;}}</p><p>//////////////// BALANCE /////////////////////////////////////<br />&nbsp; &nbsp;if(menu==3){ <br />&nbsp; &nbsp; &nbsp;if(ir.value==0x2FD906F){balans++;gr1=1;gr2=0;cl();w2=1;ogr_balans();audio();}// кнопка &gt; <br />&nbsp; &nbsp; &nbsp;if(ir.value==0xFFFFFFFF and gr1==1){balans++;gr2=0;cl();w2=1;ogr_balans();audio();}// кнопка &gt;&gt;&gt;&gt;&gt;&gt;<br />&nbsp; &nbsp; &nbsp;if(ir.value==0x2FDF20D){balans--;gr1=0;gr2=1;cl();w2=1;ogr_balans();audio();}// кнопка &lt;<br />&nbsp; &nbsp; &nbsp;if(ir.value==0xFFFFFFFF and gr2==1){balans--;gr1=0;cl();w2=1;ogr_balans();audio();}// кнопка &lt;&lt;&lt;&lt;&lt;&lt;<br />&nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; if (newPosition != oldPosition){oldPosition = newPosition;<br />&nbsp; &nbsp; balans=balans+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2=1;lcd.clear();ogr_balans();audio();} </p><p>&nbsp; &nbsp; lcd.setCursor(0,0);<br />&nbsp; &nbsp;if(balans*2&gt;=0){lcd.print(&quot;-&quot;);}else{lcd.print(&quot;+&quot;);}<br />&nbsp; lcd.print(abs(balans*2));lcd.print(&quot; dB &quot;);<br />&nbsp; lcd.print(&quot; &lt;&gt;&nbsp; &quot;);<br />&nbsp; &nbsp;if(balans*2&gt;=0){lcd.print(&quot;+&quot;);}else{lcd.print(&quot;-&quot;);}<br />&nbsp; lcd.print(abs(balans*2));lcd.print(&quot; dB &quot;);<br />&nbsp; lcd.setCursor(0,1);lcd.print(&quot;L&quot;);<br />&nbsp; lcd.setCursor(15,1);lcd.print(&quot;R&quot;);<br />&nbsp; &nbsp;if(balans&lt;0){lcd.setCursor(balans+7,1);lcd.write((uint8_t)0);}<br />&nbsp; &nbsp;if(balans&gt;0){lcd.setCursor(balans+8,1);lcd.write((uint8_t)0);}<br />&nbsp; &nbsp;if(balans==0){lcd.setCursor(7,1);lcd.write((uint8_t)0);lcd.setCursor(8,1);lcd.write((uint8_t)0);}}</p><p>&nbsp; ///////////////////////// input /////////////////////////////<br />&nbsp; if(menu==4){<br />&nbsp; &nbsp; &nbsp;if(ir.value==0x2FD906F){in++;gr1=1;gr2=0;cl1();w2=1;ogr_in();audio();}// кнопка &gt; <br />&nbsp; &nbsp; &nbsp;if(ir.value==0xFFFFFFFF and gr1==1){in++;gr2=0;cl1();w2=1;ogr_in();audio();}// кнопка &gt;&gt;&gt;&gt;&gt;&gt;<br />&nbsp; &nbsp; &nbsp;if(ir.value==0x2FDF20D){in--;gr1=0;gr2=1;cl1();w2=1;ogr_in();audio();}// кнопка &lt;<br />&nbsp; &nbsp; &nbsp;if(ir.value==0xFFFFFFFF and gr2==1){in--;gr1=0;cl1();w2=1;ogr_in();audio();}// кнопка &lt;&lt;&lt;&lt;&lt;&lt;<br />&nbsp; &nbsp; <br />if (newPosition != oldPosition) {<br />&nbsp; &nbsp; oldPosition = newPosition;<br />&nbsp; &nbsp; in=in+newPosition;myEnc.write(0);newPosition=0;audio();lcd.clear();time=millis();w=1;ogr_in();audio();}</p><p>&nbsp; lcd.setCursor(0,0);lcd.print(&quot;Source selector&quot;);<br />&nbsp; lcd.setCursor(0,1);lcd.print(&quot;INPUT: &quot;);lcd.print(in);<br /> }<br />////////////////////////////////////////////////////////////////</p><p>&nbsp; &nbsp; if(millis()-time&gt;10000 &amp;&amp; w==1){// сохранение всех настроек в eeprom через 10 сек неактивности<br />&nbsp; &nbsp; &nbsp;EEPROM.update(0,vol);<br />&nbsp; &nbsp; &nbsp;EEPROM.update(4,balans+4);<br />&nbsp; &nbsp; &nbsp;EEPROM.update(1,bass);<br />&nbsp; &nbsp; &nbsp;EEPROM.update(2,treb);<br />&nbsp; &nbsp; &nbsp;EEPROM.update(3,in);<br />&nbsp; &nbsp; &nbsp;w=0;w2=1;menu=0;cl(); }</p><br /><p>}//loop<br />void ogr_in(){if(in&gt;1){in=0;}if(in&lt;0){in=1;}}<br />void ogr_balans(){if(balans&gt;4){balans=4;}if(balans&lt;-4){balans=-4;}}<br />void ogr_treb(){if(treb&gt;10){treb=10;}if(treb&lt;2){treb=2;}}<br />void ogr_bass(){if(bass&gt;11){bass=11;}if(bass&lt;2){bass=2;}}<br />void ogr_vol(){if(vol&lt;0){vol=0;}if(vol&gt;63){vol=63;}}<br />void cl(){ir.value=0;delay(200);lcd.clear();}<br />void cl1(){ir.value=0;delay(400);lcd.clear();}<br />void to_Timer(){newPosition = myEnc.read()/4;}<br />void audio(){<br />&nbsp; tda.setVolumeL(vol+balans);<br />&nbsp; tda.setVolumeR(vol-balans);<br />&nbsp; tda.setBass(bass);<br />&nbsp; tda.setTreble(treb);<br />&nbsp; tda.setMute(mute);<br />&nbsp; tda.setSource(in);</p>]]></summary>
			<author>
				<name><![CDATA[nikolavr57]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=1904</uri>
			</author>
			<updated>2022-11-26T10:07:14Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=527&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Темброблок 5.1 на PT2323 и PT2322 (Arduino)]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=486&amp;action=new" />
			<summary type="html"><![CDATA[<p>Добрый вечер. Скетч работает отлично, переделал под свой пульт, добавил дополнительно<br />тембра в меню. Никак не могу сделать вот так<br />lcd.setCursor(0,0);lcd.print(«INPUT «);<br />switch(in){ // пропишите свои названия входов<br />case 0: lcd.print(» AUX «); break;<br />case 1: lcd.print(» mp3 «); break;<br />case 2: lcd.print(«Bluetooth»); break;<br />case 3: lcd.print(» radio «); break;<br />case 4: lcd.print(» — 5.1 — «); break;}} <br />Вот мой скетч.</p><p><span class="attention-yellow"></span></p>]]></summary>
			<author>
				<name><![CDATA[taban]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=1710</uri>
			</author>
			<updated>2022-04-02T16:14:31Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=486&amp;action=new</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Измерение температуры (18B20) с записью данных на MicroSD]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?id=258&amp;action=new" />
			<summary type="html"><![CDATA[<p>1 скетч</p><div class="codebox"><pre><code>//    Подключение
 
//  CD       MOSI D11, MISO D12, CLK D13, CS D4, VCC +5V
//  18B20    OUT A1, +5V VCC
//  DS3231   SDA A4, SCL A5, VCC +5V
 
#include &lt;SPI.h&gt;
#include &lt;SD.h&gt;
#include &lt;OneWire.h&gt;
#include &lt;Wire.h&gt;
#include &lt;DallasTemperature.h&gt;
#include &lt;DS3231.h&gt;
OneWire oneWire(A1);
DallasTemperature t(&amp;oneWire);
DS3231 clock;
RTCDateTime DateTime;
 
File myFile; 
float temp;
long nomer;
 
void setup() {
  Serial.begin(9600);
  Serial.print(&quot;Initializing SD card...&quot;);
  if (!SD.begin(4)) {Serial.println(&quot; Error!!!&quot;); return;}
  else{Serial.println(&quot; OK&quot;);}// проверка подключения
 
  t.begin(); 
  t.setResolution(12);// 12 bit 18b20
  clock.begin();
  // clock.setDateTime(__DATE__, __TIME__);// установка времени DS3231, раскомментировать и залить скетч, далее закомментировать и залить скетч повторно   
}
 
void loop() {
  DateTime = clock.getDateTime();
  Serial.print(clock.dateFormat(&quot;d-m-Y H:i:s&quot;, DateTime));
  Serial.print(&quot; &quot;);
  t.requestTemperatures();
  Serial.println(temp = t.getTempCByIndex(0));//считываем температуру
  delay(5000);// записывать данные на CD каждые 5 сек
  nomer++;
 
   myFile = SD.open(&quot;temp.txt&quot;, FILE_WRITE);// открываем файл для записи, если файла нет, то создае его
   myFile.print(nomer);// запись
   myFile.print(&quot; &quot;);// запись

   myFile.print(DateTime.day/10);myFile.print(DateTime.day%10);myFile.print(&quot;-&quot;);
   myFile.print(DateTime.month/10);myFile.print(DateTime.month%10);myFile.print(&quot;-&quot;);
   myFile.print(DateTime.year);myFile.print(&quot; &quot;);

   myFile.print(DateTime.hour/10);myFile.print(DateTime.hour%10);myFile.print(&quot;-&quot;);
   myFile.print(DateTime.minute/10);myFile.print(DateTime.minute%10);myFile.print(&quot;-&quot;);
   myFile.print(DateTime.second/10);myFile.print(DateTime.second%10);
   
   myFile.print(&quot; &quot;);// запись
   myFile.println(temp);// запись
   myFile.close();// закрываем файл
}</code></pre></div><p>2 скетч</p><div class="codebox"><pre><code>//    Подключение
 
//  CD       MOSI D11, MISO D12, CLK D13, CS D4, VCC +5V
//  18B20    OUT A1, +5V VCC
//  DS3231   SDA A4, SCL A5, VCC +5V
//  TM1637   CLK D7, DIO D6, VCC +5V
 
#include &lt;SPI.h&gt;
#include &lt;SD.h&gt;
#include &lt;OneWire.h&gt;
#include &lt;Wire.h&gt;
#include &lt;DallasTemperature.h&gt;
#include &lt;EEPROM.h&gt; //#include &lt;EEPROM.h&gt;// в новой версии ARDUINO IDE
#include &lt;DS3231.h&gt;
#include &lt;TM1637Display.h&gt;
OneWire oneWire(A1);
TM1637Display display(7, 6);// CLK,DIO
DallasTemperature t(&amp;oneWire);
DS3231 clock;
RTCDateTime DateTime;
 
File myFile; 
float temp1,temp2;
int t1,t2,n,t0,reg1,reg2,w,minus_reg1,minus_reg2;
unsigned long time;
uint8_t data[]{0,0,0,0};
const int gis = 1;// гистерезис
 
void setup() {
  Serial.begin(9600);
  pinMode(A3,INPUT);// кнопка выбора
  pinMode(9,INPUT);// кнопка плюс
  pinMode(3,INPUT);// кнопка минус
  pinMode(5,OUTPUT);// выход управления реле 1 канал
  pinMode(8,OUTPUT);// выход управления реле 2 канал
  Serial.print(&quot;Initializing SD card...&quot;);
  if (!SD.begin(4)) {Serial.println(&quot; Error!!!&quot;);}
  else{Serial.println(&quot; OK&quot;);}// проверка подключения
 
  display.setBrightness(1);// яркость TM1637 0-7 
  t.begin(); 
  t.setResolution(10);// 10 bit 18b20
  clock.begin();
  // clock.setDateTime(__DATE__, __TIME__);// установка времени DS3231, раскомментировать и залить скетч, далее закомментировать и залить скетч повторно   
 
          reg1 = EEPROM.read(0); 
          minus_reg1 = EEPROM.read(1);
          if(minus_reg1==1){reg1=reg1-2*reg1;}
          reg2 = EEPROM.read(2); 
          minus_reg2 = EEPROM.read(3);
          if(minus_reg2==1){reg2=reg2-2*reg2;}
}
 
void loop() {
  DateTime = clock.getDateTime();
  Serial.print(clock.dateFormat(&quot;d-m-Y H:i:s&quot;, DateTime));
  t.requestTemperatures();
  Serial.print(&quot; t1 = &quot;);
  Serial.print(temp1 = t.getTempCByIndex(0));//считываем температуру 1 датчик
  Serial.print(&quot; t2 = &quot;);
  Serial.print(temp2 = t.getTempCByIndex(1));//считываем температуру 2 датчик
  Serial.println(&quot; &quot;);
 
  //////////////////////// запись SD /////////////////////////////////////
 if(millis()-time&gt;10000){
   myFile = SD.open(&quot;temp.txt&quot;, FILE_WRITE);// открываем файл для записи, если файла нет, то создае его

   myFile.print(DateTime.day/10);myFile.print(DateTime.day%10);myFile.print(&quot;-&quot;);
   myFile.print(DateTime.month/10);myFile.print(DateTime.month%10);myFile.print(&quot;-&quot;);
   myFile.print(DateTime.year);myFile.print(&quot; &quot;);

   myFile.print(DateTime.hour/10);myFile.print(DateTime.hour%10);myFile.print(&quot;-&quot;);
   myFile.print(DateTime.minute/10);myFile.print(DateTime.minute%10);myFile.print(&quot;-&quot;);
   myFile.print(DateTime.second/10);myFile.print(DateTime.second%10);
   
   myFile.print(&quot; t1 = &quot;);// запись
   myFile.print(temp1);// запись
   myFile.print(&quot; r1 = &quot;);// запись
   myFile.print(reg1);// запись
   myFile.print(&quot; t2 = &quot;);// запись
   myFile.print(temp2);// запись
   myFile.print(&quot; r2 = &quot;);// запись
   myFile.println(reg2);// запись
   myFile.close();// закрываем файл
   time=millis();
  }
  ////////////////////////////////////////////////////////////////////////
 
  t1 = temp1;t2 = temp2;
 
  ///////////////////////////// кнопки управления //////////////////////
  if(analogRead(A3)&gt;=900){n++;delay(200);if(n&gt;3){n=0;}}// кнопка выбор
  // терморегулятор 1
  if(digitalRead(9)==HIGH &amp;&amp; n==2){w=1;reg1++;delay(200);if(reg1&gt;125){reg1=125;}}// плюс
  if(digitalRead(3)==HIGH &amp;&amp; n==2){w=1;reg1--;delay(200);if(reg1&lt;-55){reg1=-55;}}// минус
  // терморегулятор 2
  if(digitalRead(9)==HIGH &amp;&amp; n==3){w=1;reg2++;delay(200);if(reg2&gt;125){reg2=125;}}//плюс
  if(digitalRead(3)==HIGH &amp;&amp; n==3){w=1;reg2--;delay(200);if(reg2&lt;-55){reg2=-55;}}//минус
 
  if(n==0 &amp;&amp; w==1){  EEPROM.update(0,abs(reg1));
                     if(reg1&lt;0){minus_reg1=1;}else{minus_reg1=0;}
                     EEPROM.update(1,minus_reg1);
                     EEPROM.update(2,abs(reg2));
                     if(reg2&lt;0){minus_reg2=1;}else{minus_reg2=0;}
                     EEPROM.update(3,minus_reg2);w=0;}
  /////////////////////////////////////////////////////////////////////
 
  ////////////////////////////// вывод на индикатор M1637 /////////////
  if(n==0){t0=t1;data[0] = 0x10;}
  if(n==1){t0=t2;data[0] = 0x14;}
  if(n==2){t0=reg1;data[0] = 0x11;}
  if(n==3){t0=reg2;data[0] = 0x15;}
 
  if(t0 &gt; 99){data[1] = display.encodeDigit((t0/100)%10);}
  else{data[1] = 0x00;}
  if(t0 &lt; 0){t0=abs(t0);data[1] = 0x40;}
  data[2] =  display.encodeDigit((t0/10)%10);
  data[3] =  display.encodeDigit((t0%10)%10);
  display.setSegments(data);
  ////////////////////////////////////////////////////////////////////
 
  // выходы управления реле ///
   if(reg1 &gt;= temp1 + gis){digitalWrite(5,HIGH);}
   if(reg1 &lt;= temp1 - gis){digitalWrite(5,LOW);}
   if(reg2 &gt;= temp2 + gis){digitalWrite(8,HIGH);}
   if(reg2 &lt;= temp2 - gis){digitalWrite(8,LOW);}
}</code></pre></div>]]></summary>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2021-01-14T13:55:49Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?id=258&amp;action=new</id>
		</entry>
</feed>
