|  | @ -255,7 +255,9 @@ AsyncEventSource events("/events"); | 
		
	
		
			
				|  |  | #endif
 |  |  | #endif
 | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | TaskHandle_t mp3Play; |  |  | TaskHandle_t mp3Play; | 
		
	
		
			
				|  |  |  |  |  | #ifdef RFID_READER_TYPE_PN5180
 | 
		
	
		
			
				|  |  |     TaskHandle_t rfid; |  |  |     TaskHandle_t rfid; | 
		
	
		
			
				|  |  |  |  |  | #endif
 | 
		
	
		
			
				|  |  | TaskHandle_t fileStorageTaskHandle; |  |  | TaskHandle_t fileStorageTaskHandle; | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | #ifdef NEOPIXEL_ENABLE
 |  |  | #ifdef NEOPIXEL_ENABLE
 | 
		
	
	
		
			
				|  | @ -420,7 +422,11 @@ bool processJsonRequest(char *_serialJson); | 
		
	
		
			
				|  |  | void randomizePlaylist (char *str[], const uint32_t count); |  |  | void randomizePlaylist (char *str[], const uint32_t count); | 
		
	
		
			
				|  |  | char ** returnPlaylistFromWebstream(const char *_webUrl); |  |  | char ** returnPlaylistFromWebstream(const char *_webUrl); | 
		
	
		
			
				|  |  | char ** returnPlaylistFromSD(File _fileOrDirectory); |  |  | char ** returnPlaylistFromSD(File _fileOrDirectory); | 
		
	
		
			
				|  |  |  |  |  | #ifdef RFID_READER_TYPE_PN5180
 | 
		
	
		
			
				|  |  |     void rfidScanner(void *parameter); |  |  |     void rfidScanner(void *parameter); | 
		
	
		
			
				|  |  |  |  |  | #else
 | 
		
	
		
			
				|  |  |  |  |  |     void rfidScanner(void); | 
		
	
		
			
				|  |  |  |  |  | #endif
 | 
		
	
		
			
				|  |  | void sleepHandler(void) ; |  |  | void sleepHandler(void) ; | 
		
	
		
			
				|  |  | void sortPlaylist(const char** arr, int n); |  |  | void sortPlaylist(const char** arr, int n); | 
		
	
		
			
				|  |  | bool startsWith(const char *str, const char *pre); |  |  | bool startsWith(const char *str, const char *pre); | 
		
	
	
		
			
				|  | @ -1433,6 +1439,7 @@ size_t nvsRfidWriteWrapper (const char *_rfidCardId, const char *_track, const u | 
		
	
		
			
				|  |  | // Function to play music as task
 |  |  | // Function to play music as task
 | 
		
	
		
			
				|  |  | void playAudio(void *parameter) { |  |  | void playAudio(void *parameter) { | 
		
	
		
			
				|  |  |     static Audio audio; |  |  |     static Audio audio; | 
		
	
		
			
				|  |  |  |  |  |     uint8_t settleCount = 0; | 
		
	
		
			
				|  |  |     audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT); |  |  |     audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT); | 
		
	
		
			
				|  |  |     audio.setVolume(initVolume); |  |  |     audio.setVolume(initVolume); | 
		
	
		
			
				|  |  |     audio.forceMono(playProperties.currentPlayMono); |  |  |     audio.forceMono(playProperties.currentPlayMono); | 
		
	
	
		
			
				|  | @ -1848,11 +1855,6 @@ void playAudio(void *parameter) { | 
		
	
		
			
				|  |  |             } |  |  |             } | 
		
	
		
			
				|  |  |         #endif
 |  |  |         #endif
 | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |         // If error occured: remove playlist from ESPuino
 |  |  |  | 
		
	
		
			
				|  |  |         if ((playProperties.playMode != NO_PLAYLIST) && !audio.isRunning() && !playProperties.pausePlay) { |  |  |  | 
		
	
		
			
				|  |  |             playProperties.trackFinished = true; |  |  |  | 
		
	
		
			
				|  |  |         } |  |  |  | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  |         audio.loop(); |  |  |         audio.loop(); | 
		
	
		
			
				|  |  |         if (playProperties.playlistFinished || playProperties.pausePlay) { |  |  |         if (playProperties.playlistFinished || playProperties.pausePlay) { | 
		
	
		
			
				|  |  |             vTaskDelay(portTICK_PERIOD_MS*10);                   // Waste some time if playlist is not active
 |  |  |             vTaskDelay(portTICK_PERIOD_MS*10);                   // Waste some time if playlist is not active
 | 
		
	
	
		
			
				|  | @ -1860,6 +1862,19 @@ void playAudio(void *parameter) { | 
		
	
		
			
				|  |  |             lastTimeActiveTimestamp = millis();                  // Refresh if playlist is active so uC will not fall asleep due to reaching inactivity-time
 |  |  |             lastTimeActiveTimestamp = millis();                  // Refresh if playlist is active so uC will not fall asleep due to reaching inactivity-time
 | 
		
	
		
			
				|  |  |         } |  |  |         } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |         if (audio.isRunning()) { | 
		
	
		
			
				|  |  |  |  |  |             settleCount = 0; | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |         // If error occured: remove playlist from ESPuino
 | 
		
	
		
			
				|  |  |  |  |  |         if (playProperties.playMode != NO_PLAYLIST && playProperties.playMode != BUSY && !audio.isRunning() && !playProperties.pausePlay) { | 
		
	
		
			
				|  |  |  |  |  |             if (settleCount++ == 50) {      // Hack to give audio some time to settle down after playlist was generated
 | 
		
	
		
			
				|  |  |  |  |  |                 playProperties.playlistFinished = true; | 
		
	
		
			
				|  |  |  |  |  |                 playProperties.playMode = NO_PLAYLIST; | 
		
	
		
			
				|  |  |  |  |  |                 settleCount = 0; | 
		
	
		
			
				|  |  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |         esp_task_wdt_reset();                                    // Don't forget to feed the dog!
 |  |  |         esp_task_wdt_reset();                                    // Don't forget to feed the dog!
 | 
		
	
		
			
				|  |  |     } |  |  |     } | 
		
	
		
			
				|  |  |     vTaskDelete(NULL); |  |  |     vTaskDelete(NULL); | 
		
	
	
		
			
				|  | @ -1867,25 +1882,22 @@ void playAudio(void *parameter) { | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | #if defined RFID_READER_TYPE_MFRC522_SPI || defined RFID_READER_TYPE_MFRC522_I2C
 |  |  | #if defined RFID_READER_TYPE_MFRC522_SPI || defined RFID_READER_TYPE_MFRC522_I2C
 | 
		
	
		
			
				|  |  | // Instructs RFID-scanner to scan for new RFID-tags
 |  |  |  | 
		
	
		
			
				|  |  | void rfidScanner(void *parameter) { |  |  |  | 
		
	
		
			
				|  |  |  |  |  | // Instructs RFID-scanner to scan for new RFID-tags using RC522 (running as function)
 | 
		
	
		
			
				|  |  |  |  |  | void rfidScanner(void) { | 
		
	
		
			
				|  |  |     byte cardId[cardIdSize]; |  |  |     byte cardId[cardIdSize]; | 
		
	
		
			
				|  |  |     char *cardIdString; |  |  |     char *cardIdString; | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |     for (;;) { |  |  |  | 
		
	
		
			
				|  |  |         esp_task_wdt_reset(); |  |  |  | 
		
	
		
			
				|  |  |         vTaskDelay(10); |  |  |  | 
		
	
		
			
				|  |  |     if ((millis() - lastRfidCheckTimestamp) >= RFID_SCAN_INTERVAL) { |  |  |     if ((millis() - lastRfidCheckTimestamp) >= RFID_SCAN_INTERVAL) { | 
		
	
		
			
				|  |  |         lastRfidCheckTimestamp = millis(); |  |  |         lastRfidCheckTimestamp = millis(); | 
		
	
		
			
				|  |  |         // Reset the loop if no new card is present on the sensor/reader. This saves the entire process when idle.
 |  |  |         // Reset the loop if no new card is present on the sensor/reader. This saves the entire process when idle.
 | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |         if (!mfrc522.PICC_IsNewCardPresent()) { |  |  |         if (!mfrc522.PICC_IsNewCardPresent()) { | 
		
	
		
			
				|  |  |                 continue; |  |  |  | 
		
	
		
			
				|  |  |  |  |  |             return; | 
		
	
		
			
				|  |  |         } |  |  |         } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |         // Select one of the cards
 |  |  |         // Select one of the cards
 | 
		
	
		
			
				|  |  |         if (!mfrc522.PICC_ReadCardSerial()) { |  |  |         if (!mfrc522.PICC_ReadCardSerial()) { | 
		
	
		
			
				|  |  |                 continue; |  |  |  | 
		
	
		
			
				|  |  |  |  |  |             return; | 
		
	
		
			
				|  |  |         } |  |  |         } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |         //mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
 |  |  |         //mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
 | 
		
	
	
		
			
				|  | @ -1903,7 +1915,7 @@ void rfidScanner(void *parameter) { | 
		
	
		
			
				|  |  |             #ifdef NEOPIXEL_ENABLE
 |  |  |             #ifdef NEOPIXEL_ENABLE
 | 
		
	
		
			
				|  |  |                 showLedError = true; |  |  |                 showLedError = true; | 
		
	
		
			
				|  |  |             #endif
 |  |  |             #endif
 | 
		
	
		
			
				|  |  |                 continue; |  |  |  | 
		
	
		
			
				|  |  |  |  |  |             return; | 
		
	
		
			
				|  |  |         } |  |  |         } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |         uint8_t n = 0; |  |  |         uint8_t n = 0; | 
		
	
	
		
			
				|  | @ -1922,17 +1934,14 @@ void rfidScanner(void *parameter) { | 
		
	
		
			
				|  |  |             } |  |  |             } | 
		
	
		
			
				|  |  |         } |  |  |         } | 
		
	
		
			
				|  |  |         xQueueSend(rfidCardQueue, &cardIdString, 0); |  |  |         xQueueSend(rfidCardQueue, &cardIdString, 0); | 
		
	
		
			
				|  |  | //            free(cardIdString);
 |  |  |  | 
		
	
		
			
				|  |  |         } |  |  |  | 
		
	
		
			
				|  |  |     } |  |  |     } | 
		
	
		
			
				|  |  |     vTaskDelete(NULL); |  |  |  | 
		
	
		
			
				|  |  | } |  |  | } | 
		
	
		
			
				|  |  | #endif
 |  |  | #endif
 | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  | #ifdef RFID_READER_TYPE_PN5180
 |  |  | #ifdef RFID_READER_TYPE_PN5180
 | 
		
	
		
			
				|  |  | // Instructs RFID-scanner to scan for new RFID-tags using PN5180
 |  |  |  | 
		
	
		
			
				|  |  |  |  |  | // Instructs RFID-scanner to scan for new RFID-tags using PN5180 (running as task)
 | 
		
	
		
			
				|  |  |  |  |  | // Runs as task (instead of function) because it takes about 230 ms (IDLE) and 500 ms (non-IDLE)
 | 
		
	
		
			
				|  |  | void rfidScanner(void *parameter) { |  |  | void rfidScanner(void *parameter) { | 
		
	
		
			
				|  |  |     static PN5180ISO14443 nfc14443(RFID_CS, RFID_BUSY, RFID_RST); |  |  |     static PN5180ISO14443 nfc14443(RFID_CS, RFID_BUSY, RFID_RST); | 
		
	
		
			
				|  |  |     static PN5180ISO15693 nfc15693(RFID_CS, RFID_BUSY, RFID_RST); |  |  |     static PN5180ISO15693 nfc15693(RFID_CS, RFID_BUSY, RFID_RST); | 
		
	
	
		
			
				|  | @ -4798,6 +4807,7 @@ void setup() { | 
		
	
		
			
				|  |  |    Serial.println(F(" | |___   ___) | |  __/  | |_| | | | | | | | | (_) |")); |  |  |    Serial.println(F(" | |___   ___) | |  __/  | |_| | | | | | | | | (_) |")); | 
		
	
		
			
				|  |  |    Serial.println(F(" |_____| |____/  |_|      \\__,_| |_| |_| |_|  \\___/ ")); |  |  |    Serial.println(F(" |_____| |____/  |_|      \\__,_| |_| |_| |_|  \\___/ ")); | 
		
	
		
			
				|  |  |    Serial.println(F(" Rfid-controlled musicplayer\n")); |  |  |    Serial.println(F(" Rfid-controlled musicplayer\n")); | 
		
	
		
			
				|  |  |  |  |  |    Serial.println(F(" Rev 20210402-1\n")); | 
		
	
		
			
				|  |  |    // print wake-up reason
 |  |  |    // print wake-up reason
 | 
		
	
		
			
				|  |  |    printWakeUpReason(); |  |  |    printWakeUpReason(); | 
		
	
		
			
				|  |  |    #ifdef PN5180_ENABLE_LPCD
 |  |  |    #ifdef PN5180_ENABLE_LPCD
 | 
		
	
	
		
			
				|  | @ -5068,16 +5078,18 @@ void setup() { | 
		
	
		
			
				|  |  |     timerAlarmWrite(timer, 10000, true);        // 100 Hz
 |  |  |     timerAlarmWrite(timer, 10000, true);        // 100 Hz
 | 
		
	
		
			
				|  |  |     timerAlarmEnable(timer); |  |  |     timerAlarmEnable(timer); | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |     // Create tasks
 |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     #ifdef RFID_READER_TYPE_PN5180
 | 
		
	
		
			
				|  |  |  |  |  |         // Create task for rfid
 | 
		
	
		
			
				|  |  |         xTaskCreatePinnedToCore( |  |  |         xTaskCreatePinnedToCore( | 
		
	
		
			
				|  |  |             rfidScanner, /* Function to implement the task */ |  |  |             rfidScanner, /* Function to implement the task */ | 
		
	
		
			
				|  |  |             "rfidhandling", /* Name of the task */ |  |  |             "rfidhandling", /* Name of the task */ | 
		
	
		
			
				|  |  |         2000,  /* Stack size in words */ |  |  |  | 
		
	
		
			
				|  |  |  |  |  |             1500,  /* Stack size in words */ | 
		
	
		
			
				|  |  |             NULL,  /* Task input parameter */ |  |  |             NULL,  /* Task input parameter */ | 
		
	
		
			
				|  |  |             1,  /* Priority of the task */ |  |  |             1,  /* Priority of the task */ | 
		
	
		
			
				|  |  |             &rfid,  /* Task handle. */ |  |  |             &rfid,  /* Task handle. */ | 
		
	
		
			
				|  |  |             0 /* Core where the task should run */ |  |  |             0 /* Core where the task should run */ | 
		
	
		
			
				|  |  |         ); |  |  |         ); | 
		
	
		
			
				|  |  |  |  |  |     #endif
 | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |     // Activate internal pullups for all enabled buttons
 |  |  |     // Activate internal pullups for all enabled buttons
 | 
		
	
		
			
				|  |  |     #ifdef BUTTON_0_ENABLE
 |  |  |     #ifdef BUTTON_0_ENABLE
 | 
		
	
	
		
			
				|  | @ -5171,6 +5183,9 @@ void bluetoothHandler(void) { | 
		
	
		
			
				|  |  | #endif
 |  |  | #endif
 | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | void loop() { |  |  | void loop() { | 
		
	
		
			
				|  |  |  |  |  |     #ifndef RFID_READER_TYPE_PN5180
 | 
		
	
		
			
				|  |  |  |  |  |         rfidScanner();      // PN5180 runs as task; RC522 as function
 | 
		
	
		
			
				|  |  |  |  |  |     #endif
 | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |     #ifdef BLUETOOTH_ENABLE
 |  |  |     #ifdef BLUETOOTH_ENABLE
 | 
		
	
		
			
				|  |  |     if(operationMode == OPMODE_BLUETOOTH) { |  |  |     if(operationMode == OPMODE_BLUETOOTH) { | 
		
	
	
		
			
				|  | 
 |