sd_i2s+sd_vs_v1
This commit is contained in:
@@ -73,6 +73,7 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti
|
|||||||
/******************************************/
|
/******************************************/
|
||||||
|
|
||||||
/* SDCARD */
|
/* SDCARD */
|
||||||
|
/* MISO is the same as D0, MOSI is the same as D1 */
|
||||||
//#define SDC_SPI 18, 19, 23 /* SDCARD SPI pins (SCK, MISO, MOSI) */
|
//#define SDC_SPI 18, 19, 23 /* SDCARD SPI pins (SCK, MISO, MOSI) */
|
||||||
//#define SDC_CS 255 /* SDCARD CS pin */
|
//#define SDC_CS 255 /* SDCARD CS pin */
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -166,7 +166,7 @@ Audio::Audio(bool internalDAC /* = false */, uint8_t channelEnabled /* = I2S_DAC
|
|||||||
#ifdef AUDIO_LOG
|
#ifdef AUDIO_LOG
|
||||||
m_f_Log = true;
|
m_f_Log = true;
|
||||||
#endif
|
#endif
|
||||||
|
mutex_pl = xSemaphoreCreateMutex();
|
||||||
clientsecure.setInsecure(); // if that can't be resolved update to ESP32 Arduino version 1.0.5-rc05 or higher
|
clientsecure.setInsecure(); // if that can't be resolved update to ESP32 Arduino version 1.0.5-rc05 or higher
|
||||||
m_f_channelEnabled = channelEnabled;
|
m_f_channelEnabled = channelEnabled;
|
||||||
m_f_internalDAC = internalDAC;
|
m_f_internalDAC = internalDAC;
|
||||||
@@ -679,7 +679,8 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path, uint32_t resumeFilePos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AUDIO_INFO("Reading file: \"%s\"", audioName); vTaskDelay(2);
|
AUDIO_INFO("Reading file: \"%s\"", audioName); vTaskDelay(2);
|
||||||
|
if(audio_beginSDread) audio_beginSDread();
|
||||||
|
cardLock(true);
|
||||||
if(fs.exists(audioName)) {
|
if(fs.exists(audioName)) {
|
||||||
audiofile = fs.open(audioName); // #86
|
audiofile = fs.open(audioName); // #86
|
||||||
}
|
}
|
||||||
@@ -689,24 +690,24 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path, uint32_t resumeFilePos) {
|
|||||||
audiofile = fs.open(audioName);
|
audiofile = fs.open(audioName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cardLock(false);
|
||||||
if(!audiofile) {
|
if(!audiofile) {
|
||||||
if(audio_info) {vTaskDelay(2); audio_info("Failed to open file for reading");}
|
if(audio_info) {vTaskDelay(2); audio_info("Failed to open file for reading");}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
cardLock(true);
|
||||||
setDatamode(AUDIO_LOCALFILE);
|
setDatamode(AUDIO_LOCALFILE);
|
||||||
m_file_size = audiofile.size();//TEST loop
|
m_file_size = audiofile.size();//TEST loop
|
||||||
|
cardLock(false);
|
||||||
char* afn = NULL; // audioFileName
|
char* afn = NULL; // audioFileName
|
||||||
|
cardLock(true);
|
||||||
#ifdef SDFATFS_USED
|
#ifdef SDFATFS_USED
|
||||||
audiofile.getName(chbuf, sizeof(chbuf));
|
audiofile.getName(chbuf, sizeof(chbuf));
|
||||||
afn = strdup(chbuf);
|
afn = strdup(chbuf);
|
||||||
#else
|
#else
|
||||||
afn = strdup(audiofile.name());
|
afn = strdup(audiofile.name());
|
||||||
#endif
|
#endif
|
||||||
|
cardLock(false);
|
||||||
uint8_t dotPos = lastIndexOf(afn, ".");
|
uint8_t dotPos = lastIndexOf(afn, ".");
|
||||||
for(uint8_t i = dotPos + 1; i < strlen(afn); i++){
|
for(uint8_t i = dotPos + 1; i < strlen(afn); i++){
|
||||||
afn[i] = toLowerCase(afn[i]);
|
afn[i] = toLowerCase(afn[i]);
|
||||||
@@ -724,7 +725,9 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path, uint32_t resumeFilePos) {
|
|||||||
|
|
||||||
bool ret = initializeDecoder();
|
bool ret = initializeDecoder();
|
||||||
if(ret) m_f_running = true;
|
if(ret) m_f_running = true;
|
||||||
else audiofile.close();
|
else {
|
||||||
|
cardLock(true);audiofile.close();cardLock(false);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -974,7 +977,7 @@ void Audio::showID3Tag(const char* tag, const char* value){
|
|||||||
if(!strcmp(tag, "OWNE")) sprintf(chbuf, "Ownership: %s", value);
|
if(!strcmp(tag, "OWNE")) sprintf(chbuf, "Ownership: %s", value);
|
||||||
// if(!strcmp(tag, "PRIV")) sprintf(chbuf, "Private: %s", value);
|
// if(!strcmp(tag, "PRIV")) sprintf(chbuf, "Private: %s", value);
|
||||||
if(!strcmp(tag, "SYLT")) sprintf(chbuf, "SynLyrics: %s", value);
|
if(!strcmp(tag, "SYLT")) sprintf(chbuf, "SynLyrics: %s", value);
|
||||||
if(!strcmp(tag, "TALB")) sprintf(chbuf, "Album: %s", value);
|
if(!strcmp(tag, "TALB")) { sprintf(chbuf, "Album: %s", value); if(audio_id3album) audio_id3album(value); }
|
||||||
if(!strcmp(tag, "TBPM")) sprintf(chbuf, "BeatsPerMinute: %s", value);
|
if(!strcmp(tag, "TBPM")) sprintf(chbuf, "BeatsPerMinute: %s", value);
|
||||||
if(!strcmp(tag, "TCMP")) sprintf(chbuf, "Compilation: %s", value);
|
if(!strcmp(tag, "TCMP")) sprintf(chbuf, "Compilation: %s", value);
|
||||||
if(!strcmp(tag, "TCOM")) sprintf(chbuf, "Composer: %s", value);
|
if(!strcmp(tag, "TCOM")) sprintf(chbuf, "Composer: %s", value);
|
||||||
@@ -984,7 +987,7 @@ void Audio::showID3Tag(const char* tag, const char* value){
|
|||||||
if(!strcmp(tag, "TEXT")) sprintf(chbuf, "Lyricist: %s", value);
|
if(!strcmp(tag, "TEXT")) sprintf(chbuf, "Lyricist: %s", value);
|
||||||
if(!strcmp(tag, "TIME")) sprintf(chbuf, "Time: %s", value);
|
if(!strcmp(tag, "TIME")) sprintf(chbuf, "Time: %s", value);
|
||||||
if(!strcmp(tag, "TIT1")) sprintf(chbuf, "Grouping: %s", value);
|
if(!strcmp(tag, "TIT1")) sprintf(chbuf, "Grouping: %s", value);
|
||||||
if(!strcmp(tag, "TIT2")) sprintf(chbuf, "Title: %s", value);
|
if(!strcmp(tag, "TIT2")) { sprintf(chbuf, "Title: %s", value); if(audio_id3album) audio_id3album(value); }
|
||||||
if(!strcmp(tag, "TIT3")) sprintf(chbuf, "Subtitle: %s", value);
|
if(!strcmp(tag, "TIT3")) sprintf(chbuf, "Subtitle: %s", value);
|
||||||
if(!strcmp(tag, "TLAN")) sprintf(chbuf, "Language: %s", value);
|
if(!strcmp(tag, "TLAN")) sprintf(chbuf, "Language: %s", value);
|
||||||
if(!strcmp(tag, "TLEN")) sprintf(chbuf, "Length (ms): %s", value);
|
if(!strcmp(tag, "TLEN")) sprintf(chbuf, "Length (ms): %s", value);
|
||||||
@@ -992,7 +995,7 @@ void Audio::showID3Tag(const char* tag, const char* value){
|
|||||||
if(!strcmp(tag, "TOAL")) sprintf(chbuf, "OriginalAlbum: %s", value);
|
if(!strcmp(tag, "TOAL")) sprintf(chbuf, "OriginalAlbum: %s", value);
|
||||||
if(!strcmp(tag, "TOPE")) sprintf(chbuf, "OriginalArtist: %s", value);
|
if(!strcmp(tag, "TOPE")) sprintf(chbuf, "OriginalArtist: %s", value);
|
||||||
if(!strcmp(tag, "TORY")) sprintf(chbuf, "OriginalReleaseYear: %s", value);
|
if(!strcmp(tag, "TORY")) sprintf(chbuf, "OriginalReleaseYear: %s", value);
|
||||||
if(!strcmp(tag, "TPE1")) sprintf(chbuf, "Artist: %s", value);
|
if(!strcmp(tag, "TPE1")) { sprintf(chbuf, "Artist: %s", value); if(audio_id3artist) audio_id3artist(value); }
|
||||||
if(!strcmp(tag, "TPE2")) sprintf(chbuf, "Band: %s", value);
|
if(!strcmp(tag, "TPE2")) sprintf(chbuf, "Band: %s", value);
|
||||||
if(!strcmp(tag, "TPE3")) sprintf(chbuf, "Conductor: %s", value);
|
if(!strcmp(tag, "TPE3")) sprintf(chbuf, "Conductor: %s", value);
|
||||||
if(!strcmp(tag, "TPE4")) sprintf(chbuf, "InterpretedBy: %s", value);
|
if(!strcmp(tag, "TPE4")) sprintf(chbuf, "InterpretedBy: %s", value);
|
||||||
@@ -1728,9 +1731,11 @@ int Audio::read_ID3_Header(uint8_t *data, size_t len) {
|
|||||||
m_audioDataSize = m_contentlength - m_audioDataStart;
|
m_audioDataSize = m_contentlength - m_audioDataStart;
|
||||||
AUDIO_INFO("Audio-Length: %u", m_audioDataSize);
|
AUDIO_INFO("Audio-Length: %u", m_audioDataSize);
|
||||||
if(APIC_seen && audio_id3image){
|
if(APIC_seen && audio_id3image){
|
||||||
|
cardLock(true);
|
||||||
size_t pos = audiofile.position();
|
size_t pos = audiofile.position();
|
||||||
audio_id3image(audiofile, APIC_pos, APIC_size);
|
audio_id3image(audiofile, APIC_pos, APIC_size);
|
||||||
audiofile.seek(pos); // the filepointer could have been changed by the user, set it back
|
audiofile.seek(pos); // the filepointer could have been changed by the user, set it back
|
||||||
|
cardLock(false);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2250,13 +2255,13 @@ uint32_t Audio::stopSong() {
|
|||||||
if(getDatamode() == AUDIO_LOCALFILE){
|
if(getDatamode() == AUDIO_LOCALFILE){
|
||||||
m_streamType = ST_NONE;
|
m_streamType = ST_NONE;
|
||||||
pos = getFilePos() - inBufferFilled();
|
pos = getFilePos() - inBufferFilled();
|
||||||
audiofile.close();
|
cardLock(true);audiofile.close();cardLock(false);
|
||||||
AUDIO_INFO("Closing audio file");
|
AUDIO_INFO("Closing audio file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(audiofile){
|
if(audiofile){
|
||||||
// added this before putting 'm_f_localfile = false' in stopSong(); shoulf never occur....
|
// added this before putting 'm_f_localfile = false' in stopSong(); shoulf never occur....
|
||||||
audiofile.close();
|
cardLock(true);audiofile.close();cardLock(false);
|
||||||
AUDIO_INFO("Closing audio file");
|
AUDIO_INFO("Closing audio file");
|
||||||
log_w("Closing audio file"); // for debug
|
log_w("Closing audio file"); // for debug
|
||||||
}
|
}
|
||||||
@@ -2404,6 +2409,17 @@ bool Audio::playChunk() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void Audio::cardLock(bool lock){
|
||||||
|
#if (TFT_CS!=255) || (SDC_CS!=255)
|
||||||
|
if(lock){
|
||||||
|
xSemaphoreTake(mutex_pl, portMAX_DELAY);
|
||||||
|
}else{
|
||||||
|
xSemaphoreGive(mutex_pl);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Audio::loop() {
|
void Audio::loop() {
|
||||||
|
|
||||||
if(!m_f_running) return;
|
if(!m_f_running) return;
|
||||||
@@ -2903,7 +2919,7 @@ void Audio::processLocalFile() {
|
|||||||
if(m_resumeFilePos){
|
if(m_resumeFilePos){
|
||||||
if(m_resumeFilePos < m_audioDataStart) m_resumeFilePos = m_audioDataStart;
|
if(m_resumeFilePos < m_audioDataStart) m_resumeFilePos = m_audioDataStart;
|
||||||
if(m_avr_bitrate) m_audioCurrentTime = ((m_resumeFilePos - m_audioDataStart) / m_avr_bitrate) * 8;
|
if(m_avr_bitrate) m_audioCurrentTime = ((m_resumeFilePos - m_audioDataStart) / m_avr_bitrate) * 8;
|
||||||
audiofile.seek(m_resumeFilePos);
|
cardLock(true);audiofile.seek(m_resumeFilePos);cardLock(false);
|
||||||
InBuff.resetBuffer();
|
InBuff.resetBuffer();
|
||||||
if(m_f_Log) log_i("m_resumeFilePos %i", m_resumeFilePos);
|
if(m_f_Log) log_i("m_resumeFilePos %i", m_resumeFilePos);
|
||||||
}
|
}
|
||||||
@@ -2921,7 +2937,7 @@ void Audio::processLocalFile() {
|
|||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
bytesAddedToBuffer = audiofile.read(InBuff.getWritePtr(), bytesCanBeWritten);
|
cardLock(true); bytesAddedToBuffer = audiofile.read(InBuff.getWritePtr(), bytesCanBeWritten); cardLock(false);
|
||||||
if(bytesAddedToBuffer > 0) {
|
if(bytesAddedToBuffer > 0) {
|
||||||
InBuff.bytesWritten(bytesAddedToBuffer);
|
InBuff.bytesWritten(bytesAddedToBuffer);
|
||||||
}
|
}
|
||||||
@@ -2974,14 +2990,14 @@ void Audio::processLocalFile() {
|
|||||||
} //TEST loop
|
} //TEST loop
|
||||||
f_stream = false;
|
f_stream = false;
|
||||||
m_streamType = ST_NONE;
|
m_streamType = ST_NONE;
|
||||||
|
cardLock(true);
|
||||||
#ifdef SDFATFS_USED
|
#ifdef SDFATFS_USED
|
||||||
audiofile.getName(chbuf, sizeof(chbuf));
|
audiofile.getName(chbuf, sizeof(chbuf));
|
||||||
char *afn =strdup(chbuf);
|
char *afn =strdup(chbuf);
|
||||||
#else
|
#else
|
||||||
char *afn =strdup(audiofile.name()); // store temporary the name
|
char *afn =strdup(audiofile.name()); // store temporary the name
|
||||||
#endif
|
#endif
|
||||||
|
cardLock(false);
|
||||||
stopSong();
|
stopSong();
|
||||||
if(m_codec == CODEC_MP3) MP3Decoder_FreeBuffers();
|
if(m_codec == CODEC_MP3) MP3Decoder_FreeBuffers();
|
||||||
if(m_codec == CODEC_AAC) AACDecoder_FreeBuffers();
|
if(m_codec == CODEC_AAC) AACDecoder_FreeBuffers();
|
||||||
@@ -4336,12 +4352,18 @@ bool Audio::setPinout(uint8_t BCLK, uint8_t LRC, uint8_t DOUT, int8_t DIN, int8_
|
|||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
uint32_t Audio::getFileSize() {
|
uint32_t Audio::getFileSize() {
|
||||||
if(!audiofile) return 0;
|
if(!audiofile) return 0;
|
||||||
return audiofile.size();
|
cardLock(true);
|
||||||
|
uint32_t s = audiofile.size();
|
||||||
|
cardLock(false);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
uint32_t Audio::getFilePos() {
|
uint32_t Audio::getFilePos() {
|
||||||
if(!audiofile) return 0;
|
if(!audiofile) return 0;
|
||||||
return audiofile.position();
|
cardLock(true);
|
||||||
|
uint32_t p = audiofile.position();
|
||||||
|
cardLock(false);
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
uint32_t Audio::getAudioDataStartPos() {
|
uint32_t Audio::getAudioDataStartPos() {
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ using namespace std;
|
|||||||
|
|
||||||
extern __attribute__((weak)) void audio_info(const char*);
|
extern __attribute__((weak)) void audio_info(const char*);
|
||||||
extern __attribute__((weak)) void audio_id3data(const char*); //ID3 metadata
|
extern __attribute__((weak)) void audio_id3data(const char*); //ID3 metadata
|
||||||
|
extern __attribute__((weak)) void audio_id3artist(const char*);
|
||||||
|
extern __attribute__((weak)) void audio_id3album(const char*);
|
||||||
|
extern __attribute__((weak)) void audio_id3title(const char*);
|
||||||
|
extern __attribute__((weak)) void audio_beginSDread();
|
||||||
extern __attribute__((weak)) void audio_id3image(File& file, const size_t pos, const size_t size); //ID3 metadata image
|
extern __attribute__((weak)) void audio_id3image(File& file, const size_t pos, const size_t size); //ID3 metadata image
|
||||||
extern __attribute__((weak)) void audio_eof_mp3(const char*); //end of mp3 file
|
extern __attribute__((weak)) void audio_eof_mp3(const char*); //end of mp3 file
|
||||||
extern __attribute__((weak)) void audio_showstreamtitle(const char*);
|
extern __attribute__((weak)) void audio_showstreamtitle(const char*);
|
||||||
@@ -213,7 +217,7 @@ public:
|
|||||||
void setI2SCommFMT_LSB(bool commFMT);
|
void setI2SCommFMT_LSB(bool commFMT);
|
||||||
int getCodec() {return m_codec;}
|
int getCodec() {return m_codec;}
|
||||||
const char *getCodecname() {return codecname[m_codec];}
|
const char *getCodecname() {return codecname[m_codec];}
|
||||||
|
void cardLock(bool lock);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#ifndef ESP_ARDUINO_VERSION_VAL
|
#ifndef ESP_ARDUINO_VERSION_VAL
|
||||||
|
|||||||
@@ -568,6 +568,16 @@ void Audio::showstreamtitle(const char* ml) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void Audio::cardLock(bool lock){
|
||||||
|
#if (TFT_CS!=255) || (SDC_CS!=255)
|
||||||
|
if(lock){
|
||||||
|
xSemaphoreTake(mutex_pl, portMAX_DELAY);
|
||||||
|
}else{
|
||||||
|
xSemaphoreGive(mutex_pl);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void Audio::loop(){
|
void Audio::loop(){
|
||||||
// - localfile - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - localfile - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
if(m_f_localfile) { // Playing file fron SPIFFS or SD?
|
if(m_f_localfile) { // Playing file fron SPIFFS or SD?
|
||||||
@@ -634,7 +644,7 @@ void Audio::processLocalFile() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
bytesAddedToBuffer = audiofile.read(InBuff.getWritePtr(), bytesCanBeWritten);
|
cardLock(true); bytesAddedToBuffer = audiofile.read(InBuff.getWritePtr(), bytesCanBeWritten); cardLock(false);
|
||||||
if(bytesAddedToBuffer > 0) {
|
if(bytesAddedToBuffer > 0) {
|
||||||
InBuff.bytesWritten(bytesAddedToBuffer);
|
InBuff.bytesWritten(bytesAddedToBuffer);
|
||||||
}
|
}
|
||||||
@@ -718,9 +728,9 @@ void Audio::processLocalFile() {
|
|||||||
|
|
||||||
f_stream = false;
|
f_stream = false;
|
||||||
m_f_localfile = false;
|
m_f_localfile = false;
|
||||||
|
cardLock(true);
|
||||||
char *afn =strdup(audiofile.name()); // store temporary the name
|
char *afn =strdup(audiofile.name()); // store temporary the name
|
||||||
|
cardLock(false);
|
||||||
stopSong();
|
stopSong();
|
||||||
sprintf(chbuf, "End of file \"%s\"", afn);
|
sprintf(chbuf, "End of file \"%s\"", afn);
|
||||||
if(audio_info) audio_info(chbuf);
|
if(audio_info) audio_info(chbuf);
|
||||||
@@ -1562,7 +1572,7 @@ uint32_t Audio::stop_mp3client(){
|
|||||||
uint32_t pos = 0;
|
uint32_t pos = 0;
|
||||||
if(m_f_localfile){
|
if(m_f_localfile){
|
||||||
pos = getFilePos() - InBuff.bufferFilled();
|
pos = getFilePos() - InBuff.bufferFilled();
|
||||||
audiofile.close();
|
cardLock(true); audiofile.close(); cardLock(false);
|
||||||
m_f_localfile=false;
|
m_f_localfile=false;
|
||||||
}
|
}
|
||||||
int v=read_register(SCI_VOL);
|
int v=read_register(SCI_VOL);
|
||||||
@@ -1897,14 +1907,14 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path, uint32_t resumeFilePos) {
|
|||||||
|
|
||||||
sprintf(chbuf, "Reading file: \"%s\"", audioName);
|
sprintf(chbuf, "Reading file: \"%s\"", audioName);
|
||||||
if(audio_info) {vTaskDelay(2); audio_info(chbuf);}
|
if(audio_info) {vTaskDelay(2); audio_info(chbuf);}
|
||||||
|
if(audio_beginSDread) audio_beginSDread();
|
||||||
audiofile.close();
|
cardLock(true); audiofile.close(); cardLock(false);
|
||||||
if(fs.exists(audioName)) {
|
if(fs.exists(audioName)) {
|
||||||
audiofile = fs.open(audioName);
|
cardLock(true); audiofile = fs.open(audioName); cardLock(false);
|
||||||
} else {
|
} else {
|
||||||
UTF8toASCII(audioName);
|
UTF8toASCII(audioName);
|
||||||
if(fs.exists(audioName)) {
|
if(fs.exists(audioName)) {
|
||||||
audiofile = fs.open(audioName);
|
cardLock(true); audiofile = fs.open(audioName); cardLock(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1914,9 +1924,11 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path, uint32_t resumeFilePos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_f_localfile = true;
|
m_f_localfile = true;
|
||||||
|
cardLock(true);
|
||||||
m_file_size = audiofile.size();//TEST loop
|
m_file_size = audiofile.size();//TEST loop
|
||||||
|
|
||||||
char* afn = strdup(audiofile.name()); // audioFileName
|
char* afn = strdup(audiofile.name()); // audioFileName
|
||||||
|
cardLock(false);
|
||||||
uint8_t dotPos = lastIndexOf(afn, ".");
|
uint8_t dotPos = lastIndexOf(afn, ".");
|
||||||
for(uint8_t i = dotPos + 1; i < strlen(afn); i++){
|
for(uint8_t i = dotPos + 1; i < strlen(afn); i++){
|
||||||
afn[i] = toLowerCase(afn[i]);
|
afn[i] = toLowerCase(afn[i]);
|
||||||
@@ -1960,7 +1972,7 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path, uint32_t resumeFilePos) {
|
|||||||
|
|
||||||
sprintf(chbuf, "The %s format is not supported", afn + dotPos);
|
sprintf(chbuf, "The %s format is not supported", afn + dotPos);
|
||||||
if(audio_info) audio_info(chbuf);
|
if(audio_info) audio_info(chbuf);
|
||||||
audiofile.close();
|
cardLock(true); audiofile.close(); cardLock(false);
|
||||||
if(afn) free(afn);
|
if(afn) free(afn);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2391,7 +2403,7 @@ void Audio::showID3Tag(const char* tag, const char* value){
|
|||||||
if(!strcmp(tag, "OWNE")) sprintf(chbuf, "Ownership: %s", value);
|
if(!strcmp(tag, "OWNE")) sprintf(chbuf, "Ownership: %s", value);
|
||||||
// if(!strcmp(tag, "PRIV")) sprintf(chbuf, "Private: %s", value);
|
// if(!strcmp(tag, "PRIV")) sprintf(chbuf, "Private: %s", value);
|
||||||
if(!strcmp(tag, "SYLT")) sprintf(chbuf, "SynLyrics: %s", value);
|
if(!strcmp(tag, "SYLT")) sprintf(chbuf, "SynLyrics: %s", value);
|
||||||
if(!strcmp(tag, "TALB")) sprintf(chbuf, "Album: %s", value);
|
if(!strcmp(tag, "TALB")) { sprintf(chbuf, "Album: %s", value); if(audio_id3album) audio_id3album(value); }
|
||||||
if(!strcmp(tag, "TBPM")) sprintf(chbuf, "BeatsPerMinute: %s", value);
|
if(!strcmp(tag, "TBPM")) sprintf(chbuf, "BeatsPerMinute: %s", value);
|
||||||
if(!strcmp(tag, "TCMP")) sprintf(chbuf, "Compilation: %s", value);
|
if(!strcmp(tag, "TCMP")) sprintf(chbuf, "Compilation: %s", value);
|
||||||
if(!strcmp(tag, "TCOM")) sprintf(chbuf, "Composer: %s", value);
|
if(!strcmp(tag, "TCOM")) sprintf(chbuf, "Composer: %s", value);
|
||||||
@@ -2401,7 +2413,7 @@ void Audio::showID3Tag(const char* tag, const char* value){
|
|||||||
if(!strcmp(tag, "TEXT")) sprintf(chbuf, "Lyricist: %s", value);
|
if(!strcmp(tag, "TEXT")) sprintf(chbuf, "Lyricist: %s", value);
|
||||||
if(!strcmp(tag, "TIME")) sprintf(chbuf, "Time: %s", value);
|
if(!strcmp(tag, "TIME")) sprintf(chbuf, "Time: %s", value);
|
||||||
if(!strcmp(tag, "TIT1")) sprintf(chbuf, "Grouping: %s", value);
|
if(!strcmp(tag, "TIT1")) sprintf(chbuf, "Grouping: %s", value);
|
||||||
if(!strcmp(tag, "TIT2")) sprintf(chbuf, "Title: %s", value);
|
if(!strcmp(tag, "TIT2")) { sprintf(chbuf, "Title: %s", value); if(audio_id3album) audio_id3album(value); }
|
||||||
if(!strcmp(tag, "TIT3")) sprintf(chbuf, "Subtitle: %s", value);
|
if(!strcmp(tag, "TIT3")) sprintf(chbuf, "Subtitle: %s", value);
|
||||||
if(!strcmp(tag, "TLAN")) sprintf(chbuf, "Language: %s", value);
|
if(!strcmp(tag, "TLAN")) sprintf(chbuf, "Language: %s", value);
|
||||||
if(!strcmp(tag, "TLEN")) sprintf(chbuf, "Length (ms): %s", value);
|
if(!strcmp(tag, "TLEN")) sprintf(chbuf, "Length (ms): %s", value);
|
||||||
@@ -2409,7 +2421,7 @@ void Audio::showID3Tag(const char* tag, const char* value){
|
|||||||
if(!strcmp(tag, "TOAL")) sprintf(chbuf, "OriginalAlbum: %s", value);
|
if(!strcmp(tag, "TOAL")) sprintf(chbuf, "OriginalAlbum: %s", value);
|
||||||
if(!strcmp(tag, "TOPE")) sprintf(chbuf, "OriginalArtist: %s", value);
|
if(!strcmp(tag, "TOPE")) sprintf(chbuf, "OriginalArtist: %s", value);
|
||||||
if(!strcmp(tag, "TORY")) sprintf(chbuf, "OriginalReleaseYear: %s", value);
|
if(!strcmp(tag, "TORY")) sprintf(chbuf, "OriginalReleaseYear: %s", value);
|
||||||
if(!strcmp(tag, "TPE1")) sprintf(chbuf, "Artist: %s", value);
|
if(!strcmp(tag, "TPE1")) { sprintf(chbuf, "Artist: %s", value); if(audio_id3artist) audio_id3artist(value); }
|
||||||
if(!strcmp(tag, "TPE2")) sprintf(chbuf, "Band: %s", value);
|
if(!strcmp(tag, "TPE2")) sprintf(chbuf, "Band: %s", value);
|
||||||
if(!strcmp(tag, "TPE3")) sprintf(chbuf, "Conductor: %s", value);
|
if(!strcmp(tag, "TPE3")) sprintf(chbuf, "Conductor: %s", value);
|
||||||
if(!strcmp(tag, "TPE4")) sprintf(chbuf, "InterpretedBy: %s", value);
|
if(!strcmp(tag, "TPE4")) sprintf(chbuf, "InterpretedBy: %s", value);
|
||||||
@@ -2431,17 +2443,26 @@ void Audio::showID3Tag(const char* tag, const char* value){
|
|||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
uint32_t Audio::getFileSize(){
|
uint32_t Audio::getFileSize(){
|
||||||
if (!audiofile) return 0;
|
if (!audiofile) return 0;
|
||||||
return audiofile.size();
|
cardLock(true);
|
||||||
|
uint32_t s = audiofile.size();
|
||||||
|
cardLock(false);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
uint32_t Audio::getFilePos(){
|
uint32_t Audio::getFilePos(){
|
||||||
if (!audiofile) return 0;
|
if (!audiofile) return 0;
|
||||||
return audiofile.position();
|
cardLock(true);
|
||||||
|
uint32_t p = audiofile.position();
|
||||||
|
cardLock(false);
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool Audio::setFilePos(uint32_t pos){
|
bool Audio::setFilePos(uint32_t pos){
|
||||||
if (!audiofile) return false;
|
if (!audiofile) return false;
|
||||||
return audiofile.seek(pos);
|
cardLock(true);
|
||||||
|
uint32_t s = audiofile.seek(pos);
|
||||||
|
cardLock(false);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
uint32_t Audio::getAudioDataStartPos() {
|
uint32_t Audio::getAudioDataStartPos() {
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ extern __attribute__((weak)) void audio_showstreamtitle(const char*);
|
|||||||
extern __attribute__((weak)) void audio_showstation(const char*);
|
extern __attribute__((weak)) void audio_showstation(const char*);
|
||||||
extern __attribute__((weak)) void audio_showstreaminfo(const char*);
|
extern __attribute__((weak)) void audio_showstreaminfo(const char*);
|
||||||
extern __attribute__((weak)) void audio_id3data(const char*); //ID3 metadata
|
extern __attribute__((weak)) void audio_id3data(const char*); //ID3 metadata
|
||||||
|
extern __attribute__((weak)) void audio_id3artist(const char*);
|
||||||
|
extern __attribute__((weak)) void audio_id3album(const char*);
|
||||||
|
extern __attribute__((weak)) void audio_id3title(const char*);
|
||||||
|
extern __attribute__((weak)) void audio_beginSDread();
|
||||||
extern __attribute__((weak)) void audio_id3image(File& file, const size_t pos, const size_t size); //ID3 metadata image
|
extern __attribute__((weak)) void audio_id3image(File& file, const size_t pos, const size_t size); //ID3 metadata image
|
||||||
extern __attribute__((weak)) void audio_eof_mp3(const char*);
|
extern __attribute__((weak)) void audio_eof_mp3(const char*);
|
||||||
extern __attribute__((weak)) void audio_eof_speech(const char*);
|
extern __attribute__((weak)) void audio_eof_speech(const char*);
|
||||||
@@ -311,7 +315,7 @@ public:
|
|||||||
void setVUmeter();
|
void setVUmeter();
|
||||||
void getVUlevel();
|
void getVUlevel();
|
||||||
uint8_t vuLeft, vuRight;
|
uint8_t vuLeft, vuRight;
|
||||||
|
void cardLock(bool lock);
|
||||||
// implement several function with respect to the index of string
|
// 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 startsWith (const char* base, const char* str) { return (strstr(base, str) - base) == 0;}
|
||||||
bool endsWith (const char* base, const char* str) {
|
bool endsWith (const char* base, const char* str) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Config config;
|
|||||||
#if DSP_HSPI || TS_HSPI || VS_HSPI
|
#if DSP_HSPI || TS_HSPI || VS_HSPI
|
||||||
SPIClass SPI2(HSPI);
|
SPIClass SPI2(HSPI);
|
||||||
#endif
|
#endif
|
||||||
SPIClass SDSPI(VSPI);
|
//SPIClass SDSPI(VSPI);
|
||||||
|
|
||||||
void u8fix(char *src){
|
void u8fix(char *src){
|
||||||
char last = src[strlen(src)-1];
|
char last = src[strlen(src)-1];
|
||||||
@@ -32,10 +32,11 @@ void Config::init() {
|
|||||||
|
|
||||||
loadTheme();
|
loadTheme();
|
||||||
ssidsCount = 0;
|
ssidsCount = 0;
|
||||||
if(SDC_CS!=255 && store.play_mode==PM_WEB){
|
if(SDC_CS!=255 && store.play_mode==PM_SDCARD){
|
||||||
pinMode(SDC_CS, OUTPUT); digitalWrite(SDC_CS, HIGH);
|
//pinMode(SDC_CS, OUTPUT); digitalWrite(SDC_CS, HIGH);
|
||||||
SDSPI.begin(SDC_SPI);
|
//SDSPI.begin(SDC_SPI);
|
||||||
SDSPI.setFrequency(1000000);
|
//SDSPI.setFrequency(1000000);
|
||||||
|
//SDSPI.setFrequency(100000);
|
||||||
if(!SD.begin(SDC_CS)){
|
if(!SD.begin(SDC_CS)){
|
||||||
store.play_mode=PM_WEB;
|
store.play_mode=PM_WEB;
|
||||||
Serial.println("##[ERROR]#\tCard Mount Failed");
|
Serial.println("##[ERROR]#\tCard Mount Failed");
|
||||||
@@ -49,6 +50,7 @@ void Config::init() {
|
|||||||
store.lastStation = 1;
|
store.lastStation = 1;
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadStation(store.lastStation);
|
loadStation(store.lastStation);
|
||||||
#if IR_PIN!=255
|
#if IR_PIN!=255
|
||||||
eepromRead(EEPROM_START_IR, ircodes);
|
eepromRead(EEPROM_START_IR, ircodes);
|
||||||
@@ -297,11 +299,11 @@ bool endsWith (const char* base, const char* str) {
|
|||||||
void Config::listSD(File &plSDfile, File &plSDindex, const char * dirname, uint8_t levels){
|
void Config::listSD(File &plSDfile, File &plSDindex, const char * dirname, uint8_t levels){
|
||||||
File root = SD.open(dirname);
|
File root = SD.open(dirname);
|
||||||
if(!root){
|
if(!root){
|
||||||
Serial.println("Failed to open directory");
|
Serial.println("##[ERROR]#\tFailed to open directory");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!root.isDirectory()){
|
if(!root.isDirectory()){
|
||||||
Serial.println("Not a directory");
|
Serial.println("##[ERROR]#\tNot a directory");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,12 +317,10 @@ void Config::listSD(File &plSDfile, File &plSDindex, const char * dirname, uint8
|
|||||||
listSD(plSDfile, plSDindex, file.path(), levels -1);
|
listSD(plSDfile, plSDindex, file.path(), levels -1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(endsWith(file.name(), ".mp3") || endsWith(file.name(), ".m4a") || endsWith(file.name(), ".aac") || endsWith(file.name(), ".wav") || endsWith(file.name(), ".flac")){
|
if(endsWith(strlwr((char*)file.name()), ".mp3") || endsWith(file.name(), ".m4a") || endsWith(file.name(), ".aac") || endsWith(file.name(), ".wav") || endsWith(file.name(), ".flac")){
|
||||||
pos = plSDfile.position();
|
pos = plSDfile.position();
|
||||||
plSDfile.print(file.name()); plSDfile.print("\t"); plSDfile.print(file.path()); plSDfile.print("\t"); plSDfile.println(0);
|
plSDfile.print(file.name()); plSDfile.print("\t"); plSDfile.print(file.path()); plSDfile.print("\t"); plSDfile.println(0);
|
||||||
plSDindex.write((byte *) &pos, 4);
|
plSDindex.write((byte *) &pos, 4);
|
||||||
Serial.print(" plSDfile.position:\t");
|
|
||||||
Serial.println(pos);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file = root.openNextFile();
|
file = root.openNextFile();
|
||||||
@@ -342,8 +342,9 @@ void Config::initSDPlaylist() {
|
|||||||
store.countStation = 0;
|
store.countStation = 0;
|
||||||
indexSDPlaylist();
|
indexSDPlaylist();
|
||||||
if (SPIFFS.exists(INDEX_SD_PATH)) {
|
if (SPIFFS.exists(INDEX_SD_PATH)) {
|
||||||
File index = SD.open(INDEX_SD_PATH, "r");
|
File index = SPIFFS.open(INDEX_SD_PATH, "r");
|
||||||
store.countStation = index.size() / 4;
|
store.countStation = index.size() / 4;
|
||||||
|
store.lastStation = random(1, store.countStation);
|
||||||
index.close();
|
index.close();
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
@@ -362,9 +363,9 @@ void Config::loadStation(uint16_t ls) {
|
|||||||
if (ls > store.countStation) {
|
if (ls > store.countStation) {
|
||||||
ls = 1;
|
ls = 1;
|
||||||
}
|
}
|
||||||
File playlist = SPIFFS.open(PLAYLIST_PATH, "r");
|
File playlist = SPIFFS.open(REAL_PLAYL, "r");
|
||||||
|
|
||||||
File index = SPIFFS.open(INDEX_PATH, "r");
|
File index = SPIFFS.open(REAL_INDEX, "r");
|
||||||
index.seek((ls - 1) * 4, SeekSet);
|
index.seek((ls - 1) * 4, SeekSet);
|
||||||
uint32_t pos;
|
uint32_t pos;
|
||||||
|
|
||||||
@@ -378,7 +379,7 @@ void Config::loadStation(uint16_t ls) {
|
|||||||
strncpy(station.name, sName, BUFLEN);
|
strncpy(station.name, sName, BUFLEN);
|
||||||
strncpy(station.url, sUrl, BUFLEN);
|
strncpy(station.url, sUrl, BUFLEN);
|
||||||
station.ovol = sOvol;
|
station.ovol = sOvol;
|
||||||
setLastStation(ls);
|
if(store.play_mode==PM_WEB) setLastStation(ls);
|
||||||
}
|
}
|
||||||
playlist.close();
|
playlist.close();
|
||||||
}
|
}
|
||||||
@@ -392,8 +393,8 @@ void Config::fillPlMenu(char plmenu[][40], int from, byte count, bool removeNum)
|
|||||||
if (store.countStation == 0) {
|
if (store.countStation == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File playlist = SPIFFS.open(PLAYLIST_PATH, "r");
|
File playlist = SPIFFS.open(REAL_PLAYL, "r");
|
||||||
File index = SPIFFS.open(INDEX_PATH, "r");
|
File index = SPIFFS.open(REAL_INDEX, "r");
|
||||||
while (true) {
|
while (true) {
|
||||||
if (ls < 1) {
|
if (ls < 1) {
|
||||||
ls++;
|
ls++;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <Ticker.h>
|
#include <Ticker.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <SPIFFS.h>
|
#include <SPIFFS.h>
|
||||||
#include <SD.h>
|
#include "SD.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
#define EEPROM_SIZE 768
|
#define EEPROM_SIZE 768
|
||||||
@@ -29,6 +29,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#define BOOTLOG( ... ) { char buf[120]; sprintf( buf, __VA_ARGS__ ) ; Serial.print("##[BOOT]#\t"); Serial.println(buf); }
|
#define BOOTLOG( ... ) { char buf[120]; sprintf( buf, __VA_ARGS__ ) ; Serial.print("##[BOOT]#\t"); Serial.println(buf); }
|
||||||
#define EVERY_MS(x) static uint32_t tmr; bool flag = millis() - tmr >= (x); if (flag) tmr += (x); if (flag)
|
#define EVERY_MS(x) static uint32_t tmr; bool flag = millis() - tmr >= (x); if (flag) tmr += (x); if (flag)
|
||||||
|
#define REAL_PLAYL store.play_mode==PM_WEB?PLAYLIST_PATH:PLAYLIST_SD_PATH
|
||||||
|
#define REAL_INDEX store.play_mode==PM_WEB?INDEX_PATH:INDEX_SD_PATH
|
||||||
|
|
||||||
#define MAX_PLAY_MODE 1
|
#define MAX_PLAY_MODE 1
|
||||||
|
|
||||||
|
|||||||
@@ -363,8 +363,8 @@ void onBtnLongPressStart(int id) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EVT_BTNMODE: {
|
case EVT_BTNMODE: {
|
||||||
//onBtnClick(EVT_BTNMODE);
|
//config.doSleepW();
|
||||||
config.doSleepW();
|
display.putRequest(NEWMODE, SLEEPING);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
@@ -380,6 +380,10 @@ void onBtnLongPressStop(int id) {
|
|||||||
lpId = -1;
|
lpId = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case EVT_BTNMODE: {
|
||||||
|
config.doSleepW();
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -498,9 +502,9 @@ void onBtnClick(int id) {
|
|||||||
config.store.play_mode++;
|
config.store.play_mode++;
|
||||||
if(config.store.play_mode > MAX_PLAY_MODE){
|
if(config.store.play_mode > MAX_PLAY_MODE){
|
||||||
config.store.play_mode=0;
|
config.store.play_mode=0;
|
||||||
config.save();
|
|
||||||
ESP.restart();
|
|
||||||
}
|
}
|
||||||
|
config.save();
|
||||||
|
ESP.restart();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
|
|||||||
@@ -262,6 +262,7 @@ void Display::_swichMode(displayMode_e newmode) {
|
|||||||
}
|
}
|
||||||
if (newmode == LOST) _showDialog(const_DlgLost);
|
if (newmode == LOST) _showDialog(const_DlgLost);
|
||||||
if (newmode == UPDATING) _showDialog(const_DlgUpdate);
|
if (newmode == UPDATING) _showDialog(const_DlgUpdate);
|
||||||
|
if (newmode == SLEEPING) _showDialog("SLEEPING");
|
||||||
if (newmode == INFO || newmode == SETTINGS || newmode == TIMEZONE || newmode == WIFI) _showDialog(const_DlgNextion);
|
if (newmode == INFO || newmode == SETTINGS || newmode == TIMEZONE || newmode == WIFI) _showDialog(const_DlgNextion);
|
||||||
if (newmode == NUMBERS) _showDialog("");
|
if (newmode == NUMBERS) _showDialog("");
|
||||||
if (newmode == STATIONS) {
|
if (newmode == STATIONS) {
|
||||||
@@ -443,8 +444,12 @@ void Display::_title() {
|
|||||||
/*#ifdef USE_NEXTION
|
/*#ifdef USE_NEXTION
|
||||||
nextion.newTitle(config.station.title);
|
nextion.newTitle(config.station.title);
|
||||||
#endif*/
|
#endif*/
|
||||||
if (player_on_track_change) player_on_track_change();
|
|
||||||
|
}else{
|
||||||
|
_title1.setText("");
|
||||||
|
if(_title2) _title2->setText("");
|
||||||
}
|
}
|
||||||
|
if (player_on_track_change) player_on_track_change();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::_time(bool redraw) {
|
void Display::_time(bool redraw) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include "../displays/dspcore.h"
|
#include "../displays/dspcore.h"
|
||||||
|
|
||||||
enum displayMode_e { PLAYER, VOL, STATIONS, NUMBERS, LOST, UPDATING, INFO, SETTINGS, TIMEZONE, WIFI, CLEAR };
|
enum displayMode_e { PLAYER, VOL, STATIONS, NUMBERS, LOST, UPDATING, INFO, SETTINGS, TIMEZONE, WIFI, CLEAR, SLEEPING };
|
||||||
enum pages_e : uint8_t { PG_PLAYER=0, PG_DIALOG=1, PG_PLAYLIST=2 };
|
enum pages_e : uint8_t { PG_PLAYER=0, PG_DIALOG=1, PG_PLAYLIST=2 };
|
||||||
//enum dialogType_e : uint8_t { DG_NONE=0, DG_VOLUME=1, DG_LOST=2, DG_UPDATING=3, DG_NEXTION=4 };
|
//enum dialogType_e : uint8_t { DG_NONE=0, DG_VOLUME=1, DG_LOST=2, DG_UPDATING=3, DG_NEXTION=4 };
|
||||||
|
|
||||||
|
|||||||
@@ -636,7 +636,11 @@ void handleHTTPArgs(AsyncWebServerRequest * request) {
|
|||||||
#ifdef MQTT_HOST
|
#ifdef MQTT_HOST
|
||||||
if (strcmp(request->url().c_str(), PLAYLIST_PATH) == 0) while (mqttplaylistblock) vTaskDelay(5);
|
if (strcmp(request->url().c_str(), PLAYLIST_PATH) == 0) while (mqttplaylistblock) vTaskDelay(5);
|
||||||
#endif
|
#endif
|
||||||
netserver.chunkedHtmlPage("application/octet-stream", request, request->url().c_str());
|
if(strcmp(request->url().c_str(), PLAYLIST_PATH) == 0 && config.store.play_mode==PM_SDCARD){
|
||||||
|
netserver.chunkedHtmlPage("application/octet-stream", request, PLAYLIST_SD_PATH);
|
||||||
|
}else{
|
||||||
|
netserver.chunkedHtmlPage("application/octet-stream", request, request->url().c_str());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcmp(request->url().c_str(), "/") == 0 && request->params() == 0) {
|
if (strcmp(request->url().c_str(), "/") == 0 && request->params() == 0) {
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ void Network::begin() {
|
|||||||
errcnt = 0;
|
errcnt = 0;
|
||||||
ls++;
|
ls++;
|
||||||
if (ls > config.ssidsCount - 1) ls = 0;
|
if (ls > config.ssidsCount - 1) ls = 0;
|
||||||
|
Serial.println();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef options_h
|
#ifndef options_h
|
||||||
#define options_h
|
#define options_h
|
||||||
|
|
||||||
#define YOVERSION "0.9.000"
|
#define YOVERSION "0.8.800"
|
||||||
|
|
||||||
/*******************************************************
|
/*******************************************************
|
||||||
DO NOT EDIT THIS FILE.
|
DO NOT EDIT THIS FILE.
|
||||||
@@ -58,7 +58,7 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti
|
|||||||
|
|
||||||
/* TFT DISPLAY */
|
/* TFT DISPLAY */
|
||||||
#ifndef TFT_CS
|
#ifndef TFT_CS
|
||||||
#define TFT_CS 5
|
#define TFT_CS 255
|
||||||
#endif
|
#endif
|
||||||
#ifndef TFT_RST
|
#ifndef TFT_RST
|
||||||
#define TFT_RST 15 // Or set to -1 and connect to Esp EN pin
|
#define TFT_RST 15 // Or set to -1 and connect to Esp EN pin
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ void Player::play(uint16_t stationId) {
|
|||||||
display.putRequest(PSTOP);
|
display.putRequest(PSTOP);
|
||||||
setDefaults();
|
setDefaults();
|
||||||
setOutputPins(false);
|
setOutputPins(false);
|
||||||
config.setTitle(const_PlConnect);
|
config.setTitle(config.store.play_mode==PM_WEB?const_PlConnect:"");
|
||||||
config.station.bitrate=0;
|
config.station.bitrate=0;
|
||||||
netserver.requestOnChange(TITLE, 0);
|
netserver.requestOnChange(TITLE, 0);
|
||||||
config.loadStation(stationId);
|
config.loadStation(stationId);
|
||||||
@@ -136,8 +136,10 @@ void Player::play(uint16_t stationId) {
|
|||||||
display.putRequest(NEWSTATION);
|
display.putRequest(NEWSTATION);
|
||||||
netserver.requestOnChange(STATION, 0);
|
netserver.requestOnChange(STATION, 0);
|
||||||
telnet.printf("##CLI.NAMESET#: %d %s\n", config.store.lastStation, config.station.name);
|
telnet.printf("##CLI.NAMESET#: %d %s\n", config.store.lastStation, config.station.name);
|
||||||
if (connecttohost(config.station.url)) {
|
if (config.store.play_mode==PM_WEB?connecttohost(config.station.url):connecttoFS(SD,config.station.url)) {
|
||||||
mode = PLAYING;
|
mode = PLAYING;
|
||||||
|
config.setTitle("");
|
||||||
|
netserver.requestOnChange(TITLE, 0);
|
||||||
config.setSmartStart(1);
|
config.setSmartStart(1);
|
||||||
netserver.requestOnChange(MODE, 0);
|
netserver.requestOnChange(MODE, 0);
|
||||||
setOutputPins(true);
|
setOutputPins(true);
|
||||||
@@ -150,13 +152,19 @@ void Player::play(uint16_t stationId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Player::prev() {
|
void Player::prev() {
|
||||||
if (config.store.lastStation == 1) config.store.lastStation = config.store.countStation; else config.store.lastStation--;
|
if(config.store.play_mode==PM_WEB){
|
||||||
|
if (config.store.lastStation == 1) config.store.lastStation = config.store.countStation; else config.store.lastStation--;
|
||||||
|
}
|
||||||
request.station = config.store.lastStation;
|
request.station = config.store.lastStation;
|
||||||
request.doSave = true;
|
request.doSave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::next() {
|
void Player::next() {
|
||||||
if (config.store.lastStation == config.store.countStation) config.store.lastStation = 1; else config.store.lastStation++;
|
if(config.store.play_mode==PM_WEB){
|
||||||
|
if (config.store.lastStation == config.store.countStation) config.store.lastStation = 1; else config.store.lastStation++;
|
||||||
|
}else{
|
||||||
|
config.store.lastStation = random(1, config.store.countStation);
|
||||||
|
}
|
||||||
request.station = config.store.lastStation;
|
request.station = config.store.lastStation;
|
||||||
request.doSave = true;
|
request.doSave = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,8 +100,17 @@ void audio_info(const char *info) {
|
|||||||
#ifdef USE_NEXTION
|
#ifdef USE_NEXTION
|
||||||
nextion.audioinfo(info);
|
nextion.audioinfo(info);
|
||||||
#endif
|
#endif
|
||||||
|
if (strstr(info, "skip metadata") != NULL){
|
||||||
|
config.setTitle(config.station.name);
|
||||||
|
netserver.requestOnChange(TITLE, 0);
|
||||||
|
}
|
||||||
if (strstr(info, "failed!") != NULL || strstr(info, " 404") != NULL || strstr(info, " 403") != NULL || strstr(info, "address is empty") != NULL) player.stop(info);
|
if (strstr(info, "failed!") != NULL || strstr(info, " 404") != NULL || strstr(info, " 403") != NULL || strstr(info, "address is empty") != NULL) player.stop(info);
|
||||||
if (strstr(info, "not supported") != NULL || strstr(info, "Account already in use") != NULL || strstr(info, "HTTP/1.0 401") != NULL) player.stop(info);
|
if (strstr(info, "not supported") != NULL || strstr(info, "Account already in use") != NULL || strstr(info, "HTTP/1.0 401") != NULL) player.stop(info);
|
||||||
|
char* ici; char b[20]={0};
|
||||||
|
if ((ici = strstr(info, "BitRate: ")) != NULL) {
|
||||||
|
strlcpy(b, ici + 9, 50);
|
||||||
|
audio_bitrate(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_bitrate(const char *info)
|
void audio_bitrate(const char *info)
|
||||||
@@ -149,3 +158,41 @@ void audio_showstreamtitle(const char *info) {
|
|||||||
netserver.requestOnChange(TITLE, 0);
|
netserver.requestOnChange(TITLE, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void audio_id3artist(const char *info){
|
||||||
|
if(printable(info)) config.setStation(info);
|
||||||
|
display.putRequest(NEWSTATION);
|
||||||
|
netserver.requestOnChange(STATION, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void audio_id3album(const char *info){
|
||||||
|
if(printable(info)){
|
||||||
|
if(strlen(config.station.title)==0){
|
||||||
|
config.setTitle(info);
|
||||||
|
}else{
|
||||||
|
char out[BUFLEN]= {0};
|
||||||
|
strlcat(out, config.station.title, BUFLEN);
|
||||||
|
strlcat(out, " - ", BUFLEN);
|
||||||
|
strlcat(out, info, BUFLEN);
|
||||||
|
config.setTitle(out);
|
||||||
|
}
|
||||||
|
netserver.requestOnChange(TITLE, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void audio_id3title(const char *info){
|
||||||
|
audio_id3album(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
void audio_beginSDread(){
|
||||||
|
config.setTitle("");
|
||||||
|
netserver.requestOnChange(TITLE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void audio_id3data(const char *info){ //id3 metadata
|
||||||
|
telnet.printf("##AUDIO.ID3#: %s\n", info);
|
||||||
|
}
|
||||||
|
void audio_eof_mp3(const char *info){ //end of file
|
||||||
|
player.play(random(1, config.store.countStation));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user