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@11:9c2e3efd7cda, 2016-03-14 (annotated)
- Committer:
- tpettet3
- Date:
- Mon Mar 14 21:16:42 2016 +0000
- Revision:
- 11:9c2e3efd7cda
- Parent:
- 10:a31802412ab6
Public Release 1.0
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 | 5:070755be0a77 | 28 | #include "SDFileSystem.h" |
tpettet3 | 5:070755be0a77 | 29 | #include "SongPlayer.h" |
tpettet3 | 9:867dde4be88a | 30 | |
tpettet3 | 9:867dde4be88a | 31 | //initialize lcd |
tpettet3 | 1:89fd0d713ffc | 32 | uLCD_4DGL lcd(p9, p10, p30); // tx, rx, reset |
4180_1 | 0:e09703934ff4 | 33 | |
4180_1 | 0:e09703934ff4 | 34 | DigitalOut led1(LED1); |
4180_1 | 0:e09703934ff4 | 35 | DigitalOut led2(LED2); |
4180_1 | 0:e09703934ff4 | 36 | DigitalOut led3(LED3); |
4180_1 | 0:e09703934ff4 | 37 | DigitalOut led4(LED4); |
tpettet3 | 9:867dde4be88a | 38 | |
tpettet3 | 9:867dde4be88a | 39 | //setup analog in pin to read noise for random number generation |
tpettet3 | 1:89fd0d713ffc | 40 | AnalogIn Ain(p15); |
4180_1 | 0:e09703934ff4 | 41 | |
tpettet3 | 8:e6e1e5b3f2a9 | 42 | //Setup class D audio output on pwm out pin |
tpettet3 | 6:ca03b9c94c88 | 43 | SongPlayer mySpeaker(p21); |
tpettet3 | 8:e6e1e5b3f2a9 | 44 | |
tpettet3 | 9:867dde4be88a | 45 | //Create the interrupt receiver object on pin 26 |
4180_1 | 0:e09703934ff4 | 46 | InterruptIn interrupt(p26); |
tpettet3 | 8:e6e1e5b3f2a9 | 47 | |
tpettet3 | 8:e6e1e5b3f2a9 | 48 | //Setup the Serial to the PC for debugging |
4180_1 | 0:e09703934ff4 | 49 | Serial pc(USBTX, USBRX); |
tpettet3 | 8:e6e1e5b3f2a9 | 50 | |
tpettet3 | 8:e6e1e5b3f2a9 | 51 | //setup SD card filesystem |
tpettet3 | 8:e6e1e5b3f2a9 | 52 | SDFileSystem sd(p5, p6, p7, p8, "sd"); |
tpettet3 | 8:e6e1e5b3f2a9 | 53 | |
4180_1 | 0:e09703934ff4 | 54 | // Setup the i2c bus on pins 28 and 27 |
tpettet3 | 1:89fd0d713ffc | 55 | I2C i2c(p28, p27); |
tpettet3 | 8:e6e1e5b3f2a9 | 56 | |
tpettet3 | 8:e6e1e5b3f2a9 | 57 | //setup the note to be played upon hitting a mole |
tpettet3 | 5:070755be0a77 | 58 | float note[1]= {1568.0}; |
tpettet3 | 5:070755be0a77 | 59 | float duration[1]= {0.1}; |
tpettet3 | 8:e6e1e5b3f2a9 | 60 | |
tpettet3 | 8:e6e1e5b3f2a9 | 61 | //initialize the possition integers |
tpettet3 | 1:89fd0d713ffc | 62 | int pos1; |
tpettet3 | 1:89fd0d713ffc | 63 | int pos2; |
tpettet3 | 1:89fd0d713ffc | 64 | int pos3; |
tpettet3 | 1:89fd0d713ffc | 65 | int pos4; |
tpettet3 | 1:89fd0d713ffc | 66 | int pos5; |
tpettet3 | 1:89fd0d713ffc | 67 | int pos6; |
tpettet3 | 8:e6e1e5b3f2a9 | 68 | |
tpettet3 | 8:e6e1e5b3f2a9 | 69 | //initialize global variable to keep track of the score |
tpettet3 | 1:89fd0d713ffc | 70 | int score = 0; |
tpettet3 | 8:e6e1e5b3f2a9 | 71 | |
tpettet3 | 8:e6e1e5b3f2a9 | 72 | //create variables for the keypad outputs that correspond to mole possitions |
tpettet3 | 1:89fd0d713ffc | 73 | int hole1 = 0x100; |
tpettet3 | 1:89fd0d713ffc | 74 | int hole2 = 0x10; |
tpettet3 | 1:89fd0d713ffc | 75 | int hole3 = 0x1; |
tpettet3 | 1:89fd0d713ffc | 76 | int hole4 = 0x200; |
tpettet3 | 1:89fd0d713ffc | 77 | int hole5 = 0x20; |
tpettet3 | 1:89fd0d713ffc | 78 | int hole6 = 0x2; |
tpettet3 | 8:e6e1e5b3f2a9 | 79 | |
tpettet3 | 8:e6e1e5b3f2a9 | 80 | //create a character buffer to read from the SD card |
tpettet3 | 5:070755be0a77 | 81 | char str [80]; |
tpettet3 | 8:e6e1e5b3f2a9 | 82 | |
4180_1 | 0:e09703934ff4 | 83 | // Setup the Mpr121: |
4180_1 | 0:e09703934ff4 | 84 | // constructor(i2c object, i2c address of the mpr121) |
4180_1 | 0:e09703934ff4 | 85 | Mpr121 mpr121(&i2c, Mpr121::ADD_VSS); |
4180_1 | 0:e09703934ff4 | 86 | |
4180_1 | 0:e09703934ff4 | 87 | void fallInterrupt() { |
4180_1 | 0:e09703934ff4 | 88 | int key_code=0; |
4180_1 | 0:e09703934ff4 | 89 | int i=0; |
tpettet3 | 8:e6e1e5b3f2a9 | 90 | |
tpettet3 | 8:e6e1e5b3f2a9 | 91 | //read values from keypad after interupt and bitshift left 8 times |
4180_1 | 0:e09703934ff4 | 92 | int value=mpr121.read(0x00); |
4180_1 | 0:e09703934ff4 | 93 | value +=mpr121.read(0x01)<<8; |
tpettet3 | 8:e6e1e5b3f2a9 | 94 | //Check to see if the a mole is hit after an interupt |
tpettet3 | 3:dbae62823ec8 | 95 | if (value==256&&pos1==1) |
tpettet3 | 3:dbae62823ec8 | 96 | { |
tpettet3 | 9:867dde4be88a | 97 | mySpeaker.PlaySong(note,duration);//play note to indicate successful hit |
tpettet3 | 9:867dde4be88a | 98 | score++;//increment score by one |
tpettet3 | 8:e6e1e5b3f2a9 | 99 | pos1 = 0;//set the position to 0 after succesful hit to prevent multiple hits |
tpettet3 | 3:dbae62823ec8 | 100 | } |
tpettet3 | 3:dbae62823ec8 | 101 | if (value==16&&pos2==1) |
tpettet3 | 3:dbae62823ec8 | 102 | { |
tpettet3 | 6:ca03b9c94c88 | 103 | mySpeaker.PlaySong(note,duration); |
tpettet3 | 3:dbae62823ec8 | 104 | score++; |
tpettet3 | 7:5a8f9a018e1f | 105 | pos2 = 0; |
tpettet3 | 3:dbae62823ec8 | 106 | } |
tpettet3 | 3:dbae62823ec8 | 107 | if (value==1&&pos3==1) |
tpettet3 | 6:ca03b9c94c88 | 108 | { |
tpettet3 | 6:ca03b9c94c88 | 109 | mySpeaker.PlaySong(note,duration); |
tpettet3 | 1:89fd0d713ffc | 110 | score++; |
tpettet3 | 7:5a8f9a018e1f | 111 | pos3 = 0; |
tpettet3 | 1:89fd0d713ffc | 112 | } |
tpettet3 | 3:dbae62823ec8 | 113 | if (value==512&&pos4==1) |
tpettet3 | 3:dbae62823ec8 | 114 | { |
tpettet3 | 6:ca03b9c94c88 | 115 | mySpeaker.PlaySong(note,duration); |
tpettet3 | 3:dbae62823ec8 | 116 | score++; |
tpettet3 | 7:5a8f9a018e1f | 117 | pos4 = 0; |
tpettet3 | 3:dbae62823ec8 | 118 | } |
tpettet3 | 3:dbae62823ec8 | 119 | if (value==32&&pos5==1) |
tpettet3 | 3:dbae62823ec8 | 120 | { |
tpettet3 | 6:ca03b9c94c88 | 121 | mySpeaker.PlaySong(note,duration); |
tpettet3 | 3:dbae62823ec8 | 122 | score++; |
tpettet3 | 7:5a8f9a018e1f | 123 | pos5 = 0; |
tpettet3 | 3:dbae62823ec8 | 124 | } |
tpettet3 | 3:dbae62823ec8 | 125 | if (value==2&&pos6==1) |
tpettet3 | 3:dbae62823ec8 | 126 | { |
tpettet3 | 6:ca03b9c94c88 | 127 | mySpeaker.PlaySong(note,duration); |
tpettet3 | 3:dbae62823ec8 | 128 | score++; |
tpettet3 | 7:5a8f9a018e1f | 129 | pos6 = 0; |
tpettet3 | 3:dbae62823ec8 | 130 | } |
4180_1 | 0:e09703934ff4 | 131 | } |
tpettet3 | 9:867dde4be88a | 132 | float arand;// variable to store analog noise |
tpettet3 | 9:867dde4be88a | 133 | unsigned int state; // global state variable |
tpettet3 | 1:89fd0d713ffc | 134 | |
4180_1 | 0:e09703934ff4 | 135 | int main() { |
tpettet3 | 9:867dde4be88a | 136 | lcd.baudrate(300000);// set lcd baudrate |
tpettet3 | 1:89fd0d713ffc | 137 | |
tpettet3 | 1:89fd0d713ffc | 138 | int out = 0xFF0000;// outline color |
tpettet3 | 1:89fd0d713ffc | 139 | int fill = 0x0000;// fill color. aka no mole |
tpettet3 | 1:89fd0d713ffc | 140 | int col1 = 21; |
tpettet3 | 1:89fd0d713ffc | 141 | int col2 = 64; |
tpettet3 | 1:89fd0d713ffc | 142 | int col3=107; |
tpettet3 | 4:4cb02cde783c | 143 | int row3=107; |
tpettet3 | 1:89fd0d713ffc | 144 | int row2=64; |
tpettet3 | 4:4cb02cde783c | 145 | int row1=21; |
tpettet3 | 1:89fd0d713ffc | 146 | int r = 20; |
tpettet3 | 1:89fd0d713ffc | 147 | int rmole=18;//radius mole |
tpettet3 | 1:89fd0d713ffc | 148 | int mole= 0xD3D3D3;//mole color like gray |
tpettet3 | 1:89fd0d713ffc | 149 | |
tpettet3 | 11:9c2e3efd7cda | 150 | |
tpettet3 | 11:9c2e3efd7cda | 151 | //mole face |
tpettet3 | 11:9c2e3efd7cda | 152 | int lx114=10;//14x |
tpettet3 | 11:9c2e3efd7cda | 153 | int lx214=17; |
tpettet3 | 11:9c2e3efd7cda | 154 | int rx114=25; |
tpettet3 | 11:9c2e3efd7cda | 155 | int rx214=32; |
tpettet3 | 11:9c2e3efd7cda | 156 | int lx125=53;//25x |
tpettet3 | 11:9c2e3efd7cda | 157 | int lx225=60; |
tpettet3 | 11:9c2e3efd7cda | 158 | int rx125=68; |
tpettet3 | 11:9c2e3efd7cda | 159 | int rx225=75; |
tpettet3 | 11:9c2e3efd7cda | 160 | int lx136=97;//36x |
tpettet3 | 11:9c2e3efd7cda | 161 | int lx236=103; |
tpettet3 | 11:9c2e3efd7cda | 162 | int rx136=111; |
tpettet3 | 11:9c2e3efd7cda | 163 | int rx236=118; |
tpettet3 | 11:9c2e3efd7cda | 164 | |
tpettet3 | 11:9c2e3efd7cda | 165 | int eyey123=10;//123y |
tpettet3 | 11:9c2e3efd7cda | 166 | int eyey456=56;//456y |
tpettet3 | 11:9c2e3efd7cda | 167 | int eyecolor=0x0000; |
tpettet3 | 11:9c2e3efd7cda | 168 | int nosecolor=0x0000; |
tpettet3 | 11:9c2e3efd7cda | 169 | int whisker=0x0000; |
tpettet3 | 11:9c2e3efd7cda | 170 | int rnose=2; |
tpettet3 | 11:9c2e3efd7cda | 171 | |
tpettet3 | 11:9c2e3efd7cda | 172 | int wb123=27;//pos123 |
tpettet3 | 11:9c2e3efd7cda | 173 | int wm123=21; |
tpettet3 | 11:9c2e3efd7cda | 174 | int wt123=15; |
tpettet3 | 11:9c2e3efd7cda | 175 | int wb456=70;//pos456 |
tpettet3 | 11:9c2e3efd7cda | 176 | int wm456=64; |
tpettet3 | 11:9c2e3efd7cda | 177 | int wt456=58; |
tpettet3 | 11:9c2e3efd7cda | 178 | |
tpettet3 | 11:9c2e3efd7cda | 179 | |
tpettet3 | 11:9c2e3efd7cda | 180 | |
tpettet3 | 11:9c2e3efd7cda | 181 | |
tpettet3 | 9:867dde4be88a | 182 | lcd.circle(col1, row1 , r, out);// draws 6 circles to the lcd screen to show where the moles will appear |
tpettet3 | 1:89fd0d713ffc | 183 | lcd.circle(col1, row2 , r, out); |
tpettet3 | 1:89fd0d713ffc | 184 | lcd.circle(col2, row1 , r, out); |
tpettet3 | 1:89fd0d713ffc | 185 | lcd.circle(col2, row2 , r, out); |
tpettet3 | 1:89fd0d713ffc | 186 | lcd.circle(col3, row1 , r, out); |
tpettet3 | 1:89fd0d713ffc | 187 | lcd.circle(col3, row2 , r, out); |
4180_1 | 0:e09703934ff4 | 188 | |
tpettet3 | 9:867dde4be88a | 189 | // Begin test code for mpr121 |
tpettet3 | 9:867dde4be88a | 190 | pc.printf("\nHello from the mbed & mpr121\n\r"); |
4180_1 | 0:e09703934ff4 | 191 | |
tpettet3 | 9:867dde4be88a | 192 | unsigned char dataArray[2]; |
tpettet3 | 9:867dde4be88a | 193 | int key; |
tpettet3 | 9:867dde4be88a | 194 | int count = 0; |
4180_1 | 0:e09703934ff4 | 195 | |
tpettet3 | 9:867dde4be88a | 196 | pc.printf("Test 1: read a value: \r\n"); |
tpettet3 | 9:867dde4be88a | 197 | dataArray[0] = mpr121.read(AFE_CFG); |
4180_1 | 0:e09703934ff4 | 198 | pc.printf("Read value=%x\r\n\n",dataArray[0]); |
4180_1 | 0:e09703934ff4 | 199 | |
4180_1 | 0:e09703934ff4 | 200 | pc.printf("Test 2: read a value: \r\n"); |
4180_1 | 0:e09703934ff4 | 201 | dataArray[0] = mpr121.read(0x5d); |
4180_1 | 0:e09703934ff4 | 202 | pc.printf("Read value=%x\r\n\n",dataArray[0]); |
4180_1 | 0:e09703934ff4 | 203 | |
4180_1 | 0:e09703934ff4 | 204 | pc.printf("Test 3: write & read a value: \r\n"); |
4180_1 | 0:e09703934ff4 | 205 | mpr121.read(ELE0_T); |
4180_1 | 0:e09703934ff4 | 206 | mpr121.write(ELE0_T,0x22); |
4180_1 | 0:e09703934ff4 | 207 | dataArray[0] = mpr121.read(ELE0_T); |
4180_1 | 0:e09703934ff4 | 208 | pc.printf("Read value=%x\r\n\n",dataArray[0]); |
4180_1 | 0:e09703934ff4 | 209 | |
4180_1 | 0:e09703934ff4 | 210 | pc.printf("Test 4: Write many values: \r\n"); |
4180_1 | 0:e09703934ff4 | 211 | unsigned char data[] = {0x1,0x3,0x5,0x9,0x15,0x25,0x41}; |
4180_1 | 0:e09703934ff4 | 212 | mpr121.writeMany(0x42,data,7); |
4180_1 | 0:e09703934ff4 | 213 | |
4180_1 | 0:e09703934ff4 | 214 | // Now read them back .. |
4180_1 | 0:e09703934ff4 | 215 | key = 0x42; |
4180_1 | 0:e09703934ff4 | 216 | count = 0; |
4180_1 | 0:e09703934ff4 | 217 | while (count < 7) { |
4180_1 | 0:e09703934ff4 | 218 | char result = mpr121.read(key); |
4180_1 | 0:e09703934ff4 | 219 | key++; |
4180_1 | 0:e09703934ff4 | 220 | count++; |
4180_1 | 0:e09703934ff4 | 221 | pc.printf("Read value: '%x'=%x\n\r",key,result); |
4180_1 | 0:e09703934ff4 | 222 | } |
4180_1 | 0:e09703934ff4 | 223 | |
4180_1 | 0:e09703934ff4 | 224 | pc.printf("Test 5: Read Electrodes:\r\n"); |
4180_1 | 0:e09703934ff4 | 225 | key = ELE0_T; |
4180_1 | 0:e09703934ff4 | 226 | count = 0; |
4180_1 | 0:e09703934ff4 | 227 | while (count < 24) { |
4180_1 | 0:e09703934ff4 | 228 | char result = mpr121.read(key); |
4180_1 | 0:e09703934ff4 | 229 | pc.printf("Read key:%x value:%x\n\r",key,result); |
4180_1 | 0:e09703934ff4 | 230 | key++; |
4180_1 | 0:e09703934ff4 | 231 | count++; |
4180_1 | 0:e09703934ff4 | 232 | } |
4180_1 | 0:e09703934ff4 | 233 | pc.printf("--------- \r\n\n"); |
4180_1 | 0:e09703934ff4 | 234 | |
4180_1 | 0:e09703934ff4 | 235 | // mpr121.setProximityMode(true); |
4180_1 | 0:e09703934ff4 | 236 | |
4180_1 | 0:e09703934ff4 | 237 | pc.printf("ELE_CFG=%x", mpr121.read(ELE_CFG)); |
tpettet3 | 9:867dde4be88a | 238 | // end test code of mpr121 |
4180_1 | 0:e09703934ff4 | 239 | |
tpettet3 | 9:867dde4be88a | 240 | |
tpettet3 | 9:867dde4be88a | 241 | interrupt.fall(&fallInterrupt);//set up the interrupt mode |
4180_1 | 0:e09703934ff4 | 242 | interrupt.mode(PullUp); |
tpettet3 | 9:867dde4be88a | 243 | |
tpettet3 | 9:867dde4be88a | 244 | int counter = 0;// initialize the variable to count the number of transitions per game |
tpettet3 | 9:867dde4be88a | 245 | |
tpettet3 | 9:867dde4be88a | 246 | //read in a psuedo random noise reading and multiply so that it can later be cast to int by truncation |
tpettet3 | 9:867dde4be88a | 247 | arand = Ain.read()*1000000; |
tpettet3 | 9:867dde4be88a | 248 | |
tpettet3 | 9:867dde4be88a | 249 | //seed rand with noise reading |
tpettet3 | 9:867dde4be88a | 250 | srand(arand); |
tpettet3 | 9:867dde4be88a | 251 | |
tpettet3 | 9:867dde4be88a | 252 | //game runs for transitions |
tpettet3 | 8:e6e1e5b3f2a9 | 253 | while (counter < 30) { |
tpettet3 | 8:e6e1e5b3f2a9 | 254 | |
tpettet3 | 9:867dde4be88a | 255 | //determine state using rand() |
tpettet3 | 1:89fd0d713ffc | 256 | state = rand()%15; |
tpettet3 | 9:867dde4be88a | 257 | |
tpettet3 | 9:867dde4be88a | 258 | //switch the value of state to determine the output to the lcd |
tpettet3 | 1:89fd0d713ffc | 259 | switch(state) |
tpettet3 | 1:89fd0d713ffc | 260 | { |
tpettet3 | 1:89fd0d713ffc | 261 | case 0: |
tpettet3 | 9:867dde4be88a | 262 | //mutex functionality can be incorperated my uncommenting //POS_MUTEX.un/lock() |
tpettet3 | 3:dbae62823ec8 | 263 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 264 | pos1=1; |
tpettet3 | 1:89fd0d713ffc | 265 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 266 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 267 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 268 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 269 | pos6=0; |
tpettet3 | 3:dbae62823ec8 | 270 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 271 | pc.printf("%i should be 0 \n\r",state); |
tpettet3 | 9:867dde4be88a | 272 | lcd.filled_circle(col1, row1 , rmole, fill);// 1 |
tpettet3 | 9:867dde4be88a | 273 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 274 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 275 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 276 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 277 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 278 | lcd.filled_circle(col1, row1 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 279 | //face1 |
tpettet3 | 11:9c2e3efd7cda | 280 | lcd.line(lx114, eyey123 , lx214, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 281 | lcd.line(rx114, eyey123 , rx214, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 282 | lcd.line(lx114, wb123 , rx214, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 283 | lcd.line(lx114, wm123 , rx214, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 284 | lcd.line(lx114, wt123 , rx214, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 285 | lcd.filled_circle(col1, row1 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 286 | |
tpettet3 | 11:9c2e3efd7cda | 287 | |
tpettet3 | 1:89fd0d713ffc | 288 | break; |
tpettet3 | 1:89fd0d713ffc | 289 | case 1: |
tpettet3 | 3:dbae62823ec8 | 290 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 291 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 292 | pos2=1; |
tpettet3 | 1:89fd0d713ffc | 293 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 294 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 295 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 296 | pos6=0; |
tpettet3 | 3:dbae62823ec8 | 297 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 298 | pc.printf("%i should be 1 \n\r",state); |
tpettet3 | 9:867dde4be88a | 299 | lcd.filled_circle(col1, row1 , rmole, fill);// 2 |
tpettet3 | 9:867dde4be88a | 300 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 301 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 302 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 303 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 304 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 305 | lcd.filled_circle(col2, row1 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 306 | //face2 |
tpettet3 | 11:9c2e3efd7cda | 307 | lcd.line(lx125, eyey123 , lx225, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 308 | lcd.line(rx125, eyey123 , rx225, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 309 | lcd.line(lx125, wb123 , rx225, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 310 | lcd.line(lx125, wm123 , rx225, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 311 | lcd.line(lx125, wt123 , rx225, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 312 | lcd.filled_circle(col2, row1 , rnose, nosecolor);//nose |
tpettet3 | 1:89fd0d713ffc | 313 | break; |
tpettet3 | 1:89fd0d713ffc | 314 | case 2: |
tpettet3 | 3:dbae62823ec8 | 315 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 316 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 317 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 318 | pos3=1; |
tpettet3 | 1:89fd0d713ffc | 319 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 320 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 321 | pos6=0; |
tpettet3 | 3:dbae62823ec8 | 322 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 323 | pc.printf("%i should be 2 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 324 | lcd.filled_circle(col1, row1 , rmole, fill);// 3 |
tpettet3 | 9:867dde4be88a | 325 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 326 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 327 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 328 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 329 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 330 | lcd.filled_circle(col3, row1 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 331 | |
tpettet3 | 11:9c2e3efd7cda | 332 | //face3 |
tpettet3 | 11:9c2e3efd7cda | 333 | lcd.line(lx136, eyey123 , lx236, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 334 | lcd.line(rx136, eyey123 , rx236, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 335 | lcd.line(lx136, wb123 , rx236, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 336 | lcd.line(lx136, wm123 , rx236, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 337 | lcd.line(lx136, wt123 , rx236, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 338 | lcd.filled_circle(col3, row1 , rnose, nosecolor);//nose |
tpettet3 | 1:89fd0d713ffc | 339 | break; |
tpettet3 | 1:89fd0d713ffc | 340 | case 3: |
tpettet3 | 3:dbae62823ec8 | 341 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 342 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 343 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 344 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 345 | pos4=1; |
tpettet3 | 1:89fd0d713ffc | 346 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 347 | pos6=0; |
tpettet3 | 3:dbae62823ec8 | 348 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 349 | pc.printf("%i should be 3 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 350 | lcd.filled_circle(col1, row1 , rmole, fill);// 4 |
tpettet3 | 9:867dde4be88a | 351 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 352 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 353 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 354 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 355 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 356 | lcd.filled_circle(col1, row2 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 357 | |
tpettet3 | 11:9c2e3efd7cda | 358 | //face4 |
tpettet3 | 11:9c2e3efd7cda | 359 | lcd.line(lx114, eyey456 , lx214, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 360 | lcd.line(rx114, eyey456 , rx214, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 361 | lcd.line(lx114, wb456 , rx214, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 362 | lcd.line(lx114, wm456 , rx214, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 363 | lcd.line(lx114, wt456 , rx214, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 364 | lcd.filled_circle(col1, row2 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 365 | |
tpettet3 | 1:89fd0d713ffc | 366 | break; |
tpettet3 | 1:89fd0d713ffc | 367 | case 4: |
tpettet3 | 3:dbae62823ec8 | 368 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 369 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 370 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 371 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 372 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 373 | pos5=1; |
tpettet3 | 1:89fd0d713ffc | 374 | pos6=0; |
tpettet3 | 3:dbae62823ec8 | 375 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 376 | pc.printf("%i should be 4 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 377 | lcd.filled_circle(col1, row1 , rmole, fill);// 5 |
tpettet3 | 9:867dde4be88a | 378 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 379 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 380 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 381 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 382 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 383 | lcd.filled_circle(col2, row2 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 384 | //face5 |
tpettet3 | 11:9c2e3efd7cda | 385 | lcd.line(lx125, eyey456 , lx225, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 386 | lcd.line(rx125, eyey456 , rx225, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 387 | lcd.line(lx125, wb456 , rx225, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 388 | lcd.line(lx125, wm456 , rx225, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 389 | lcd.line(lx125, wt456 , rx225, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 390 | lcd.filled_circle(col2, row2 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 391 | |
tpettet3 | 1:89fd0d713ffc | 392 | break; |
tpettet3 | 1:89fd0d713ffc | 393 | case 5: |
tpettet3 | 3:dbae62823ec8 | 394 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 395 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 396 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 397 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 398 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 399 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 400 | pos6=1; |
tpettet3 | 3:dbae62823ec8 | 401 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 402 | pc.printf("%i should be 5 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 403 | |
tpettet3 | 9:867dde4be88a | 404 | lcd.filled_circle(col1, row1 , rmole, fill);// 6 |
tpettet3 | 9:867dde4be88a | 405 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 406 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 407 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 408 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 409 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 11:9c2e3efd7cda | 410 | lcd.filled_circle(col3, row2 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 411 | //face6 |
tpettet3 | 11:9c2e3efd7cda | 412 | lcd.line(lx136, eyey456 , lx236, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 413 | lcd.line(rx136, eyey456 , rx236, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 414 | lcd.line(lx136, wb456 , rx236, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 415 | lcd.line(lx136, wm456 , rx236, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 416 | lcd.line(lx136, wt456 , rx236, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 417 | lcd.filled_circle(col3, row2 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 418 | |
tpettet3 | 1:89fd0d713ffc | 419 | break; |
tpettet3 | 1:89fd0d713ffc | 420 | case 6: |
tpettet3 | 3:dbae62823ec8 | 421 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 422 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 423 | pos2=1; |
tpettet3 | 1:89fd0d713ffc | 424 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 425 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 426 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 427 | pos6=1; |
tpettet3 | 3:dbae62823ec8 | 428 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 429 | pc.printf("%i should be 6 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 430 | lcd.filled_circle(col1, row1 , rmole, fill);// 2,6 |
tpettet3 | 9:867dde4be88a | 431 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 432 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 433 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 434 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 435 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 436 | lcd.filled_circle(col2, row1 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 437 | lcd.filled_circle(col3, row2 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 438 | |
tpettet3 | 11:9c2e3efd7cda | 439 | //face2 |
tpettet3 | 11:9c2e3efd7cda | 440 | lcd.line(lx125, eyey123 , lx225, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 441 | lcd.line(rx125, eyey123 , rx225, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 442 | lcd.line(lx125, wb123 , rx225, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 443 | lcd.line(lx125, wm123 , rx225, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 444 | lcd.line(lx125, wt123 , rx225, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 445 | lcd.filled_circle(col2, row1 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 446 | //face6 |
tpettet3 | 11:9c2e3efd7cda | 447 | lcd.line(lx136, eyey456 , lx236, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 448 | lcd.line(rx136, eyey456 , rx236, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 449 | lcd.line(lx136, wb456 , rx236, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 450 | lcd.line(lx136, wm456 , rx236, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 451 | lcd.line(lx136, wt456 , rx236, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 452 | lcd.filled_circle(col3, row2 , rnose, nosecolor);//nose |
tpettet3 | 1:89fd0d713ffc | 453 | break; |
tpettet3 | 1:89fd0d713ffc | 454 | case 7: |
tpettet3 | 3:dbae62823ec8 | 455 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 456 | pos1=1; |
tpettet3 | 1:89fd0d713ffc | 457 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 458 | pos3=1; |
tpettet3 | 1:89fd0d713ffc | 459 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 460 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 461 | pos6=0; |
tpettet3 | 3:dbae62823ec8 | 462 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 463 | pc.printf("%i should be 7 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 464 | lcd.filled_circle(col1, row1 , rmole, fill);// 1,3 |
tpettet3 | 9:867dde4be88a | 465 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 466 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 467 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 468 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 469 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 470 | lcd.filled_circle(col1, row1 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 471 | lcd.filled_circle(col3, row1 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 472 | |
tpettet3 | 11:9c2e3efd7cda | 473 | //face1 |
tpettet3 | 11:9c2e3efd7cda | 474 | lcd.line(lx114, eyey123 , lx214, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 475 | lcd.line(rx114, eyey123 , rx214, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 476 | lcd.line(lx114, wb123 , rx214, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 477 | lcd.line(lx114, wm123 , rx214, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 478 | lcd.line(lx114, wt123 , rx214, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 479 | lcd.filled_circle(col1, row1 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 480 | //face3 |
tpettet3 | 11:9c2e3efd7cda | 481 | lcd.line(lx136, eyey123 , lx236, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 482 | lcd.line(rx136, eyey123 , rx236, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 483 | lcd.line(lx136, wb123 , rx236, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 484 | lcd.line(lx136, wm123 , rx236, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 485 | lcd.line(lx136, wt123 , rx236, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 486 | lcd.filled_circle(col3, row1 , rnose, nosecolor);//nose |
tpettet3 | 1:89fd0d713ffc | 487 | break; |
tpettet3 | 1:89fd0d713ffc | 488 | case 8: |
tpettet3 | 3:dbae62823ec8 | 489 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 490 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 491 | pos2=1; |
tpettet3 | 1:89fd0d713ffc | 492 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 493 | pos4=1; |
tpettet3 | 1:89fd0d713ffc | 494 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 495 | pos6=1; |
tpettet3 | 3:dbae62823ec8 | 496 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 497 | pc.printf("%i should be 8 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 498 | |
tpettet3 | 9:867dde4be88a | 499 | lcd.filled_circle(col1, row1 , rmole, fill);// 2,4,6 |
tpettet3 | 9:867dde4be88a | 500 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 501 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 502 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 503 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 504 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 505 | lcd.filled_circle(col2, row1 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 506 | lcd.filled_circle(col1, row2 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 507 | //face2 |
tpettet3 | 11:9c2e3efd7cda | 508 | lcd.line(lx125, eyey123 , lx225, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 509 | lcd.line(rx125, eyey123 , rx225, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 510 | lcd.line(lx125, wb123 , rx225, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 511 | lcd.line(lx125, wm123 , rx225, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 512 | lcd.line(lx125, wt123 , rx225, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 513 | lcd.filled_circle(col2, row1 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 514 | //face4 |
tpettet3 | 11:9c2e3efd7cda | 515 | lcd.line(lx114, eyey456 , lx214, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 516 | lcd.line(rx114, eyey456 , rx214, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 517 | lcd.line(lx114, wb456 , rx214, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 518 | lcd.line(lx114, wm456 , rx214, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 519 | lcd.line(lx114, wt456 , rx214, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 520 | lcd.filled_circle(col1, row2 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 521 | |
tpettet3 | 1:89fd0d713ffc | 522 | break; |
tpettet3 | 1:89fd0d713ffc | 523 | case 9: |
tpettet3 | 3:dbae62823ec8 | 524 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 525 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 526 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 527 | pos3=1; |
tpettet3 | 1:89fd0d713ffc | 528 | pos4=1; |
tpettet3 | 1:89fd0d713ffc | 529 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 530 | pos6=1; |
tpettet3 | 3:dbae62823ec8 | 531 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 532 | pc.printf("%i should be 9 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 533 | lcd.filled_circle(col1, row1 , rmole, fill);// 3,4,6 |
tpettet3 | 9:867dde4be88a | 534 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 535 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 536 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 537 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 538 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 539 | lcd.filled_circle(col3, row1 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 540 | lcd.filled_circle(col1, row2 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 541 | lcd.filled_circle(col3, row2 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 542 | //face3 |
tpettet3 | 11:9c2e3efd7cda | 543 | lcd.line(lx136, eyey123 , lx236, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 544 | lcd.line(rx136, eyey123 , rx236, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 545 | lcd.line(lx136, wb123 , rx236, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 546 | lcd.line(lx136, wm123 , rx236, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 547 | lcd.line(lx136, wt123 , rx236, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 548 | lcd.filled_circle(col3, row1 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 549 | //face4 |
tpettet3 | 11:9c2e3efd7cda | 550 | lcd.line(lx114, eyey456 , lx214, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 551 | lcd.line(rx114, eyey456 , rx214, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 552 | lcd.line(lx114, wb456 , rx214, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 553 | lcd.line(lx114, wm456 , rx214, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 554 | lcd.line(lx114, wt456 , rx214, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 555 | lcd.filled_circle(col1, row2 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 556 | //face6 |
tpettet3 | 11:9c2e3efd7cda | 557 | lcd.line(lx136, eyey456 , lx236, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 558 | lcd.line(rx136, eyey456 , rx236, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 559 | lcd.line(lx136, wb456 , rx236, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 560 | lcd.line(lx136, wm456 , rx236, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 561 | lcd.line(lx136, wt456 , rx236, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 562 | lcd.filled_circle(col3, row2 , rnose, nosecolor);//nose |
tpettet3 | 1:89fd0d713ffc | 563 | break; |
tpettet3 | 1:89fd0d713ffc | 564 | case 10: |
tpettet3 | 3:dbae62823ec8 | 565 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 566 | pos1=1; |
tpettet3 | 1:89fd0d713ffc | 567 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 568 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 569 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 570 | pos5=0; |
tpettet3 | 1:89fd0d713ffc | 571 | pos6=1; |
tpettet3 | 3:dbae62823ec8 | 572 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 573 | pc.printf("%i should be 10 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 574 | lcd.filled_circle(col1, row1 , rmole, fill);// 1,6 |
tpettet3 | 9:867dde4be88a | 575 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 576 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 577 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 578 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 579 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 580 | lcd.filled_circle(col1, row1 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 581 | lcd.filled_circle(col3, row2 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 582 | //face1 |
tpettet3 | 11:9c2e3efd7cda | 583 | lcd.line(lx114, eyey123 , lx214, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 584 | lcd.line(rx114, eyey123 , rx214, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 585 | lcd.line(lx114, wb123 , rx214, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 586 | lcd.line(lx114, wm123 , rx214, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 587 | lcd.line(lx114, wt123 , rx214, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 588 | lcd.filled_circle(col1, row1 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 589 | //face6 |
tpettet3 | 11:9c2e3efd7cda | 590 | lcd.line(lx136, eyey456 , lx236, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 591 | lcd.line(rx136, eyey456 , rx236, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 592 | lcd.line(lx136, wb456 , rx236, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 593 | lcd.line(lx136, wm456 , rx236, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 594 | lcd.line(lx136, wt456 , rx236, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 595 | lcd.filled_circle(col3, row2 , rnose, nosecolor);//nose |
tpettet3 | 1:89fd0d713ffc | 596 | break; |
tpettet3 | 1:89fd0d713ffc | 597 | case 11: |
tpettet3 | 3:dbae62823ec8 | 598 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 599 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 600 | pos2=1; |
tpettet3 | 1:89fd0d713ffc | 601 | pos3=1; |
tpettet3 | 1:89fd0d713ffc | 602 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 603 | pos5=1; |
tpettet3 | 1:89fd0d713ffc | 604 | pos6=1; |
tpettet3 | 3:dbae62823ec8 | 605 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 606 | pc.printf("%i should be 11 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 607 | lcd.filled_circle(col1, row1 , rmole, fill);// 2,3,5,6 |
tpettet3 | 9:867dde4be88a | 608 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 609 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 610 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 611 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 612 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 613 | lcd.filled_circle(col2, row1 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 614 | lcd.filled_circle(col3, row1 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 615 | lcd.filled_circle(col2, row2 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 616 | lcd.filled_circle(col3, row2 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 617 | //face2 |
tpettet3 | 11:9c2e3efd7cda | 618 | lcd.line(lx125, eyey123 , lx225, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 619 | lcd.line(rx125, eyey123 , rx225, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 620 | lcd.line(lx125, wb123 , rx225, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 621 | lcd.line(lx125, wm123 , rx225, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 622 | lcd.line(lx125, wt123 , rx225, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 623 | lcd.filled_circle(col2, row1 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 624 | //face3 |
tpettet3 | 11:9c2e3efd7cda | 625 | lcd.line(lx136, eyey123 , lx236, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 626 | lcd.line(rx136, eyey123 , rx236, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 627 | lcd.line(lx136, wb123 , rx236, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 628 | lcd.line(lx136, wm123 , rx236, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 629 | lcd.line(lx136, wt123 , rx236, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 630 | lcd.filled_circle(col3, row1 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 631 | //face5 |
tpettet3 | 11:9c2e3efd7cda | 632 | lcd.line(lx125, eyey456 , lx225, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 633 | lcd.line(rx125, eyey456 , rx225, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 634 | lcd.line(lx125, wb456 , rx225, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 635 | lcd.line(lx125, wm456 , rx225, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 636 | lcd.line(lx125, wt456 , rx225, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 637 | lcd.filled_circle(col2, row2 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 638 | //face6 |
tpettet3 | 11:9c2e3efd7cda | 639 | lcd.line(lx136, eyey456 , lx236, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 640 | lcd.line(rx136, eyey456 , rx236, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 641 | lcd.line(lx136, wb456 , rx236, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 642 | lcd.line(lx136, wm456 , rx236, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 643 | lcd.line(lx136, wt456 , rx236, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 644 | lcd.filled_circle(col3, row2 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 645 | |
tpettet3 | 1:89fd0d713ffc | 646 | break; |
tpettet3 | 1:89fd0d713ffc | 647 | case 12: |
tpettet3 | 3:dbae62823ec8 | 648 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 649 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 650 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 651 | pos3=1; |
tpettet3 | 1:89fd0d713ffc | 652 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 653 | pos5=1; |
tpettet3 | 1:89fd0d713ffc | 654 | pos6=0; |
tpettet3 | 3:dbae62823ec8 | 655 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 656 | pc.printf("%i should be 12 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 657 | lcd.filled_circle(col1, row1 , rmole, fill);// 3,5 |
tpettet3 | 9:867dde4be88a | 658 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 659 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 660 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 661 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 662 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 663 | lcd.filled_circle(col3, row1 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 664 | lcd.filled_circle(col2, row2 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 665 | |
tpettet3 | 11:9c2e3efd7cda | 666 | //face3 |
tpettet3 | 11:9c2e3efd7cda | 667 | lcd.line(lx136, eyey123 , lx236, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 668 | lcd.line(rx136, eyey123 , rx236, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 669 | lcd.line(lx136, wb123 , rx236, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 670 | lcd.line(lx136, wm123 , rx236, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 671 | lcd.line(lx136, wt123 , rx236, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 672 | lcd.filled_circle(col3, row1 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 673 | //face5 |
tpettet3 | 11:9c2e3efd7cda | 674 | lcd.line(lx125, eyey456 , lx225, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 675 | lcd.line(rx125, eyey456 , rx225, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 676 | lcd.line(lx125, wb456 , rx225, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 677 | lcd.line(lx125, wm456 , rx225, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 678 | lcd.line(lx125, wt456 , rx225, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 679 | lcd.filled_circle(col2, row2 , rnose, nosecolor);//nose |
tpettet3 | 1:89fd0d713ffc | 680 | break; |
tpettet3 | 1:89fd0d713ffc | 681 | case 13: |
tpettet3 | 3:dbae62823ec8 | 682 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 683 | pos1=1; |
tpettet3 | 1:89fd0d713ffc | 684 | pos2=0; |
tpettet3 | 1:89fd0d713ffc | 685 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 686 | pos4=1; |
tpettet3 | 1:89fd0d713ffc | 687 | pos5=1; |
tpettet3 | 1:89fd0d713ffc | 688 | pos6=0; |
tpettet3 | 3:dbae62823ec8 | 689 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 690 | pc.printf("%i should be 13 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 691 | lcd.filled_circle(col1, row1 , rmole, fill);// 1,4,5 |
tpettet3 | 9:867dde4be88a | 692 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 693 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 694 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 695 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 696 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 697 | lcd.filled_circle(col1, row1 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 698 | lcd.filled_circle(col1, row2 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 699 | lcd.filled_circle(col2, row2 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 700 | //face1 |
tpettet3 | 11:9c2e3efd7cda | 701 | lcd.line(lx114, eyey123 , lx214, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 702 | lcd.line(rx114, eyey123 , rx214, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 703 | lcd.line(lx114, wb123 , rx214, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 704 | lcd.line(lx114, wm123 , rx214, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 705 | lcd.line(lx114, wt123 , rx214, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 706 | lcd.filled_circle(col1, row1 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 707 | |
tpettet3 | 11:9c2e3efd7cda | 708 | //face4 |
tpettet3 | 11:9c2e3efd7cda | 709 | lcd.line(lx114, eyey456 , lx214, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 710 | lcd.line(rx114, eyey456 , rx214, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 711 | lcd.line(lx114, wb456 , rx214, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 712 | lcd.line(lx114, wm456 , rx214, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 713 | lcd.line(lx114, wt456 , rx214, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 714 | lcd.filled_circle(col1, row2 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 715 | //face5 |
tpettet3 | 11:9c2e3efd7cda | 716 | lcd.line(lx125, eyey456 , lx225, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 717 | lcd.line(rx125, eyey456 , rx225, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 718 | lcd.line(lx125, wb456 , rx225, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 719 | lcd.line(lx125, wm456 , rx225, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 720 | lcd.line(lx125, wt456 , rx225, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 721 | lcd.filled_circle(col2, row2 , rnose, nosecolor);//nose |
tpettet3 | 1:89fd0d713ffc | 722 | break; |
tpettet3 | 1:89fd0d713ffc | 723 | case 14: |
tpettet3 | 3:dbae62823ec8 | 724 | //POS_MUTEX.lock(); |
tpettet3 | 1:89fd0d713ffc | 725 | pos1=0; |
tpettet3 | 1:89fd0d713ffc | 726 | pos2=1; |
tpettet3 | 1:89fd0d713ffc | 727 | pos3=0; |
tpettet3 | 1:89fd0d713ffc | 728 | pos4=0; |
tpettet3 | 1:89fd0d713ffc | 729 | pos5=1; |
tpettet3 | 1:89fd0d713ffc | 730 | pos6=0; |
tpettet3 | 3:dbae62823ec8 | 731 | //POS_MUTEX.unlock(); |
tpettet3 | 1:89fd0d713ffc | 732 | pc.printf("%i should be 14 \n\r",state); |
tpettet3 | 1:89fd0d713ffc | 733 | |
tpettet3 | 9:867dde4be88a | 734 | lcd.filled_circle(col1, row1 , rmole, fill);// 2,5 |
tpettet3 | 9:867dde4be88a | 735 | lcd.filled_circle(col1, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 736 | lcd.filled_circle(col2, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 737 | lcd.filled_circle(col2, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 738 | lcd.filled_circle(col3, row1 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 739 | lcd.filled_circle(col3, row2 , rmole, fill); |
tpettet3 | 9:867dde4be88a | 740 | lcd.filled_circle(col2, row1 , rmole, mole); |
tpettet3 | 9:867dde4be88a | 741 | lcd.filled_circle(col2, row2 , rmole, mole); |
tpettet3 | 11:9c2e3efd7cda | 742 | |
tpettet3 | 11:9c2e3efd7cda | 743 | //face2 |
tpettet3 | 11:9c2e3efd7cda | 744 | lcd.line(lx125, eyey123 , lx225, eyey123, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 745 | lcd.line(rx125, eyey123 , rx225, eyey123, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 746 | lcd.line(lx125, wb123 , rx225, wt123, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 747 | lcd.line(lx125, wm123 , rx225, wm123, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 748 | lcd.line(lx125, wt123 , rx225, wb123, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 749 | lcd.filled_circle(col2, row1 , rnose, nosecolor);//nose |
tpettet3 | 11:9c2e3efd7cda | 750 | //face5 |
tpettet3 | 11:9c2e3efd7cda | 751 | lcd.line(lx125, eyey456 , lx225, eyey456, eyecolor);//left eye |
tpettet3 | 11:9c2e3efd7cda | 752 | lcd.line(rx125, eyey456 , rx225, eyey456, eyecolor);//right eye |
tpettet3 | 11:9c2e3efd7cda | 753 | lcd.line(lx125, wb456 , rx225, wt456, whisker);//bottom |
tpettet3 | 11:9c2e3efd7cda | 754 | lcd.line(lx125, wm456 , rx225, wm456, whisker);//middle |
tpettet3 | 11:9c2e3efd7cda | 755 | lcd.line(lx125, wt456 , rx225, wb456, whisker);//top |
tpettet3 | 11:9c2e3efd7cda | 756 | lcd.filled_circle(col2, row2 , rnose, nosecolor);//nose |
tpettet3 | 1:89fd0d713ffc | 757 | break; |
tpettet3 | 1:89fd0d713ffc | 758 | } |
tpettet3 | 8:e6e1e5b3f2a9 | 759 | wait(0.5); |
tpettet3 | 9:867dde4be88a | 760 | counter++; // increment counter and run the "state machine again" |
tpettet3 | 10:a31802412ab6 | 761 | lcd.text_string("Score: ", 1, 15, FONT_7X8, GREEN); |
tpettet3 | 10:a31802412ab6 | 762 | lcd.printf("%d",score); |
tpettet3 | 5:070755be0a77 | 763 | } |
tpettet3 | 11:9c2e3efd7cda | 764 | |
tpettet3 | 9:867dde4be88a | 765 | // clear the lcd screen |
tpettet3 | 9:867dde4be88a | 766 | lcd.cls(); |
tpettet3 | 9:867dde4be88a | 767 | wait(0.5); |
tpettet3 | 9:867dde4be88a | 768 | lcd.cls(); |
tpettet3 | 9:867dde4be88a | 769 | // int variable to read current high score |
tpettet3 | 7:5a8f9a018e1f | 770 | int please; |
tpettet3 | 7:5a8f9a018e1f | 771 | mkdir("/sd/mydir", 0777); |
tpettet3 | 7:5a8f9a018e1f | 772 | FILE *fp1 = fopen("/sd/mydir/sdtest.txt", "r"); |
tpettet3 | 7:5a8f9a018e1f | 773 | if(fp1 == NULL) |
tpettet3 | 7:5a8f9a018e1f | 774 | { |
tpettet3 | 7:5a8f9a018e1f | 775 | pc.printf("Could not open file for read\n"); |
tpettet3 | 7:5a8f9a018e1f | 776 | } |
tpettet3 | 7:5a8f9a018e1f | 777 | pc.printf("Opened file for read\n\r"); |
tpettet3 | 7:5a8f9a018e1f | 778 | fscanf (fp1, "%s", str); |
tpettet3 | 7:5a8f9a018e1f | 779 | sscanf(str, "%d", &please); |
tpettet3 | 7:5a8f9a018e1f | 780 | fclose(fp1); |
tpettet3 | 8:e6e1e5b3f2a9 | 781 | pc.printf (": %d \n",please); |
tpettet3 | 8:e6e1e5b3f2a9 | 782 | if (score > please) |
tpettet3 | 8:e6e1e5b3f2a9 | 783 | { |
tpettet3 | 8:e6e1e5b3f2a9 | 784 | FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); |
tpettet3 | 8:e6e1e5b3f2a9 | 785 | if(fp == NULL) { |
tpettet3 | 7:5a8f9a018e1f | 786 | error("Could not open file for write\n"); |
tpettet3 | 7:5a8f9a018e1f | 787 | } |
tpettet3 | 7:5a8f9a018e1f | 788 | char buf[10]; |
tpettet3 | 8:e6e1e5b3f2a9 | 789 | sprintf(buf, "%d", score); |
tpettet3 | 7:5a8f9a018e1f | 790 | fprintf(fp, "%s",buf); |
tpettet3 | 7:5a8f9a018e1f | 791 | fclose(fp); |
tpettet3 | 8:e6e1e5b3f2a9 | 792 | lcd.printf("CONGRATULATIONS!\n\n"); |
tpettet3 | 8:e6e1e5b3f2a9 | 793 | lcd.printf("You set the new\n\n"); |
tpettet3 | 8:e6e1e5b3f2a9 | 794 | lcd.printf("High score!!!!!!\n\n"); |
tpettet3 | 8:e6e1e5b3f2a9 | 795 | lcd.printf("New high score: %d\n\n",score); |
tpettet3 | 8:e6e1e5b3f2a9 | 796 | lcd.printf("Press reset to\n\n"); |
tpettet3 | 8:e6e1e5b3f2a9 | 797 | lcd.printf("Play Again!"); |
tpettet3 | 8:e6e1e5b3f2a9 | 798 | } |
tpettet3 | 8:e6e1e5b3f2a9 | 799 | else |
tpettet3 | 8:e6e1e5b3f2a9 | 800 | { |
tpettet3 | 8:e6e1e5b3f2a9 | 801 | lcd.printf("High score: %d\n\n",please); |
tpettet3 | 8:e6e1e5b3f2a9 | 802 | lcd.printf("Your score: %d\n\n",score); |
tpettet3 | 8:e6e1e5b3f2a9 | 803 | lcd.printf("You did not set\n\n"); |
tpettet3 | 8:e6e1e5b3f2a9 | 804 | lcd.printf("A new high score\n\n"); |
tpettet3 | 8:e6e1e5b3f2a9 | 805 | lcd.printf("Press reset to\n\n"); |
tpettet3 | 9:867dde4be88a | 806 | lcd.printf("Try again"); |
tpettet3 | 8:e6e1e5b3f2a9 | 807 | } |
tpettet3 | 8:e6e1e5b3f2a9 | 808 | |
tpettet3 | 9:867dde4be88a | 809 | pc.printf("Goodbye World!\n"); |
tpettet3 | 9:867dde4be88a | 810 | }//end |
4180_1 | 0:e09703934ff4 | 811 | |
4180_1 | 0:e09703934ff4 | 812 | |
4180_1 | 0:e09703934ff4 | 813 | |
tpettet3 | 1:89fd0d713ffc | 814 |