Mert Us Matthew Hannay Logan Starr
Dependencies: mbed 4DGL-uLCD-SE
Revision 18:9b27f5dd7c4b, committed 23 months ago
- Comitter:
- mhannay3
- Date:
- Thu Dec 08 23:16:14 2022 +0000
- Parent:
- 17:4d74a661d6a0
- Commit message:
- speaker (final?)
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Dec 05 12:12:50 2022 +0000 +++ b/main.cpp Thu Dec 08 23:16:14 2022 +0000 @@ -7,6 +7,7 @@ DigitalOut bad_move(p18); DigitalIn reset_button(p19); DigitalIn game_mode_switch(p20); +PwmOut speaker(p21); enum Piece {e, wK, bK, wQ, bQ, wR, bR, wB, bB, wN, bN, w, b}; std::vector<Piece> whitePieces; @@ -998,6 +999,24 @@ boardPos selectedPos; Piece selectedPiece; std::vector<boardPos> possibleMoves; + +void playGameOverTune() +{ + speaker.period(1.0/261.63); + speaker = 0.5; + wait(0.5); + speaker = 0.0; + wait(0.01); + speaker.period(1.0/293.66); + speaker = 0.5; + wait(0.5); + speaker = 0.0; + wait(0.01); + speaker.period(1.0/329.63); + speaker = 0.5; + wait(0.5); + speaker = 0.0; +} // callbacks void moveCursor(int rowChange, int columnChange) @@ -1163,6 +1182,7 @@ uLCD.printf("WHITE"); uLCD.locate(2,4); uLCD.printf("WINS"); + playGameOverTune(); while(1) { if (!reset_button) { reset_game(); @@ -1179,6 +1199,7 @@ uLCD.printf("BLACK"); uLCD.locate(2,4); uLCD.printf("WINS"); + playGameOverTune(); while(1) { if (!reset_button) { reset_game(); @@ -1293,6 +1314,7 @@ uLCD.printf("BLACK"); uLCD.locate(2,4); uLCD.printf("WINS"); + playGameOverTune(); while(1) { if (!reset_button) { reset_game();