diff --git a/src/AudioFileSourceSPIRAMBuffer.cpp b/src/AudioFileSourceSPIRAMBuffer.cpp index b5f9193..c74d878 100644 --- a/src/AudioFileSourceSPIRAMBuffer.cpp +++ b/src/AudioFileSourceSPIRAMBuffer.cpp @@ -36,7 +36,7 @@ AudioFileSourceSPIRAMBuffer::AudioFileSourceSPIRAMBuffer(AudioFileSource *source length = 0; filled = false; bytesAvailable = 0; - Serial.printf("SPI RAM buffer size: %u Bytes\n", ramSize); + Serial.printf_P(PSTR("SPI RAM buffer size: %u Bytes\n"), ramSize); } AudioFileSourceSPIRAMBuffer::~AudioFileSourceSPIRAMBuffer() @@ -81,7 +81,7 @@ uint32_t AudioFileSourceSPIRAMBuffer::read(void *data, uint32_t len) writePtr = readPtr = 0; uint16_t toRead = sizeof(buffer); // Fill up completely before returning any data at all - Serial.println("Buffering..."); + Serial.printf_P(PSTR("Buffering...\n")); while (bytesAvailable!=ramSize) { length = src->read(buffer, toRead); if(length>0) { @@ -95,7 +95,7 @@ uint32_t AudioFileSourceSPIRAMBuffer::read(void *data, uint32_t len) } writePtr = bytesAvailable % ramSize; filled = true; - Serial.println("Filling Done !"); + Serial.printf_P(PSTR("Filling Done !\n")); } // Serial.printf("Buffer: %u%\n", bytesAvailable*100/ramSize); @@ -139,7 +139,7 @@ void AudioFileSourceSPIRAMBuffer::fill() bytesAvailable+=cnt; writePtr = (writePtr + cnt) % ramSize; #ifdef SPIBUF_DEBUG - Serial.printf("SockRead: %u | RamAvail: %u\n", cnt, bytesAvailable); + Serial.printf_P(PSTR("SockRead: %u | RamAvail: %u\n"), cnt, bytesAvailable); #endif } return; diff --git a/src/AudioGeneratorAAC.cpp b/src/AudioGeneratorAAC.cpp index abc7184..007c223 100644 --- a/src/AudioGeneratorAAC.cpp +++ b/src/AudioGeneratorAAC.cpp @@ -28,7 +28,10 @@ AudioGeneratorAAC::AudioGeneratorAAC() file = NULL; output = NULL; hAACDecoder = AACInitDecoder(); - if (!hAACDecoder) { Serial.println("Out of memory error! hAACDecoder==NULL"); Serial.flush(); } + if (!hAACDecoder) { + Serial.printf_P(PSTR("Out of memory error! hAACDecoder==NULL\n")); + Serial.flush(); + } // For sanity's sake... memset(buff, 0, sizeof(buff)); memset(outSample, 0, sizeof(outSample)); diff --git a/src/AudioGeneratorFLAC.cpp b/src/AudioGeneratorFLAC.cpp index 9868b16..db9daca 100644 --- a/src/AudioGeneratorFLAC.cpp +++ b/src/AudioGeneratorFLAC.cpp @@ -186,7 +186,7 @@ void AudioGeneratorFLAC::metadata_cb(const FLAC__StreamDecoder *decoder, const F { (void) decoder; (void) metadata; - Serial.printf("Metadata\n"); + Serial.printf_P(PSTR("Metadata\n")); } void AudioGeneratorFLAC::error_cb(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status) { diff --git a/src/AudioGeneratorMP3.cpp b/src/AudioGeneratorMP3.cpp index 2229948..d82c4db 100644 --- a/src/AudioGeneratorMP3.cpp +++ b/src/AudioGeneratorMP3.cpp @@ -98,7 +98,7 @@ enum mad_flow AudioGeneratorMP3::Input() int len = buffLen - unused; len = file->read(buff + unused, len); if (len == 0) { - Serial.println("MP3 stop, len==0"); + Serial.printf_P(PSTR("MP3 stop, len==0\n")); return MAD_FLOW_STOP; } @@ -121,7 +121,7 @@ bool AudioGeneratorMP3::DecodeNextFrame() return true; } } while (stream.error == MAD_ERROR_BUFLEN); - Serial.println("stream.error != mad_Err_bufflen"); + Serial.printf_P(PSTR("stream.error != mad_Err_bufflen\n")); return false; } @@ -146,7 +146,7 @@ bool AudioGeneratorMP3::GetOneSample(int16_t sample[2]) switch ( mad_synth_frame_onens(&synth, &frame, nsCount++) ) { case MAD_FLOW_STOP: - case MAD_FLOW_BREAK: Serial.println("msf1ns failed\n"); + case MAD_FLOW_BREAK: Serial.printf_P(PSTR("msf1ns failed\n")); return false; // Either way we're done default: break; // Do nothing @@ -177,7 +177,7 @@ bool AudioGeneratorMP3::loop() } if (!DecodeNextFrame()) { - Serial.println("DNF failed"); + Serial.printf_P(PSTR("DNF failed\n")); return false; } samplePtr = 9999; @@ -185,7 +185,7 @@ bool AudioGeneratorMP3::loop() } if (!GetOneSample(lastSample)) { - Serial.println("G1S failed\n"); + Serial.printf_P(PSTR("G1S failed\n")); running = false; goto done; } @@ -207,7 +207,7 @@ bool AudioGeneratorMP3::begin(AudioFileSource *source, AudioOutput *output) if (!output) return false; this->output = output; if (!file->isOpen()) { - Serial.printf("MP3 source file not open\n"); + Serial.printf_P(PSTR("MP3 source file not open\n")); return false; // Error } if (!output->begin()) return false; @@ -249,11 +249,18 @@ extern "C" { int freeheap = ESP.getFreeHeap(); if ((freestack < 512) || (freeheap < 5120)) { static int laststack, lastheap; - if (laststack!=freestack|| lastheap !=freeheap) - Serial.printf("%s: FREESTACK=%d, FREEHEAP=%d\n", s, /*t, i,*/ freestack, /*cont_get_free_stack(&g_cont),*/ freeheap); Serial.flush(); - if (freestack < 256) {Serial.printf("out of stack!\n"); while (1); } - if (freeheap < 1024) {Serial.printf("out of heap!\n"); while (1); } - laststack=freestack;lastheap=freeheap; + if (laststack!=freestack|| lastheap !=freeheap) { + Serial.printf_P(PSTR("%s: FREESTACK=%d, FREEHEAP=%d\n"), s, /*t, i,*/ freestack, /*cont_get_free_stack(&g_cont),*/ freeheap); + } + if (freestack < 256) { + Serial.printf_P(PSTR("out of stack!\n")); + } + if (freeheap < 1024) { + Serial.printf_P(PSTR("out of heap!\n")); + } + Serial.flush(); + laststack=freestack; + lastheap=freeheap; } } diff --git a/src/AudioGeneratorMP3a.cpp b/src/AudioGeneratorMP3a.cpp index fcdf966..63eac10 100644 --- a/src/AudioGeneratorMP3a.cpp +++ b/src/AudioGeneratorMP3a.cpp @@ -29,7 +29,10 @@ AudioGeneratorMP3a::AudioGeneratorMP3a() file = NULL; output = NULL; hMP3Decoder = MP3InitDecoder(); - if (!hMP3Decoder) { Serial.println("Out of memory error! hMP3Decoder==NULL"); Serial.flush(); } + if (!hMP3Decoder) { + Serial.printf_P(PSTR("Out of memory error! hMP3Decoder==NULL\n")); + Serial.flush(); + } // For sanity's sake... memset(buff, 0, sizeof(buff)); memset(outSample, 0, sizeof(outSample)); diff --git a/src/AudioOutputSerialWAV.cpp b/src/AudioOutputSerialWAV.cpp index 40e9876..8b65e26 100644 --- a/src/AudioOutputSerialWAV.cpp +++ b/src/AudioOutputSerialWAV.cpp @@ -67,7 +67,7 @@ bool AudioOutputSerialWAV::ConsumeSample(int16_t sample[2]) bool AudioOutputSerialWAV::stop() { - Serial.print("\n\n\nEOF\n\n\n"); + Serial.printf_P(PSTR("\n\n\nEOF\n\n\n")); return true; } diff --git a/src/libhelix-mp3/debug.h b/src/libhelix-mp3/debug.h deleted file mode 100644 index d24cabd..0000000 --- a/src/libhelix-mp3/debug.h +++ /dev/null @@ -1,16 +0,0 @@ - -#if !defined(DEBUG_h) - -#include -#include - - -#define DBG Serial2 -//#define DBG_SERIAL Serial -#define DBG_BAUD 115200 - -void initDBG(); - - -#define DEBUG_h -#endif \ No newline at end of file