Whack a Mole game! Features: - LCD graphics display - Touch pad input - Speaker effects through a class D audio amplifier\ - A high score page maintained by the SD card file system - Analog noise used to seed random numbers
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed
Fork of MPR121_Demo by
Revision 2:d85c5ce4d397, committed 2016-03-14
- Comitter:
- tpettet3
- Date:
- Mon Mar 14 03:34:58 2016 +0000
- Parent:
- 1:89fd0d713ffc
- Child:
- 3:dbae62823ec8
- Commit message:
- with mutexes not working;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Mar 14 03:28:28 2016 +0000
+++ b/main.cpp Mon Mar 14 03:34:58 2016 +0000
@@ -37,7 +37,7 @@
// Create the interrupt receiver object on pin 26
InterruptIn interrupt(p26);
-Mutex POS_MUTTEX;
+Mutex POS_MUTEX;
// Setup the Serial to the PC for debugging
Serial pc(USBTX, USBRX);
@@ -67,12 +67,12 @@
int value=mpr121.read(0x00);
value +=mpr121.read(0x01)<<8;
// LED demo mod by J. Hamblen
- POS_MUTEX.lock;
+ POS_MUTEX.lock();
if (value==hole1&&pos1==1)
{
score++;
}
- POS_MUTEX.lock;
+ POS_MUTEX.unlock();
pc.printf("MPR value: %x \r\n", value);
/*if (value == 1)
{
@@ -195,14 +195,14 @@
switch(state)
{
case 0:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=1;
pos2=0;
pos3=0;
pos4=0;
pos5=0;
pos6=0;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 0 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 1
lcd.filled_circle(col1, row2 , rmole, fill);
@@ -213,14 +213,14 @@
lcd.filled_circle(col1, row1 , rmole, mole);
break;
case 1:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=0;
pos2=1;
pos3=0;
pos4=0;
pos5=0;
pos6=0;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 1 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 2
lcd.filled_circle(col1, row2 , rmole, fill);
@@ -231,14 +231,14 @@
lcd.filled_circle(col2, row1 , rmole, mole);
break;
case 2:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=0;
pos2=0;
pos3=1;
pos4=0;
pos5=0;
pos6=0;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 2 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 3
lcd.filled_circle(col1, row2 , rmole, fill);
@@ -249,14 +249,14 @@
lcd.filled_circle(col3, row1 , rmole, mole);
break;
case 3:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=0;
pos2=0;
pos3=0;
pos4=1;
pos5=0;
pos6=0;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 3 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 4
lcd.filled_circle(col1, row2 , rmole, fill);
@@ -267,14 +267,14 @@
lcd.filled_circle(col1, row2 , rmole, mole);
break;
case 4:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=0;
pos2=0;
pos3=0;
pos4=0;
pos5=1;
pos6=0;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 4 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 5
lcd.filled_circle(col1, row2 , rmole, fill);
@@ -285,14 +285,14 @@
lcd.filled_circle(col2, row2 , rmole, mole);
break;
case 5:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=0;
pos2=0;
pos3=0;
pos4=0;
pos5=0;
pos6=1;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 5 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 6
@@ -304,14 +304,14 @@
lcd.filled_circle(col2, row2 , rmole, mole);
break;
case 6:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=0;
pos2=1;
pos3=0;
pos4=0;
pos5=0;
pos6=1;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 6 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 2,6
lcd.filled_circle(col1, row2 , rmole, fill);
@@ -323,14 +323,14 @@
lcd.filled_circle(col3, row2 , rmole, mole);
break;
case 7:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=1;
pos2=0;
pos3=1;
pos4=0;
pos5=0;
pos6=0;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 7 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 1,3
lcd.filled_circle(col1, row2 , rmole, fill);
@@ -342,14 +342,14 @@
lcd.filled_circle(col3, row1 , rmole, mole);
break;
case 8:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=0;
pos2=1;
pos3=0;
pos4=1;
pos5=0;
pos6=1;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 8 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 2,4,6
@@ -363,14 +363,14 @@
lcd.filled_circle(col3, row2 , rmole, mole);
break;
case 9:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=0;
pos2=0;
pos3=1;
pos4=1;
pos5=0;
pos6=1;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 9 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 3,4,6
lcd.filled_circle(col1, row2 , rmole, fill);
@@ -383,14 +383,14 @@
lcd.filled_circle(col3, row2 , rmole, mole);
break;
case 10:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=1;
pos2=0;
pos3=0;
pos4=0;
pos5=0;
pos6=1;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 10 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 1,6
lcd.filled_circle(col1, row2 , rmole, fill);
@@ -402,14 +402,14 @@
lcd.filled_circle(col3, row2 , rmole, mole);
break;
case 11:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=0;
pos2=1;
pos3=1;
pos4=0;
pos5=1;
pos6=1;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 11 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 2,3,5,6
lcd.filled_circle(col1, row2 , rmole, fill);
@@ -423,14 +423,14 @@
lcd.filled_circle(col3, row2 , rmole, mole);
break;
case 12:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=0;
pos2=0;
pos3=1;
pos4=0;
pos5=1;
pos6=0;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 12 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 3,5
lcd.filled_circle(col1, row2 , rmole, fill);
@@ -442,14 +442,14 @@
lcd.filled_circle(col2, row2 , rmole, mole);
break;
case 13:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=1;
pos2=0;
pos3=0;
pos4=1;
pos5=1;
pos6=0;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 13 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 1,4,5
lcd.filled_circle(col1, row2 , rmole, fill);
@@ -462,14 +462,14 @@
lcd.filled_circle(col2, row2 , rmole, mole);
break;
case 14:
- Mutex POS_MUTEX.lock;
+ POS_MUTEX.lock();
pos1=0;
pos2=1;
pos3=0;
pos4=0;
pos5=1;
pos6=0;
- Mutex POS_MUTEX.unlock;
+ POS_MUTEX.unlock();
pc.printf("%i should be 14 \n\r",state);
lcd.filled_circle(col1, row1 , rmole, fill);// 2,5
--- a/mbed.bld Mon Mar 14 03:28:28 2016 +0000 +++ b/mbed.bld Mon Mar 14 03:34:58 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912 +http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68 \ No newline at end of file
