updated 7seg controls for new 7 seg boards

Dependencies:   PixelArray WS2812 mbed

Fork of frdm_pong_table_controller by Demo Team

Committer:
DanGibbons
Date:
Tue Jul 11 08:51:23 2017 +0000
Revision:
8:66dac2e00cce
Parent:
7:dc6f1f105c52
Child:
9:f3f194982bb3
Buttons debounced; Idle state reanimated (180 degreesa out of phase)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DanGibbons 4:2e80bd814f57 1 #include "main.h"
benswindell 0:f2b739e846ae 2
DanGibbons 4:2e80bd814f57 3 int main()
DanGibbons 4:2e80bd814f57 4 {
DanGibbons 4:2e80bd814f57 5 Setup();
DanGibbons 7:dc6f1f105c52 6
DanGibbons 7:dc6f1f105c52 7 pc.printf("\nIDLE");
benswindell 0:f2b739e846ae 8
DanGibbons 4:2e80bd814f57 9 while(1) {
DanGibbons 4:2e80bd814f57 10
DanGibbons 7:dc6f1f105c52 11 if (idle_flag == 0) {
DanGibbons 7:dc6f1f105c52 12
DanGibbons 7:dc6f1f105c52 13 if (idle_button_pressed == 1) { // button just pressed
DanGibbons 7:dc6f1f105c52 14
DanGibbons 7:dc6f1f105c52 15 pc.printf("\nIDLE");
DanGibbons 7:dc6f1f105c52 16
DanGibbons 7:dc6f1f105c52 17 idle_button_pressed = 0;
DanGibbons 7:dc6f1f105c52 18
DanGibbons 7:dc6f1f105c52 19 PlayToIdleTransition();
DanGibbons 7:dc6f1f105c52 20
DanGibbons 7:dc6f1f105c52 21 }
DanGibbons 7:dc6f1f105c52 22
DanGibbons 7:dc6f1f105c52 23 CircleAnimation(true,true,true,true,1);
benswindell 0:f2b739e846ae 24
DanGibbons 7:dc6f1f105c52 25 wait(0.02);
DanGibbons 7:dc6f1f105c52 26
DanGibbons 4:2e80bd814f57 27 }
DanGibbons 7:dc6f1f105c52 28
DanGibbons 7:dc6f1f105c52 29 if (idle_flag == 1) {
DanGibbons 7:dc6f1f105c52 30
DanGibbons 7:dc6f1f105c52 31 if (idle_button_pressed == 1) { // button just pressed
DanGibbons 7:dc6f1f105c52 32
DanGibbons 7:dc6f1f105c52 33 pc.printf("\nPLAY");
DanGibbons 7:dc6f1f105c52 34
DanGibbons 7:dc6f1f105c52 35 idle_button_pressed = 0;
DanGibbons 7:dc6f1f105c52 36
DanGibbons 7:dc6f1f105c52 37 IdleToPlayTransition();
DanGibbons 7:dc6f1f105c52 38
DanGibbons 7:dc6f1f105c52 39 }
DanGibbons 7:dc6f1f105c52 40
DanGibbons 7:dc6f1f105c52 41 double rbbValue = robotBreakBeam; // Read Robot Break beam
DanGibbons 7:dc6f1f105c52 42 double pbbValue = playerBreakBeam; // Read Player Break beam
benswindell 0:f2b739e846ae 43
DanGibbons 7:dc6f1f105c52 44 // IF PLAYER HAS SCORED A GOAL
DanGibbons 7:dc6f1f105c52 45 if (((prevRbbValue - rbbValue)>0.03)|| (PB1==0)) {
DanGibbons 7:dc6f1f105c52 46 //pc.printf("Player has scored a goal \n\r");
DanGibbons 7:dc6f1f105c52 47 HandleGoal(false);
DanGibbons 7:dc6f1f105c52 48 }
benswindell 0:f2b739e846ae 49
DanGibbons 7:dc6f1f105c52 50 // IF ROBOT HAS SCORED A GOAL
DanGibbons 7:dc6f1f105c52 51 if (((prevPbbValue - pbbValue) > 0.03)|| (PB2==0)) {
DanGibbons 7:dc6f1f105c52 52 //pc.printf("Robot has scored a goal \n\r");
DanGibbons 7:dc6f1f105c52 53 HandleGoal(true);
DanGibbons 7:dc6f1f105c52 54 }
DanGibbons 7:dc6f1f105c52 55
DanGibbons 7:dc6f1f105c52 56 prevRbbValue = rbbValue;
DanGibbons 7:dc6f1f105c52 57 prevPbbValue = pbbValue;
DanGibbons 7:dc6f1f105c52 58
DanGibbons 7:dc6f1f105c52 59 //pc.printf("PlayerGoal: %f, RobotGoal: %f \r\n",pbbValue,rbbValue);
DanGibbons 7:dc6f1f105c52 60 //pc.printf("Player: %i v %i : Robot \r\n",playerScore,robotScore);
DanGibbons 7:dc6f1f105c52 61 wait(0.02);
DanGibbons 7:dc6f1f105c52 62
DanGibbons 7:dc6f1f105c52 63 }
benswindell 0:f2b739e846ae 64
DanGibbons 4:2e80bd814f57 65 }
DanGibbons 6:5e8e2645cd93 66
DanGibbons 4:2e80bd814f57 67 }
samuelmoss 2:ff409472bc08 68
DanGibbons 4:2e80bd814f57 69 void Setup()
benswindell 0:f2b739e846ae 70 {
benswindell 0:f2b739e846ae 71 // Turn on green LED
benswindell 0:f2b739e846ae 72 led_green = 0;
DanGibbons 6:5e8e2645cd93 73
DanGibbons 8:66dac2e00cce 74 // enable the internal pull-down resistor on idleButton
DanGibbons 8:66dac2e00cce 75 idleButton.mode(PullDown);
DanGibbons 8:66dac2e00cce 76
DanGibbons 6:5e8e2645cd93 77 // attach idle button isr to rising edge of button press
DanGibbons 6:5e8e2645cd93 78 idleButton.rise(&idleButtonISR);
DanGibbons 6:5e8e2645cd93 79
benswindell 1:24bc4d8ed2ae 80 // Set brightness of the 4 LED strips
samuelmoss 2:ff409472bc08 81 robotScoreLED.setII(0xB0);
benswindell 1:24bc4d8ed2ae 82 robotScoreLED.useII(WS2812::GLOBAL);
samuelmoss 2:ff409472bc08 83 playerScoreLED.setII(0xB0);
benswindell 1:24bc4d8ed2ae 84 playerScoreLED.useII(WS2812::GLOBAL);
DanGibbons 4:2e80bd814f57 85
benswindell 0:f2b739e846ae 86 // Set scores to 0
benswindell 0:f2b739e846ae 87 robotScore = 0;
benswindell 0:f2b739e846ae 88 playerScore = 0;
benswindell 0:f2b739e846ae 89 numFlashes = 0;
DanGibbons 5:2d439ccefc7d 90
DanGibbons 7:dc6f1f105c52 91 memset(mainArray, 0, sizeof mainArray);
DanGibbons 7:dc6f1f105c52 92
DanGibbons 7:dc6f1f105c52 93 // Turn off green LED
DanGibbons 7:dc6f1f105c52 94 led_green = 1;
DanGibbons 7:dc6f1f105c52 95
DanGibbons 7:dc6f1f105c52 96 }
DanGibbons 7:dc6f1f105c52 97
DanGibbons 7:dc6f1f105c52 98 void IdleToPlayTransition()
DanGibbons 7:dc6f1f105c52 99 {
DanGibbons 7:dc6f1f105c52 100 robotScore = 0;
DanGibbons 7:dc6f1f105c52 101 playerScore = 0;
DanGibbons 7:dc6f1f105c52 102
DanGibbons 7:dc6f1f105c52 103 memset(mainArray, 0, sizeof mainArray);
DanGibbons 7:dc6f1f105c52 104
DanGibbons 8:66dac2e00cce 105 for (int i = 9; i < 115; i++) { // loop to set LEDs around the circle from start of segment A to end of Segment F
DanGibbons 7:dc6f1f105c52 106
DanGibbons 8:66dac2e00cce 107 if (i < 104) {
DanGibbons 8:66dac2e00cce 108 mainArray[0][i] = 1;
DanGibbons 8:66dac2e00cce 109 }
DanGibbons 8:66dac2e00cce 110 if (i > 103) {
DanGibbons 8:66dac2e00cce 111 mainArray[0][i-104] = 1;
DanGibbons 8:66dac2e00cce 112 }
DanGibbons 8:66dac2e00cce 113 if (i < 19) {
DanGibbons 8:66dac2e00cce 114 mainArray[1][18-i] = 1;
DanGibbons 8:66dac2e00cce 115 }
DanGibbons 8:66dac2e00cce 116 if (i > 18) {
DanGibbons 8:66dac2e00cce 117 mainArray[1][122-i] = 1;
DanGibbons 8:66dac2e00cce 118 }
DanGibbons 7:dc6f1f105c52 119
DanGibbons 7:dc6f1f105c52 120 wait_ms(10);
DanGibbons 7:dc6f1f105c52 121
DanGibbons 8:66dac2e00cce 122 WritePxAnimation(0,false,true);
DanGibbons 7:dc6f1f105c52 123 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 8:66dac2e00cce 124 WritePxAnimation(1,true,true);
DanGibbons 7:dc6f1f105c52 125 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 8:66dac2e00cce 126
DanGibbons 7:dc6f1f105c52 127 }
DanGibbons 7:dc6f1f105c52 128
DanGibbons 7:dc6f1f105c52 129 DrainAnimation(true,true,robotScore,true,true,playerScore);
DanGibbons 5:2d439ccefc7d 130
DanGibbons 7:dc6f1f105c52 131 wait(1);
DanGibbons 7:dc6f1f105c52 132
DanGibbons 8:66dac2e00cce 133 WriteScores();
DanGibbons 8:66dac2e00cce 134
DanGibbons 8:66dac2e00cce 135 idleButton.enable_irq();
DanGibbons 5:2d439ccefc7d 136
DanGibbons 7:dc6f1f105c52 137 }
samuelmoss 2:ff409472bc08 138
DanGibbons 7:dc6f1f105c52 139 void PlayToIdleTransition()
DanGibbons 7:dc6f1f105c52 140 {
DanGibbons 7:dc6f1f105c52 141 robotScore = 0;
DanGibbons 7:dc6f1f105c52 142 playerScore = 0;
DanGibbons 7:dc6f1f105c52 143 memset(mainArray, 0, sizeof mainArray);
DanGibbons 7:dc6f1f105c52 144
DanGibbons 8:66dac2e00cce 145 wait(1);
DanGibbons 8:66dac2e00cce 146
DanGibbons 8:66dac2e00cce 147 idleButton.enable_irq();
DanGibbons 8:66dac2e00cce 148
benswindell 0:f2b739e846ae 149 }
benswindell 0:f2b739e846ae 150
DanGibbons 7:dc6f1f105c52 151
DanGibbons 5:2d439ccefc7d 152 // set segment number patterns
DanGibbons 4:2e80bd814f57 153 void SetNumberPatterns()
benswindell 0:f2b739e846ae 154 {
DanGibbons 4:2e80bd814f57 155 for (int num = 0; num < 11; num++) {
benswindell 0:f2b739e846ae 156
DanGibbons 4:2e80bd814f57 157 switch (num) {
DanGibbons 4:2e80bd814f57 158 case 0 :
DanGibbons 4:2e80bd814f57 159 // 0
DanGibbons 4:2e80bd814f57 160 seg1A = 1;
DanGibbons 4:2e80bd814f57 161 seg1B = 1;
DanGibbons 4:2e80bd814f57 162 seg1C = 1;
DanGibbons 4:2e80bd814f57 163 seg1D = 1;
DanGibbons 4:2e80bd814f57 164 seg1E = 1;
DanGibbons 4:2e80bd814f57 165 seg1F = 1;
DanGibbons 4:2e80bd814f57 166 seg1G = 0;
benswindell 0:f2b739e846ae 167
DanGibbons 4:2e80bd814f57 168 SetLEDArray(0);
DanGibbons 4:2e80bd814f57 169 break;
benswindell 0:f2b739e846ae 170
DanGibbons 4:2e80bd814f57 171 case 1 :
DanGibbons 4:2e80bd814f57 172 // 1
DanGibbons 4:2e80bd814f57 173 seg1A = 0;
DanGibbons 4:2e80bd814f57 174 seg1B = 1;
DanGibbons 4:2e80bd814f57 175 seg1C = 1;
DanGibbons 4:2e80bd814f57 176 seg1D = 0;
DanGibbons 4:2e80bd814f57 177 seg1E = 0;
DanGibbons 4:2e80bd814f57 178 seg1F = 0;
DanGibbons 4:2e80bd814f57 179 seg1G = 0;
benswindell 0:f2b739e846ae 180
DanGibbons 4:2e80bd814f57 181 SetLEDArray(1);
DanGibbons 4:2e80bd814f57 182 break;
benswindell 0:f2b739e846ae 183
DanGibbons 4:2e80bd814f57 184 case 2 :
DanGibbons 4:2e80bd814f57 185 // 2
DanGibbons 4:2e80bd814f57 186 seg1A = 1;
DanGibbons 4:2e80bd814f57 187 seg1B = 1;
DanGibbons 4:2e80bd814f57 188 seg1C = 0;
DanGibbons 4:2e80bd814f57 189 seg1D = 1;
DanGibbons 4:2e80bd814f57 190 seg1E = 1;
DanGibbons 4:2e80bd814f57 191 seg1F = 0;
DanGibbons 4:2e80bd814f57 192 seg1G = 1;
benswindell 0:f2b739e846ae 193
DanGibbons 4:2e80bd814f57 194 SetLEDArray(2);
DanGibbons 4:2e80bd814f57 195 break;
benswindell 0:f2b739e846ae 196
DanGibbons 4:2e80bd814f57 197 case 3 :
DanGibbons 4:2e80bd814f57 198 // 3
DanGibbons 4:2e80bd814f57 199 seg1A = 1;
DanGibbons 4:2e80bd814f57 200 seg1B = 1;
DanGibbons 4:2e80bd814f57 201 seg1C = 1;
DanGibbons 4:2e80bd814f57 202 seg1D = 1;
DanGibbons 4:2e80bd814f57 203 seg1E = 0;
DanGibbons 4:2e80bd814f57 204 seg1F = 0;
DanGibbons 4:2e80bd814f57 205 seg1G = 1;
benswindell 0:f2b739e846ae 206
DanGibbons 4:2e80bd814f57 207 SetLEDArray(3);
DanGibbons 4:2e80bd814f57 208 break;
benswindell 0:f2b739e846ae 209
DanGibbons 4:2e80bd814f57 210 case 4:
DanGibbons 4:2e80bd814f57 211 // 4
DanGibbons 4:2e80bd814f57 212 seg1A = 0;
DanGibbons 4:2e80bd814f57 213 seg1B = 1;
DanGibbons 4:2e80bd814f57 214 seg1C = 1;
DanGibbons 4:2e80bd814f57 215 seg1D = 0;
DanGibbons 4:2e80bd814f57 216 seg1E = 0;
DanGibbons 4:2e80bd814f57 217 seg1F = 1;
DanGibbons 4:2e80bd814f57 218 seg1G = 1;
benswindell 0:f2b739e846ae 219
DanGibbons 4:2e80bd814f57 220 SetLEDArray(4);
DanGibbons 4:2e80bd814f57 221 break;
benswindell 0:f2b739e846ae 222
DanGibbons 4:2e80bd814f57 223 case 5:
DanGibbons 4:2e80bd814f57 224 // 5
DanGibbons 4:2e80bd814f57 225 seg1A = 1;
DanGibbons 4:2e80bd814f57 226 seg1B = 0;
DanGibbons 4:2e80bd814f57 227 seg1C = 1;
DanGibbons 4:2e80bd814f57 228 seg1D = 1;
DanGibbons 4:2e80bd814f57 229 seg1E = 0;
DanGibbons 4:2e80bd814f57 230 seg1F = 1;
DanGibbons 4:2e80bd814f57 231 seg1G = 1;
benswindell 0:f2b739e846ae 232
DanGibbons 4:2e80bd814f57 233 SetLEDArray(5);
DanGibbons 4:2e80bd814f57 234 break;
benswindell 0:f2b739e846ae 235
DanGibbons 4:2e80bd814f57 236 case 6:
DanGibbons 4:2e80bd814f57 237 // 6
DanGibbons 4:2e80bd814f57 238 seg1A = 1;
DanGibbons 4:2e80bd814f57 239 seg1B = 0;
DanGibbons 4:2e80bd814f57 240 seg1C = 1;
DanGibbons 4:2e80bd814f57 241 seg1D = 1;
DanGibbons 4:2e80bd814f57 242 seg1E = 1;
DanGibbons 4:2e80bd814f57 243 seg1F = 1;
DanGibbons 4:2e80bd814f57 244 seg1G = 1;
benswindell 0:f2b739e846ae 245
DanGibbons 4:2e80bd814f57 246 SetLEDArray(6);
DanGibbons 4:2e80bd814f57 247 break;
benswindell 0:f2b739e846ae 248
DanGibbons 4:2e80bd814f57 249 case 7:
DanGibbons 4:2e80bd814f57 250 // 7
DanGibbons 4:2e80bd814f57 251 seg1A = 1;
DanGibbons 4:2e80bd814f57 252 seg1B = 1;
DanGibbons 4:2e80bd814f57 253 seg1C = 1;
DanGibbons 4:2e80bd814f57 254 seg1D = 0;
DanGibbons 4:2e80bd814f57 255 seg1E = 0;
DanGibbons 4:2e80bd814f57 256 seg1F = 0;
DanGibbons 4:2e80bd814f57 257 seg1G = 0;
benswindell 0:f2b739e846ae 258
DanGibbons 4:2e80bd814f57 259 SetLEDArray(7);
DanGibbons 4:2e80bd814f57 260 break;
benswindell 0:f2b739e846ae 261
DanGibbons 4:2e80bd814f57 262 case 8:
DanGibbons 4:2e80bd814f57 263 // 8
DanGibbons 4:2e80bd814f57 264 seg1A = 1;
DanGibbons 4:2e80bd814f57 265 seg1B = 1;
DanGibbons 4:2e80bd814f57 266 seg1C = 1;
DanGibbons 4:2e80bd814f57 267 seg1D = 1;
DanGibbons 4:2e80bd814f57 268 seg1E = 1;
DanGibbons 4:2e80bd814f57 269 seg1F = 1;
DanGibbons 4:2e80bd814f57 270 seg1G = 1;
benswindell 0:f2b739e846ae 271
DanGibbons 4:2e80bd814f57 272 SetLEDArray(8);
DanGibbons 4:2e80bd814f57 273 break;
benswindell 0:f2b739e846ae 274
DanGibbons 4:2e80bd814f57 275 case 9:
DanGibbons 4:2e80bd814f57 276 // 9
DanGibbons 4:2e80bd814f57 277 seg1A = 1;
DanGibbons 4:2e80bd814f57 278 seg1B = 1;
DanGibbons 4:2e80bd814f57 279 seg1C = 1;
DanGibbons 4:2e80bd814f57 280 seg1D = 0;
DanGibbons 4:2e80bd814f57 281 seg1E = 0;
DanGibbons 4:2e80bd814f57 282 seg1F = 1;
DanGibbons 4:2e80bd814f57 283 seg1G = 1;
benswindell 0:f2b739e846ae 284
DanGibbons 4:2e80bd814f57 285 SetLEDArray(9);
DanGibbons 4:2e80bd814f57 286 break;
benswindell 0:f2b739e846ae 287
DanGibbons 4:2e80bd814f57 288 case 10:
DanGibbons 4:2e80bd814f57 289 // OFF
DanGibbons 4:2e80bd814f57 290 seg1A = 0;
DanGibbons 4:2e80bd814f57 291 seg1B = 0;
DanGibbons 4:2e80bd814f57 292 seg1C = 0;
DanGibbons 4:2e80bd814f57 293 seg1D = 0;
DanGibbons 4:2e80bd814f57 294 seg1E = 0;
DanGibbons 4:2e80bd814f57 295 seg1F = 0;
DanGibbons 4:2e80bd814f57 296 seg1G = 0;
benswindell 0:f2b739e846ae 297
DanGibbons 4:2e80bd814f57 298 SetLEDArray(10);
DanGibbons 4:2e80bd814f57 299 break;
benswindell 0:f2b739e846ae 300
DanGibbons 4:2e80bd814f57 301 default :
benswindell 0:f2b739e846ae 302
DanGibbons 4:2e80bd814f57 303 break;
DanGibbons 4:2e80bd814f57 304
DanGibbons 4:2e80bd814f57 305 }
benswindell 0:f2b739e846ae 306
benswindell 0:f2b739e846ae 307 }
DanGibbons 4:2e80bd814f57 308
DanGibbons 4:2e80bd814f57 309 }
DanGibbons 4:2e80bd814f57 310
benswindell 0:f2b739e846ae 311 // Write segment config to main array
benswindell 0:f2b739e846ae 312 void SetLEDArray(int x)
benswindell 0:f2b739e846ae 313 {
benswindell 0:f2b739e846ae 314 for (int i = 0; i < WS2812_BUF; i++) {
samuelmoss 2:ff409472bc08 315 if (i < 18) {
DanGibbons 5:2d439ccefc7d 316 mainArray[x][i] = seg1A;
benswindell 0:f2b739e846ae 317 }
benswindell 0:f2b739e846ae 318
samuelmoss 2:ff409472bc08 319 if ( i >= 18 && i < 35) {
benswindell 0:f2b739e846ae 320 mainArray[x][i] = seg1B;
benswindell 0:f2b739e846ae 321 }
benswindell 0:f2b739e846ae 322
samuelmoss 2:ff409472bc08 323 if (i >= 35 && i < 52) {
benswindell 0:f2b739e846ae 324 mainArray[x][i] = seg1C;
benswindell 0:f2b739e846ae 325 }
benswindell 0:f2b739e846ae 326
samuelmoss 2:ff409472bc08 327 if (i >= 52 && i < 70) {
benswindell 0:f2b739e846ae 328 mainArray[x][i]= seg1D;
benswindell 0:f2b739e846ae 329 }
benswindell 0:f2b739e846ae 330
samuelmoss 2:ff409472bc08 331 if ( i >= 70 && i < 87) {
benswindell 0:f2b739e846ae 332 mainArray[x][i] = seg1E;
benswindell 0:f2b739e846ae 333 }
benswindell 0:f2b739e846ae 334
samuelmoss 2:ff409472bc08 335 if (i >= 87 && i < 104) {
benswindell 0:f2b739e846ae 336 mainArray[x][i] = seg1F;
benswindell 0:f2b739e846ae 337 }
benswindell 0:f2b739e846ae 338
samuelmoss 2:ff409472bc08 339 if ( i >= 104 && i < 122) {
benswindell 0:f2b739e846ae 340 mainArray[x][i] = seg1G;
benswindell 0:f2b739e846ae 341 }
DanGibbons 4:2e80bd814f57 342 }
benswindell 0:f2b739e846ae 343 }
benswindell 0:f2b739e846ae 344
benswindell 1:24bc4d8ed2ae 345 // Update both Score LEDs with the current score
DanGibbons 8:66dac2e00cce 346 void WriteScores()
benswindell 0:f2b739e846ae 347 {
DanGibbons 8:66dac2e00cce 348 SetNumberPatterns();
DanGibbons 6:5e8e2645cd93 349 WritePxAnimation(playerScore,false,false);
benswindell 1:24bc4d8ed2ae 350 playerScoreLED.write(playerScorePx.getBuf());
benswindell 0:f2b739e846ae 351 wait(0.01);
DanGibbons 6:5e8e2645cd93 352 WritePxAnimation(robotScore,true,false);
benswindell 1:24bc4d8ed2ae 353 robotScoreLED.write(robotScorePx.getBuf());
benswindell 0:f2b739e846ae 354 }
benswindell 0:f2b739e846ae 355
DanGibbons 6:5e8e2645cd93 356 // Write Pixel array with either random colour pattern or in standard blue
DanGibbons 6:5e8e2645cd93 357 void WritePxAnimation(int line_num,bool isRobot,bool colour)
benswindell 0:f2b739e846ae 358 {
DanGibbons 6:5e8e2645cd93 359 if (colour == true) { // random colours
DanGibbons 6:5e8e2645cd93 360 if(isRobot == true) {
benswindell 1:24bc4d8ed2ae 361
DanGibbons 6:5e8e2645cd93 362 for (int i = 0; i < WS2812_BUF; i++) {
DanGibbons 6:5e8e2645cd93 363 if (mainArray[line_num][i] == 0) {
DanGibbons 6:5e8e2645cd93 364 robotScorePx.Set(i,OFF);
DanGibbons 6:5e8e2645cd93 365 }
DanGibbons 5:2d439ccefc7d 366
DanGibbons 6:5e8e2645cd93 367 if (mainArray[line_num][i] == 1) {
DanGibbons 6:5e8e2645cd93 368 robotScorePx.Set(i,rand_colors[rand() % 10]);
DanGibbons 6:5e8e2645cd93 369 }
DanGibbons 5:2d439ccefc7d 370 }
DanGibbons 6:5e8e2645cd93 371 } else {
DanGibbons 6:5e8e2645cd93 372 for (int i = 0; i < WS2812_BUF; i++) {
DanGibbons 6:5e8e2645cd93 373 if (mainArray[line_num][i] == 0) {
DanGibbons 6:5e8e2645cd93 374 playerScorePx.Set(i,OFF);
DanGibbons 6:5e8e2645cd93 375 }
DanGibbons 5:2d439ccefc7d 376
DanGibbons 6:5e8e2645cd93 377 if (mainArray[line_num][i] == 1) {
DanGibbons 6:5e8e2645cd93 378 playerScorePx.Set(i,rand_colors[rand() % 10]);
DanGibbons 6:5e8e2645cd93 379 }
DanGibbons 5:2d439ccefc7d 380 }
DanGibbons 5:2d439ccefc7d 381 }
DanGibbons 6:5e8e2645cd93 382 } else { // blue
DanGibbons 6:5e8e2645cd93 383 if(isRobot == true) {
DanGibbons 6:5e8e2645cd93 384
DanGibbons 6:5e8e2645cd93 385 for (int i = 0; i < WS2812_BUF; i++) {
DanGibbons 6:5e8e2645cd93 386 if (mainArray[line_num][i] == 0) {
DanGibbons 6:5e8e2645cd93 387 robotScorePx.Set(i,OFF);
DanGibbons 6:5e8e2645cd93 388 }
DanGibbons 6:5e8e2645cd93 389
DanGibbons 6:5e8e2645cd93 390 if (mainArray[line_num][i] == 1) {
DanGibbons 6:5e8e2645cd93 391 robotScorePx.Set(i,BLUE);
DanGibbons 6:5e8e2645cd93 392 }
DanGibbons 5:2d439ccefc7d 393 }
DanGibbons 6:5e8e2645cd93 394 } else {
DanGibbons 6:5e8e2645cd93 395 for (int i = 0; i < WS2812_BUF; i++) {
DanGibbons 6:5e8e2645cd93 396 if (mainArray[line_num][i] == 0) {
DanGibbons 6:5e8e2645cd93 397 playerScorePx.Set(i,OFF);
DanGibbons 6:5e8e2645cd93 398 }
DanGibbons 5:2d439ccefc7d 399
DanGibbons 6:5e8e2645cd93 400 if (mainArray[line_num][i] == 1) {
DanGibbons 6:5e8e2645cd93 401 playerScorePx.Set(i,BLUE);
DanGibbons 6:5e8e2645cd93 402 }
DanGibbons 5:2d439ccefc7d 403 }
DanGibbons 5:2d439ccefc7d 404 }
DanGibbons 5:2d439ccefc7d 405
DanGibbons 6:5e8e2645cd93 406 }
DanGibbons 6:5e8e2645cd93 407 }
benswindell 0:f2b739e846ae 408
DanGibbons 6:5e8e2645cd93 409 // Handle behaviour for the goal scored event
benswindell 0:f2b739e846ae 410 void HandleGoal(bool hasRobotScored)
benswindell 0:f2b739e846ae 411 {
DanGibbons 4:2e80bd814f57 412 GoalAnimation(hasRobotScored);
benswindell 1:24bc4d8ed2ae 413
benswindell 1:24bc4d8ed2ae 414 // If either player reaches the score limit, then call HandleWin(). If not, then turn goal LEDs off
benswindell 1:24bc4d8ed2ae 415 if(robotScore == scoreLimit || playerScore == scoreLimit) {
benswindell 1:24bc4d8ed2ae 416 HandleWin();
samuelmoss 2:ff409472bc08 417 }
benswindell 1:24bc4d8ed2ae 418 }
benswindell 1:24bc4d8ed2ae 419
benswindell 1:24bc4d8ed2ae 420 // Handle behaviour when either the player or robot has won a game.
benswindell 1:24bc4d8ed2ae 421 void HandleWin()
benswindell 1:24bc4d8ed2ae 422 {
benswindell 1:24bc4d8ed2ae 423 // Initalise variable as true
benswindell 1:24bc4d8ed2ae 424 bool isRobotWinner = true;
benswindell 1:24bc4d8ed2ae 425
benswindell 1:24bc4d8ed2ae 426 // Decide if the robot is the winner. If not, then change isRobotWinner to false
benswindell 1:24bc4d8ed2ae 427 if(playerScore == scoreLimit) {
DanGibbons 4:2e80bd814f57 428
benswindell 1:24bc4d8ed2ae 429 isRobotWinner = false;
benswindell 1:24bc4d8ed2ae 430 pc.printf("Player won!");
DanGibbons 4:2e80bd814f57 431 WinAnimation(isRobotWinner);
benswindell 1:24bc4d8ed2ae 432
benswindell 1:24bc4d8ed2ae 433 } else {
benswindell 1:24bc4d8ed2ae 434 pc.printf("Robot won!");
DanGibbons 4:2e80bd814f57 435 WinAnimation(isRobotWinner);
benswindell 1:24bc4d8ed2ae 436
benswindell 1:24bc4d8ed2ae 437 }
benswindell 1:24bc4d8ed2ae 438
benswindell 1:24bc4d8ed2ae 439 // Reset scores then write to LEDs
benswindell 1:24bc4d8ed2ae 440 robotScore = 0;
benswindell 1:24bc4d8ed2ae 441 playerScore = 0;
DanGibbons 5:2d439ccefc7d 442
DanGibbons 7:dc6f1f105c52 443 idle_flag = 0;
DanGibbons 5:2d439ccefc7d 444
DanGibbons 7:dc6f1f105c52 445 memset(mainArray, 0, sizeof mainArray);
DanGibbons 6:5e8e2645cd93 446
benswindell 0:f2b739e846ae 447 }
benswindell 0:f2b739e846ae 448
DanGibbons 5:2d439ccefc7d 449 // animation for when a goal is scored
DanGibbons 4:2e80bd814f57 450 void GoalAnimation(bool hasRobotScored)
benswindell 0:f2b739e846ae 451 {
DanGibbons 4:2e80bd814f57 452 if(hasRobotScored == true) {
DanGibbons 6:5e8e2645cd93 453
DanGibbons 6:5e8e2645cd93 454 switch (robotScore) {
DanGibbons 6:5e8e2645cd93 455 case 0:
DanGibbons 6:5e8e2645cd93 456 ZeroOutAnimation(true,false,false,false);
DanGibbons 6:5e8e2645cd93 457 break;
DanGibbons 6:5e8e2645cd93 458 case 1:
DanGibbons 6:5e8e2645cd93 459 OneOutAnimation(true,false,false,false);
DanGibbons 6:5e8e2645cd93 460 break;
DanGibbons 6:5e8e2645cd93 461 case 2:
DanGibbons 6:5e8e2645cd93 462 TwoOutAnimation(true,false,false,false);
DanGibbons 6:5e8e2645cd93 463 break;
DanGibbons 6:5e8e2645cd93 464 case 3:
DanGibbons 6:5e8e2645cd93 465 ThreeOutAnimation(true,false,false,false);
DanGibbons 6:5e8e2645cd93 466 default :
DanGibbons 6:5e8e2645cd93 467 break;
DanGibbons 6:5e8e2645cd93 468 }
DanGibbons 6:5e8e2645cd93 469
DanGibbons 4:2e80bd814f57 470 robotScore++;
DanGibbons 5:2d439ccefc7d 471 wait_ms(250);
DanGibbons 6:5e8e2645cd93 472
DanGibbons 6:5e8e2645cd93 473 switch (robotScore) {
DanGibbons 6:5e8e2645cd93 474 case 0:
DanGibbons 6:5e8e2645cd93 475 ZeroInAnimation(true,false,false,false);
DanGibbons 6:5e8e2645cd93 476 break;
DanGibbons 6:5e8e2645cd93 477 case 1:
DanGibbons 6:5e8e2645cd93 478 OneInAnimation(true,false,false,false);
DanGibbons 6:5e8e2645cd93 479 break;
DanGibbons 6:5e8e2645cd93 480 case 2:
DanGibbons 6:5e8e2645cd93 481 TwoInAnimation(true,false,false,false);
DanGibbons 6:5e8e2645cd93 482 break;
DanGibbons 6:5e8e2645cd93 483 case 3:
DanGibbons 6:5e8e2645cd93 484 ThreeInAnimation(true,true,false,false);
DanGibbons 6:5e8e2645cd93 485 default :
DanGibbons 6:5e8e2645cd93 486 break;
DanGibbons 6:5e8e2645cd93 487 }
DanGibbons 4:2e80bd814f57 488
DanGibbons 4:2e80bd814f57 489 } else {
DanGibbons 6:5e8e2645cd93 490
DanGibbons 6:5e8e2645cd93 491 switch (playerScore) {
DanGibbons 6:5e8e2645cd93 492 case 0:
DanGibbons 6:5e8e2645cd93 493 ZeroOutAnimation(false,false,true,false);
DanGibbons 6:5e8e2645cd93 494 break;
DanGibbons 6:5e8e2645cd93 495 case 1:
DanGibbons 6:5e8e2645cd93 496 OneOutAnimation(false,false,true,false);
DanGibbons 6:5e8e2645cd93 497 break;
DanGibbons 6:5e8e2645cd93 498 case 2:
DanGibbons 6:5e8e2645cd93 499 TwoOutAnimation(false,false,true,false);
DanGibbons 6:5e8e2645cd93 500 break;
DanGibbons 6:5e8e2645cd93 501 case 3:
DanGibbons 6:5e8e2645cd93 502 ThreeOutAnimation(false,false ,true,false);
DanGibbons 6:5e8e2645cd93 503 default :
DanGibbons 6:5e8e2645cd93 504 break;
DanGibbons 6:5e8e2645cd93 505 }
DanGibbons 4:2e80bd814f57 506 playerScore++;
DanGibbons 5:2d439ccefc7d 507 wait_ms(250);
DanGibbons 6:5e8e2645cd93 508
DanGibbons 6:5e8e2645cd93 509 switch (playerScore) {
DanGibbons 6:5e8e2645cd93 510 case 0:
DanGibbons 6:5e8e2645cd93 511 ZeroInAnimation(false,false,true,false);
DanGibbons 6:5e8e2645cd93 512 break;
DanGibbons 6:5e8e2645cd93 513 case 1:
DanGibbons 6:5e8e2645cd93 514 OneInAnimation(false,false,true,false);
DanGibbons 6:5e8e2645cd93 515 break;
DanGibbons 6:5e8e2645cd93 516 case 2:
DanGibbons 6:5e8e2645cd93 517 TwoInAnimation(false,false,true,false);
DanGibbons 6:5e8e2645cd93 518 break;
DanGibbons 6:5e8e2645cd93 519 case 3:
DanGibbons 6:5e8e2645cd93 520 ThreeInAnimation(false,false,true,true);
DanGibbons 6:5e8e2645cd93 521 default :
DanGibbons 6:5e8e2645cd93 522 break;
DanGibbons 6:5e8e2645cd93 523 }
DanGibbons 4:2e80bd814f57 524 }
DanGibbons 4:2e80bd814f57 525
DanGibbons 4:2e80bd814f57 526 }
benswindell 0:f2b739e846ae 527
DanGibbons 5:2d439ccefc7d 528 // animation when player or robot win the game
DanGibbons 4:2e80bd814f57 529 void WinAnimation(bool isRobotWinner)
DanGibbons 4:2e80bd814f57 530 {
DanGibbons 4:2e80bd814f57 531 if(isRobotWinner == false) {
DanGibbons 4:2e80bd814f57 532
DanGibbons 6:5e8e2645cd93 533 // dim brightness of the robot score because it lost
DanGibbons 6:5e8e2645cd93 534 robotScoreLED.setII(0x20);
DanGibbons 6:5e8e2645cd93 535 robotScoreLED.useII(WS2812::GLOBAL);
DanGibbons 6:5e8e2645cd93 536 robotScoreLED.write(robotScorePx.getBuf()); // rewrite buffer to change brightness
DanGibbons 6:5e8e2645cd93 537
DanGibbons 6:5e8e2645cd93 538 for (int i = 0; i < 80; i++) { // flash player score with changing random colours
DanGibbons 6:5e8e2645cd93 539 WritePxAnimation(playerScore,false,true);
DanGibbons 5:2d439ccefc7d 540 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 541 wait_ms(50);
DanGibbons 5:2d439ccefc7d 542 }
DanGibbons 5:2d439ccefc7d 543
DanGibbons 6:5e8e2645cd93 544 DrainAnimation(true,false,robotScore,true,true,playerScore); // drain both scores away with the player score in random colours
DanGibbons 6:5e8e2645cd93 545
DanGibbons 6:5e8e2645cd93 546 // reset robot score brightness
DanGibbons 6:5e8e2645cd93 547 robotScoreLED.setII(0xB0);
DanGibbons 6:5e8e2645cd93 548 robotScoreLED.useII(WS2812::GLOBAL);
DanGibbons 5:2d439ccefc7d 549
DanGibbons 4:2e80bd814f57 550 } else {
DanGibbons 4:2e80bd814f57 551
DanGibbons 6:5e8e2645cd93 552 // dim brightness of the player score because they lost
DanGibbons 6:5e8e2645cd93 553 playerScoreLED.setII(0x20);
DanGibbons 6:5e8e2645cd93 554 playerScoreLED.useII(WS2812::GLOBAL);
DanGibbons 6:5e8e2645cd93 555 playerScoreLED.write(playerScorePx.getBuf()); // rewrite buffer to change brightness
DanGibbons 6:5e8e2645cd93 556
DanGibbons 6:5e8e2645cd93 557 for (int i = 0; i < 80; i++) { // flash robot score with changing random colours
DanGibbons 6:5e8e2645cd93 558 WritePxAnimation(robotScore,true,true);
DanGibbons 5:2d439ccefc7d 559 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 560 wait_ms(50);
DanGibbons 5:2d439ccefc7d 561 }
DanGibbons 4:2e80bd814f57 562
DanGibbons 6:5e8e2645cd93 563 DrainAnimation(true,true,robotScore,true,false,playerScore); // drain both scores away with the robot score in random colours
DanGibbons 6:5e8e2645cd93 564
DanGibbons 6:5e8e2645cd93 565 // reset player score brightness
DanGibbons 6:5e8e2645cd93 566 playerScoreLED.setII(0xB0);
DanGibbons 6:5e8e2645cd93 567 playerScoreLED.useII(WS2812::GLOBAL);
benswindell 0:f2b739e846ae 568 }
DanGibbons 4:2e80bd814f57 569
DanGibbons 5:2d439ccefc7d 570 wait(3);
DanGibbons 5:2d439ccefc7d 571
DanGibbons 4:2e80bd814f57 572 }
DanGibbons 4:2e80bd814f57 573
DanGibbons 6:5e8e2645cd93 574
DanGibbons 6:5e8e2645cd93 575 void CircleAnimation(bool robot, bool robotColour, bool player, bool playerColour, int numberOfRepititions)
DanGibbons 7:dc6f1f105c52 576 {
DanGibbons 6:5e8e2645cd93 577 for (int loops = 0; loops < numberOfRepititions; loops++) {
DanGibbons 6:5e8e2645cd93 578
DanGibbons 7:dc6f1f105c52 579 for (int i = 9; i < 115; i++) { // loop to set LEDs around the circle from start of segment A to end of Segment F
DanGibbons 5:2d439ccefc7d 580
DanGibbons 8:66dac2e00cce 581 if (i < 104) {
DanGibbons 6:5e8e2645cd93 582 mainArray[0][i] = 1;
DanGibbons 8:66dac2e00cce 583 for (int j = 0; j < i-10; j++) { // Loop to clear previously set LEDs so that the chain that animates round the display is 10 LEDs long
DanGibbons 8:66dac2e00cce 584 mainArray[0][j] = 0;
DanGibbons 8:66dac2e00cce 585 }
DanGibbons 8:66dac2e00cce 586 }
DanGibbons 8:66dac2e00cce 587 if (i > 103) {
DanGibbons 8:66dac2e00cce 588 mainArray[0][i-104] = 1;
DanGibbons 8:66dac2e00cce 589 for (int j = 90; j < i-10; j++) { // Loop to clear previously set LEDs so that the chain that animates round the display is 10 LEDs long
DanGibbons 7:dc6f1f105c52 590 mainArray[0][j] = 0;
DanGibbons 7:dc6f1f105c52 591 }
DanGibbons 6:5e8e2645cd93 592 }
DanGibbons 8:66dac2e00cce 593 if (i < 19) {
DanGibbons 8:66dac2e00cce 594 mainArray[1][18-i] = 1;
DanGibbons 8:66dac2e00cce 595 for (int j = 17; j > 25-i; j--) { // Loop to clear previously set LEDs so that the chain that animates round the display is 10 LEDs long
DanGibbons 8:66dac2e00cce 596 mainArray[1][j] = 0;
DanGibbons 8:66dac2e00cce 597 }
DanGibbons 8:66dac2e00cce 598 }
DanGibbons 8:66dac2e00cce 599 if (i > 18) {
DanGibbons 8:66dac2e00cce 600
DanGibbons 8:66dac2e00cce 601 mainArray[1][122-i] = 1;
DanGibbons 8:66dac2e00cce 602
DanGibbons 8:66dac2e00cce 603 if (i < 29) {
DanGibbons 8:66dac2e00cce 604 for (int j = 9; j > 27-i; j--) { // Loop to clear previously set LEDs so that the chain that animates round the display is 10 LEDs long
DanGibbons 8:66dac2e00cce 605 mainArray[1][j] = 0;
DanGibbons 8:66dac2e00cce 606 }
DanGibbons 8:66dac2e00cce 607 }
DanGibbons 8:66dac2e00cce 608 if (i > 28) {
DanGibbons 8:66dac2e00cce 609 for (int j = 103; j > 131-i; j--) { // Loop to clear previously set LEDs so that the chain that animates round the display is 10 LEDs long
DanGibbons 8:66dac2e00cce 610 mainArray[1][j] = 0;
DanGibbons 8:66dac2e00cce 611 }
DanGibbons 7:dc6f1f105c52 612 }
DanGibbons 6:5e8e2645cd93 613 }
DanGibbons 7:dc6f1f105c52 614
DanGibbons 6:5e8e2645cd93 615 wait_ms(10);
DanGibbons 6:5e8e2645cd93 616
DanGibbons 6:5e8e2645cd93 617 if (player == true) {
DanGibbons 7:dc6f1f105c52 618 WritePxAnimation(0,false,playerColour);
DanGibbons 5:2d439ccefc7d 619 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 5:2d439ccefc7d 620 }
DanGibbons 6:5e8e2645cd93 621 if (robot == true) {
DanGibbons 8:66dac2e00cce 622 WritePxAnimation(1,true,robotColour);
DanGibbons 6:5e8e2645cd93 623 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 624 }
DanGibbons 8:66dac2e00cce 625
DanGibbons 6:5e8e2645cd93 626 }
DanGibbons 8:66dac2e00cce 627
DanGibbons 6:5e8e2645cd93 628 }
DanGibbons 6:5e8e2645cd93 629
DanGibbons 5:2d439ccefc7d 630 }
DanGibbons 5:2d439ccefc7d 631
DanGibbons 5:2d439ccefc7d 632 // animation that drains the display from the top segment A to the bottom segment D
DanGibbons 5:2d439ccefc7d 633 void DrainAnimation(bool robot, bool robotColour, int robotScore, bool player, bool playerColour, int playerScore)
DanGibbons 5:2d439ccefc7d 634 {
DanGibbons 8:66dac2e00cce 635 SetNumberPatterns();
DanGibbons 8:66dac2e00cce 636
DanGibbons 6:5e8e2645cd93 637 for (int i = 0; i < 10; i++) { // A
DanGibbons 6:5e8e2645cd93 638 mainArray[robotScore][9+i] = 0;
DanGibbons 6:5e8e2645cd93 639 mainArray[robotScore][9-i] = 0;
DanGibbons 6:5e8e2645cd93 640 mainArray[playerScore][9+i] = 0;
DanGibbons 6:5e8e2645cd93 641 mainArray[playerScore][9-i] = 0;
DanGibbons 6:5e8e2645cd93 642 wait_ms(30);
DanGibbons 6:5e8e2645cd93 643 if (player == true){
DanGibbons 6:5e8e2645cd93 644 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 5:2d439ccefc7d 645 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 646 }
DanGibbons 6:5e8e2645cd93 647 if (robot == true) {
DanGibbons 6:5e8e2645cd93 648 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 649 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 5:2d439ccefc7d 650 }
DanGibbons 6:5e8e2645cd93 651 }
DanGibbons 6:5e8e2645cd93 652 for (int i = 0; i < 18; i++) { // B and F
DanGibbons 6:5e8e2645cd93 653 mainArray[robotScore][18+i] = 0;
DanGibbons 6:5e8e2645cd93 654 mainArray[robotScore][103-i] = 0;
DanGibbons 6:5e8e2645cd93 655 mainArray[playerScore][18+i] = 0;
DanGibbons 6:5e8e2645cd93 656 mainArray[playerScore][103-i] = 0;
DanGibbons 6:5e8e2645cd93 657 wait_ms(30);
DanGibbons 6:5e8e2645cd93 658 if (player == true){
DanGibbons 6:5e8e2645cd93 659 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 5:2d439ccefc7d 660 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 661 }
DanGibbons 6:5e8e2645cd93 662 if (robot == true) {
DanGibbons 6:5e8e2645cd93 663 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 664 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 665 }
DanGibbons 6:5e8e2645cd93 666 }
DanGibbons 6:5e8e2645cd93 667 if (robotScore != 0 | playerScore != 0) { // endgame - at least one score is three
DanGibbons 6:5e8e2645cd93 668
DanGibbons 6:5e8e2645cd93 669 for (int i = 0; i < 18; i++) { // G
DanGibbons 6:5e8e2645cd93 670 mainArray[robotScore][104+i] = 0;
DanGibbons 6:5e8e2645cd93 671 mainArray[playerScore][104+i] = 0;
DanGibbons 6:5e8e2645cd93 672 if (player == true) {
DanGibbons 6:5e8e2645cd93 673 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 674 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 675 }
DanGibbons 6:5e8e2645cd93 676 if (robot == true) {
DanGibbons 6:5e8e2645cd93 677 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 678 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 679 }
DanGibbons 6:5e8e2645cd93 680 }
DanGibbons 6:5e8e2645cd93 681 } else { // start of game - both scores are 0
DanGibbons 5:2d439ccefc7d 682 for (int i = 0; i < 18; i++) { // G
DanGibbons 5:2d439ccefc7d 683 mainArray[robotScore][104+i] = 0;
DanGibbons 5:2d439ccefc7d 684 mainArray[playerScore][104+i] = 0;
DanGibbons 6:5e8e2645cd93 685 }
DanGibbons 6:5e8e2645cd93 686 if (player == true) {
DanGibbons 6:5e8e2645cd93 687 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 688 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 689 }
DanGibbons 6:5e8e2645cd93 690 if (robot == true) {
DanGibbons 6:5e8e2645cd93 691 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 692 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 693 }
DanGibbons 6:5e8e2645cd93 694 }
DanGibbons 6:5e8e2645cd93 695
DanGibbons 6:5e8e2645cd93 696 for (int i = 0; i < 18; i++) { // C and E
DanGibbons 6:5e8e2645cd93 697 mainArray[robotScore][35+i] = 0;
DanGibbons 6:5e8e2645cd93 698 mainArray[robotScore][86-i] = 0;
DanGibbons 6:5e8e2645cd93 699 mainArray[playerScore][35+i] = 0;
DanGibbons 6:5e8e2645cd93 700 mainArray[playerScore][86-i] = 0;
DanGibbons 6:5e8e2645cd93 701 wait_ms(30);
DanGibbons 6:5e8e2645cd93 702 if (player == true){
DanGibbons 6:5e8e2645cd93 703 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 704 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 705 }
DanGibbons 6:5e8e2645cd93 706 if (robot == true) {
DanGibbons 6:5e8e2645cd93 707 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 5:2d439ccefc7d 708 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 709 }
DanGibbons 6:5e8e2645cd93 710 }
DanGibbons 6:5e8e2645cd93 711 for (int i = 0; i < 10; i++) { // D
DanGibbons 6:5e8e2645cd93 712 mainArray[robotScore][52+i] = 0;
DanGibbons 6:5e8e2645cd93 713 mainArray[robotScore][70-i] = 0;
DanGibbons 6:5e8e2645cd93 714 mainArray[playerScore][52+i] = 0;
DanGibbons 6:5e8e2645cd93 715 mainArray[playerScore][70-i] = 0;
DanGibbons 6:5e8e2645cd93 716 wait_ms(30);
DanGibbons 6:5e8e2645cd93 717 if (player == true){
DanGibbons 6:5e8e2645cd93 718 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 719 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 720 }
DanGibbons 6:5e8e2645cd93 721 if (robot == true) {
DanGibbons 6:5e8e2645cd93 722 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 723 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 724 }
DanGibbons 6:5e8e2645cd93 725 }
DanGibbons 6:5e8e2645cd93 726
DanGibbons 6:5e8e2645cd93 727
DanGibbons 8:66dac2e00cce 728 memset(mainArray, 0, sizeof mainArray);
DanGibbons 6:5e8e2645cd93 729
DanGibbons 6:5e8e2645cd93 730 }
DanGibbons 6:5e8e2645cd93 731
DanGibbons 6:5e8e2645cd93 732 void ZeroInAnimation(bool robot, bool robotColour, bool player, bool playerColour)
DanGibbons 6:5e8e2645cd93 733 {
DanGibbons 6:5e8e2645cd93 734 memset(mainArray, 0, sizeof mainArray);
DanGibbons 6:5e8e2645cd93 735
DanGibbons 6:5e8e2645cd93 736 if (player == true && robot == true) {
DanGibbons 6:5e8e2645cd93 737
DanGibbons 6:5e8e2645cd93 738 for (int i = 0; i < 10; i++) { // A
DanGibbons 6:5e8e2645cd93 739 mainArray[0][9+i] = 1;
DanGibbons 6:5e8e2645cd93 740 mainArray[0][9-i] = 1;
DanGibbons 6:5e8e2645cd93 741 wait_ms(10);
DanGibbons 6:5e8e2645cd93 742 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 743 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 744 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 745 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 746 }
DanGibbons 6:5e8e2645cd93 747 for (int i = 0; i < 18; i++) { // B and F
DanGibbons 6:5e8e2645cd93 748 mainArray[0][18+i] = 1;
DanGibbons 6:5e8e2645cd93 749 mainArray[0][103-i] = 1;
DanGibbons 6:5e8e2645cd93 750 wait_ms(10);
DanGibbons 6:5e8e2645cd93 751 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 752 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 753 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 754 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 755 }
DanGibbons 5:2d439ccefc7d 756 for (int i = 0; i < 18; i++) { // C and E
DanGibbons 6:5e8e2645cd93 757 mainArray[0][35+i] = 1;
DanGibbons 6:5e8e2645cd93 758 mainArray[0][86-i] = 1;
DanGibbons 6:5e8e2645cd93 759 wait_ms(10);
DanGibbons 6:5e8e2645cd93 760 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 5:2d439ccefc7d 761 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 762 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 5:2d439ccefc7d 763 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 764 }
DanGibbons 5:2d439ccefc7d 765 for (int i = 0; i < 10; i++) { // D
DanGibbons 6:5e8e2645cd93 766 mainArray[0][52+i] = 1;
DanGibbons 6:5e8e2645cd93 767 mainArray[0][70-i] = 1;
DanGibbons 6:5e8e2645cd93 768 wait_ms(10);
DanGibbons 6:5e8e2645cd93 769 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 770 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 771 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 772 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 773 }
DanGibbons 6:5e8e2645cd93 774
DanGibbons 6:5e8e2645cd93 775 }
DanGibbons 6:5e8e2645cd93 776
DanGibbons 6:5e8e2645cd93 777 if (player == true && robot == false) {
DanGibbons 6:5e8e2645cd93 778
DanGibbons 6:5e8e2645cd93 779 for (int i = 0; i < 10; i++) { // A
DanGibbons 6:5e8e2645cd93 780 mainArray[0][9+i] = 1;
DanGibbons 6:5e8e2645cd93 781 mainArray[0][9-i] = 1;
DanGibbons 6:5e8e2645cd93 782 wait_ms(10);
DanGibbons 6:5e8e2645cd93 783 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 784 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 785 }
DanGibbons 6:5e8e2645cd93 786 for (int i = 0; i < 18; i++) { // B and F
DanGibbons 6:5e8e2645cd93 787 mainArray[0][18+i] = 1;
DanGibbons 6:5e8e2645cd93 788 mainArray[0][103-i] = 1;
DanGibbons 6:5e8e2645cd93 789 wait_ms(10);
DanGibbons 6:5e8e2645cd93 790 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 791 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 792 }
DanGibbons 6:5e8e2645cd93 793 for (int i = 0; i < 18; i++) { // G
DanGibbons 6:5e8e2645cd93 794 mainArray[0][104+i] = 1;
DanGibbons 6:5e8e2645cd93 795 }
DanGibbons 6:5e8e2645cd93 796
DanGibbons 6:5e8e2645cd93 797 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 798 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 799
DanGibbons 6:5e8e2645cd93 800 for (int i = 0; i < 18; i++) { // C and E
DanGibbons 6:5e8e2645cd93 801 mainArray[0][35+i] = 1;
DanGibbons 6:5e8e2645cd93 802 mainArray[0][86-i] = 1;
DanGibbons 5:2d439ccefc7d 803 wait_ms(30);
DanGibbons 6:5e8e2645cd93 804 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 805 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 806 }
DanGibbons 6:5e8e2645cd93 807 for (int i = 0; i < 10; i++) { // D
DanGibbons 6:5e8e2645cd93 808 mainArray[0][52+i] = 1;
DanGibbons 6:5e8e2645cd93 809 mainArray[0][70-i] = 1;
DanGibbons 6:5e8e2645cd93 810 wait_ms(10);
DanGibbons 6:5e8e2645cd93 811 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 5:2d439ccefc7d 812 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 813 }
DanGibbons 6:5e8e2645cd93 814
DanGibbons 6:5e8e2645cd93 815 }
DanGibbons 6:5e8e2645cd93 816
DanGibbons 6:5e8e2645cd93 817 if (player == false && robot == true) {
DanGibbons 6:5e8e2645cd93 818
DanGibbons 6:5e8e2645cd93 819 for (int i = 0; i < 10; i++) { // A
DanGibbons 6:5e8e2645cd93 820 mainArray[0][9+i] = 1;
DanGibbons 6:5e8e2645cd93 821 mainArray[0][9-i] = 1;
DanGibbons 6:5e8e2645cd93 822 wait_ms(10);
DanGibbons 6:5e8e2645cd93 823 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 824 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 825 }
DanGibbons 6:5e8e2645cd93 826 for (int i = 0; i < 18; i++) { // B and F
DanGibbons 6:5e8e2645cd93 827 mainArray[0][18+i] = 1;
DanGibbons 6:5e8e2645cd93 828 mainArray[0][103-i] = 1;
DanGibbons 6:5e8e2645cd93 829 wait_ms(10);
DanGibbons 6:5e8e2645cd93 830 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 5:2d439ccefc7d 831 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 832 }
DanGibbons 6:5e8e2645cd93 833 for (int i = 0; i < 18; i++) { // G
DanGibbons 6:5e8e2645cd93 834 mainArray[0][104+i] = 1;
DanGibbons 6:5e8e2645cd93 835 }
DanGibbons 6:5e8e2645cd93 836
DanGibbons 6:5e8e2645cd93 837 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 838 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 839
DanGibbons 6:5e8e2645cd93 840 for (int i = 0; i < 18; i++) { // C and E
DanGibbons 6:5e8e2645cd93 841 mainArray[0][35+i] = 1;
DanGibbons 6:5e8e2645cd93 842 mainArray[0][86-i] = 1;
DanGibbons 6:5e8e2645cd93 843 wait_ms(10);
DanGibbons 6:5e8e2645cd93 844 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 845 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 846 }
DanGibbons 6:5e8e2645cd93 847 for (int i = 0; i < 10; i++) { // D
DanGibbons 6:5e8e2645cd93 848 mainArray[0][52+i] = 1;
DanGibbons 6:5e8e2645cd93 849 mainArray[0][70-i] = 1;
DanGibbons 6:5e8e2645cd93 850 wait_ms(10);
DanGibbons 6:5e8e2645cd93 851 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 852 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 853 }
DanGibbons 6:5e8e2645cd93 854
DanGibbons 6:5e8e2645cd93 855 }
DanGibbons 6:5e8e2645cd93 856
DanGibbons 6:5e8e2645cd93 857 SetNumberPatterns();
DanGibbons 5:2d439ccefc7d 858
DanGibbons 6:5e8e2645cd93 859
DanGibbons 6:5e8e2645cd93 860 }
DanGibbons 6:5e8e2645cd93 861
DanGibbons 6:5e8e2645cd93 862 void ZeroOutAnimation(bool robot, bool robotColour, bool player, bool playerColour)
DanGibbons 6:5e8e2645cd93 863 {
DanGibbons 6:5e8e2645cd93 864 if (player == true && robot == true) {
DanGibbons 6:5e8e2645cd93 865
DanGibbons 5:2d439ccefc7d 866 for (int i = 0; i < 10; i++) { // A
DanGibbons 6:5e8e2645cd93 867 mainArray[0][9+i] = 0;
DanGibbons 6:5e8e2645cd93 868 mainArray[0][9-i] = 0;
DanGibbons 6:5e8e2645cd93 869 wait_ms(10);
DanGibbons 6:5e8e2645cd93 870 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 871 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 872 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 873 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 874 }
DanGibbons 6:5e8e2645cd93 875 for (int i = 0; i < 18; i++) { // B and F
DanGibbons 6:5e8e2645cd93 876 mainArray[0][18+i] = 0;
DanGibbons 6:5e8e2645cd93 877 mainArray[0][103-i] = 0;
DanGibbons 6:5e8e2645cd93 878 wait_ms(10);
DanGibbons 6:5e8e2645cd93 879 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 880 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 881 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 882 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 883 }
DanGibbons 6:5e8e2645cd93 884 for (int i = 0; i < 18; i++) { // G
DanGibbons 6:5e8e2645cd93 885 mainArray[0][104+i] = 0;
DanGibbons 6:5e8e2645cd93 886 }
DanGibbons 6:5e8e2645cd93 887
DanGibbons 6:5e8e2645cd93 888 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 889 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 890 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 891 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 892
DanGibbons 6:5e8e2645cd93 893 for (int i = 0; i < 18; i++) { // C and E
DanGibbons 6:5e8e2645cd93 894 mainArray[0][35+i] = 0;
DanGibbons 6:5e8e2645cd93 895 mainArray[0][86-i] = 0;
DanGibbons 6:5e8e2645cd93 896 wait_ms(10);
DanGibbons 6:5e8e2645cd93 897 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 898 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 899 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 900 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 901 }
DanGibbons 6:5e8e2645cd93 902 for (int i = 0; i < 10; i++) { // D
DanGibbons 6:5e8e2645cd93 903 mainArray[0][52+i] = 0;
DanGibbons 6:5e8e2645cd93 904 mainArray[0][70-i] = 0;
DanGibbons 6:5e8e2645cd93 905 wait_ms(10);
DanGibbons 6:5e8e2645cd93 906 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 907 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 908 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 909 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 910 }
DanGibbons 6:5e8e2645cd93 911
DanGibbons 6:5e8e2645cd93 912 }
DanGibbons 6:5e8e2645cd93 913
DanGibbons 6:5e8e2645cd93 914 if (player == true && robot == false) {
DanGibbons 6:5e8e2645cd93 915
DanGibbons 6:5e8e2645cd93 916 for (int i = 0; i < 10; i++) { // A
DanGibbons 6:5e8e2645cd93 917 mainArray[0][9+i] = 0;
DanGibbons 6:5e8e2645cd93 918 mainArray[0][9-i] = 0;
DanGibbons 6:5e8e2645cd93 919 wait_ms(10);
DanGibbons 6:5e8e2645cd93 920 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 5:2d439ccefc7d 921 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 5:2d439ccefc7d 922 }
DanGibbons 5:2d439ccefc7d 923 for (int i = 0; i < 18; i++) { // B and F
DanGibbons 6:5e8e2645cd93 924 mainArray[0][18+i] = 0;
DanGibbons 6:5e8e2645cd93 925 mainArray[0][103-i] = 0;
DanGibbons 6:5e8e2645cd93 926 wait_ms(10);
DanGibbons 6:5e8e2645cd93 927 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 5:2d439ccefc7d 928 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 929 }
DanGibbons 5:2d439ccefc7d 930 for (int i = 0; i < 18; i++) { // G
DanGibbons 6:5e8e2645cd93 931 mainArray[0][104+i] = 0;
DanGibbons 6:5e8e2645cd93 932 }
DanGibbons 6:5e8e2645cd93 933
DanGibbons 6:5e8e2645cd93 934 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 935 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 936
DanGibbons 5:2d439ccefc7d 937 for (int i = 0; i < 18; i++) { // C and E
DanGibbons 6:5e8e2645cd93 938 mainArray[0][35+i] = 0;
DanGibbons 6:5e8e2645cd93 939 mainArray[0][86-i] = 0;
DanGibbons 6:5e8e2645cd93 940 wait_ms(10);
DanGibbons 6:5e8e2645cd93 941 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 5:2d439ccefc7d 942 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 943 }
DanGibbons 5:2d439ccefc7d 944 for (int i = 0; i < 10; i++) { // D
DanGibbons 6:5e8e2645cd93 945 mainArray[0][52+i] = 0;
DanGibbons 6:5e8e2645cd93 946 mainArray[0][70-i] = 0;
DanGibbons 6:5e8e2645cd93 947 wait_ms(10);
DanGibbons 6:5e8e2645cd93 948 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 5:2d439ccefc7d 949 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 950 }
DanGibbons 6:5e8e2645cd93 951
DanGibbons 6:5e8e2645cd93 952 }
DanGibbons 6:5e8e2645cd93 953
DanGibbons 5:2d439ccefc7d 954 if (player == false && robot == true) {
DanGibbons 6:5e8e2645cd93 955
DanGibbons 5:2d439ccefc7d 956 for (int i = 0; i < 10; i++) { // A
DanGibbons 6:5e8e2645cd93 957 mainArray[0][9+i] = 0;
DanGibbons 6:5e8e2645cd93 958 mainArray[0][9-i] = 0;
DanGibbons 6:5e8e2645cd93 959 wait_ms(10);
DanGibbons 6:5e8e2645cd93 960 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 5:2d439ccefc7d 961 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 5:2d439ccefc7d 962 }
DanGibbons 5:2d439ccefc7d 963 for (int i = 0; i < 18; i++) { // B and F
DanGibbons 6:5e8e2645cd93 964 mainArray[0][18+i] = 0;
DanGibbons 6:5e8e2645cd93 965 mainArray[0][103-i] = 0;
DanGibbons 6:5e8e2645cd93 966 wait_ms(10);
DanGibbons 6:5e8e2645cd93 967 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 5:2d439ccefc7d 968 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 969 }
DanGibbons 5:2d439ccefc7d 970 for (int i = 0; i < 18; i++) { // G
DanGibbons 6:5e8e2645cd93 971 mainArray[0][104+i] = 0;
DanGibbons 6:5e8e2645cd93 972 }
DanGibbons 6:5e8e2645cd93 973
DanGibbons 6:5e8e2645cd93 974 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 975 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 976
DanGibbons 5:2d439ccefc7d 977 for (int i = 0; i < 18; i++) { // C and E
DanGibbons 6:5e8e2645cd93 978 mainArray[0][35+i] = 0;
DanGibbons 6:5e8e2645cd93 979 mainArray[0][86-i] = 0;
DanGibbons 6:5e8e2645cd93 980 wait_ms(10);
DanGibbons 6:5e8e2645cd93 981 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 5:2d439ccefc7d 982 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 983 }
DanGibbons 5:2d439ccefc7d 984 for (int i = 0; i < 10; i++) { // D
DanGibbons 6:5e8e2645cd93 985 mainArray[0][52+i] = 0;
DanGibbons 6:5e8e2645cd93 986 mainArray[0][70-i] = 0;
DanGibbons 6:5e8e2645cd93 987 wait_ms(10);
DanGibbons 6:5e8e2645cd93 988 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 989 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 990 }
DanGibbons 6:5e8e2645cd93 991
DanGibbons 6:5e8e2645cd93 992 }
DanGibbons 6:5e8e2645cd93 993
DanGibbons 6:5e8e2645cd93 994 SetNumberPatterns();
DanGibbons 6:5e8e2645cd93 995
DanGibbons 6:5e8e2645cd93 996
DanGibbons 6:5e8e2645cd93 997 }
DanGibbons 6:5e8e2645cd93 998
DanGibbons 6:5e8e2645cd93 999 void OneInAnimation(bool robot, bool robotColour,bool player, bool playerColour)
DanGibbons 6:5e8e2645cd93 1000 {
DanGibbons 6:5e8e2645cd93 1001 memset(mainArray, 0, sizeof mainArray);
DanGibbons 6:5e8e2645cd93 1002
DanGibbons 6:5e8e2645cd93 1003 if (player == true && robot == true) {
DanGibbons 6:5e8e2645cd93 1004
DanGibbons 6:5e8e2645cd93 1005 for (int i = 51; i > 17; i--) {
DanGibbons 6:5e8e2645cd93 1006 mainArray[1][i] = 1;
DanGibbons 6:5e8e2645cd93 1007 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1008 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1009 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1010 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1011 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1012 }
DanGibbons 6:5e8e2645cd93 1013
DanGibbons 6:5e8e2645cd93 1014 }
DanGibbons 6:5e8e2645cd93 1015
DanGibbons 6:5e8e2645cd93 1016 if (player == true && robot == false) {
DanGibbons 6:5e8e2645cd93 1017
DanGibbons 6:5e8e2645cd93 1018 for (int i = 51; i > 17; i--) {
DanGibbons 6:5e8e2645cd93 1019 mainArray[1][i] = 1;
DanGibbons 6:5e8e2645cd93 1020 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1021 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1022 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1023 }
DanGibbons 6:5e8e2645cd93 1024
DanGibbons 6:5e8e2645cd93 1025 }
DanGibbons 6:5e8e2645cd93 1026
DanGibbons 6:5e8e2645cd93 1027 if (player == false && robot == true) {
DanGibbons 6:5e8e2645cd93 1028
DanGibbons 6:5e8e2645cd93 1029 for (int i = 51; i > 17; i--) { // B and F
DanGibbons 6:5e8e2645cd93 1030 mainArray[1][i] = 1;
DanGibbons 6:5e8e2645cd93 1031 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1032 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1033 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1034 }
DanGibbons 6:5e8e2645cd93 1035
DanGibbons 6:5e8e2645cd93 1036 }
DanGibbons 6:5e8e2645cd93 1037
DanGibbons 6:5e8e2645cd93 1038 SetNumberPatterns();
DanGibbons 6:5e8e2645cd93 1039
DanGibbons 6:5e8e2645cd93 1040
DanGibbons 6:5e8e2645cd93 1041 }
DanGibbons 6:5e8e2645cd93 1042
DanGibbons 6:5e8e2645cd93 1043 void OneOutAnimation(bool robot, bool robotColour,bool player, bool playerColour)
DanGibbons 6:5e8e2645cd93 1044 {
DanGibbons 6:5e8e2645cd93 1045 if (player == true && robot == true) {
DanGibbons 6:5e8e2645cd93 1046
DanGibbons 6:5e8e2645cd93 1047 for (int i = 18; i < 52; i++) {
DanGibbons 6:5e8e2645cd93 1048 mainArray[1][i] = 0;
DanGibbons 6:5e8e2645cd93 1049 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1050 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1051 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1052 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 5:2d439ccefc7d 1053 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1054 }
DanGibbons 6:5e8e2645cd93 1055
DanGibbons 6:5e8e2645cd93 1056 }
DanGibbons 6:5e8e2645cd93 1057
DanGibbons 6:5e8e2645cd93 1058 if (player == true && robot == false) {
DanGibbons 6:5e8e2645cd93 1059
DanGibbons 6:5e8e2645cd93 1060 for (int i = 18; i < 52; i++) {
DanGibbons 6:5e8e2645cd93 1061 mainArray[1][i] = 0;
DanGibbons 6:5e8e2645cd93 1062 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1063 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1064 playerScoreLED.write(playerScorePx.getBuf());;
DanGibbons 6:5e8e2645cd93 1065 }
DanGibbons 6:5e8e2645cd93 1066
DanGibbons 6:5e8e2645cd93 1067 }
DanGibbons 6:5e8e2645cd93 1068
DanGibbons 6:5e8e2645cd93 1069 if (player == false && robot == true) {
DanGibbons 6:5e8e2645cd93 1070
DanGibbons 6:5e8e2645cd93 1071 for (int i = 18; i < 52; i++) {
DanGibbons 6:5e8e2645cd93 1072 mainArray[1][i] = 0;
DanGibbons 6:5e8e2645cd93 1073 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1074 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1075 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1076 }
DanGibbons 6:5e8e2645cd93 1077
DanGibbons 6:5e8e2645cd93 1078 }
DanGibbons 6:5e8e2645cd93 1079
DanGibbons 6:5e8e2645cd93 1080 SetNumberPatterns();
DanGibbons 6:5e8e2645cd93 1081
DanGibbons 6:5e8e2645cd93 1082 }
DanGibbons 6:5e8e2645cd93 1083
DanGibbons 6:5e8e2645cd93 1084 void TwoInAnimation(bool robot, bool robotColour,bool player, bool playerColour)
DanGibbons 6:5e8e2645cd93 1085 {
DanGibbons 6:5e8e2645cd93 1086 memset(mainArray, 0, sizeof mainArray);
DanGibbons 5:2d439ccefc7d 1087
DanGibbons 6:5e8e2645cd93 1088 if (player == true && robot == true) {
DanGibbons 6:5e8e2645cd93 1089
DanGibbons 6:5e8e2645cd93 1090 for (int i = 0; i < 35; i++) {
DanGibbons 6:5e8e2645cd93 1091 mainArray[2][i] = 1;
DanGibbons 6:5e8e2645cd93 1092 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1093 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1094 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1095 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1096 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1097 }
DanGibbons 6:5e8e2645cd93 1098 for (int i = 121; i > 103; i--) {
DanGibbons 6:5e8e2645cd93 1099 mainArray[2][i] = 1;
DanGibbons 6:5e8e2645cd93 1100 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1101 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1102 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1103 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1104 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1105 }
DanGibbons 6:5e8e2645cd93 1106 for (int i = 86; i > 51; i--) {
DanGibbons 6:5e8e2645cd93 1107 mainArray[2][i] = 1;
DanGibbons 6:5e8e2645cd93 1108 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1109 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1110 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1111 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1112 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1113 }
DanGibbons 6:5e8e2645cd93 1114
DanGibbons 6:5e8e2645cd93 1115 }
DanGibbons 6:5e8e2645cd93 1116
DanGibbons 6:5e8e2645cd93 1117 if (player == true && robot == false) {
DanGibbons 6:5e8e2645cd93 1118
DanGibbons 6:5e8e2645cd93 1119 for (int i = 0; i < 35; i++) {
DanGibbons 6:5e8e2645cd93 1120 mainArray[2][i] = 1;
DanGibbons 6:5e8e2645cd93 1121 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1122 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1123 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1124 }
DanGibbons 6:5e8e2645cd93 1125 for (int i = 121; i > 103; i--) {
DanGibbons 6:5e8e2645cd93 1126 mainArray[2][i] = 1;
DanGibbons 6:5e8e2645cd93 1127 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1128 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1129 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1130 }
DanGibbons 6:5e8e2645cd93 1131 for (int i = 86; i > 51; i--) {
DanGibbons 6:5e8e2645cd93 1132 mainArray[2][i] = 1;
DanGibbons 6:5e8e2645cd93 1133 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1134 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1135 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1136 }
DanGibbons 6:5e8e2645cd93 1137
DanGibbons 6:5e8e2645cd93 1138 }
DanGibbons 6:5e8e2645cd93 1139
DanGibbons 6:5e8e2645cd93 1140 if (player == false && robot == true) {
DanGibbons 6:5e8e2645cd93 1141
DanGibbons 6:5e8e2645cd93 1142 for (int i = 0; i < 35; i++) {
DanGibbons 6:5e8e2645cd93 1143 mainArray[2][i] = 1;
DanGibbons 6:5e8e2645cd93 1144 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1145 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1146 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1147 }
DanGibbons 6:5e8e2645cd93 1148 for (int i = 121; i > 103; i--) {
DanGibbons 6:5e8e2645cd93 1149 mainArray[2][i] = 1;
DanGibbons 6:5e8e2645cd93 1150 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1151 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1152 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1153 }
DanGibbons 6:5e8e2645cd93 1154 for (int i = 86; i > 51; i--) {
DanGibbons 6:5e8e2645cd93 1155 mainArray[2][i] = 1;
DanGibbons 6:5e8e2645cd93 1156 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1157 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1158 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1159 }
DanGibbons 6:5e8e2645cd93 1160
DanGibbons 6:5e8e2645cd93 1161 }
DanGibbons 6:5e8e2645cd93 1162
DanGibbons 5:2d439ccefc7d 1163 SetNumberPatterns();
DanGibbons 5:2d439ccefc7d 1164
DanGibbons 6:5e8e2645cd93 1165 }
DanGibbons 6:5e8e2645cd93 1166
DanGibbons 6:5e8e2645cd93 1167 void TwoOutAnimation(bool robot, bool robotColour,bool player, bool playerColour)
DanGibbons 6:5e8e2645cd93 1168 {
DanGibbons 6:5e8e2645cd93 1169 if (player == true && robot == true) {
DanGibbons 6:5e8e2645cd93 1170
DanGibbons 6:5e8e2645cd93 1171 for (int i = 0; i < 35; i++) {
DanGibbons 6:5e8e2645cd93 1172 mainArray[2][i] = 0;
DanGibbons 6:5e8e2645cd93 1173 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1174 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1175 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1176 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1177 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1178 }
DanGibbons 6:5e8e2645cd93 1179 for (int i = 121; i > 103; i--) {
DanGibbons 6:5e8e2645cd93 1180 mainArray[2][i] = 0;
DanGibbons 6:5e8e2645cd93 1181 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1182 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1183 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1184 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1185 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1186 }
DanGibbons 6:5e8e2645cd93 1187 for (int i = 86; i > 51; i--) {
DanGibbons 6:5e8e2645cd93 1188 mainArray[2][i] = 0;
DanGibbons 6:5e8e2645cd93 1189 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1190 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1191 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1192 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1193 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1194 }
DanGibbons 6:5e8e2645cd93 1195
DanGibbons 6:5e8e2645cd93 1196 }
DanGibbons 6:5e8e2645cd93 1197
DanGibbons 6:5e8e2645cd93 1198 if (player == true && robot == false) {
DanGibbons 6:5e8e2645cd93 1199
DanGibbons 6:5e8e2645cd93 1200 for (int i = 0; i < 35; i++) {
DanGibbons 6:5e8e2645cd93 1201 mainArray[2][i] = 0;
DanGibbons 6:5e8e2645cd93 1202 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1203 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1204 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1205 }
DanGibbons 6:5e8e2645cd93 1206 for (int i = 121; i > 103; i--) {
DanGibbons 6:5e8e2645cd93 1207 mainArray[2][i] = 0;
DanGibbons 6:5e8e2645cd93 1208 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1209 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1210 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1211 }
DanGibbons 6:5e8e2645cd93 1212 for (int i = 86; i > 51; i--) {
DanGibbons 6:5e8e2645cd93 1213 mainArray[2][i] = 0;
DanGibbons 6:5e8e2645cd93 1214 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1215 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1216 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1217 }
DanGibbons 6:5e8e2645cd93 1218
DanGibbons 6:5e8e2645cd93 1219 }
DanGibbons 6:5e8e2645cd93 1220
DanGibbons 6:5e8e2645cd93 1221 if (player == false && robot == true) {
DanGibbons 6:5e8e2645cd93 1222
DanGibbons 6:5e8e2645cd93 1223 for (int i = 0; i < 35; i++) {
DanGibbons 6:5e8e2645cd93 1224 mainArray[2][i] = 0;
DanGibbons 6:5e8e2645cd93 1225 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1226 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1227 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1228 }
DanGibbons 6:5e8e2645cd93 1229 for (int i = 121; i > 103; i--) {
DanGibbons 6:5e8e2645cd93 1230 mainArray[2][i] = 0;
DanGibbons 6:5e8e2645cd93 1231 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1232 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1233 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1234 }
DanGibbons 6:5e8e2645cd93 1235 for (int i = 86; i > 51; i--) {
DanGibbons 6:5e8e2645cd93 1236 mainArray[2][i] = 0;
DanGibbons 6:5e8e2645cd93 1237 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1238 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1239 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1240 }
DanGibbons 6:5e8e2645cd93 1241
DanGibbons 6:5e8e2645cd93 1242 }
DanGibbons 6:5e8e2645cd93 1243
DanGibbons 6:5e8e2645cd93 1244 SetNumberPatterns();
DanGibbons 6:5e8e2645cd93 1245
DanGibbons 6:5e8e2645cd93 1246 }
DanGibbons 6:5e8e2645cd93 1247
DanGibbons 6:5e8e2645cd93 1248 void ThreeInAnimation(bool robot, bool robotColour,bool player, bool playerColour)
DanGibbons 6:5e8e2645cd93 1249 {
DanGibbons 6:5e8e2645cd93 1250 memset(mainArray, 0, sizeof mainArray);
DanGibbons 6:5e8e2645cd93 1251
DanGibbons 6:5e8e2645cd93 1252 if (player == true && robot == true) {
DanGibbons 6:5e8e2645cd93 1253
DanGibbons 6:5e8e2645cd93 1254 for (int i = 0; i < 35; i++) {
DanGibbons 6:5e8e2645cd93 1255 mainArray[3][i] = 1;
DanGibbons 6:5e8e2645cd93 1256 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1257 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1258 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1259 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1260 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1261 }
DanGibbons 6:5e8e2645cd93 1262 for (int i = 0; i < 17; i++) {
DanGibbons 6:5e8e2645cd93 1263 mainArray[3][35+i] = 1;
DanGibbons 6:5e8e2645cd93 1264 mainArray[3][121-i] = 1;
DanGibbons 6:5e8e2645cd93 1265 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1266 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1267 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1268 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1269 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1270 }
DanGibbons 6:5e8e2645cd93 1271 for (int i = 52; i < 70; i++) {
DanGibbons 6:5e8e2645cd93 1272 mainArray[3][i] = 1;
DanGibbons 6:5e8e2645cd93 1273 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1274 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1275 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1276 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1277 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1278 }
DanGibbons 6:5e8e2645cd93 1279
DanGibbons 6:5e8e2645cd93 1280 }
DanGibbons 6:5e8e2645cd93 1281
DanGibbons 6:5e8e2645cd93 1282 if (player == true && robot == false) {
DanGibbons 6:5e8e2645cd93 1283
DanGibbons 6:5e8e2645cd93 1284 for (int i = 0; i < 35; i++) {
DanGibbons 6:5e8e2645cd93 1285 mainArray[3][i] = 1;
DanGibbons 6:5e8e2645cd93 1286 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1287 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1288 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1289 }
DanGibbons 6:5e8e2645cd93 1290 for (int i = 0; i < 17; i++) {
DanGibbons 6:5e8e2645cd93 1291 mainArray[3][35+i] = 1;
DanGibbons 6:5e8e2645cd93 1292 mainArray[3][121-i] = 1;
DanGibbons 6:5e8e2645cd93 1293 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1294 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1295 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1296 }
DanGibbons 6:5e8e2645cd93 1297 for (int i = 52; i < 70; i++) {
DanGibbons 6:5e8e2645cd93 1298 mainArray[3][i] = 1;
DanGibbons 6:5e8e2645cd93 1299 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1300 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1301 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1302 }
DanGibbons 6:5e8e2645cd93 1303
DanGibbons 6:5e8e2645cd93 1304 }
DanGibbons 6:5e8e2645cd93 1305
DanGibbons 6:5e8e2645cd93 1306 if (player == false && robot == true) {
DanGibbons 6:5e8e2645cd93 1307
DanGibbons 6:5e8e2645cd93 1308 for (int i = 0; i < 35; i++) {
DanGibbons 6:5e8e2645cd93 1309 mainArray[3][i] = 1;
DanGibbons 6:5e8e2645cd93 1310 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1311 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1312 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1313 }
DanGibbons 6:5e8e2645cd93 1314 for (int i = 0; i < 18; i++) {
DanGibbons 6:5e8e2645cd93 1315 mainArray[3][35+i] = 1;
DanGibbons 6:5e8e2645cd93 1316 mainArray[3][121-i] = 1;
DanGibbons 6:5e8e2645cd93 1317 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1318 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1319 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1320 }
DanGibbons 6:5e8e2645cd93 1321 for (int i = 52; i < 70; i++) {
DanGibbons 6:5e8e2645cd93 1322 mainArray[3][i] = 1;
DanGibbons 6:5e8e2645cd93 1323 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1324 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1325 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1326 }
DanGibbons 6:5e8e2645cd93 1327
DanGibbons 6:5e8e2645cd93 1328 }
DanGibbons 6:5e8e2645cd93 1329
DanGibbons 6:5e8e2645cd93 1330 SetNumberPatterns();
DanGibbons 6:5e8e2645cd93 1331
DanGibbons 6:5e8e2645cd93 1332 }
DanGibbons 6:5e8e2645cd93 1333
DanGibbons 6:5e8e2645cd93 1334 void ThreeOutAnimation(bool robot, bool robotColour,bool player, bool playerColour)
DanGibbons 6:5e8e2645cd93 1335 {
DanGibbons 6:5e8e2645cd93 1336 if (player == true && robot == true) {
DanGibbons 6:5e8e2645cd93 1337
DanGibbons 6:5e8e2645cd93 1338 for (int i = 0; i < 18; i++) {
DanGibbons 6:5e8e2645cd93 1339 mainArray[3][i] = 0;
DanGibbons 6:5e8e2645cd93 1340 mainArray[3][104+i] = 0;
DanGibbons 6:5e8e2645cd93 1341 mainArray[3][69-i] = 0;
DanGibbons 6:5e8e2645cd93 1342 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1343 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1344 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1345 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1346 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1347 }
DanGibbons 6:5e8e2645cd93 1348 for (int i = 0; i < 18; i++) {
DanGibbons 6:5e8e2645cd93 1349 mainArray[3][18+i] = 0;
DanGibbons 6:5e8e2645cd93 1350 mainArray[3][51-i] = 0;
DanGibbons 6:5e8e2645cd93 1351 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1352 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1353 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1354 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1355 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1356 }
DanGibbons 6:5e8e2645cd93 1357
DanGibbons 6:5e8e2645cd93 1358 }
DanGibbons 6:5e8e2645cd93 1359
DanGibbons 6:5e8e2645cd93 1360 if (player == true && robot == false) {
DanGibbons 6:5e8e2645cd93 1361
DanGibbons 6:5e8e2645cd93 1362 for (int i = 0; i < 18; i++) {
DanGibbons 6:5e8e2645cd93 1363 mainArray[3][i] = 0;
DanGibbons 6:5e8e2645cd93 1364 mainArray[3][104+i] = 0;
DanGibbons 6:5e8e2645cd93 1365 mainArray[3][69-i] = 0;
DanGibbons 6:5e8e2645cd93 1366 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1367 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1368 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1369 }
DanGibbons 6:5e8e2645cd93 1370 for (int i = 0; i < 18; i++) {
DanGibbons 6:5e8e2645cd93 1371 mainArray[3][18+i] = 0;
DanGibbons 6:5e8e2645cd93 1372 mainArray[3][51-i] = 0;
DanGibbons 6:5e8e2645cd93 1373 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1374 WritePxAnimation(playerScore,false,playerColour);
DanGibbons 6:5e8e2645cd93 1375 playerScoreLED.write(playerScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1376 }
DanGibbons 6:5e8e2645cd93 1377
DanGibbons 6:5e8e2645cd93 1378 }
DanGibbons 6:5e8e2645cd93 1379
DanGibbons 6:5e8e2645cd93 1380 if (player == false && robot == true) {
DanGibbons 6:5e8e2645cd93 1381
DanGibbons 6:5e8e2645cd93 1382 for (int i = 0; i < 18; i++) {
DanGibbons 6:5e8e2645cd93 1383 mainArray[3][i] = 0;
DanGibbons 6:5e8e2645cd93 1384 mainArray[3][104+i] = 0;
DanGibbons 6:5e8e2645cd93 1385 mainArray[3][69-i] = 0;
DanGibbons 6:5e8e2645cd93 1386 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1387 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1388 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1389 }
DanGibbons 6:5e8e2645cd93 1390 for (int i = 0; i < 18; i++) {
DanGibbons 6:5e8e2645cd93 1391 mainArray[3][18+i] = 0;
DanGibbons 6:5e8e2645cd93 1392 mainArray[3][51-i] = 0;
DanGibbons 6:5e8e2645cd93 1393 wait_ms(10);
DanGibbons 6:5e8e2645cd93 1394 WritePxAnimation(robotScore,true,robotColour);
DanGibbons 6:5e8e2645cd93 1395 robotScoreLED.write(robotScorePx.getBuf());
DanGibbons 6:5e8e2645cd93 1396 }
DanGibbons 6:5e8e2645cd93 1397
DanGibbons 6:5e8e2645cd93 1398 }
DanGibbons 6:5e8e2645cd93 1399
DanGibbons 6:5e8e2645cd93 1400 SetNumberPatterns();
DanGibbons 6:5e8e2645cd93 1401
DanGibbons 6:5e8e2645cd93 1402 }
DanGibbons 6:5e8e2645cd93 1403
DanGibbons 6:5e8e2645cd93 1404 void idleButtonISR()
DanGibbons 6:5e8e2645cd93 1405 {
DanGibbons 6:5e8e2645cd93 1406 idle_flag = !idle_flag;
DanGibbons 7:dc6f1f105c52 1407 idle_button_pressed = 1;
DanGibbons 7:dc6f1f105c52 1408 pc.printf("\nidle flag = %d",idle_flag);
DanGibbons 7:dc6f1f105c52 1409 idleButton.disable_irq();
DanGibbons 6:5e8e2645cd93 1410 }