diff --git a/README.md b/README.md index 207b42e..e6a8457 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ Rotation of the displays is configured in the files [src/displays/displayXXXXX.h ````c++ #define TFT_ROTATE 3 // 180 degress ```` -If there is a noisy line on one side of the screen, then in Adafruit_ST7735.cpp: +##### If there is a noisy line on one side of the screen, then in Adafruit_ST7735.cpp: ````c++ // Black tab, change MADCTL color filter if ((options == INITR_BLACKTAB) || (options == INITR_MINI160x80)) { diff --git a/yoRadio/options.h b/yoRadio/options.h index e01da76..cf6dcb7 100644 --- a/yoRadio/options.h +++ b/yoRadio/options.h @@ -1,7 +1,7 @@ #ifndef options_h #define options_h -#define VERSION "0.4.251" +#define VERSION "0.4.255" /* DISPLAY MODEL * 0 - DUMMY @@ -59,7 +59,12 @@ /* * ESP DEVBOARD */ -#define LED_BUILTIN 2 +#define LED_BUILTIN 2 + +/* + * Other settings. You can overwrite them in the myoptions.h file + */ +#define TFT_ROTATE 3 // display rotation. 3 - 180 degress #if __has_include("myoptions.h") #include "myoptions.h" diff --git a/yoRadio/src/audioVS1053/audioVS1053Ex.cpp b/yoRadio/src/audioVS1053/audioVS1053Ex.cpp index 9ef8310..9b5617a 100644 --- a/yoRadio/src/audioVS1053/audioVS1053Ex.cpp +++ b/yoRadio/src/audioVS1053/audioVS1053Ex.cpp @@ -10,6 +10,7 @@ #include "audioVS1053Ex.h" + //--------------------------------------------------------------------------------------------------------------------- AudioBuffer::AudioBuffer(size_t maxBlockSize) { // if maxBlockSize isn't set use defaultspace (1600 bytes) is enough for aac and mp3 player @@ -349,26 +350,32 @@ size_t Audio::bufferFree(){ //--------------------------------------------------------------------------------------------------------------------- void Audio::setVolume(uint8_t vol){ - // Set volume. Both left and right. - // Input value is 0..21. 21 is the loudest. + // Input value is 0..254. 254 is the loudest. // Clicking reduced by using 0xf8 to 0x00 as limits. uint16_t value; // Value to send to SCI_VOL - - //if(vol > 21) vol=21; - //uint8_t vol2 = map(vol, 0, 254, 128, 254); - //uint8_t vol2 = log((float)vol)*23+128; - //uint8_t vol2 = log10((float)vol)*50.0+128; - uint8_t lgvol = log10(((float)vol+1)) * 50.54571334 + 128; - //uint8_t vol2 = sqrt((float)vol)*7.5+128; - if(vol != curvol){ - curvol = vol; // #20 - //vol=volumetable[vol]; // Save for later use - value=map(lgvol, 0, 254, 0xF8, 0x00); // 0..100% to one channel - value=(value << 8) | value; - - write_register(SCI_VOL, value); // Volume left and right + uint8_t valueL, valueR; + int16_t balance_map = map(m_balance, -16, 16, -100, 100); + + valueL = vol; + valueR = vol; + if (balance_map < 0) { + valueR = (float)valueR-(float)valueR * abs((float)balance_map)/100; + } else if (balance_map > 0) { + valueL = (float)valueL-(float)valueL * abs((float)balance_map)/100; } + curvol = vol; + + //uint8_t lgvolL = log10(((float)valueL+1)) * 64.54571334 + 96; + //uint8_t lgvolR = log10(((float)valueR+1)) * 64.54571334 + 96; + uint8_t lgvolL = VS1053VOL(valueL); + uint8_t lgvolR = VS1053VOL(valueR); + if(lgvolL==VS1053VOLM) lgvolL=0; + if(lgvolR==VS1053VOLM) lgvolR=0; + valueL=map(lgvolL, 0, 254, 0xF8, 0x00); + valueR=map(lgvolR, 0, 254, 0xF8, 0x00); + value=(valueL << 8) | valueR; + write_register(SCI_VOL, value); } //--------------------------------------------------------------------------------------------------------------------- void Audio::setTone(uint8_t *rtone){ // Set bass/treble (4 nibbles) @@ -383,11 +390,24 @@ void Audio::setTone(uint8_t *rtone){ // Set bass/treble (4 } write_register(SCI_BASS, value); // Volume left and right } +/* +Name Bits Description +ST AMPLITUDE 15:12 Treble Control in 1.5 dB steps (-8..7, 0 = off) +ST FREQLIMIT 11:8 Lower limit frequency in 1000 Hz steps (1..15) // 1000..15000 +SB AMPLITUDE 7:4 Bass Enhancement in 1 dB steps (0..15, 0 = off) +SB FREQLIMIT 3:0 Lower limit frequency in 10 Hz steps (2..15) // 20..150 +*/ void Audio::setTone(int8_t gainLowPass, int8_t gainBandPass, int8_t gainHighPass){ - // TODO + if(gainLowPass<0) gainLowPass=0; + if(gainLowPass>15) gainLowPass=15; + if(gainBandPass<0) gainBandPass=0; + if(gainBandPass>13) gainBandPass=13; + uint8_t rtone[] = {map(gainHighPass, -16, 16, -8, 7), 2+gainBandPass, gainLowPass, 15-gainBandPass}; + setTone(rtone); } void Audio::setBalance(int8_t bal){ - // TODO + m_balance = bal; + setVolume(curvol); } //--------------------------------------------------------------------------------------------------------------------- uint8_t Audio::getVolume() // Get the currenet volume setting. diff --git a/yoRadio/src/audioVS1053/audioVS1053Ex.h b/yoRadio/src/audioVS1053/audioVS1053Ex.h index 4859a92..2957e7f 100644 --- a/yoRadio/src/audioVS1053/audioVS1053Ex.h +++ b/yoRadio/src/audioVS1053/audioVS1053Ex.h @@ -11,6 +11,9 @@ #define AUDIOBUFFER_MULTIPLIER 13 +#define VS1053VOLM 128 // 128 or 96 only +#define VS1053VOL(v) (VS1053VOLM==128?log10(((float)v+1)) * 50.54571334 + 128:log10(((float)v+1)) * 64.54571334 + 96) + #include "Arduino.h" #include "libb64/cencode.h" #include "SPI.h" @@ -128,6 +131,7 @@ private: uint8_t curvol ; // Current volume setting 0..100% const uint8_t vs1053_chunk_size = 32 ; + int8_t m_balance = 0; // -16 (mute left) ... +16 (mute right) // SCI Register const uint8_t SCI_MODE = 0x0 ; const uint8_t SCI_STATUS = 0x1 ; diff --git a/yoRadio/src/displays/displayDummy.h b/yoRadio/src/displays/displayDummy.h index 8503776..0236d6e 100644 --- a/yoRadio/src/displays/displayDummy.h +++ b/yoRadio/src/displays/displayDummy.h @@ -3,7 +3,6 @@ #include "Arduino.h" -#define TFT_ROTATE 3 #define TFT_LINEHGHT 10 #define TFT_FRAMEWDT 4 diff --git a/yoRadio/src/displays/displayN5110.h b/yoRadio/src/displays/displayN5110.h index 3668ec7..6b5b5f8 100644 --- a/yoRadio/src/displays/displayN5110.h +++ b/yoRadio/src/displays/displayN5110.h @@ -8,7 +8,6 @@ #include "fonts/TinyFont6.h" #include "fonts/DS_DIGI15pt7b.h" -#define TFT_ROTATE 0 #define TFT_LINEHGHT 8 #define TFT_FRAMEWDT 0 #define TFT_CONTRAST 55 diff --git a/yoRadio/src/displays/displaySSD1306.h b/yoRadio/src/displays/displaySSD1306.h index 774a7c0..b6f6468 100644 --- a/yoRadio/src/displays/displaySSD1306.h +++ b/yoRadio/src/displays/displaySSD1306.h @@ -5,7 +5,6 @@ #include #include -#define TFT_ROTATE 0 #define TFT_LINEHGHT 8 #define TFT_FRAMEWDT 0 diff --git a/yoRadio/src/displays/displayST7735.cpp b/yoRadio/src/displays/displayST7735.cpp index ec49f04..dc2a064 100644 --- a/yoRadio/src/displays/displayST7735.cpp +++ b/yoRadio/src/displays/displayST7735.cpp @@ -8,20 +8,6 @@ #include "../../config.h" #include "../../network.h" -#define DTYPE INITR_BLACKTAB // 1.8' https://aliexpress.ru/item/1005002822797745.html -/* If there is a noisy line on one side of the screen, then in Adafruit_ST7735.cpp: - - // Black tab, change MADCTL color filter - if ((options == INITR_BLACKTAB) || (options == INITR_MINI160x80)) { - uint8_t data = 0xC0; - sendCommand(ST77XX_MADCTL, &data, 1); - _add this_ -> _colstart = 2; - _add this_ -> _rowstart = 1; - } - -*/ -//#define DTYPE INITR_144GREENTAB // 1.44' https://aliexpress.ru/item/1005002822797745.html - class GFXClock { public: GFXClock() {}; diff --git a/yoRadio/src/displays/displayST7735.h b/yoRadio/src/displays/displayST7735.h index 73592c4..fbe36ed 100644 --- a/yoRadio/src/displays/displayST7735.h +++ b/yoRadio/src/displays/displayST7735.h @@ -6,7 +6,6 @@ #include #include "fonts/DS_DIGI28pt7b.h" -#define TFT_ROTATE 3 #define TFT_LINEHGHT 10 #define TFT_FRAMEWDT 4