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
main.cpp@2:d85c5ce4d397, 2016-03-14 (annotated)
- Committer:
- tpettet3
- Date:
- Mon Mar 14 03:34:58 2016 +0000
- Revision:
- 2:d85c5ce4d397
- Parent:
- 1:89fd0d713ffc
- Child:
- 3:dbae62823ec8
with mutexes not working;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
4180_1 | 0:e09703934ff4 | 1 | /* |
4180_1 | 0:e09703934ff4 | 2 | Copyright (c) 2011 Anthony Buckton (abuckton [at] blackink [dot} net {dot} au) |
4180_1 | 0:e09703934ff4 | 3 | |
4180_1 | 0:e09703934ff4 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
4180_1 | 0:e09703934ff4 | 5 | of this software and associated documentation files (the "Software"), to deal |
4180_1 | 0:e09703934ff4 | 6 | in the Software without restriction, including without limitation the rights |
4180_1 | 0:e09703934ff4 | 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
4180_1 | 0:e09703934ff4 | 8 | copies of the Software, and to permit persons to whom the Software is |
4180_1 | 0:e09703934ff4 | 9 | furnished to do so, subject to the following conditions: |
4180_1 | 0:e09703934ff4 | 10 | |
4180_1 | 0:e09703934ff4 | 11 | The above copyright notice and this permission notice shall be included in |
4180_1 | 0:e09703934ff4 | 12 | all copies or substantial portions of the Software. |
4180_1 | 0:e09703934ff4 | 13 | |
4180_1 | 0:e09703934ff4 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
4180_1 | 0:e09703934ff4 | 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
4180_1 | 0:e09703934ff4 | 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
4180_1 | 0:e09703934ff4 | 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
4180_1 | 0:e09703934ff4 | 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
4180_1 | 0:e09703934ff4 | 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
4180_1 | 0:e09703934ff4 | 20 | THE SOFTWARE. |
4180_1 | 0:e09703934ff4 | 21 | */ |
4180_1 | 0:e09703934ff4 | 22 | |
4180_1 | 0:e09703934ff4 | 23 | #include <mbed.h> |
4180_1 | 0:e09703934ff4 | 24 | #include <string> |
4180_1 | 0:e09703934ff4 | 25 | #include <list> |
tpettet3 | 1:89fd0d713ffc | 26 | #include "uLCD_4DGL.h" |
tpettet3 | 1:89fd0d713ffc | 27 | #include <mpr121.h> |
tpettet3 | 1:89fd0d713ffc | 28 | #include "rtos.h" |
4180_1 | 0:e09703934ff4 | 29 | |
tpettet3 | 1:89fd0d713ffc | 30 | uLCD_4DGL lcd(p9, p10, p30); // tx, rx, reset |
4180_1 | 0:e09703934ff4 | 31 | |
4180_1 | 0:e09703934ff4 | 32 | DigitalOut led1(LED1); |
4180_1 | 0:e09703934ff4 | 33 | DigitalOut led2(LED2); |
4180_1 | 0:e09703934ff4 | 34 | DigitalOut led3(LED3); |
4180_1 | 0:e09703934ff4 | 35 | DigitalOut led4(LED4); |
tpettet3 | 1:89fd0d713ffc | 36 | AnalogIn Ain(p15); |
4180_1 | 0:e09703934ff4 | 37 | |
4180_1 | 0:e09703934ff4 | 38 | // Create the interrupt receiver object on pin 26 |
4180_1 | 0:e09703934ff4 | 39 | InterruptIn interrupt(p26); |
tpettet3 | 2:d85c5ce4d397 | 40 | Mutex POS_MUTEX; |
4180_1 | 0:e09703934ff4 | 41 | // Setup the Serial to the PC for debugging |
4180_1 | 0:e09703934ff4 | 42 | Serial pc(USBTX, USBRX); |
4180_1 | 0:e09703934ff4 | 43 | |
4180_1 | 0:e09703934ff4 | 44 | // Setup the i2c bus on pins 28 and 27 |
tpettet3 | 1:89fd0d713ffc | 45 | I2C i2c(p28, p27); |
4180_1 | 0:e09703934ff4 | 46 | |
tpettet3 | 1:89fd0d713ffc | 47 | int pos1; |
tpettet3 | 1:89fd0d713ffc | 48 | int pos2; |
tpettet3 | 1:89fd0d713ffc | 49 | int pos3; |
tpettet3 | 1:89fd0d713ffc | 50 | int pos4; |
tpettet3 | 1:89fd0d713ffc | 51 | int pos5; |
tpettet3 | 1:89fd0d713ffc | 52 | int pos6; |
tpettet3 | 1:89fd0d713ffc | 53 | int score = 0; |
tpettet3 | 1:89fd0d713ffc | 54 | int hole1 = 0x100; |
tpettet3 | 1:89fd0d713ffc | 55 | int hole2 = 0x10; |
tpettet3 | 1:89fd0d713ffc | 56 | int hole3 = 0x1; |
tpettet3 | 1:89fd0d713ffc | 57 | int hole4 = 0x200; |
tpettet3 | 1:89fd0d713ffc | 58 | int hole5 = 0x20; |
tpettet3 | 1:89fd0d713ffc | 59 | int hole6 = 0x2; |
4180_1 | 0:e09703934ff4 | 60 | // Setup the Mpr121: |
4180_1 | 0:e09703934ff4 | 61 | // constructor(i2c object, i2c address of the mpr121) |
4180_1 | 0:e09703934ff4 | 62 | Mpr121 mpr121(&i2c, Mpr121::ADD_VSS); |
4180_1 | 0:e09703934ff4 | 63 | |
4180_1 | 0:e09703934ff4 | 64 | void fallInterrupt() { |
4180_1 | 0:e09703934ff4 | 65 | int key_code=0; |
4180_1 | 0:e09703934ff4 | 66 | int i=0; |
4180_1 | 0:e09703934ff4 | 67 | int value=mpr121.read(0x00); |
4180_1 | 0:e09703934ff4 | 68 | value +=mpr121.read(0x01)<<8; |
4180_1 | 0:e09703934ff4 | 69 | // LED demo mod by J. Hamblen |
tpettet3 | 2:d85c5ce4d397 | 70 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 71 | if (value==hole1&&pos1==1) |
tpettet3 | 1:89fd0d713ffc | 72 | { |
tpettet3 | 1:89fd0d713ffc | 73 | score++; |
tpettet3 | 1:89fd0d713ffc | 74 | } |
tpettet3 | 2:d85c5ce4d397 | 75 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 76 | pc.printf("MPR value: %x \r\n", value); |
tpettet3 | 1:89fd0d713ffc | 77 | /*if (value == 1) |
tpettet3 | 1:89fd0d713ffc | 78 | { |
tpettet3 | 1:89fd0d713ffc | 79 | led1 = !led1; |
tpettet3 | 1:89fd0d713ffc | 80 | } |
tpettet3 | 1:89fd0d713ffc | 81 | if (value == 2) |
tpettet3 | 1:89fd0d713ffc | 82 | { |
tpettet3 | 1:89fd0d713ffc | 83 | led2 = !led2; |
tpettet3 | 1:89fd0d713ffc | 84 | } |
tpettet3 | 1:89fd0d713ffc | 85 | if (value == 16) |
tpettet3 | 1:89fd0d713ffc | 86 | { |
tpettet3 | 1:89fd0d713ffc | 87 | led3 = !led3; |
tpettet3 | 1:89fd0d713ffc | 88 | } |
tpettet3 | 1:89fd0d713ffc | 89 | if (value == 32) |
tpettet3 | 1:89fd0d713ffc | 90 | { |
tpettet3 | 1:89fd0d713ffc | 91 | led4 = !led4; |
tpettet3 | 1:89fd0d713ffc | 92 | } |
tpettet3 | 1:89fd0d713ffc | 93 | |
tpettet3 | 1:89fd0d713ffc | 94 | if (value == 256) |
tpettet3 | 1:89fd0d713ffc | 95 | { |
tpettet3 | 1:89fd0d713ffc | 96 | led3 = !led3; |
tpettet3 | 1:89fd0d713ffc | 97 | } |
tpettet3 | 1:89fd0d713ffc | 98 | if (value == 512) |
tpettet3 | 1:89fd0d713ffc | 99 | { |
tpettet3 | 1:89fd0d713ffc | 100 | led4 = !led4; |
tpettet3 | 1:89fd0d713ffc | 101 | }*/ |
tpettet3 | 1:89fd0d713ffc | 102 | //i=0; |
4180_1 | 0:e09703934ff4 | 103 | // puts key number out to LEDs for demo |
tpettet3 | 1:89fd0d713ffc | 104 | /* for (i=0; i<12; i++) { |
4180_1 | 0:e09703934ff4 | 105 | if (((value>>i)&0x01)==1) key_code=i+1; |
4180_1 | 0:e09703934ff4 | 106 | } |
4180_1 | 0:e09703934ff4 | 107 | led4=key_code & 0x01; |
4180_1 | 0:e09703934ff4 | 108 | led3=(key_code>>1) & 0x01; |
4180_1 | 0:e09703934ff4 | 109 | led2=(key_code>>2) & 0x01; |
tpettet3 | 1:89fd0d713ffc | 110 | led1=(key_code>>3) & 0x01;*/ |
4180_1 | 0:e09703934ff4 | 111 | } |
tpettet3 | 1:89fd0d713ffc | 112 | float arand; |
tpettet3 | 1:89fd0d713ffc | 113 | unsigned int state; |
tpettet3 | 1:89fd0d713ffc | 114 | |
4180_1 | 0:e09703934ff4 | 115 | int main() { |
tpettet3 | 1:89fd0d713ffc | 116 | lcd.baudrate(300000); |
tpettet3 | 1:89fd0d713ffc | 117 | |
tpettet3 | 1:89fd0d713ffc | 118 | int out = 0xFF0000;// outline color |
tpettet3 | 1:89fd0d713ffc | 119 | int fill = 0x0000;// fill color. aka no mole |
tpettet3 | 1:89fd0d713ffc | 120 | int col1 = 21; |
tpettet3 | 1:89fd0d713ffc | 121 | int col2 = 64; |
tpettet3 | 1:89fd0d713ffc | 122 | int col3=107; |
tpettet3 | 1:89fd0d713ffc | 123 | int row1=107; |
tpettet3 | 1:89fd0d713ffc | 124 | int row2=64; |
tpettet3 | 1:89fd0d713ffc | 125 | int row3=21; |
tpettet3 | 1:89fd0d713ffc | 126 | int r = 20; |
tpettet3 | 1:89fd0d713ffc | 127 | int rmole=18;//radius mole |
tpettet3 | 1:89fd0d713ffc | 128 | int mole= 0xD3D3D3;//mole color like gray |
tpettet3 | 1:89fd0d713ffc | 129 | |
tpettet3 | 1:89fd0d713ffc | 130 | lcd.circle(col1, row1 , r, out);// all empty |
tpettet3 | 1:89fd0d713ffc | 131 | lcd.circle(col1, row2 , r, out); |
tpettet3 | 1:89fd0d713ffc | 132 | lcd.circle(col2, row1 , r, out); |
tpettet3 | 1:89fd0d713ffc | 133 | lcd.circle(col2, row2 , r, out); |
tpettet3 | 1:89fd0d713ffc | 134 | lcd.circle(col3, row1 , r, out); |
tpettet3 | 1:89fd0d713ffc | 135 | lcd.circle(col3, row2 , r, out); |
4180_1 | 0:e09703934ff4 | 136 | |
4180_1 | 0:e09703934ff4 | 137 | pc.printf("\nHello from the mbed & mpr121\n\r"); |
4180_1 | 0:e09703934ff4 | 138 | |
4180_1 | 0:e09703934ff4 | 139 | unsigned char dataArray[2]; |
4180_1 | 0:e09703934ff4 | 140 | int key; |
4180_1 | 0:e09703934ff4 | 141 | int count = 0; |
4180_1 | 0:e09703934ff4 | 142 | |
4180_1 | 0:e09703934ff4 | 143 | pc.printf("Test 1: read a value: \r\n"); |
4180_1 | 0:e09703934ff4 | 144 | dataArray[0] = mpr121.read(AFE_CFG); |
4180_1 | 0:e09703934ff4 | 145 | pc.printf("Read value=%x\r\n\n",dataArray[0]); |
4180_1 | 0:e09703934ff4 | 146 | |
4180_1 | 0:e09703934ff4 | 147 | pc.printf("Test 2: read a value: \r\n"); |
4180_1 | 0:e09703934ff4 | 148 | dataArray[0] = mpr121.read(0x5d); |
4180_1 | 0:e09703934ff4 | 149 | pc.printf("Read value=%x\r\n\n",dataArray[0]); |
4180_1 | 0:e09703934ff4 | 150 | |
4180_1 | 0:e09703934ff4 | 151 | pc.printf("Test 3: write & read a value: \r\n"); |
4180_1 | 0:e09703934ff4 | 152 | mpr121.read(ELE0_T); |
4180_1 | 0:e09703934ff4 | 153 | mpr121.write(ELE0_T,0x22); |
4180_1 | 0:e09703934ff4 | 154 | dataArray[0] = mpr121.read(ELE0_T); |
4180_1 | 0:e09703934ff4 | 155 | pc.printf("Read value=%x\r\n\n",dataArray[0]); |
4180_1 | 0:e09703934ff4 | 156 | |
4180_1 | 0:e09703934ff4 | 157 | pc.printf("Test 4: Write many values: \r\n"); |
4180_1 | 0:e09703934ff4 | 158 | unsigned char data[] = {0x1,0x3,0x5,0x9,0x15,0x25,0x41}; |
4180_1 | 0:e09703934ff4 | 159 | mpr121.writeMany(0x42,data,7); |
4180_1 | 0:e09703934ff4 | 160 | |
4180_1 | 0:e09703934ff4 | 161 | // Now read them back .. |
4180_1 | 0:e09703934ff4 | 162 | key = 0x42; |
4180_1 | 0:e09703934ff4 | 163 | count = 0; |
4180_1 | 0:e09703934ff4 | 164 | while (count < 7) { |
4180_1 | 0:e09703934ff4 | 165 | char result = mpr121.read(key); |
4180_1 | 0:e09703934ff4 | 166 | key++; |
4180_1 | 0:e09703934ff4 | 167 | count++; |
4180_1 | 0:e09703934ff4 | 168 | pc.printf("Read value: '%x'=%x\n\r",key,result); |
4180_1 | 0:e09703934ff4 | 169 | } |
4180_1 | 0:e09703934ff4 | 170 | |
4180_1 | 0:e09703934ff4 | 171 | pc.printf("Test 5: Read Electrodes:\r\n"); |
4180_1 | 0:e09703934ff4 | 172 | key = ELE0_T; |
4180_1 | 0:e09703934ff4 | 173 | count = 0; |
4180_1 | 0:e09703934ff4 | 174 | while (count < 24) { |
4180_1 | 0:e09703934ff4 | 175 | char result = mpr121.read(key); |
4180_1 | 0:e09703934ff4 | 176 | pc.printf("Read key:%x value:%x\n\r",key,result); |
4180_1 | 0:e09703934ff4 | 177 | key++; |
4180_1 | 0:e09703934ff4 | 178 | count++; |
4180_1 | 0:e09703934ff4 | 179 | } |
4180_1 | 0:e09703934ff4 | 180 | pc.printf("--------- \r\n\n"); |
4180_1 | 0:e09703934ff4 | 181 | |
4180_1 | 0:e09703934ff4 | 182 | // mpr121.setProximityMode(true); |
4180_1 | 0:e09703934ff4 | 183 | |
4180_1 | 0:e09703934ff4 | 184 | pc.printf("ELE_CFG=%x", mpr121.read(ELE_CFG)); |
4180_1 | 0:e09703934ff4 | 185 | |
4180_1 | 0:e09703934ff4 | 186 | interrupt.fall(&fallInterrupt); |
4180_1 | 0:e09703934ff4 | 187 | interrupt.mode(PullUp); |
tpettet3 | 1:89fd0d713ffc | 188 | int counter = 0; |
tpettet3 | 1:89fd0d713ffc | 189 | while (counter < 5) { |
tpettet3 | 1:89fd0d713ffc | 190 | arand = Ain.read()*1000000; |
tpettet3 | 1:89fd0d713ffc | 191 | state = arand; |
tpettet3 | 1:89fd0d713ffc | 192 | srand(state); |
tpettet3 | 1:89fd0d713ffc | 193 | state = rand()%15; |
tpettet3 | 1:89fd0d713ffc | 194 | pc.printf("%i\n\r",state); |
tpettet3 | 1:89fd0d713ffc | 195 | switch(state) |
tpettet3 | 1:89fd0d713ffc | 196 | { |
tpettet3 | 1:89fd0d713ffc | 197 | case 0: |
tpettet3 | 2:d85c5ce4d397 | 198 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 199 | pos1=1; |
tpettet3 | 1:89fd0d713ffc | 200 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 201 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 202 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 203 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 204 | pos6=0; |
tpettet3 | 2:d85c5ce4d397 | 205 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 206 | pc.printf("%i should be 0 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 207 | lcd.filled_circle(col1, row1 , rmole, fill);// 1 |
tpettet3 | 1:89fd0d713ffc | 208 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 209 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 210 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 211 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 212 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 213 | lcd.filled_circle(col1, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 214 | break; |
tpettet3 | 1:89fd0d713ffc | 215 | case 1: |
tpettet3 | 2:d85c5ce4d397 | 216 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 217 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 218 | pos2=1; |
tpettet3 | 1:89fd0d713ffc | 219 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 220 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 221 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 222 | pos6=0; |
tpettet3 | 2:d85c5ce4d397 | 223 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 224 | pc.printf("%i should be 1 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 225 | lcd.filled_circle(col1, row1 , rmole, fill);// 2 |
tpettet3 | 1:89fd0d713ffc | 226 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 227 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 228 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 229 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 230 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 231 | lcd.filled_circle(col2, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 232 | break; |
tpettet3 | 1:89fd0d713ffc | 233 | case 2: |
tpettet3 | 2:d85c5ce4d397 | 234 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 235 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 236 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 237 | pos3=1; |
tpettet3 | 1:89fd0d713ffc | 238 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 239 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 240 | pos6=0; |
tpettet3 | 2:d85c5ce4d397 | 241 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 242 | pc.printf("%i should be 2 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 243 | lcd.filled_circle(col1, row1 , rmole, fill);// 3 |
tpettet3 | 1:89fd0d713ffc | 244 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 245 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 246 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 247 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 248 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 249 | lcd.filled_circle(col3, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 250 | break; |
tpettet3 | 1:89fd0d713ffc | 251 | case 3: |
tpettet3 | 2:d85c5ce4d397 | 252 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 253 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 254 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 255 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 256 | pos4=1; |
tpettet3 | 1:89fd0d713ffc | 257 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 258 | pos6=0; |
tpettet3 | 2:d85c5ce4d397 | 259 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 260 | pc.printf("%i should be 3 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 261 | lcd.filled_circle(col1, row1 , rmole, fill);// 4 |
tpettet3 | 1:89fd0d713ffc | 262 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 263 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 264 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 265 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 266 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 267 | lcd.filled_circle(col1, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 268 | break; |
tpettet3 | 1:89fd0d713ffc | 269 | case 4: |
tpettet3 | 2:d85c5ce4d397 | 270 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 271 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 272 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 273 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 274 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 275 | pos5=1; |
tpettet3 | 1:89fd0d713ffc | 276 | pos6=0; |
tpettet3 | 2:d85c5ce4d397 | 277 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 278 | pc.printf("%i should be 4 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 279 | lcd.filled_circle(col1, row1 , rmole, fill);// 5 |
tpettet3 | 1:89fd0d713ffc | 280 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 281 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 282 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 283 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 284 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 285 | lcd.filled_circle(col2, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 286 | break; |
tpettet3 | 1:89fd0d713ffc | 287 | case 5: |
tpettet3 | 2:d85c5ce4d397 | 288 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 289 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 290 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 291 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 292 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 293 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 294 | pos6=1; |
tpettet3 | 2:d85c5ce4d397 | 295 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 296 | pc.printf("%i should be 5 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 297 | |
tpettet3 | 1:89fd0d713ffc | 298 | lcd.filled_circle(col1, row1 , rmole, fill);// 6 |
tpettet3 | 1:89fd0d713ffc | 299 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 300 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 301 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 302 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 303 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 304 | lcd.filled_circle(col2, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 305 | break; |
tpettet3 | 1:89fd0d713ffc | 306 | case 6: |
tpettet3 | 2:d85c5ce4d397 | 307 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 308 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 309 | pos2=1; |
tpettet3 | 1:89fd0d713ffc | 310 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 311 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 312 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 313 | pos6=1; |
tpettet3 | 2:d85c5ce4d397 | 314 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 315 | pc.printf("%i should be 6 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 316 | lcd.filled_circle(col1, row1 , rmole, fill);// 2,6 |
tpettet3 | 1:89fd0d713ffc | 317 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 318 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 319 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 320 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 321 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 322 | lcd.filled_circle(col2, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 323 | lcd.filled_circle(col3, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 324 | break; |
tpettet3 | 1:89fd0d713ffc | 325 | case 7: |
tpettet3 | 2:d85c5ce4d397 | 326 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 327 | pos1=1; |
tpettet3 | 1:89fd0d713ffc | 328 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 329 | pos3=1; |
tpettet3 | 1:89fd0d713ffc | 330 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 331 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 332 | pos6=0; |
tpettet3 | 2:d85c5ce4d397 | 333 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 334 | pc.printf("%i should be 7 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 335 | lcd.filled_circle(col1, row1 , rmole, fill);// 1,3 |
tpettet3 | 1:89fd0d713ffc | 336 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 337 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 338 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 339 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 340 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 341 | lcd.filled_circle(col1, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 342 | lcd.filled_circle(col3, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 343 | break; |
tpettet3 | 1:89fd0d713ffc | 344 | case 8: |
tpettet3 | 2:d85c5ce4d397 | 345 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 346 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 347 | pos2=1; |
tpettet3 | 1:89fd0d713ffc | 348 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 349 | pos4=1; |
tpettet3 | 1:89fd0d713ffc | 350 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 351 | pos6=1; |
tpettet3 | 2:d85c5ce4d397 | 352 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 353 | pc.printf("%i should be 8 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 354 | |
tpettet3 | 1:89fd0d713ffc | 355 | lcd.filled_circle(col1, row1 , rmole, fill);// 2,4,6 |
tpettet3 | 1:89fd0d713ffc | 356 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 357 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 358 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 359 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 360 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 361 | lcd.filled_circle(col2, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 362 | lcd.filled_circle(col2, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 363 | lcd.filled_circle(col3, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 364 | break; |
tpettet3 | 1:89fd0d713ffc | 365 | case 9: |
tpettet3 | 2:d85c5ce4d397 | 366 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 367 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 368 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 369 | pos3=1; |
tpettet3 | 1:89fd0d713ffc | 370 | pos4=1; |
tpettet3 | 1:89fd0d713ffc | 371 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 372 | pos6=1; |
tpettet3 | 2:d85c5ce4d397 | 373 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 374 | pc.printf("%i should be 9 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 375 | lcd.filled_circle(col1, row1 , rmole, fill);// 3,4,6 |
tpettet3 | 1:89fd0d713ffc | 376 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 377 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 378 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 379 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 380 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 381 | lcd.filled_circle(col3, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 382 | lcd.filled_circle(col1, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 383 | lcd.filled_circle(col3, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 384 | break; |
tpettet3 | 1:89fd0d713ffc | 385 | case 10: |
tpettet3 | 2:d85c5ce4d397 | 386 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 387 | pos1=1; |
tpettet3 | 1:89fd0d713ffc | 388 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 389 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 390 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 391 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 392 | pos6=1; |
tpettet3 | 2:d85c5ce4d397 | 393 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 394 | pc.printf("%i should be 10 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 395 | lcd.filled_circle(col1, row1 , rmole, fill);// 1,6 |
tpettet3 | 1:89fd0d713ffc | 396 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 397 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 398 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 399 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 400 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 401 | lcd.filled_circle(col1, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 402 | lcd.filled_circle(col3, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 403 | break; |
tpettet3 | 1:89fd0d713ffc | 404 | case 11: |
tpettet3 | 2:d85c5ce4d397 | 405 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 406 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 407 | pos2=1; |
tpettet3 | 1:89fd0d713ffc | 408 | pos3=1; |
tpettet3 | 1:89fd0d713ffc | 409 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 410 | pos5=1; |
tpettet3 | 1:89fd0d713ffc | 411 | pos6=1; |
tpettet3 | 2:d85c5ce4d397 | 412 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 413 | pc.printf("%i should be 11 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 414 | lcd.filled_circle(col1, row1 , rmole, fill);// 2,3,5,6 |
tpettet3 | 1:89fd0d713ffc | 415 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 416 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 417 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 418 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 419 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 420 | lcd.filled_circle(col2, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 421 | lcd.filled_circle(col3, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 422 | lcd.filled_circle(col2, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 423 | lcd.filled_circle(col3, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 424 | break; |
tpettet3 | 1:89fd0d713ffc | 425 | case 12: |
tpettet3 | 2:d85c5ce4d397 | 426 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 427 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 428 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 429 | pos3=1; |
tpettet3 | 1:89fd0d713ffc | 430 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 431 | pos5=1; |
tpettet3 | 1:89fd0d713ffc | 432 | pos6=0; |
tpettet3 | 2:d85c5ce4d397 | 433 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 434 | pc.printf("%i should be 12 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 435 | lcd.filled_circle(col1, row1 , rmole, fill);// 3,5 |
tpettet3 | 1:89fd0d713ffc | 436 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 437 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 438 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 439 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 440 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 441 | lcd.filled_circle(col3, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 442 | lcd.filled_circle(col2, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 443 | break; |
tpettet3 | 1:89fd0d713ffc | 444 | case 13: |
tpettet3 | 2:d85c5ce4d397 | 445 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 446 | pos1=1; |
tpettet3 | 1:89fd0d713ffc | 447 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 448 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 449 | pos4=1; |
tpettet3 | 1:89fd0d713ffc | 450 | pos5=1; |
tpettet3 | 1:89fd0d713ffc | 451 | pos6=0; |
tpettet3 | 2:d85c5ce4d397 | 452 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 453 | pc.printf("%i should be 13 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 454 | lcd.filled_circle(col1, row1 , rmole, fill);// 1,4,5 |
tpettet3 | 1:89fd0d713ffc | 455 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 456 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 457 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 458 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 459 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 460 | lcd.filled_circle(col1, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 461 | lcd.filled_circle(col1, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 462 | lcd.filled_circle(col2, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 463 | break; |
tpettet3 | 1:89fd0d713ffc | 464 | case 14: |
tpettet3 | 2:d85c5ce4d397 | 465 | POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 466 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 467 | pos2=1; |
tpettet3 | 1:89fd0d713ffc | 468 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 469 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 470 | pos5=1; |
tpettet3 | 1:89fd0d713ffc | 471 | pos6=0; |
tpettet3 | 2:d85c5ce4d397 | 472 | POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 473 | pc.printf("%i should be 14 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 474 | |
tpettet3 | 1:89fd0d713ffc | 475 | lcd.filled_circle(col1, row1 , rmole, fill);// 2,5 |
tpettet3 | 1:89fd0d713ffc | 476 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 477 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 478 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 479 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 480 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 1:89fd0d713ffc | 481 | lcd.filled_circle(col2, row1 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 482 | lcd.filled_circle(col2, row2 , rmole, mole); |
tpettet3 | 1:89fd0d713ffc | 483 | break; |
tpettet3 | 1:89fd0d713ffc | 484 | } |
tpettet3 | 1:89fd0d713ffc | 485 | wait(2); |
tpettet3 | 1:89fd0d713ffc | 486 | counter++; |
tpettet3 | 1:89fd0d713ffc | 487 | } |
tpettet3 | 1:89fd0d713ffc | 488 | pc.printf("you scored %i \n\r",score); |
4180_1 | 0:e09703934ff4 | 489 | } |
4180_1 | 0:e09703934ff4 | 490 | |
4180_1 | 0:e09703934ff4 | 491 | |
4180_1 | 0:e09703934ff4 | 492 | |
tpettet3 | 1:89fd0d713ffc | 493 |