updated 7seg controls for new 7 seg boards

Dependencies:   PixelArray WS2812 mbed

Fork of frdm_pong_table_controller by Demo Team

Committer:
DanGibbons
Date:
Sun Aug 06 11:53:00 2017 +0000
Revision:
12:7f428ce8ab35
Parent:
11:4a73fdc60de6
Reduced LED Brightness

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