Power Grid Board Game Timer. Acts like a chess timer for 3-6 people. Uses an ADXL accelerometer to pause the timer and change players. Uses an LCD screen to prompt the players for input, read that input, and change between rounds.
Dependencies: DmTouch_UniGraphic UniGraphic-forLdelaney17FinalProject mbed
Song.h@5:e07903df9510, 2017-01-25 (annotated)
- Committer:
- ldelaney17
- Date:
- Wed Jan 25 16:30:13 2017 +0000
- Revision:
- 5:e07903df9510
- Parent:
- 4:e14c199c2466
publish commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ldelaney17 | 4:e14c199c2466 | 1 | #ifndef SONG_H |
ldelaney17 | 4:e14c199c2466 | 2 | #define SONG_H |
ldelaney17 | 4:e14c199c2466 | 3 | #include<vector> |
ldelaney17 | 4:e14c199c2466 | 4 | #include "mbed.h" |
ldelaney17 | 4:e14c199c2466 | 5 | extern PwmOut myBuzzer; |
ldelaney17 | 4:e14c199c2466 | 6 | extern Timeout note_duration; |
ldelaney17 | 4:e14c199c2466 | 7 | extern DigitalOut led; |
ldelaney17 | 4:e14c199c2466 | 8 | extern Serial pc; |
ldelaney17 | 4:e14c199c2466 | 9 | |
ldelaney17 | 4:e14c199c2466 | 10 | class Song{ |
ldelaney17 | 4:e14c199c2466 | 11 | protected: |
ldelaney17 | 4:e14c199c2466 | 12 | float beat_length; |
ldelaney17 | 4:e14c199c2466 | 13 | public: |
ldelaney17 | 4:e14c199c2466 | 14 | vector<float> freqs; |
ldelaney17 | 4:e14c199c2466 | 15 | vector<float> beats; |
ldelaney17 | 4:e14c199c2466 | 16 | //int * freqs; |
ldelaney17 | 4:e14c199c2466 | 17 | //int * beats; |
ldelaney17 | 4:e14c199c2466 | 18 | int song_length; |
ldelaney17 | 4:e14c199c2466 | 19 | int place_in_song; |
ldelaney17 | 4:e14c199c2466 | 20 | |
ldelaney17 | 4:e14c199c2466 | 21 | Song(vector<float> &freq, vector<float> &beat, int length, int tempo){ //length format left over from int arrays. Had pointer issues. Replaced with vectors. |
ldelaney17 | 4:e14c199c2466 | 22 | pc.printf("In song constructor with length %d\r\n", length); |
ldelaney17 | 4:e14c199c2466 | 23 | if (tempo == 0) //prevent divide by zero runtime errors |
ldelaney17 | 4:e14c199c2466 | 24 | tempo = 120; |
ldelaney17 | 4:e14c199c2466 | 25 | beat_length = 60.0/tempo; //beats/minute -> beat duration in seconds |
ldelaney17 | 4:e14c199c2466 | 26 | pc.printf("Beat length is %.2fs\r\n", beat_length); |
ldelaney17 | 4:e14c199c2466 | 27 | freqs = freq; |
ldelaney17 | 4:e14c199c2466 | 28 | beats = beat; |
ldelaney17 | 4:e14c199c2466 | 29 | song_length = length; |
ldelaney17 | 4:e14c199c2466 | 30 | place_in_song = 0; |
ldelaney17 | 4:e14c199c2466 | 31 | return; |
ldelaney17 | 4:e14c199c2466 | 32 | } |
ldelaney17 | 4:e14c199c2466 | 33 | |
ldelaney17 | 4:e14c199c2466 | 34 | void play(); |
ldelaney17 | 4:e14c199c2466 | 35 | void set_note(int index); |
ldelaney17 | 4:e14c199c2466 | 36 | void set_tempo(int tempo); |
ldelaney17 | 4:e14c199c2466 | 37 | }; |
ldelaney17 | 4:e14c199c2466 | 38 | |
ldelaney17 | 4:e14c199c2466 | 39 | #endif |