From 4824d651d2f41f4605c6ef211ff6b3ee9c377bb9 Mon Sep 17 00:00:00 2001 From: e2002 Date: Mon, 7 Feb 2022 10:46:29 +0300 Subject: [PATCH] vol steps 0..256 --- yoRadio/display.cpp | 4 ++-- yoRadio/options.h | 12 +++++++++--- yoRadio/src/audioI2S/Audio.cpp | 22 ++++++++++++---------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/yoRadio/display.cpp b/yoRadio/display.cpp index e12abda..30c6c5b 100644 --- a/yoRadio/display.cpp +++ b/yoRadio/display.cpp @@ -8,8 +8,8 @@ #include "network.h" //#define DSP_DUMMY -#define DSP_ST7735 -//#define DSP_SSD1306 +//#define DSP_ST7735 +#define DSP_SSD1306 #ifdef DSP_DUMMY #include "src/displays/displayDummy.h" diff --git a/yoRadio/options.h b/yoRadio/options.h index dde3c43..ee87d27 100644 --- a/yoRadio/options.h +++ b/yoRadio/options.h @@ -1,7 +1,7 @@ #ifndef options_h #define options_h -#define VERSION "0.4.177" +#define VERSION "0.4.180" /* * TFT DISPLAY @@ -27,21 +27,27 @@ /* * I2S DAC */ +/* #define I2S_DOUT 27 // DIN connection #define I2S_BCLK 26 // BCLK Bit clock #define I2S_LRC 25 // WSEL Left Right Clock +/*/ +#define I2S_DOUT 22 // DIN connection +#define I2S_BCLK 26 // BCLK Bit clock +#define I2S_LRC 25 // WSEL Left Right Clock +//*/ /* * ENCODER */ #define ENC_BTNL 13 -#define ENC_BTNB 12 +#define ENC_BTNB 13 #define ENC_BTNR 14 /* * BUTTONS */ #define BTN_LEFT 32 -#define BTN_CENTER 31 +#define BTN_CENTER 14 #define BTN_RIGHT 33 /* * ESP DEVBOARD diff --git a/yoRadio/src/audioI2S/Audio.cpp b/yoRadio/src/audioI2S/Audio.cpp index 01a8ca4..89b43a0 100644 --- a/yoRadio/src/audioI2S/Audio.cpp +++ b/yoRadio/src/audioI2S/Audio.cpp @@ -550,7 +550,7 @@ bool Audio::connecttohost(const char* host, const char* user, const char* pwd) { } const uint32_t TIMEOUT_MS_SSL{3700}; - + if(m_f_ssl == true) { uint32_t t = millis(); if(clientsecure.connect(hostwoext, port, TIMEOUT_MS_SSL)) { @@ -4244,37 +4244,39 @@ void Audio::setBalance(int8_t bal){ // bal -16...16 } //--------------------------------------------------------------------------------------------------------------------- void Audio::setVolume(uint8_t vol) { // vol 22 steps, 0...21 - //if(vol > 21) vol = 21; + if(vol > 256) vol = 256; //volume = map(eeprom_config.volume, 0, 21, 0, 255); - m_vol = map(vol, 0, 254, 0, 64); + //m_vol = map(vol, 0, 254, 0, 64); + m_vol = vol; //m_vol = volumetable[vol]; } //--------------------------------------------------------------------------------------------------------------------- uint8_t Audio::getVolume() { - return map(m_vol, 0, 64, 0, 254); + return m_vol; + /*return map(m_vol, 0, 64, 0, 254); for(uint8_t i = 0; i < 22; i++) { if(volumetable[i] == m_vol) return i; } m_vol = 12; // if m_vol not found in table - return m_vol; + return m_vol;*/ } //--------------------------------------------------------------------------------------------------------------------- int32_t Audio::Gain(int16_t s[2]) { int32_t v[2]; - float step = (float)m_vol /64; + float step = (float)m_vol /254; uint8_t l = 0, r = 0; if(m_balance < 0){ - step = step * (float)(abs(m_balance) * 4); + step = step * (float)(abs(m_balance) * 16); l = (uint8_t)(step); } if(m_balance > 0){ - step = step * m_balance * 4; + step = step * m_balance * 16; r = (uint8_t)(step); } - v[LEFTCHANNEL] = (s[LEFTCHANNEL] * (m_vol - l)) >> 6; - v[RIGHTCHANNEL]= (s[RIGHTCHANNEL] * (m_vol - r)) >> 6; + v[LEFTCHANNEL] = (s[LEFTCHANNEL] * (m_vol - l)) >> 8; + v[RIGHTCHANNEL]= (s[RIGHTCHANNEL] * (m_vol - r)) >> 8; return (v[RIGHTCHANNEL] << 16) | (v[LEFTCHANNEL] & 0xffff); }