v0.6.494
This commit is contained in:
@@ -4269,7 +4269,8 @@ int32_t Audio::Gain(int16_t s[2]) {
|
||||
step = step * m_balance * 16;
|
||||
r = (uint8_t)(step);
|
||||
}
|
||||
|
||||
vuLeft = s[LEFTCHANNEL] >> 7;
|
||||
vuRight = s[RIGHTCHANNEL] >> 7;
|
||||
v[LEFTCHANNEL] = (s[LEFTCHANNEL] * (m_vol - l)) >> 8;
|
||||
v[RIGHTCHANNEL]= (s[RIGHTCHANNEL] * (m_vol - r)) >> 8;
|
||||
|
||||
|
||||
@@ -186,7 +186,10 @@ public:
|
||||
uint32_t getAudioCurrentTime();
|
||||
uint32_t getTotalPlayingTime();
|
||||
void setDefaults();
|
||||
|
||||
/* VU METER */
|
||||
void setVUmeter() {};
|
||||
void getVUlevel() {};
|
||||
uint8_t vuLeft, vuRight;
|
||||
SemaphoreHandle_t mutex_pl=NULL;
|
||||
|
||||
esp_err_t i2s_mclk_pin_select(const uint8_t pin);
|
||||
|
||||
@@ -331,6 +331,8 @@ void Audio::begin(){
|
||||
write_register(SCI_AUDATA, 44100 + 1); // 44.1kHz + stereo
|
||||
// The next clocksetting allows SPI clocking at 5 MHz, 4 MHz is safe then.
|
||||
write_register(SCI_CLOCKF, 6 << 12); // Normal clock settings multiplyer 3.0=12.2 MHz
|
||||
//set vu meter
|
||||
setVUmeter();
|
||||
//SPI Clock to 4 MHz. Now you can set high speed SPI clock.
|
||||
VS1053_SPI=SPISettings(6700000, MSBFIRST, SPI_MODE0); // SPIDIV 12 -> 80/12=6.66 MHz
|
||||
write_register(SCI_MODE, _BV (SM_SDINEW) | _BV(SM_LINE1));
|
||||
@@ -353,6 +355,16 @@ size_t Audio::bufferFree(){
|
||||
return InBuff.freeSpace();
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
uint32_t Audio::inBufferFilled() {
|
||||
// current audio input buffer fillsize in bytes
|
||||
return InBuff.bufferFilled();
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
uint32_t Audio::inBufferFree() {
|
||||
// current audio input buffer free space in bytes
|
||||
return InBuff.freeSpace();
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void Audio::setVolume(uint8_t vol){
|
||||
// Set volume. Both left and right.
|
||||
@@ -1542,6 +1554,45 @@ void Audio::setDefaults(){
|
||||
m_f_tts = false; // text to speech
|
||||
m_f_localfile = false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
* \brief enable VSdsp VU Meter
|
||||
*
|
||||
* \param[in] enable when set will enable the VU meter
|
||||
*
|
||||
* Writes the SS_VU_ENABLE bit of the SCI_STATUS register to enable VU meter on
|
||||
* board to the VSdsp.
|
||||
*
|
||||
* See data patches data sheet VU meter for details.
|
||||
* \warning This feature is only available with patches that support VU meter.
|
||||
* \n The VU meter takes about 0.2MHz of processing power with 48 kHz samplerate.
|
||||
*/
|
||||
void Audio::setVUmeter() {
|
||||
if(!ENABLE_VU_METER) return;
|
||||
uint16_t MP3Status = read_register(SCI_STATUS);
|
||||
write_register(SCI_STATUS, MP3Status | _BV(9));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
* \brief get current measured VU Meter
|
||||
*
|
||||
* Returns the calculated peak sample values from both channels in 3 dB
|
||||
* increaments through. Where the high byte represent the left channel,
|
||||
* and the low bytes the right channel.
|
||||
*
|
||||
* Values from 0 to 31 are valid for both channels.
|
||||
*
|
||||
* \warning This feature is only available with patches that support VU meter.
|
||||
*/
|
||||
void Audio::getVUlevel() {
|
||||
if(!ENABLE_VU_METER) return;
|
||||
int16_t reg = read_register(SCI_AICTRL3);
|
||||
uint8_t rl = map((uint8_t)reg, 81, 92, 0, 255);
|
||||
uint8_t rr = map((uint8_t)(reg >> 8), 81, 92, 0, 255);
|
||||
if(rl>30 || !isRunning()) vuLeft = rl;
|
||||
if(rr>30 || !isRunning()) vuRight = rr;
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool Audio::connecttohost(String host){
|
||||
return connecttohost(host.c_str());
|
||||
|
||||
@@ -241,7 +241,6 @@ protected:
|
||||
void loadUserCode();
|
||||
|
||||
|
||||
|
||||
public:
|
||||
// Constructor. Only sets pin values. Doesn't touch the chip. Be sure to call begin()!
|
||||
Audio ( uint8_t _cs_pin, uint8_t _dcs_pin, uint8_t _dreq_pin, uint8_t spi = VSPI, uint8_t mosi = 23, uint8_t miso = 19, uint8_t sclk = 18);
|
||||
@@ -269,11 +268,17 @@ public:
|
||||
SemaphoreHandle_t mutex_pl=NULL;
|
||||
size_t bufferFilled();
|
||||
size_t bufferFree();
|
||||
uint32_t inBufferFilled(); // returns the number of stored bytes in the inputbuffer
|
||||
uint32_t inBufferFree(); // returns the number of free bytes in the inputbuffer
|
||||
bool isRunning() {/*Serial.printf("m_f_running=%d\n", m_f_running); */return m_f_running;}
|
||||
void setBalance(int8_t bal = 0);
|
||||
void setTone(int8_t gainLowPass, int8_t gainBandPass, int8_t gainHighPass);
|
||||
void setDefaults();
|
||||
void forceMono(bool m) {} // TODO
|
||||
/* VU METER */
|
||||
void setVUmeter();
|
||||
void getVUlevel();
|
||||
uint8_t vuLeft, vuRight;
|
||||
// implement several function with respect to the index of string
|
||||
bool startsWith (const char* base, const char* str) { return (strstr(base, str) - base) == 0;}
|
||||
bool endsWith (const char* base, const char* str) {
|
||||
|
||||
@@ -284,7 +284,6 @@ void DspCore::displayHeapForDebug() {
|
||||
fillRect(TFT_FRAMEWDT, vTop, swidth - TFT_FRAMEWDT / 2, 7, TFT_BG);
|
||||
sprintf(buf, "%d / %d", ESP.getFreeHeap(), ESP.getMaxAllocHeap());
|
||||
print(buf);
|
||||
#if VS1053_CS==255
|
||||
// audio buffer;
|
||||
fillRect(0, sheight - 2, swidth, 2, TFT_BG);
|
||||
int astored = player.inBufferFilled();
|
||||
@@ -292,7 +291,6 @@ void DspCore::displayHeapForDebug() {
|
||||
int aprcnt = 100 * astored / (astored + afree);
|
||||
byte sbw = map(aprcnt, 0, 100 , 0, swidth);
|
||||
fillRect(0, sheight - 2, sbw, 2, SILVER);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DspCore::printClock(const char* timestr) {
|
||||
|
||||
@@ -121,6 +121,7 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
|
||||
setTextSize(1);
|
||||
screenwidth = width();
|
||||
screenheight = height();
|
||||
Serial.printf("ILI9341 %dx%d\n", screenwidth, screenheight);
|
||||
swidth = screenwidth;
|
||||
sheight = screenheight;
|
||||
}
|
||||
@@ -208,7 +209,6 @@ void DspCore::displayHeapForDebug() {
|
||||
print(ESP.getFreeHeap());
|
||||
print(" / ");
|
||||
print(ESP.getMaxAllocHeap());
|
||||
#if VS1053_CS==255
|
||||
// audio buffer;
|
||||
fillRect(0, sheight - 2, swidth, 2, TFT_BG);
|
||||
int astored = player.inBufferFilled();
|
||||
@@ -216,7 +216,6 @@ void DspCore::displayHeapForDebug() {
|
||||
int aprcnt = 100 * astored / (astored + afree);
|
||||
byte sbw = map(aprcnt, 0, 100 , 0, swidth);
|
||||
fillRect(0, sheight - 2, sbw, 2, SILVER);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DspCore::printClock(const char* timestr) {
|
||||
|
||||
@@ -220,7 +220,6 @@ void DspCore::displayHeapForDebug() {
|
||||
print(ESP.getFreeHeap());
|
||||
print(" / ");
|
||||
print(ESP.getMaxAllocHeap());
|
||||
#if VS1053_CS==255
|
||||
// audio buffer;
|
||||
fillRect(0, sheight - 2, swidth, 2, TFT_BG);
|
||||
int astored = player.inBufferFilled();
|
||||
@@ -228,7 +227,6 @@ void DspCore::displayHeapForDebug() {
|
||||
int aprcnt = 100 * astored / (astored + afree);
|
||||
byte sbw = map(aprcnt, 0, 100 , 0, swidth);
|
||||
fillRect(0, sheight - 2, sbw, 2, DARK_GRAY);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DspCore::setClockBounds(){
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
#define DEF_SPI_FREQ 40000000UL /* set it to 0 for system default */
|
||||
#endif
|
||||
|
||||
#if ENABLE_VU_METER && DTYPE==INITR_BLACKTAB
|
||||
#define CLOCK_DELTA 12
|
||||
#else
|
||||
#define CLOCK_DELTA 0
|
||||
#endif
|
||||
|
||||
#define TAKE_MUTEX() if(player.mutex_pl) xSemaphoreTake(player.mutex_pl, portMAX_DELAY)
|
||||
#define GIVE_MUTEX() if(player.mutex_pl) xSemaphoreGive(player.mutex_pl)
|
||||
|
||||
@@ -220,7 +226,6 @@ void DspCore::displayHeapForDebug() {
|
||||
print(ESP.getFreeHeap());
|
||||
print(" / ");
|
||||
print(ESP.getMaxAllocHeap());
|
||||
#if VS1053_CS==255
|
||||
// audio buffer;
|
||||
fillRect(0, sheight - 2, swidth, 2, TFT_BG);
|
||||
int astored = player.inBufferFilled();
|
||||
@@ -229,7 +234,6 @@ void DspCore::displayHeapForDebug() {
|
||||
byte sbw = map(aprcnt, 0, 100 , 0, swidth);
|
||||
fillRect(0, sheight - 2, sbw, 2, SILVER);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void DspCore::setClockBounds(){
|
||||
@@ -263,10 +267,10 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
|
||||
setFont(&DS_DIGI28pt7b);
|
||||
if(strstr(oldTimeBuf, timeBuf)==NULL || redraw){
|
||||
getTextBounds(oldTimeBuf, 0, 0, &x, &y, &wot, &hot);
|
||||
setCursor((swidth - wot) / 2 - 4, clockY+28+6);
|
||||
setCursor((swidth - wot) / 2 - 4 + CLOCK_DELTA, clockY+28+6);
|
||||
setTextColor(TFT_BG);
|
||||
print(oldTimeBuf);
|
||||
dot = (swidth - wot) / 2 - 4;
|
||||
dot = (swidth - wot) / 2 - 4 + CLOCK_DELTA;
|
||||
/* dots */
|
||||
strlcpy(tmpBuf, oldTimeBuf, 3);
|
||||
getTextBounds(tmpBuf, 0, 0, &x, &y, &ncwidth, &ncheight);
|
||||
@@ -279,8 +283,8 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
|
||||
setTextSize(1);
|
||||
getTextBounds(timeBuf, 0, 0, &x, &y, &ncwidth, &ncheight);
|
||||
setTextColor(TFT_LOGO);
|
||||
setCursor((swidth - ncwidth) / 2 - 4, clockY+28+6);
|
||||
dot = (swidth - ncwidth) / 2 - 4;
|
||||
setCursor((swidth - ncwidth) / 2 - 4 + CLOCK_DELTA, clockY+28+6);
|
||||
dot = (swidth - ncwidth) / 2 - 4 + CLOCK_DELTA;
|
||||
setTextSize(1);
|
||||
print(timeBuf);
|
||||
/* dots */
|
||||
|
||||
@@ -216,7 +216,6 @@ void DspCore::displayHeapForDebug() {
|
||||
print(ESP.getFreeHeap());
|
||||
print(" / ");
|
||||
print(ESP.getMaxAllocHeap());
|
||||
#if VS1053_CS==255
|
||||
// audio buffer;
|
||||
fillRect(0, sheight - 2, swidth, 2, TFT_BG);
|
||||
int astored = player.inBufferFilled();
|
||||
@@ -224,7 +223,6 @@ void DspCore::displayHeapForDebug() {
|
||||
int aprcnt = 100 * astored / (astored + afree);
|
||||
byte sbw = map(aprcnt, 0, 100 , 0, swidth);
|
||||
fillRect(0, sheight - 2, sbw, 2, SILVER);
|
||||
#endif
|
||||
yield();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user