I can't use serial communications to diagnose the problem because I have to use RX/TX pins 1 and 2 to communicate with the ht1632c LED. I wonder if that's part of the problem -- I tried commenting out <WaveUtil.h> and any of the waveshield functions that were trying to use the serial port, but that didn't help. The binary sketch size for the combined code is about 24k (of 32k max). Maybe its a memory problem? SRAM?
I'm stuck. Any suggestions?
The code is here if you want to check it out. The minimum additional code that I added for the waveshield is below.
https://github.com/cbonsig/openclock
Code: Select all
...
#include <WaveHC.h>
//#include <WaveUtil.h>
SdReader card; // This object holds the information for the card
FatVolume vol; // This holds the information for the partition on the card
FatReader root; // This holds the information for the volumes root directory
FatReader file; // This object represent the WAV file for a pi digit or period
WaveHC wave; // This is the only wave (audio) object, since we will only play one at a time
...
void setup(){
...
playcomplete("CLK_TOWR.WAV");
}
/////////////////////////////////// HELPERS for WaveShield
char filename[13];
void speaknum(char c) {
uint8_t i=0;
// copy flash string for 'period' to filename
strcpy_P(filename, PSTR("P.WAV"));
if ('0' <= c && c <= '9') {
// digit - change 'P' to digit
filename[0] = c;
i = 1;
}
else if (c != '.') {
// error if not period
return;
}
playcomplete(filename);
}
/*
* print error message and halt
*/
//void error_P(const char *str) {
// PgmPrint("Error: ");
// SerialPrint_P(str);
// sdErrorCheck();
// while(1);
//}
/*
* print error message and halt if SD I/O error
*/
//void sdErrorCheck(void) {
// if (!card.errorCode()) return;
// PgmPrint("\r\nSD I/O error: ");
// Serial.print(card.errorCode(), HEX);
// PgmPrint(", ");
// Serial.println(card.errorData(), HEX);
// while(1);
// }
/*
* Play a file and wait for it to complete
*/
void playcomplete(char *name) {
playfile(name);
while (wave.isplaying);
// see if an error occurred while playing
// sdErrorCheck();
}
/*
* Open and start playing a WAV file
*/
void playfile(char *name) {
if (wave.isplaying) {// already playing something, so stop it!
wave.stop(); // stop it
}
// if (!file.open(root, name)) {
// PgmPrint("Couldn't open file ");
// Serial.print(name);
// return;
// }
// if (!wave.create(file)) {
// PgmPrintln("Not a valid WAV");
// return;
// }
// ok time to play!
wave.play();
}