ECE 4180 Final
Dependencies: mbed wave_player mbed-rtos C12832_lcd 4DGL-uLCD-SE LCD_fonts SDFileSystem
Revision 20:7d56cdcbc9a5, committed 2019-12-06
- Comitter:
- jcrane32
- Date:
- Fri Dec 06 18:00:11 2019 +0000
- Parent:
- 19:d65f9fb1023b
- Parent:
- 17:13e45fdcf0b0
- Child:
- 21:cbcbb3480cad
- Commit message:
- TODO: fix status LED (tracks bubblesMissed) and add in scoreboard at the end.
Changed in this revision
--- a/Bubble.hpp Fri Dec 06 15:46:16 2019 +0000 +++ b/Bubble.hpp Fri Dec 06 18:00:11 2019 +0000 @@ -20,8 +20,8 @@ // these may need to be adjusted to prevent weird visual artifacts if // bubbles collide - const static int bubbleSpeed = 5; - const static int bubbleRadius = 25; + const static int bubbleSpeed = 15; + const static int bubbleRadius = 10; }; #endif //bubble_hpp \ No newline at end of file
--- a/Lane.cpp Fri Dec 06 15:46:16 2019 +0000 +++ b/Lane.cpp Fri Dec 06 18:00:11 2019 +0000 @@ -13,8 +13,10 @@ } void Lane::draw() { - for (pops_ptr = pops.begin(); pops_ptr < pops.end(); pops_ptr++) { - (*pops_ptr).draw(); + if (!pops.empty()){ + for (pops_ptr = pops.begin(); pops_ptr < pops.end(); pops_ptr++) { + (*pops_ptr).draw(); + } } } @@ -25,6 +27,7 @@ // black out the bubble and remove it from the lane's vector (pops.begin())->clear(); pops.erase(pops.begin()); + ++bubblesMissed; } for (pops_ptr = pops.begin(); pops_ptr < pops.end(); pops_ptr++) {
--- a/bubbles.h Fri Dec 06 15:46:16 2019 +0000 +++ b/bubbles.h Fri Dec 06 18:00:11 2019 +0000 @@ -1,256 +1,256 @@ -const unsigned short the_middle_bubbles[62][5] = {2, 0, 1, 0, 0, -3, 0, 1, 0, 0, -4, 0, 1, 0, 0, -5, 0, 1, 0, 0, -6, 0, 0, 1, 0, -7, 0, 0, 1, 0, -8, 0, 0, 1, 0, -9, 0, 0, 1, 0, -10, 0, 0, 1, 0, -11, 0, 0, 0, 1, -12, 0, 0, 0, 1, -13, 0, 0, 0, 1, -15, 0, 0, 1, 1, -16, 0, 0, 1, 1, -17, 0, 0, 1, 1, -18, 0, 1, 1, 0, -19, 0, 1, 1, 0, -20, 0, 1, 1, 0, -21, 0, 1, 1, 0, -22, 0, 1, 1, 0, -23, 0, 1, 1, 0, -24, 0, 1, 1, 0, -25, 0, 1, 1, 0, -27, 0, 1, 0, 0, -28, 0, 1, 0, 0, -29, 0, 1, 0, 0, -30, 0, 1, 0, 0, -31, 0, 0, 1, 0, -32, 0, 0, 1, 0, -33, 0, 0, 1, 0, -34, 0, 0, 1, 0, -35, 0, 0, 1, 0, -36, 0, 0, 1, 0, -37, 0, 0, 0, 1, -38, 0, 0, 0, 1, -39, 0, 0, 0, 1, -40, 0, 0, 0, 1, -42, 0, 1, 1, 0, -43, 0, 0, 1, 1, -44, 0, 1, 1, 0, -45, 0, 0, 1, 1, -46, 0, 1, 1, 0, -47, 0, 0, 1, 1, -48, 0, 1, 1, 0, -49, 0, 0, 1, 1, -51, 0, 1, 1, 1, -52, 0, 1, 1, 1, -53, 0, 1, 1, 1, -54, 0, 1, 1, 1, -56, 0, 1, 0, 0, -57, 0, 1, 0, 0, -58, 0, 1, 0, 0, -59, 0, 1, 0, 0, -61, 0, 0, 1, 0, -62, 0, 1, 1, 1, -63, 0, 1, 1, 1, -64, 0, 1, 1, 1, -66, 0, 1, 1, 0, -67, 0, 0, 1, 1, -68, 0, 1, 1, 0, -69, 0, 0, 1, 1, -70, 0, 1, 1, 0}; +#define SAMPLE_RATE 8000 +const unsigned short the_middle_bubbles[62][5] = {SAMPLE_RATE*2, 0, 1, 0, 0, +SAMPLE_RATE*3, 0, 1, 0, 0, +SAMPLE_RATE*4, 0, 1, 0, 0, +SAMPLE_RATE*5, 0, 1, 0, 0, +SAMPLE_RATE*6, 0, 0, 1, 0, +SAMPLE_RATE*7, 0, 0, 1, 0, +SAMPLE_RATE*8, 0, 0, 1, 0, +SAMPLE_RATE*9, 0, 0, 1, 0, +SAMPLE_RATE*10, 0, 0, 1, 0, +SAMPLE_RATE*11, 0, 0, 0, 1, +SAMPLE_RATE*12, 0, 0, 0, 1, +SAMPLE_RATE*13, 0, 0, 0, 1, +SAMPLE_RATE*15, 0, 0, 1, 1, +SAMPLE_RATE*16, 0, 0, 1, 1, +SAMPLE_RATE*17, 0, 0, 1, 1, +SAMPLE_RATE*18, 0, 1, 1, 0, +SAMPLE_RATE*19, 0, 1, 1, 0, +SAMPLE_RATE*20, 0, 1, 1, 0, +SAMPLE_RATE*21, 0, 1, 1, 0, +SAMPLE_RATE*22, 0, 1, 1, 0, +SAMPLE_RATE*23, 0, 1, 1, 0, +SAMPLE_RATE*24, 0, 1, 1, 0, +SAMPLE_RATE*25, 0, 1, 1, 0, +SAMPLE_RATE*27, 0, 1, 0, 0, +SAMPLE_RATE*28, 0, 1, 0, 0, +SAMPLE_RATE*29, 0, 1, 0, 0, +SAMPLE_RATE*30, 0, 1, 0, 0, +SAMPLE_RATE*31, 0, 0, 1, 0, +SAMPLE_RATE*32, 0, 0, 1, 0, +SAMPLE_RATE*33, 0, 0, 1, 0, +SAMPLE_RATE*34, 0, 0, 1, 0, +SAMPLE_RATE*35, 0, 0, 1, 0, +SAMPLE_RATE*36, 0, 0, 1, 0, +SAMPLE_RATE*37, 0, 0, 0, 1, +SAMPLE_RATE*38, 0, 0, 0, 1, +SAMPLE_RATE*39, 0, 0, 0, 1, +SAMPLE_RATE*40, 0, 0, 0, 1, +SAMPLE_RATE*42, 0, 1, 1, 0, +SAMPLE_RATE*43, 0, 0, 1, 1, +SAMPLE_RATE*44, 0, 1, 1, 0, +SAMPLE_RATE*45, 0, 0, 1, 1, +SAMPLE_RATE*46, 0, 1, 1, 0, +SAMPLE_RATE*47, 0, 0, 1, 1, +SAMPLE_RATE*48, 0, 1, 1, 0, +SAMPLE_RATE*49, 0, 0, 1, 1, +SAMPLE_RATE*51, 0, 1, 1, 1, +SAMPLE_RATE*52, 0, 1, 1, 1, +SAMPLE_RATE*53, 0, 1, 1, 1, +SAMPLE_RATE*54, 0, 1, 1, 1, +SAMPLE_RATE*56, 0, 1, 0, 0, +SAMPLE_RATE*57, 0, 1, 0, 0, +SAMPLE_RATE*58, 0, 1, 0, 0, +SAMPLE_RATE*59, 0, 1, 0, 0, +SAMPLE_RATE*61, 0, 0, 1, 0, +SAMPLE_RATE*62, 0, 1, 1, 1, +SAMPLE_RATE*63, 0, 1, 1, 1, +SAMPLE_RATE*64, 0, 1, 1, 1, +SAMPLE_RATE*66, 0, 1, 1, 0, +SAMPLE_RATE*67, 0, 0, 1, 1, +SAMPLE_RATE*68, 0, 1, 1, 0, +SAMPLE_RATE*69, 0, 0, 1, 1, +SAMPLE_RATE*70, 0, 1, 1, 0}; -const unsigned short stacys_mom_bubbles[70][5] = {1, 0, 1, 0, 0, -2, 0, 1, 0, 0, -3, 0, 1, 1, 0, -4, 0, 1, 0, 0, -5, 0, 1, 0, 0, -6, 0, 1, 1, 0, -8, 0, 0, 1, 0, -9, 0, 0, 0, 1, -10, 0, 1, 0, 0, -11, 0, 0, 1, 0, -12, 0, 1, 1, 0, -13, 0, 1, 1, 0, -15, 0, 0, 1, 1, -16, 0, 0, 1, 1, -17, 0, 0, 1, 1, -18, 0, 0, 1, 1, -20, 0, 1, 0, 0, -21, 0, 0, 1, 0, -22, 0, 0, 0, 1, -24, 0, 0, 1, 1, -25, 0, 0, 1, 1, -26, 0, 0, 1, 0, -27, 0, 0, 1, 0, -28, 0, 0, 0, 1, -29, 0, 1, 0, 0, -31, 0, 1, 1, 1, -32, 0, 1, 0, 1, -33, 0, 1, 0, 1, -34, 0, 1, 0, 1, -35, 0, 1, 0, 1, -36, 0, 1, 0, 1, -37, 0, 1, 0, 1, -39, 0, 0, 1, 0, -40, 0, 0, 1, 0, -41, 0, 0, 1, 0, -42, 0, 0, 1, 0, -43, 0, 0, 0, 1, -44, 0, 0, 0, 1, -45, 0, 0, 1, 0, -46, 0, 0, 1, 0, -47, 0, 0, 1, 1, -48, 0, 0, 1, 1, -49, 0, 0, 1, 1, -51, 0, 1, 0, 0, -52, 0, 0, 1, 0, -53, 0, 0, 0, 1, -54, 0, 0, 1, 1, -55, 0, 0, 1, 1, -56, 0, 0, 1, 0, -57, 0, 0, 1, 0, -58, 0, 0, 1, 0, -59, 0, 0, 1, 0, -60, 0, 0, 1, 0, -61, 0, 0, 1, 0, -62, 0, 0, 1, 0, -64, 0, 1, 0, 0, -65, 0, 1, 0, 0, -66, 0, 1, 0, 0, -67, 0, 1, 0, 0, -68, 0, 1, 0, 0, -69, 0, 1, 0, 0, -70, 0, 1, 0, 0, -73, 0, 0, 1, 1, -74, 0, 0, 1, 1, -75, 0, 1, 0, 0, -76, 0, 0, 1, 0, -77, 0, 0, 0, 1, -78, 0, 1, 0, 0, -79, 0, 0, 1, 0, -80, 0, 0, 0, 1}; +const unsigned short stacys_mom_bubbles[70][5] = {SAMPLE_RATE*1, 0, 1, 0, 0, +SAMPLE_RATE*2, 0, 1, 0, 0, +SAMPLE_RATE*3, 0, 1, 1, 0, +SAMPLE_RATE*4, 0, 1, 0, 0, +SAMPLE_RATE*5, 0, 1, 0, 0, +SAMPLE_RATE*6, 0, 1, 1, 0, +SAMPLE_RATE*8, 0, 0, 1, 0, +SAMPLE_RATE*9, 0, 0, 0, 1, +SAMPLE_RATE*10, 0, 1, 0, 0, +SAMPLE_RATE*11, 0, 0, 1, 0, +SAMPLE_RATE*12, 0, 1, 1, 0, +SAMPLE_RATE*13, 0, 1, 1, 0, +SAMPLE_RATE*15, 0, 0, 1, 1, +SAMPLE_RATE*16, 0, 0, 1, 1, +SAMPLE_RATE*17, 0, 0, 1, 1, +SAMPLE_RATE*18, 0, 0, 1, 1, +SAMPLE_RATE*20, 0, 1, 0, 0, +SAMPLE_RATE*21, 0, 0, 1, 0, +SAMPLE_RATE*22, 0, 0, 0, 1, +SAMPLE_RATE*24, 0, 0, 1, 1, +SAMPLE_RATE*25, 0, 0, 1, 1, +SAMPLE_RATE*26, 0, 0, 1, 0, +SAMPLE_RATE*27, 0, 0, 1, 0, +SAMPLE_RATE*28, 0, 0, 0, 1, +SAMPLE_RATE*29, 0, 1, 0, 0, +SAMPLE_RATE*31, 0, 1, 1, 1, +SAMPLE_RATE*32, 0, 1, 0, 1, +SAMPLE_RATE*33, 0, 1, 0, 1, +SAMPLE_RATE*34, 0, 1, 0, 1, +SAMPLE_RATE*35, 0, 1, 0, 1, +SAMPLE_RATE*36, 0, 1, 0, 1, +SAMPLE_RATE*37, 0, 1, 0, 1, +SAMPLE_RATE*39, 0, 0, 1, 0, +SAMPLE_RATE*40, 0, 0, 1, 0, +SAMPLE_RATE*41, 0, 0, 1, 0, +SAMPLE_RATE*42, 0, 0, 1, 0, +SAMPLE_RATE*43, 0, 0, 0, 1, +SAMPLE_RATE*44, 0, 0, 0, 1, +SAMPLE_RATE*45, 0, 0, 1, 0, +SAMPLE_RATE*46, 0, 0, 1, 0, +SAMPLE_RATE*47, 0, 0, 1, 1, +SAMPLE_RATE*48, 0, 0, 1, 1, +SAMPLE_RATE*49, 0, 0, 1, 1, +SAMPLE_RATE*51, 0, 1, 0, 0, +SAMPLE_RATE*52, 0, 0, 1, 0, +SAMPLE_RATE*53, 0, 0, 0, 1, +SAMPLE_RATE*54, 0, 0, 1, 1, +SAMPLE_RATE*55, 0, 0, 1, 1, +SAMPLE_RATE*56, 0, 0, 1, 0, +SAMPLE_RATE*57, 0, 0, 1, 0, +SAMPLE_RATE*58, 0, 0, 1, 0, +SAMPLE_RATE*59, 0, 0, 1, 0, +SAMPLE_RATE*60, 0, 0, 1, 0, +SAMPLE_RATE*61, 0, 0, 1, 0, +SAMPLE_RATE*62, 0, 0, 1, 0, +SAMPLE_RATE*64, 0, 1, 0, 0, +SAMPLE_RATE*65, 0, 1, 0, 0, +SAMPLE_RATE*66, 0, 1, 0, 0, +SAMPLE_RATE*67, 0, 1, 0, 0, +SAMPLE_RATE*68, 0, 1, 0, 0, +SAMPLE_RATE*69, 0, 1, 0, 0, +SAMPLE_RATE*70, 0, 1, 0, 0, +SAMPLE_RATE*73, 0, 0, 1, 1, +SAMPLE_RATE*74, 0, 0, 1, 1, +SAMPLE_RATE*75, 0, 1, 0, 0, +SAMPLE_RATE*76, 0, 0, 1, 0, +SAMPLE_RATE*77, 0, 0, 0, 1, +SAMPLE_RATE*78, 0, 1, 0, 0, +SAMPLE_RATE*79, 0, 0, 1, 0, +SAMPLE_RATE*80, 0, 0, 0, 1}; const unsigned short sins_bubbles[60][5] = { -2, 0, 1, 0, 0, -3, 0, 0, 1, 0, -4, 0, 1, 0, 0, -5, 0, 0, 1, 0, -6, 0, 0, 0, 1, -7, 0, 1, 0, 0, -8, 0, 0, 0, 1, -9, 0, 1, 0, 0, -10, 0, 0, 0, 1, -11, 0, 1, 1, 1, -13, 0, 1, 0, 0, -14, 0, 0, 1, 0, -15, 0, 1, 0, 0, -16, 0, 0, 1, 0, -17, 0, 0, 1, 0, -18, 0, 0, 1, 0, -19, 0, 0, 1, 0, -20, 0, 0, 1, 0, -22, 0, 0, 0, 1, -23, 0, 0, 1, 1, -24, 0, 0, 0, 1, -25, 0, 0, 1, 1, -26, 0, 0, 0, 1, -27, 0, 0, 1, 1, -28, 0, 1, 0, 0, -29, 0, 1, 1, 0, -30, 0, 1, 0, 0, -31, 0, 1, 1, 0, -33, 0, 1, 0, 0, -34, 0, 1, 0, 0, -35, 0, 1, 0, 0, -36, 0, 0, 1, 1, -37, 0, 0, 1, 1, -38, 0, 0, 1, 1, -39, 0, 0, 1, 1, -40, 0, 0, 1, 1, -42, 0, 1, 1, 0, -43, 0, 1, 1, 0, -44, 0, 0, 1, 0, -45, 0, 0, 1, 1, -46, 0, 0, 1, 1, -47, 0, 0, 1, 1, -48, 0, 0, 1, 1, -49, 0, 0, 1, 1, -50, 0, 0, 1, 0, -51, 0, 1, 1, 0, -52, 0, 1, 1, 0, -53, 0, 1, 1, 0, -54, 0, 1, 1, 0, -55, 0, 1, 1, 0, -56, 0, 1, 0, 0, -57, 0, 0, 1, 0, -58, 0, 1, 0, 0, -59, 0, 0, 1, 0, -60, 0, 1, 0, 0, -62, 0, 1, 1, 0, -63, 0, 1, 1, 0, -64, 0, 1, 1, 0, -65, 0, 1, 1, 0, -66, 0, 1, 1, 0}; +SAMPLE_RATE*2, 0, 1, 0, 0, +SAMPLE_RATE*3, 0, 0, 1, 0, +SAMPLE_RATE*4, 0, 1, 0, 0, +SAMPLE_RATE*5, 0, 0, 1, 0, +SAMPLE_RATE*6, 0, 0, 0, 1, +SAMPLE_RATE*7, 0, 1, 0, 0, +SAMPLE_RATE*8, 0, 0, 0, 1, +SAMPLE_RATE*9, 0, 1, 0, 0, +SAMPLE_RATE*10, 0, 0, 0, 1, +SAMPLE_RATE*11, 0, 1, 1, 1, +SAMPLE_RATE*13, 0, 1, 0, 0, +SAMPLE_RATE*14, 0, 0, 1, 0, +SAMPLE_RATE*15, 0, 1, 0, 0, +SAMPLE_RATE*16, 0, 0, 1, 0, +SAMPLE_RATE*17, 0, 0, 1, 0, +SAMPLE_RATE*18, 0, 0, 1, 0, +SAMPLE_RATE*19, 0, 0, 1, 0, +SAMPLE_RATE*20, 0, 0, 1, 0, +SAMPLE_RATE*22, 0, 0, 0, 1, +SAMPLE_RATE*23, 0, 0, 1, 1, +SAMPLE_RATE*24, 0, 0, 0, 1, +SAMPLE_RATE*25, 0, 0, 1, 1, +SAMPLE_RATE*26, 0, 0, 0, 1, +SAMPLE_RATE*27, 0, 0, 1, 1, +SAMPLE_RATE*28, 0, 1, 0, 0, +SAMPLE_RATE*29, 0, 1, 1, 0, +SAMPLE_RATE*30, 0, 1, 0, 0, +SAMPLE_RATE*31, 0, 1, 1, 0, +SAMPLE_RATE*33, 0, 1, 0, 0, +SAMPLE_RATE*34, 0, 1, 0, 0, +SAMPLE_RATE*35, 0, 1, 0, 0, +SAMPLE_RATE*36, 0, 0, 1, 1, +SAMPLE_RATE*37, 0, 0, 1, 1, +SAMPLE_RATE*38, 0, 0, 1, 1, +SAMPLE_RATE*39, 0, 0, 1, 1, +SAMPLE_RATE*40, 0, 0, 1, 1, +SAMPLE_RATE*42, 0, 1, 1, 0, +SAMPLE_RATE*43, 0, 1, 1, 0, +SAMPLE_RATE*44, 0, 0, 1, 0, +SAMPLE_RATE*45, 0, 0, 1, 1, +SAMPLE_RATE*46, 0, 0, 1, 1, +SAMPLE_RATE*47, 0, 0, 1, 1, +SAMPLE_RATE*48, 0, 0, 1, 1, +SAMPLE_RATE*49, 0, 0, 1, 1, +SAMPLE_RATE*50, 0, 0, 1, 0, +SAMPLE_RATE*51, 0, 1, 1, 0, +SAMPLE_RATE*52, 0, 1, 1, 0, +SAMPLE_RATE*53, 0, 1, 1, 0, +SAMPLE_RATE*54, 0, 1, 1, 0, +SAMPLE_RATE*55, 0, 1, 1, 0, +SAMPLE_RATE*56, 0, 1, 0, 0, +SAMPLE_RATE*57, 0, 0, 1, 0, +SAMPLE_RATE*58, 0, 1, 0, 0, +SAMPLE_RATE*59, 0, 0, 1, 0, +SAMPLE_RATE*60, 0, 1, 0, 0, +SAMPLE_RATE*62, 0, 1, 1, 0, +SAMPLE_RATE*63, 0, 1, 1, 0, +SAMPLE_RATE*64, 0, 1, 1, 0, +SAMPLE_RATE*65, 0, 1, 1, 0, +SAMPLE_RATE*66, 0, 1, 1, 0}; const unsigned short fireflies_bubbles[58][5] = { -1, 0, 1, 0, 0, -2, 0, 0, 1, 0, -3, 0, 1, 0, 0, -4, 0, 0, 1, 0, -5, 0, 1, 0, 0, -6, 0, 0, 1, 0, -7, 0, 1, 0, 0, -8, 0, 0, 1, 0, -9, 0, 1, 0, 0, -10, 0, 0, 1, 0, -11, 0, 0, 0, 1, -12, 0, 0, 1, 0, -13, 0, 1, 0, 0, -14, 0, 0, 1, 0, -15, 0, 0, 0, 1, -16, 0, 1, 1, 0, -17, 0, 1, 1, 0, -18, 0, 0, 1, 1, -19, 0, 0, 1, 1, -21, 0, 0, 1, 0, -22, 0, 0, 1, 0, -23, 0, 0, 1, 0, -24, 0, 0, 1, 0, -25, 0, 1, 0, 0, -26, 0, 1, 0, 0, -27, 0, 0, 1, 0, -28, 0, 0, 1, 0, -29, 0, 0, 0, 1, -30, 0, 0, 0, 1, -32, 0, 1, 0, 0, -33, 0, 1, 0, 0, -34, 0, 0, 1, 0, -35, 0, 0, 1, 0, -36, 0, 0, 0, 1, -37, 0, 0, 0, 1, -38, 0, 0, 1, 0, -39, 0, 0, 1, 0, -40, 0, 1, 0, 0, -41, 0, 1, 0, 0, -43, 0, 1, 1, 1, -44, 0, 1, 1, 1, -45, 0, 1, 1, 1, -46, 0, 1, 1, 1, -47, 0, 1, 1, 0, -48, 0, 1, 1, 0, -49, 0, 0, 1, 1, -50, 0, 0, 1, 1, -51, 0, 0, 1, 1, -53, 0, 1, 1, 0, -54, 0, 1, 1, 0, -55, 0, 0, 1, 1, -56, 0, 1, 1, 0, -57, 0, 0, 1, 1, -59, 0, 1, 0, 0, -60, 0, 0, 1, 0, -61, 0, 0, 0, 1, -62, 0, 0, 1, 0, -63, 0, 1, 0, 0}; - +SAMPLE_RATE*1, 0, 1, 0, 0, +SAMPLE_RATE*2, 0, 0, 1, 0, +SAMPLE_RATE*3, 0, 1, 0, 0, +SAMPLE_RATE*4, 0, 0, 1, 0, +SAMPLE_RATE*5, 0, 1, 0, 0, +SAMPLE_RATE*6, 0, 0, 1, 0, +SAMPLE_RATE*7, 0, 1, 0, 0, +SAMPLE_RATE*8, 0, 0, 1, 0, +SAMPLE_RATE*9, 0, 1, 0, 0, +SAMPLE_RATE*10, 0, 0, 1, 0, +SAMPLE_RATE*11, 0, 0, 0, 1, +SAMPLE_RATE*12, 0, 0, 1, 0, +SAMPLE_RATE*13, 0, 1, 0, 0, +SAMPLE_RATE*14, 0, 0, 1, 0, +SAMPLE_RATE*15, 0, 0, 0, 1, +SAMPLE_RATE*16, 0, 1, 1, 0, +SAMPLE_RATE*17, 0, 1, 1, 0, +SAMPLE_RATE*18, 0, 0, 1, 1, +SAMPLE_RATE*19, 0, 0, 1, 1, +SAMPLE_RATE*21, 0, 0, 1, 0, +SAMPLE_RATE*22, 0, 0, 1, 0, +SAMPLE_RATE*23, 0, 0, 1, 0, +SAMPLE_RATE*24, 0, 0, 1, 0, +SAMPLE_RATE*25, 0, 1, 0, 0, +SAMPLE_RATE*26, 0, 1, 0, 0, +SAMPLE_RATE*27, 0, 0, 1, 0, +SAMPLE_RATE*28, 0, 0, 1, 0, +SAMPLE_RATE*29, 0, 0, 0, 1, +SAMPLE_RATE*30, 0, 0, 0, 1, +SAMPLE_RATE*32, 0, 1, 0, 0, +SAMPLE_RATE*33, 0, 1, 0, 0, +SAMPLE_RATE*34, 0, 0, 1, 0, +SAMPLE_RATE*35, 0, 0, 1, 0, +SAMPLE_RATE*36, 0, 0, 0, 1, +SAMPLE_RATE*37, 0, 0, 0, 1, +SAMPLE_RATE*38, 0, 0, 1, 0, +SAMPLE_RATE*39, 0, 0, 1, 0, +SAMPLE_RATE*40, 0, 1, 0, 0, +SAMPLE_RATE*41, 0, 1, 0, 0, +SAMPLE_RATE*43, 0, 1, 1, 1, +SAMPLE_RATE*44, 0, 1, 1, 1, +SAMPLE_RATE*45, 0, 1, 1, 1, +SAMPLE_RATE*46, 0, 1, 1, 1, +SAMPLE_RATE*47, 0, 1, 1, 0, +SAMPLE_RATE*48, 0, 1, 1, 0, +SAMPLE_RATE*49, 0, 0, 1, 1, +SAMPLE_RATE*50, 0, 0, 1, 1, +SAMPLE_RATE*51, 0, 0, 1, 1, +SAMPLE_RATE*53, 0, 1, 1, 0, +SAMPLE_RATE*54, 0, 1, 1, 0, +SAMPLE_RATE*55, 0, 0, 1, 1, +SAMPLE_RATE*56, 0, 1, 1, 0, +SAMPLE_RATE*57, 0, 0, 1, 1, +SAMPLE_RATE*59, 0, 1, 0, 0, +SAMPLE_RATE*60, 0, 0, 1, 0, +SAMPLE_RATE*61, 0, 0, 0, 1, +SAMPLE_RATE*62, 0, 0, 1, 0, +SAMPLE_RATE*63, 0, 1, 0, 0};
--- a/globals.h Fri Dec 06 15:46:16 2019 +0000 +++ b/globals.h Fri Dec 06 18:00:11 2019 +0000 @@ -12,7 +12,7 @@ extern uLCD_4DGL uLCD; extern Mutex lcd_mutex; -extern int bubblesDrawn; -extern int bubblesMissed; +extern volatile int bubblesDrawn; +extern volatile int bubblesMissed; #endif //globals_h \ No newline at end of file
--- a/main.cpp Fri Dec 06 15:46:16 2019 +0000 +++ b/main.cpp Fri Dec 06 18:00:11 2019 +0000 @@ -1,8 +1,11 @@ #include "mbed.h" #include "rtos.h" #include "stdio.h" +#include <stdlib.h> +#include <time.h> #include "SDFileSystem.h" #include "wave_player.h" +#include "mpr121.h" #include "uLCD_4DGL.h" #include "Small_6.h" @@ -12,7 +15,7 @@ #include "globals.h" -#include "bubbles.h" +//#include "bubbles.h" #include "stacys_mom.h" //#include "the_middle.h" #include "fireflies.h" @@ -40,6 +43,27 @@ DigitalIn pb1(p20); DigitalIn pb2(p19); AnalogOut DACout(p18); +// Create the interrupt receiver object on pin 26 for touch pad IRQ +InterruptIn interrupt(p26); +// Setup the i2c bus on pins 9 and 10 +I2C i2c(p9, p10); +// Setup the Mpr121: +// constructor(i2c object, i2c address of the mpr121) +Mpr121 mpr121(&i2c, Mpr121::ADD_VSS); + +// Key hit/release interrupt routine +//void fallInterrupt() { +// int key_code=0; +// int i=0; +// int value=mpr121.read(0x00); +// value +=mpr121.read(0x01)<<8; +// for (i=0; i<12; i++) { +// if (((value>>i)&0x01)==1) { +// key_code=i+1; +// } +// } +//} + wave_player waver(&DACout); Thread thread1, thread2, thread3, thread4; @@ -53,8 +77,8 @@ unsigned short **currentBubbles = NULL; int bubbleNdx = 0; -int bubblesDrawn = 0; -int bubblesMissed = 0; +volatile int bubblesDrawn = 0; +volatile int bubblesMissed = 0; @@ -95,7 +119,7 @@ } lcd_mutex.unlock(); - Thread::wait(200); + Thread::wait(500); } } @@ -153,15 +177,16 @@ myRGBled = green; Thread::wait(200); } else if (playing) { - - if (bubblesMissed <= 3) { + //lcd_mutex.lock(); +// uLCD.printf("%d", bubblesMissed); +// lcd_mutex.unlock(); + if (bubblesMissed <= 1) { myRGBled = green; - } else if (bubblesMissed <= 5) { - myRGBled = yellow; + } else if (bubblesMissed <= 3) { + myRGBled = blue; } else { myRGBled = red; } - Thread::wait(300); } @@ -239,27 +264,26 @@ Thread::wait(2000); } - -void play() { - Lane *bubbleLanes[3]; - // these positions may need to be adjusted as I assume they're positioned incorrectly... - bubbleLanes[0] = new Lane(3,3); - bubbleLanes[1] = new Lane(3,6); - bubbleLanes[2] = new Lane(3,9); +int main() { +//<<<<<<< working copy +// +// uLCD.baudrate(3000000); // set baud rate to max +// +//======= +// interrupt.fall(&fallInterrupt); +// interrupt.mode(PullUp); //for touch keypad +// lcd_mutex.lock(); +// uLCD.baudrate(3000000); +// uLCD.cls(); +// uLCD.media_init(); +// uLCD.set_sector_address(0x0077, 0x4002); +// uLCD.display_video(0,0); +// wait(4); +// lcd_mutex.unlock(); +//>>>>>>> merge rev - while (playing && !bubbleLanes[0]->isEmpty() && !bubbleLanes[1]->isEmpty() && !bubbleLanes[2]->isEmpty()) { - - } - - // return to homescreen when - homescreen = true; -} - - - -int main() { - - uLCD.baudrate(3000000); // set baud rate to max + // seed random + srand (time(NULL)); thread1.start(homescreen_thread); thread2.start(joystick_thread); @@ -269,9 +293,9 @@ Lane *bubbleLanes[3]; // these positions may need to be adjusted as I assume they're positioned incorrectly... - bubbleLanes[0] = new Lane(15,15); - bubbleLanes[1] = new Lane(40,15); - bubbleLanes[2] = new Lane(80,15); + bubbleLanes[0] = new Lane(20,15); + bubbleLanes[1] = new Lane(60,15); + bubbleLanes[2] = new Lane(100,15); //startup sound? @@ -283,51 +307,76 @@ // uLCD.printf("You selected song %2d", songnum); // lcd_mutex.unlock(); pickSong(); + homescreen = false; // "playing" is updated by playsound() thread - while (playing && !bubbleLanes[0]->isEmpty() && !bubbleLanes[1]->isEmpty() && !bubbleLanes[2]->isEmpty()) { + bubbleLanes[0]->add(); +// bubbleLanes[1]->add(); +// bubbleLanes[2]->add(); + bubbleNdx = 0; + bool runninggame = true; + bubblesMissed = 0; + lcd_mutex.lock(); + uLCD.cls(); + lcd_mutex.unlock(); + while (runninggame) { + // draw unufilled circles at the bottom of the screen where the user should "tap" - uLCD.circle(15,110, 30, GREEN); - uLCD.circle(40,110, 30, GREEN); - uLCD.circle(80,110, 30, GREEN); + lcd_mutex.lock(); + uLCD.circle(20,110, 10, GREEN); + uLCD.circle(60,110, 10, GREEN); + uLCD.circle(100,110, 10, GREEN); + lcd_mutex.unlock(); // add bubbles to lanes - if (fireflies_bubbles[bubbleNdx][0] > songNdx) { // check if it's time to load a bubble +// uLCD.printf("%d", fireflies_bubbles[bubbleNdx][0]); + /*if (songNdx > fireflies_bubbles[bubbleNdx][0]) { // check if it's time to load a bubble bool addedbubbles = false; - if (fireflies_bubbles[bubbleNdx][2] > songNdx) { // check if add bubble at ndx + if (fireflies_bubbles[bubbleNdx][2]) { // check if add bubble at ndx bubbleLanes[0]->add(); addedbubbles = true; } - if (fireflies_bubbles[bubbleNdx][3] > songNdx) { // check if add bubble at ndx + if (fireflies_bubbles[bubbleNdx][3]) { // check if add bubble at ndx bubbleLanes[1]->add(); addedbubbles = true; } - if (fireflies_bubbles[bubbleNdx][4] > songNdx) { // check if add bubble at ndx + if (fireflies_bubbles[bubbleNdx][4]) { // check if add bubble at ndx bubbleLanes[2]->add(); addedbubbles = true; } - if (addedbubbles) ++songNdx; + if (addedbubbles) ++bubbleNdx; + }*/ + + if (playing && ((rand() % 99) < 20)) { // 20% chance of inserting a bubble + bubbleLanes[rand() % 3]->add(); } // draw all bubbles + lcd_mutex.lock(); bubbleLanes[0]->draw(); bubbleLanes[1]->draw(); bubbleLanes[2]->draw(); + lcd_mutex.unlock(); // TODO: check for hits with capacitive touchpad // if there is a hit, delete the bubble from the dynamic array - if (true) bubbleLanes[0]->checkHit(); - if (true) bubbleLanes[1]->checkHit(); - if (true) bubbleLanes[2]->checkHit(); + // replace "true" in the next 3 lines with your logic of when to check for a hit +// if (true) bubbleLanes[0]->checkHit(); +// if (true) bubbleLanes[1]->checkHit(); +// if (true) bubbleLanes[2]->checkHit(); // move down all the bubbles, deleting bubbles that are out of bounds if required bubbleLanes[0]->moveDown(); bubbleLanes[1]->moveDown(); bubbleLanes[2]->moveDown(); + if (!playing && bubbleLanes[0]->isEmpty() && bubbleLanes[1]->isEmpty() && bubbleLanes[2]->isEmpty()) { + runninggame = false; + } + //this wait delay may need to be tuned Thread::wait(100); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpr121.cpp Fri Dec 06 18:00:11 2019 +0000 @@ -0,0 +1,221 @@ +/* +Copyright (c) 2011 Anthony Buckton (abuckton [at] blackink [dot} net {dot} au) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include <mbed.h> +#include <sstream> +#include <string> +#include <list> + +#include <mpr121.h> + +Mpr121::Mpr121(I2C *i2c, Address i2cAddress) +{ + this->i2c = i2c; + + address = i2cAddress; + + // Configure the MPR121 settings to default + this->configureSettings(); +} + + +void Mpr121::configureSettings() +{ + // Put the MPR into setup mode + this->write(ELE_CFG,0x00); + + // Electrode filters for when data is > baseline + unsigned char gtBaseline[] = { + 0x01, //MHD_R + 0x01, //NHD_R + 0x00, //NCL_R + 0x00 //FDL_R + }; + + writeMany(MHD_R,gtBaseline,4); + + // Electrode filters for when data is < baseline + unsigned char ltBaseline[] = { + 0x01, //MHD_F + 0x01, //NHD_F + 0xFF, //NCL_F + 0x02 //FDL_F + }; + + writeMany(MHD_F,ltBaseline,4); + + // Electrode touch and release thresholds + unsigned char electrodeThresholds[] = { + E_THR_T, // Touch Threshhold + E_THR_R // Release Threshold + }; + + for(int i=0; i<12; i++){ + int result = writeMany((ELE0_T+(i*2)),electrodeThresholds,2); + } + + // Proximity Settings + unsigned char proximitySettings[] = { + 0xff, //MHD_Prox_R + 0xff, //NHD_Prox_R + 0x00, //NCL_Prox_R + 0x00, //FDL_Prox_R + 0x01, //MHD_Prox_F + 0x01, //NHD_Prox_F + 0xFF, //NCL_Prox_F + 0xff, //FDL_Prox_F + 0x00, //NHD_Prox_T + 0x00, //NCL_Prox_T + 0x00 //NFD_Prox_T + }; + writeMany(MHDPROXR,proximitySettings,11); + + unsigned char proxThresh[] = { + PROX_THR_T, // Touch Threshold + PROX_THR_R // Release Threshold + }; + writeMany(EPROXTTH,proxThresh,2); + + this->write(FIL_CFG,0x04); + + // Set the electrode config to transition to active mode + this->write(ELE_CFG,0x0c); +} + +void Mpr121::setElectrodeThreshold(int electrode, unsigned char touch, unsigned char release){ + + if(electrode > 11) return; + + // Get the current mode + unsigned char mode = this->read(ELE_CFG); + + // Put the MPR into setup mode + this->write(ELE_CFG,0x00); + + // Write the new threshold + this->write((ELE0_T+(electrode*2)), touch); + this->write((ELE0_T+(electrode*2)+1), release); + + //Restore the operating mode + this->write(ELE_CFG, mode); +} + + +unsigned char Mpr121::read(int key){ + + unsigned char data[2]; + + //Start the command + i2c->start(); + + // Address the target (Write mode) + int ack1= i2c->write(address); + + // Set the register key to read + int ack2 = i2c->write(key); + + // Re-start for read of data + i2c->start(); + + // Re-send the target address in read mode + int ack3 = i2c->write(address+1); + + // Read in the result + data[0] = i2c->read(0); + + // Reset the bus + i2c->stop(); + + return data[0]; +} + + +int Mpr121::write(int key, unsigned char value){ + + //Start the command + i2c->start(); + + // Address the target (Write mode) + int ack1= i2c->write(address); + + // Set the register key to write + int ack2 = i2c->write(key); + + // Read in the result + int ack3 = i2c->write(value); + + // Reset the bus + i2c->stop(); + + return (ack1+ack2+ack3)-3; +} + + +int Mpr121::writeMany(int start, unsigned char* dataSet, int length){ + //Start the command + i2c->start(); + + // Address the target (Write mode) + int ack= i2c->write(address); + if(ack!=1){ + return -1; + } + + // Set the register key to write + ack = i2c->write(start); + if(ack!=1){ + return -1; + } + + // Write the date set + int count = 0; + while(ack==1 && (count < length)){ + ack = i2c->write(dataSet[count]); + count++; + } + // Stop the cmd + i2c->stop(); + + return count; +} + + +bool Mpr121::getProximityMode(){ + if(this->read(ELE_CFG) > 0x0c) + return true; + else + return false; +} + +void Mpr121::setProximityMode(bool mode){ + this->write(ELE_CFG,0x00); + if(mode){ + this->write(ELE_CFG,0x30); //Sense proximity from ALL pads + } else { + this->write(ELE_CFG,0x0c); //Sense touch, all 12 pads active. + } +} + + +int Mpr121::readTouchData(){ + return this->read(0x00); +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpr121.h Fri Dec 06 18:00:11 2019 +0000 @@ -0,0 +1,157 @@ +/* +Copyright (c) 2011 Anthony Buckton (abuckton [at] blackink [dot} net {dot} au) + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + Parts written by Jim Lindblom of Sparkfun + Ported to mbed by A.Buckton, Feb 2011 +*/ + +#ifndef MPR121_H +#define MPR121_H + +//using namespace std; + +class Mpr121 +{ + +public: + // i2c Addresses, bit-shifted + enum Address { ADD_VSS = 0xb4,// ADD->VSS = 0x5a <-wiring on Sparkfun board + ADD_VDD = 0xb6,// ADD->VDD = 0x5b + ADD_SCL = 0xb8,// ADD->SDA = 0x5c + ADD_SDA = 0xba // ADD->SCL = 0x5d + }; + + // Real initialiser, takes the i2c address of the device. + Mpr121(I2C *i2c, Address i2cAddress); + + bool getProximityMode(); + + void setProximityMode(bool mode); + + int readTouchData(); + + unsigned char read(int key); + + int write(int address, unsigned char value); + int writeMany(int start, unsigned char* dataSet, int length); + + void setElectrodeThreshold(int electrodeId, unsigned char touchThreshold, unsigned char releaseThreshold); + +protected: + // Configures the MPR with standard settings. This is permitted to be overwritten by sub-classes. + void configureSettings(); + +private: + // The I2C bus instance. + I2C *i2c; + + // i2c address of this mpr121 + Address address; +}; + + +// MPR121 Register Defines +#define MHD_R 0x2B +#define NHD_R 0x2C +#define NCL_R 0x2D +#define FDL_R 0x2E +#define MHD_F 0x2F +#define NHD_F 0x30 +#define NCL_F 0x31 +#define FDL_F 0x32 +#define NHDT 0x33 +#define NCLT 0x34 +#define FDLT 0x35 +// Proximity sensing controls +#define MHDPROXR 0x36 +#define NHDPROXR 0x37 +#define NCLPROXR 0x38 +#define FDLPROXR 0x39 +#define MHDPROXF 0x3A +#define NHDPROXF 0x3B +#define NCLPROXF 0x3C +#define FDLPROXF 0x3D +#define NHDPROXT 0x3E +#define NCLPROXT 0x3F +#define FDLPROXT 0x40 +// Electrode Touch/Release thresholds +#define ELE0_T 0x41 +#define ELE0_R 0x42 +#define ELE1_T 0x43 +#define ELE1_R 0x44 +#define ELE2_T 0x45 +#define ELE2_R 0x46 +#define ELE3_T 0x47 +#define ELE3_R 0x48 +#define ELE4_T 0x49 +#define ELE4_R 0x4A +#define ELE5_T 0x4B +#define ELE5_R 0x4C +#define ELE6_T 0x4D +#define ELE6_R 0x4E +#define ELE7_T 0x4F +#define ELE7_R 0x50 +#define ELE8_T 0x51 +#define ELE8_R 0x52 +#define ELE9_T 0x53 +#define ELE9_R 0x54 +#define ELE10_T 0x55 +#define ELE10_R 0x56 +#define ELE11_T 0x57 +#define ELE11_R 0x58 +// Proximity Touch/Release thresholds +#define EPROXTTH 0x59 +#define EPROXRTH 0x5A +// Debounce configuration +#define DEB_CFG 0x5B +// AFE- Analogue Front End configuration +#define AFE_CFG 0x5C +// Filter configuration +#define FIL_CFG 0x5D +// Electrode configuration - transistions to "active mode" +#define ELE_CFG 0x5E + +#define GPIO_CTRL0 0x73 +#define GPIO_CTRL1 0x74 +#define GPIO_DATA 0x75 +#define GPIO_DIR 0x76 +#define GPIO_EN 0x77 +#define GPIO_SET 0x78 +#define GPIO_CLEAR 0x79 +#define GPIO_TOGGLE 0x7A +// Auto configration registers +#define AUTO_CFG_0 0x7B +#define AUTO_CFG_U 0x7D +#define AUTO_CFG_L 0x7E +#define AUTO_CFG_T 0x7F + +// Threshold defaults +// Electrode touch threshold +#define E_THR_T 0x0F +// Electrode release threshold +#define E_THR_R 0x0A +// Prox touch threshold +#define PROX_THR_T 0x02 +// Prox release threshold +#define PROX_THR_R 0x02 + +#endif