Big Mouth Billy Bass automation library
Diff: song.cpp
- Revision:
- 3:6c91a6232c4a
- Parent:
- 1:9b1f3eb204ac
- Child:
- 4:f009306756b3
--- a/song.cpp Tue Jun 18 06:12:48 2013 +0000
+++ b/song.cpp Tue Jun 18 13:11:07 2013 +0000
@@ -22,16 +22,16 @@
{
Song *s = new Song;
if (!s) {
- pc.printf("new Song == 0\r\n");
+ fprintf(stderr, "new Song == 0\r\n");
return 0;
}
if (! s->parseFilename(_name)) {
- pc.printf("parseFilename(%s) failed\r\n", _name);
+ fprintf(stderr, "parseFilename(%s) failed\r\n", _name);
goto on_error;
}
- pc.printf("parsed filename OK\r\n");
+ fprintf(stderr, "parsed filename OK\r\n");
if (! s->readActions()) {
- pc.printf("readActions(%s) failed\r\n", _name);
+ fprintf(stderr, "readActions(%s) failed\r\n", _name);
goto on_error;
}
@@ -85,19 +85,19 @@
bool Song::readActions()
{
- pc.printf("reading actions of %s\r\n", getTextFileName());
+ fprintf(stderr, "reading actions of %s\r\n", getTextFileName());
FILE *txtfile = fopen(getTextFileName(), "r");
if (!txtfile) {
- pc.printf("can't open %s\r\n", getTextFileName());
+ fprintf(stderr, "can't open %s\r\n", getTextFileName());
return false;
} else
- pc.printf("opened %s OK\r\n", getTextFileName());
+ fprintf(stderr, "opened %s OK\r\n", getTextFileName());
bool retval = false;
BillyBass *bass = BillyBass::bassNumber(whichFish);
if (!bass) {
- pc.printf("No bass!\r\n");
+ fprintf(stderr, "No bass!\r\n");
goto done;
}
@@ -105,7 +105,7 @@
static char textFileBuffer[ 2048 ];
memset(textFileBuffer, 0, sizeof(textFileBuffer));
int nread = fread(textFileBuffer, 1, sizeof(textFileBuffer), txtfile);
- pc.printf("Read %d\r\n", nread);
+ // fprintf(stderr, "Read %d bytes\r\n", nread);
if (nread <= 0 || nread == sizeof(textFileBuffer)) {
goto done;
}
@@ -126,15 +126,15 @@
char const *outName;
DigitalOut *out = bass->outputNamed(++q, &outName);
if (!out) {
- pc.printf("%s line %d: bad outname \"%s\"\r\n", getTextFileName(), line, q);
+ fprintf(stderr, "%s line %d: bad outname \"%s\"\r\n", getTextFileName(), line, q);
goto done;
}
- pc.printf("%d add %f %f %s\r\n", line, startTime, endTime, outName);
+ // fprintf(stderr, "%d add %f %f %s\r\n", line, startTime, endTime, outName);
- // actions.push_back(Action(startTime, true, out, outName));
- // actions.push_back(Action(endTime, false, out, outName));
+ actions.push_back(Action(startTime, bass->onState(), out, outName));
+ actions.push_back(Action(endTime, bass->offState(), out, outName));
}
-
+ fprintf(stderr, "Added %d actions\r\n", actions.size());
std::sort(actions.begin(), actions.end()); // sort actions by time
retval = true;
Ned Konz