Fix 8 bugs: SD 1-bit mode GPIO conflict, PNG file handle leak, audio stack overflow, null terminator, error degradation logic, modulo div-by-zero, upload file validation, screen clear before PNG draw. Improve web UI with progress bar and toast feedback.

This commit is contained in:
drjones
2026-07-02 21:54:57 -07:00
parent bac1af80fe
commit 7a9d971310
5 changed files with 244 additions and 77 deletions

View File

@@ -29,7 +29,7 @@ void initAudioPlayer() {
xTaskCreatePinnedToCore(
audioLoopTask,
"audioLoopTask",
8192, // Stack size (ESP32-audioI2S requires a larger stack size for decoding)
16384, // Increased from 8192 — ESP32-audioI2S MP3 decode needs ~12-16KB stack
NULL,
5, // Priority
&audioTaskHandle,
@@ -66,6 +66,14 @@ uint8_t getPlayerVolume() {
return currentVolume;
}
// Case-insensitive check if filename ends with a given extension
static bool hasExtension(const char* name, const char* ext) {
size_t nLen = strlen(name);
size_t eLen = strlen(ext);
if (nLen < eLen) return false;
return strcasecmp(name + nLen - eLen, ext) == 0;
}
void Search_Audio(const char* directory) {
File Path = SD_MMC.open(directory);
if (!Path) {
@@ -79,8 +87,8 @@ void Search_Audio(const char* directory) {
while (file && fileCount < 100) {
if (!file.isDirectory()) {
const char* name = file.name();
// Match WAV or MP3 files
if (strstr(name, ".wav") || strstr(name, ".mp3") || strstr(name, ".WAV") || strstr(name, ".MP3")) {
// Case-insensitive extension match to handle FAT32 uppercase names
if (hasExtension(name, ".wav") || hasExtension(name, ".mp3")) {
strncpy(Audio_Names[fileCount], name, sizeof(Audio_Names[fileCount]) - 1);
Audio_Names[fileCount][sizeof(Audio_Names[fileCount]) - 1] = '\0';
fileCount++;