Big Mouth Billy Bass player that takes raw wavefiles and decision list text files from an SD card
Dependencies: SDFileSystem mbed BillyBass
main.cpp
- Committer:
- bikeNomad
- Date:
- 2013-06-18
- Revision:
- 8:1dd2bb31dec6
- Parent:
- 7:ce27f959813b
- Child:
- 9:99213347474f
File content as of revision 8:1dd2bb31dec6:
#include "billybass.hpp"
#include "SDFileSystem.h"
#include "song.hpp"
#include "player.hpp"
#include "action.hpp"
// Power:
// Power GND J9/14
// Vin (6V) J9/16
// tailPin, mouthPin, bodyPin
BillyBass testBass(LED_RED, LED_GREEN, LED_BLUE);
// tailPin, mouthPin, bodyPin
// J3/2, J3/1, J3/3
BillyBass realBass(PTA13, PTC12, PTC13);
DigitalIn pushbutton(PTD5); // J3/4
// Analog:
// GND J3/14
// VrefH J3/16
AnalogOut speaker(PTE30); // J10/11
// PTD0 D10 - Used for CS of SPI
// PTD2 D11 - Used for MOSI of SPI
// PTD3 D12 - Used for MISO of SPI
// PTC5 J1/9 Used for SCLK of SPI
// MOSI, MISO, SCLK, CS, name
SDFileSystem sd(PTD2, PTD3, PTC5, PTD0, SD_NAME);
Serial pc(USBTX, USBRX);
void biggestAllocation()
{
size_t blksize = 16384;
char *m;
while (blksize > 0 && (m = (char *)malloc(blksize)) == 0) {
blksize -= 1024;
}
char *heaptop = m + blksize;
fprintf(stderr, "biggest: %u, heaptop: %p, current SP: %p, room: %u\r\n",
blksize,
heaptop,
__current_sp(),
(char *)__current_sp() - heaptop);
free(m);
}
void dumpHeap()
{
biggestAllocation();
__heapstats((__heapprt)fprintf,stderr);
__heapvalid((__heapprt)fprintf,stderr, 0);
}
int main()
{
SongPlayer player;
pc.baud(SERIAL_BAUD);
fprintf(stderr, "*** REBOOT ***\r\n");
fprintf(stderr, "sizeof Action=%u, Song=%u\r\n", sizeof(Action), sizeof(Song));
dumpHeap();
Song *song = Song::newSong("6_1_sciencefish.raw");
delete song;
dumpHeap();
song = Song::newSong("2_1_i_hardly_slept.raw");
dumpHeap();
delete song;
dumpHeap();
song = Song::newSong("1_1_a_sound.raw");
dumpHeap();
delete song;
song = Song::newSong("4_1_GoodEvening.raw");
dumpHeap();
delete song;
song = Song::newSong("5_1_listen_kid_THISONE.raw");
dumpHeap();
delete song;
Song::newSong("3_1_BoatingThemeSong.raw");
dumpHeap();
delete song;
// read the directory
DIR *bassDir = 0;
while (!bassDir) {
if ((bassDir = opendir(BASS_DIRECTORY)) != 0)
break;
pc.printf("Error opening " BASS_DIRECTORY "\r\n");
wait(1.0);
}
closedir(bassDir);
}
Ned Konz