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:
@@ -68,13 +68,17 @@ void setup() {
|
||||
printf("Initialization complete!\r\n");
|
||||
printf("Found %d PNG images and %d Audio files (.mp3/.wav).\r\n", Image_Count, Audio_Count);
|
||||
|
||||
if (Image_Count == 0 || Audio_Count == 0) {
|
||||
if (Image_Count == 0 && Audio_Count == 0) {
|
||||
hasError = true;
|
||||
currentState = STATE_ERROR;
|
||||
printf("ERROR: No media found on microSD card!\r\n");
|
||||
} else {
|
||||
printf("Displaying initial image (index 0): %s\r\n", Image_Names[0]);
|
||||
Display_Image_By_Index("/", 0);
|
||||
if (Image_Count == 0) printf("WARNING: No PNG images found — audio-only mode.\r\n");
|
||||
if (Audio_Count == 0) printf("WARNING: No audio files found — silent slideshow mode.\r\n");
|
||||
if (Image_Count > 0) {
|
||||
printf("Displaying initial image (index 0): %s\r\n", Image_Names[0]);
|
||||
Display_Image_By_Index("/", 0);
|
||||
}
|
||||
currentState = STATE_IDLE;
|
||||
}
|
||||
|
||||
@@ -111,11 +115,13 @@ void playCurrentPair() {
|
||||
void handleSinglePress() {
|
||||
printf("Gesture: Single Click - Next Slide\r\n");
|
||||
if (!hasError) {
|
||||
uint16_t total = std::max(Image_Count, Audio_Count);
|
||||
if (total == 0) return;
|
||||
if (currentState == STATE_AUTOPLAY) {
|
||||
currentState = STATE_IDLE;
|
||||
printf("Autoplay Disabled.\r\n");
|
||||
}
|
||||
currentIndex = (currentIndex + 1) % std::max(Image_Count, Audio_Count);
|
||||
currentIndex = (currentIndex + 1) % total;
|
||||
playCurrentPair();
|
||||
}
|
||||
}
|
||||
@@ -130,12 +136,13 @@ void handleDoublePress() {
|
||||
void handleTriplePress() {
|
||||
printf("Gesture: Triple Click - Previous Slide\r\n");
|
||||
if (!hasError) {
|
||||
uint16_t total = std::max(Image_Count, Audio_Count);
|
||||
if (total == 0) return;
|
||||
if (currentState == STATE_AUTOPLAY) {
|
||||
currentState = STATE_IDLE;
|
||||
printf("Autoplay Disabled.\r\n");
|
||||
}
|
||||
uint16_t totalMedia = std::max(Image_Count, Audio_Count);
|
||||
currentIndex = (currentIndex + totalMedia - 1) % totalMedia;
|
||||
currentIndex = (currentIndex + total - 1) % total;
|
||||
playCurrentPair();
|
||||
}
|
||||
}
|
||||
@@ -214,10 +221,11 @@ void loop() {
|
||||
|
||||
// Handle slideshow auto-advance in Autoplay mode
|
||||
if (currentState == STATE_AUTOPLAY && !hasError) {
|
||||
uint16_t total = std::max(Image_Count, Audio_Count);
|
||||
// Only advance when the audio stops playing and slideShowInterval (5s) has passed
|
||||
if (!isAudioPlaying() && (now - lastSlideTime > slideShowInterval)) {
|
||||
if (total > 0 && !isAudioPlaying() && (now - lastSlideTime > slideShowInterval)) {
|
||||
lastSlideTime = now;
|
||||
currentIndex = (currentIndex + 1) % std::max(Image_Count, Audio_Count);
|
||||
currentIndex = (currentIndex + 1) % total;
|
||||
playCurrentPair();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user