Big Mouth Billy Bass player that takes raw wavefiles and decision list text files from an SD card
Dependencies: SDFileSystem mbed BillyBass
main.cpp@7:ce27f959813b, 2013-06-17 (annotated)
- Committer:
- bikeNomad
- Date:
- Mon Jun 17 22:18:12 2013 +0000
- Revision:
- 7:ce27f959813b
- Parent:
- 6:e90a12ca056f
- Child:
- 8:1dd2bb31dec6
mostly working; hangs when reading actions
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| bikeNomad | 5:5b846ef42702 | 1 | #include "billybass.hpp" |
| bikeNomad | 7:ce27f959813b | 2 | #include "SDFileSystem.h" |
| bikeNomad | 5:5b846ef42702 | 3 | #include "song.hpp" |
| bikeNomad | 5:5b846ef42702 | 4 | #include "player.hpp" |
| bikeNomad | 5:5b846ef42702 | 5 | #include "action.hpp" |
| bikeNomad | 0:0944c3654ded | 6 | |
| bikeNomad | 0:0944c3654ded | 7 | // Power: |
| bikeNomad | 0:0944c3654ded | 8 | // Power GND J9/14 |
| bikeNomad | 0:0944c3654ded | 9 | // Vin (6V) J9/16 |
| bikeNomad | 0:0944c3654ded | 10 | |
| bikeNomad | 7:ce27f959813b | 11 | // tailPin, mouthPin, bodyPin |
| bikeNomad | 7:ce27f959813b | 12 | BillyBass testBass(LED_RED, LED_GREEN, LED_BLUE); |
| bikeNomad | 7:ce27f959813b | 13 | |
| bikeNomad | 7:ce27f959813b | 14 | // tailPin, mouthPin, bodyPin |
| bikeNomad | 7:ce27f959813b | 15 | // J3/2, J3/1, J3/3 |
| bikeNomad | 7:ce27f959813b | 16 | BillyBass realBass(PTA13, PTC12, PTC13); |
| bikeNomad | 0:0944c3654ded | 17 | |
| bikeNomad | 0:0944c3654ded | 18 | DigitalIn pushbutton(PTD5); // J3/4 |
| bikeNomad | 0:0944c3654ded | 19 | |
| bikeNomad | 0:0944c3654ded | 20 | // Analog: |
| bikeNomad | 0:0944c3654ded | 21 | // GND J3/14 |
| bikeNomad | 0:0944c3654ded | 22 | // VrefH J3/16 |
| bikeNomad | 5:5b846ef42702 | 23 | AnalogOut speaker(PTE30); // J10/11 |
| bikeNomad | 0:0944c3654ded | 24 | |
| bikeNomad | 5:5b846ef42702 | 25 | // PTD0 D10 - Used for CS of SPI |
| bikeNomad | 5:5b846ef42702 | 26 | // PTD2 D11 - Used for MOSI of SPI |
| bikeNomad | 5:5b846ef42702 | 27 | // PTD3 D12 - Used for MISO of SPI |
| bikeNomad | 0:0944c3654ded | 28 | // PTC5 J1/9 Used for SCLK of SPI |
| bikeNomad | 0:0944c3654ded | 29 | |
| bikeNomad | 7:ce27f959813b | 30 | // MOSI, MISO, SCLK, CS, name |
| bikeNomad | 0:0944c3654ded | 31 | SDFileSystem sd(PTD2, PTD3, PTC5, PTD0, SD_NAME); |
| bikeNomad | 7:ce27f959813b | 32 | |
| bikeNomad | 0:0944c3654ded | 33 | Serial pc(USBTX, USBRX); |
| bikeNomad | 0:0944c3654ded | 34 | |
| bikeNomad | 0:0944c3654ded | 35 | int main() |
| bikeNomad | 0:0944c3654ded | 36 | { |
| bikeNomad | 3:00b4c1aadd30 | 37 | SongPlayer player; |
| bikeNomad | 5:5b846ef42702 | 38 | pc.baud(SERIAL_BAUD); |
| bikeNomad | 7:ce27f959813b | 39 | |
| bikeNomad | 7:ce27f959813b | 40 | pc.printf("*** REBOOT ***\r\n"); |
| bikeNomad | 3:00b4c1aadd30 | 41 | |
| bikeNomad | 0:0944c3654ded | 42 | // read the directory |
| bikeNomad | 7:ce27f959813b | 43 | DIR *bassDir = 0; |
| bikeNomad | 7:ce27f959813b | 44 | while (!bassDir) { |
| bikeNomad | 7:ce27f959813b | 45 | if ((bassDir = opendir(BASS_DIRECTORY)) != 0) |
| bikeNomad | 7:ce27f959813b | 46 | break; |
| bikeNomad | 7:ce27f959813b | 47 | pc.printf("Error opening " BASS_DIRECTORY "\r\n"); |
| bikeNomad | 7:ce27f959813b | 48 | wait(1.0); |
| bikeNomad | 7:ce27f959813b | 49 | } |
| bikeNomad | 7:ce27f959813b | 50 | |
| bikeNomad | 7:ce27f959813b | 51 | if (!Song::readAllSongs(bassDir)) { |
| bikeNomad | 7:ce27f959813b | 52 | pc.printf("Found no songs!\r\n"); |
| bikeNomad | 7:ce27f959813b | 53 | } else { |
| bikeNomad | 7:ce27f959813b | 54 | for (std::list<Song *>::const_iterator song_it = Song::songs.begin(); song_it != Song::songs.end(); song_it++) { |
| bikeNomad | 7:ce27f959813b | 55 | Song *song = *song_it; |
| bikeNomad | 7:ce27f959813b | 56 | song->print(pc); |
| bikeNomad | 0:0944c3654ded | 57 | } |
| bikeNomad | 5:5b846ef42702 | 58 | } |
| bikeNomad | 0:0944c3654ded | 59 | } |
Ned Konz