From 0dfca956150474302432e8f494f69c65c868ca19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D0=BB=D0=B8=D0=BD=D0=B8=D0=BD=20=D0=A1=D0=B5?= =?UTF-8?q?=D1=80=D0=B3=D0=B5=D0=B9=20=D0=92=D0=B0=D0=BB=D0=B5=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=D0=B8=D1=87?= Date: Mon, 6 Jan 2025 15:22:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=83=D1=80=D0=BE=D0=B2=D0=BD=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=83=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D1=8F=D1=8E?= =?UTF-8?q?=D1=89=D0=B8=D1=85=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=D1=85?= =?UTF-8?q?=20=D1=80=D0=B5=D0=BB=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../control-panel-for-for-dac.ino | 101 +++++++++++------- 1 file changed, 65 insertions(+), 36 deletions(-) diff --git a/control-panel-for-for-dac/control-panel-for-for-dac.ino b/control-panel-for-for-dac/control-panel-for-for-dac.ino index 69ecff3..f712029 100644 --- a/control-panel-for-for-dac/control-panel-for-for-dac.ino +++ b/control-panel-for-for-dac/control-panel-for-for-dac.ino @@ -3,16 +3,17 @@ // https://alexgyver.ru/lessons/ // https://www.hackster.io/mircemk/diy-arduino-vfd-display-20x2-vu-volume-unit-meter-37898f -#define GAIN 1 // усиление 0...50 -#define STEP 1 // плавность полос 0...20 +#define GAIN 5 // усиление 0...50 +#define STEP 20 // плавность полос 0...20 #define RL 1 // RL - горизонт, вертикаль 0...1 // Выходы для управления реле (вкл.вкл ЦАП/Блютуз) -#define RELAY_POWER_USB 6 -#define RELAY_POWER_BT 7 +#define RELAY_POWER_USB 7 +#define RELAY_POWER_BT 6 #define RELAY_POWER_MP3 10 -#define RELAY_OUT_USB 8 -#define RELAY_OUT_BT 9 -#define RELAY_OUT_MP3 11 +#define RELAY_OUT_BT_LEFT 8 +#define RELAY_OUT_BT_RIGHT 9 +#define RELAY_OUT_MP3_LEFT 11 +#define RELAY_OUT_MP3_RIGHT 12 // Кнопки #define BTN_MENU 2 // Кнопка меню @@ -62,9 +63,10 @@ void setup() { pinMode(RELAY_POWER_USB, OUTPUT); pinMode(RELAY_POWER_BT, OUTPUT); pinMode(RELAY_POWER_MP3, OUTPUT); - pinMode(RELAY_OUT_USB, OUTPUT); - pinMode(RELAY_OUT_BT, OUTPUT); - pinMode(RELAY_OUT_MP3, OUTPUT); + pinMode(RELAY_OUT_BT_LEFT, OUTPUT); + pinMode(RELAY_OUT_BT_RIGHT, OUTPUT); + pinMode(RELAY_OUT_MP3_LEFT, OUTPUT); + pinMode(RELAY_OUT_MP3_RIGHT, OUTPUT); // lcdVuMeter.createChar(5,znak_l); // lcdVuMeter.begin(16, 2);// lcdVuMeter 16X2 @@ -89,14 +91,36 @@ void setup() { } w = EEPROM.read(0); + if (usb) { + digitalWrite(RELAY_POWER_BT,HIGH); + digitalWrite(RELAY_POWER_MP3,HIGH); + digitalWrite(RELAY_POWER_USB,HIGH); + delay(500); + digitalWrite(RELAY_OUT_BT_LEFT,HIGH); + digitalWrite(RELAY_OUT_BT_RIGHT,HIGH); + digitalWrite(RELAY_OUT_MP3_LEFT,HIGH); + digitalWrite(RELAY_OUT_MP3_RIGHT,HIGH); + } - + if (bluetooth) { + digitalWrite(RELAY_POWER_USB,HIGH); + digitalWrite(RELAY_POWER_MP3,HIGH); + delay(500); + digitalWrite(RELAY_OUT_MP3_LEFT,HIGH); + digitalWrite(RELAY_OUT_MP3_RIGHT,HIGH); + delay(1000); + digitalWrite(RELAY_OUT_BT_LEFT,LOW); + digitalWrite(RELAY_OUT_BT_RIGHT,LOW); + digitalWrite(RELAY_POWER_BT,LOW); + } + if (mp3) { + } updateMenu(); } void vu_metter() { - if(digitalRead(8)==LOW){w++;www=1;if(w>4){w=0;}delay(200);EEPROM.update(0,w);} +// if(digitalRead(8)==LOW){w++;www=1;if(w>4){w=0;}delay(200);EEPROM.update(0,w);} if(w==0&&www==1){www=0; byte a1[8] = {0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101}; @@ -168,7 +192,7 @@ i++;if(i<19){u_l0[i]=abs(ull);u_r0[i]=abs(urr);}else{i=1;} } String setUSBinput() { - return "USB input"; + return "Input: USB"; } @@ -236,52 +260,54 @@ void actionUSB() { // lcdService.clear(); lcdService.setCursor(2,1); lcdService.print("On "); - digitalWrite(RELAY_POWER_BT,LOW); - digitalWrite(RELAY_POWER_MP3,LOW); - - digitalWrite(RELAY_OUT_BT,LOW); - digitalWrite(RELAY_OUT_MP3,LOW); - delay(1000); - digitalWrite(RELAY_OUT_USB,HIGH); + digitalWrite(RELAY_POWER_BT,HIGH); + digitalWrite(RELAY_POWER_MP3,HIGH); digitalWrite(RELAY_POWER_USB,HIGH); + delay(500); + digitalWrite(RELAY_OUT_BT_LEFT,HIGH); + digitalWrite(RELAY_OUT_BT_RIGHT,HIGH); + digitalWrite(RELAY_OUT_MP3_LEFT,HIGH); + digitalWrite(RELAY_OUT_MP3_RIGHT,HIGH); usb = true; bluetooth = false; mp3 = false; - delay(1500); +// delay(1500); } void actionBT() { // lcdService.clear(); lcdService.setCursor(2,1); lcdService.print("On "); - digitalWrite(RELAY_POWER_USB,LOW); - digitalWrite(RELAY_POWER_MP3,LOW); - - digitalWrite(RELAY_OUT_USB,LOW); - digitalWrite(RELAY_OUT_MP3,LOW); + digitalWrite(RELAY_POWER_USB,HIGH); + digitalWrite(RELAY_POWER_MP3,HIGH); + delay(500); + digitalWrite(RELAY_OUT_MP3_LEFT,HIGH); + digitalWrite(RELAY_OUT_MP3_RIGHT,HIGH); delay(1000); - digitalWrite(RELAY_OUT_BT,HIGH); - digitalWrite(RELAY_POWER_BT,HIGH); + digitalWrite(RELAY_OUT_BT_LEFT,LOW); + digitalWrite(RELAY_OUT_BT_RIGHT,LOW); + digitalWrite(RELAY_POWER_BT,LOW); usb = false; bluetooth = true; mp3 = false; - delay(1500); +// delay(1500); } void actionMP3() { // lcdService.clear(); lcdService.setCursor(2,1); lcdService.print("On "); - digitalWrite(RELAY_POWER_USB,LOW); - digitalWrite(RELAY_POWER_BT,LOW); - - digitalWrite(RELAY_OUT_USB,LOW); - digitalWrite(RELAY_OUT_BT,LOW); + digitalWrite(RELAY_POWER_USB,HIGH); + digitalWrite(RELAY_POWER_BT,HIGH); + delay(500); + digitalWrite(RELAY_OUT_BT_LEFT,HIGH); + digitalWrite(RELAY_OUT_BT_RIGHT,HIGH); delay(1000); - digitalWrite(RELAY_OUT_MP3,HIGH); - digitalWrite(RELAY_POWER_MP3,HIGH); + digitalWrite(RELAY_OUT_MP3_LEFT,LOW); + digitalWrite(RELAY_OUT_MP3_RIGHT,LOW); + digitalWrite(RELAY_POWER_MP3,LOW); usb = false; bluetooth = false; mp3 = true; @@ -299,12 +325,15 @@ void loop() { lcdService.print("USB DAC"); lcdService.setCursor(0,1); lcdService.print(setUSBinput()); +// actionUSB(); } if(bluetooth){ lcdService.print("Bluetooth"); +// actionBT(); } if(mp3){ lcdService.print("MP3 module"); +// actionMP3(); } } // bool btnMenuState = digitalRead(BTN_MENU);