Skip to content

Commit

Permalink
v0.9.220
Browse files Browse the repository at this point in the history
  • Loading branch information
e2002 committed May 26, 2023
1 parent c31ed52 commit 3cd53f2
Show file tree
Hide file tree
Showing 30 changed files with 298 additions and 172 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ Work is in progress...

---
## Version history
#### v0.9.220
- fixed SD prelist indexing error when switching Web>>SD
- fixed a bug of switching to the next track when accidentally playing SD
- fixed import of large playlists (tried). PS: import playlist size is limited by SPIFFS size (SPIFFS.totalBytes()/100*65-SPIFFS.usedBytes() = approximately 60kb )
- new url parameter - http://YPRADIOIP/?clearspiffs - for clearing tails from SD playlist
- optimization of the issuance of the WEB-interface
- brought back the functionality of the track slider
- fixing bugs in the application logic

#### v0.9.201
- fixed a bug when importing a playlist

Expand Down
Binary file modified yoRadio/data/www/script.js.gz
Binary file not shown.
6 changes: 3 additions & 3 deletions yoRadio/src/SSD1322/SSD1322.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
*/
#include "../core/options.h"
#include "../core/player.h"
#include "../core/spidog.h"
#if DSP_MODEL==DSP_SSD1322


Expand All @@ -39,8 +39,8 @@
#define SSD1322_MODE_DATA digitalWrite(dcPin, HIGH); ///< Data mode

#if defined(SPI_HAS_TRANSACTION)
#define TAKE_MUTEX() if(player.mutex_pl) xSemaphoreTake(player.mutex_pl, portMAX_DELAY)
#define GIVE_MUTEX() if(player.mutex_pl) xSemaphoreGive(player.mutex_pl)
#define TAKE_MUTEX() sdog.takeMutex()
#define GIVE_MUTEX() sdog.giveMutex()
#define SPI_TRANSACTION_START TAKE_MUTEX(); spi->beginTransaction(spiSettings) ///< Pre-SPI
#define SPI_TRANSACTION_END spi->endTransaction(); GIVE_MUTEX() ///< Post-SPI
#else // SPI transactions likewise not present in older Arduino SPI lib
Expand Down
6 changes: 3 additions & 3 deletions yoRadio/src/ST7920/ST7920.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "../core/options.h"
#include "../core/player.h"
#include "../core/spidog.h"
#if DSP_MODEL==DSP_ST7920

#include "Adafruit_GFX.h"
Expand All @@ -10,8 +10,8 @@
//This display is split into two halfs. Pages are 16bit long and pages are arranged in that way that are lied horizontaly instead of verticaly, unlike SSD1306 OLED, Nokia 5110 LCD, etc.
//After 8 horizonral page is written, it jumps to half of the screen (Y = 32) and continues until 16 lines of page have been written. After that, we have set cursor in new line.

#define TAKE_MUTEX() if(player.mutex_pl) xSemaphoreTake(player.mutex_pl, portMAX_DELAY)
#define GIVE_MUTEX() if(player.mutex_pl) xSemaphoreGive(player.mutex_pl)
#define TAKE_MUTEX() sdog.takeMutex()
#define GIVE_MUTEX() sdog.giveMutex()
#define st7920_swap(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b)))

void ST7920::drawPixel(int16_t x, int16_t y, uint16_t color) {
Expand Down
20 changes: 10 additions & 10 deletions yoRadio/src/audioI2S/Audio.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "../core/options.h"
#include "../core/spidog.h"
#if VS1053_CS==255
/*
* Audio.cpp
Expand Down Expand Up @@ -170,7 +171,6 @@ Audio::Audio(bool internalDAC /* = false */, uint8_t channelEnabled /* = I2S_DAC
#ifdef AUDIO_LOG
m_f_Log = true;
#endif
mutex_pl = xSemaphoreCreateMutex();
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_internalDAC = internalDAC;
Expand Down Expand Up @@ -315,7 +315,7 @@ void Audio::setDefaults() {
vector_clear_and_shrink(m_playlistURL);
vector_clear_and_shrink(m_playlistContent);
m_hashQueue.clear(); m_hashQueue.shrink_to_fit(); // uint32_t vector
if(config.store.play_mode!=PM_SDCARD){
if(config.getMode()!=PM_SDCARD){
client.stop();
client.flush(); // release memory
clientsecure.stop();
Expand Down Expand Up @@ -711,14 +711,14 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path, uint32_t resumeFilePos) {
m_file_size = audiofile.size();//TEST loop
cardLock(false);
char* afn = NULL; // audioFileName
//cardLock(true);
cardLock(true);
#ifdef SDFATFS_USED
audiofile.getName(chbuf, sizeof(chbuf));
afn = strdup(chbuf);
#else
afn = strdup(audiofile.name());
#endif
//cardLock(false);
cardLock(false);
uint8_t dotPos = lastIndexOf(afn, ".");
for(uint8_t i = dotPos + 1; i < strlen(afn); i++){
afn[i] = toLowerCase(afn[i]);
Expand Down Expand Up @@ -2458,9 +2458,9 @@ bool Audio::playChunk() {
void Audio::cardLock(bool lock){
#if (TFT_CS!=255) || (SDC_CS!=255)
if(lock){
xSemaphoreTake(mutex_pl, portMAX_DELAY);
sdog.takeMutex();
}else{
xSemaphoreGive(mutex_pl);
sdog.giveMutex();
}
#endif
}
Expand Down Expand Up @@ -3035,14 +3035,14 @@ void Audio::processLocalFile() {
} //TEST loop
f_stream = false;
m_streamType = ST_NONE;
//cardLock(true);
cardLock(true);
#ifdef SDFATFS_USED
audiofile.getName(chbuf, sizeof(chbuf));
char *afn =strdup(chbuf);
#else
char *afn =strdup(audiofile.name()); // store temporary the name
#endif
//cardLock(false);
cardLock(false);
stopSong();
if(m_codec == CODEC_MP3) MP3Decoder_FreeBuffers();
if(m_codec == CODEC_AAC) AACDecoder_FreeBuffers();
Expand Down Expand Up @@ -4400,9 +4400,9 @@ bool Audio::setPinout(uint8_t BCLK, uint8_t LRC, uint8_t DOUT, int8_t DIN, int8_
//---------------------------------------------------------------------------------------------------------------------
uint32_t Audio::getFileSize() {
if(!audiofile) return 0;
//cardLock(true);
cardLock(true);
uint32_t s = audiofile.size();
//cardLock(false);
cardLock(false);
return s;
}
//---------------------------------------------------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion yoRadio/src/audioI2S/AudioEx.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ class Audio : private AudioBuffer{
void setVUmeter() {};
void getVUlevel() {};
uint8_t vuLeft, vuRight;
SemaphoreHandle_t mutex_pl=NULL;
bool eofHeader;
esp_err_t i2s_mclk_pin_select(const uint8_t pin);
uint32_t inBufferFilled(); // returns the number of stored bytes in the inputbuffer
Expand Down
26 changes: 12 additions & 14 deletions yoRadio/src/audioVS1053/audioVS1053Ex.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "../core/options.h"
#include "../core/spidog.h"
#if I2S_DOUT==255
/*
* vs1053_ext.cpp
Expand Down Expand Up @@ -152,7 +153,6 @@ Audio::Audio(uint8_t _cs_pin, uint8_t _dcs_pin, uint8_t _dreq_pin, uint8_t spi,
m_endFillByte=0;
curvol=50;
m_LFcount=0;
mutex_pl = xSemaphoreCreateMutex();
}
Audio::~Audio(){
// destructor
Expand Down Expand Up @@ -180,18 +180,18 @@ void Audio::control_mode_off()
{
CS_HIGH(); // End control mode
spi_VS1053->endTransaction(); // Allow other SPI users
xSemaphoreGive(mutex_pl);
sdog.giveMutex();
}
void Audio::control_mode_on()
{
xSemaphoreTake(mutex_pl, portMAX_DELAY);
sdog.takeMutex();
spi_VS1053->beginTransaction(VS1053_SPI_CTL); // Prevent other SPI users
DCS_HIGH(); // Bring slave in control mode
CS_LOW();
}
void Audio::data_mode_on()
{
xSemaphoreTake(mutex_pl, portMAX_DELAY);
sdog.takeMutex();
spi_VS1053->beginTransaction(VS1053_SPI_DATA); // Prevent other SPI users
CS_HIGH(); // Bring slave in data mode
DCS_LOW();
Expand All @@ -201,7 +201,7 @@ void Audio::data_mode_off()
//digitalWrite(dcs_pin, HIGH); // End data mode
DCS_HIGH();
spi_VS1053->endTransaction(); // Allow other SPI users
xSemaphoreGive(mutex_pl);
sdog.giveMutex();
}
//---------------------------------------------------------------------------------------------------------------------
uint16_t Audio::read_register(uint8_t _reg)
Expand Down Expand Up @@ -303,7 +303,6 @@ void Audio::begin(){
pinMode(dreq_pin, INPUT); // DREQ is an input
pinMode(cs_pin, OUTPUT); // The SCI and SDI signals
pinMode(dcs_pin, OUTPUT);
//mutex_pl = xSemaphoreCreateMutex();
DCS_HIGH();
CS_HIGH();
delay(170);
Expand Down Expand Up @@ -573,10 +572,9 @@ void Audio::showstreamtitle(const char* ml) {
void Audio::cardLock(bool lock){
#if (SDC_CS!=255)
if(lock){
xSemaphoreTake(mutex_pl, portMAX_DELAY);
sdog.takeMutex();
}else{
// digitalWrite(SDC_CS, HIGH);
xSemaphoreGive(mutex_pl);
sdog.giveMutex();
}
#endif
}
Expand Down Expand Up @@ -744,9 +742,9 @@ void Audio::processLocalFile() {

f_stream = false;
m_f_localfile = false;
//cardLock(true);
cardLock(true);
char *afn =strdup(audiofile.name()); // store temporary the name
//cardLock(false);
cardLock(false);
stopSong();
sprintf(chbuf, "End of file \"%s\"", afn);
if(audio_info) audio_info(chbuf);
Expand Down Expand Up @@ -1612,7 +1610,7 @@ void Audio::setDefaults(){
InBuff.resetBuffer();
vector_clear_and_shrink(m_playlistURL);
vector_clear_and_shrink(m_playlistContent);
if(config.store.play_mode!=PM_SDCARD){
if(config.getMode()!=PM_SDCARD){
client.stop();
client.flush(); // release memory
clientsecure.stop();
Expand Down Expand Up @@ -2484,9 +2482,9 @@ void Audio::showID3Tag(const char* tag, const char* value){
//---------------------------------------------------------------------------------------------------------------------
uint32_t Audio::getFileSize(){
if (!audiofile) return 0;
//cardLock(true);
cardLock(true);
uint32_t s = audiofile.size();
//cardLock(false);
cardLock(false);
return s;
}
//---------------------------------------------------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion yoRadio/src/audioVS1053/audioVS1053Ex.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ class Audio : private AudioBuffer{
bool setFilePos(uint32_t pos);
uint32_t getAudioFileDuration();
uint32_t getAudioCurrentTime();
SemaphoreHandle_t mutex_pl=NULL;
size_t bufferFilled();
size_t bufferFree();
size_t inBufferFilled(){ return bufferFilled(); }
Expand Down
8 changes: 2 additions & 6 deletions yoRadio/src/core/audiohandlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,13 @@ void audio_id3data(const char *info){ //id3 metadata

void audio_eof_mp3(const char *info){ //end of file
config.sdResumePos = 0;
if(config.sdSnuffle){
player.sendCommand({PR_PLAY, random(1, config.store.countStation)});
}else{
player.next();
}
player.next();
}

void audio_eof_stream(const char *info){
player.sendCommand({PR_STOP, 0});
if(!player.resumeAfterUrl) return;
if (config.store.play_mode==PM_WEB){
if (config.getMode()==PM_WEB){
player.sendCommand({PR_PLAY, config.store.lastStation});
}else{
player.setResumeFilePos( config.sdResumePos==0?0:config.sdResumePos-player.sd_min);
Expand Down
Loading

0 comments on commit 3cd53f2

Please sign in to comment.