el15mh 200929957

Dependencies:   mbed

Committer:
el15mh
Date:
Thu Mar 30 12:20:02 2017 +0000
Revision:
0:d7701c5c20e6
Child:
1:8ce2586b5965
menu test whole

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el15mh 0:d7701c5c20e6 1 #include "mbed.h"
el15mh 0:d7701c5c20e6 2 #include "N5110.h"
el15mh 0:d7701c5c20e6 3 #include "Gamepad.h"
el15mh 0:d7701c5c20e6 4
el15mh 0:d7701c5c20e6 5 // CREATE OBJECTS //
el15mh 0:d7701c5c20e6 6 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
el15mh 0:d7701c5c20e6 7 Gamepad pad;
el15mh 0:d7701c5c20e6 8
el15mh 0:d7701c5c20e6 9 // FUNCTION PROTOTYPES //
el15mh 0:d7701c5c20e6 10 void init();
el15mh 0:d7701c5c20e6 11 void play();
el15mh 0:d7701c5c20e6 12 void menu();
el15mh 0:d7701c5c20e6 13 void options();
el15mh 0:d7701c5c20e6 14 void lcdSettings();
el15mh 0:d7701c5c20e6 15 void soundSettings();
el15mh 0:d7701c5c20e6 16 void drawBox();
el15mh 0:d7701c5c20e6 17
el15mh 0:d7701c5c20e6 18 int main()
el15mh 0:d7701c5c20e6 19 {
el15mh 0:d7701c5c20e6 20 init(); // initialise devices
el15mh 0:d7701c5c20e6 21
el15mh 0:d7701c5c20e6 22 while(1){
el15mh 0:d7701c5c20e6 23
el15mh 0:d7701c5c20e6 24 menu();
el15mh 0:d7701c5c20e6 25
el15mh 0:d7701c5c20e6 26 }
el15mh 0:d7701c5c20e6 27 }
el15mh 0:d7701c5c20e6 28
el15mh 0:d7701c5c20e6 29 void init()
el15mh 0:d7701c5c20e6 30 {
el15mh 0:d7701c5c20e6 31 lcd.init();
el15mh 0:d7701c5c20e6 32 pad.init();
el15mh 0:d7701c5c20e6 33 }
el15mh 0:d7701c5c20e6 34
el15mh 0:d7701c5c20e6 35 void play()
el15mh 0:d7701c5c20e6 36 {
el15mh 0:d7701c5c20e6 37 int exit = 0;
el15mh 0:d7701c5c20e6 38
el15mh 0:d7701c5c20e6 39 while(exit == 0){
el15mh 0:d7701c5c20e6 40
el15mh 0:d7701c5c20e6 41 // coordinates for centre of lcd
el15mh 0:d7701c5c20e6 42 float x = 41.0;
el15mh 0:d7701c5c20e6 43 float y = 23.0;
el15mh 0:d7701c5c20e6 44
el15mh 0:d7701c5c20e6 45 lcd.clear();
el15mh 0:d7701c5c20e6 46
el15mh 0:d7701c5c20e6 47 double size = pad.read_pot() * 10.0;
el15mh 0:d7701c5c20e6 48
el15mh 0:d7701c5c20e6 49 if (pad.check_event(Gamepad::A_PRESSED)){
el15mh 0:d7701c5c20e6 50 pad.leds_on();
el15mh 0:d7701c5c20e6 51 }
el15mh 0:d7701c5c20e6 52 if (pad.check_event(Gamepad::B_PRESSED)){
el15mh 0:d7701c5c20e6 53 pad.leds_off();
el15mh 0:d7701c5c20e6 54 }
el15mh 0:d7701c5c20e6 55
el15mh 0:d7701c5c20e6 56 // check four sides of ball (+x, -x, +y, -y)
el15mh 0:d7701c5c20e6 57 float leftSide = x - size;
el15mh 0:d7701c5c20e6 58 float rightSide = x + size;
el15mh 0:d7701c5c20e6 59 float topSide = y - size;
el15mh 0:d7701c5c20e6 60 float bottomSide = y + size;
el15mh 0:d7701c5c20e6 61
el15mh 0:d7701c5c20e6 62 // default values for bool values are true
el15mh 0:d7701c5c20e6 63 bool MOVE_X = true;
el15mh 0:d7701c5c20e6 64 bool MOVE_Y = true;
el15mh 0:d7701c5c20e6 65
el15mh 0:d7701c5c20e6 66 if (leftSide == 1) {
el15mh 0:d7701c5c20e6 67 MOVE_X = false; // only set bool values false if circle on the edge
el15mh 0:d7701c5c20e6 68 }
el15mh 0:d7701c5c20e6 69
el15mh 0:d7701c5c20e6 70 if (rightSide == 82) {
el15mh 0:d7701c5c20e6 71 MOVE_X = false;
el15mh 0:d7701c5c20e6 72 }
el15mh 0:d7701c5c20e6 73
el15mh 0:d7701c5c20e6 74 if (topSide == 1) {
el15mh 0:d7701c5c20e6 75 MOVE_Y = false;
el15mh 0:d7701c5c20e6 76 }
el15mh 0:d7701c5c20e6 77
el15mh 0:d7701c5c20e6 78 if (bottomSide == 46){
el15mh 0:d7701c5c20e6 79 MOVE_Y = false;
el15mh 0:d7701c5c20e6 80 }
el15mh 0:d7701c5c20e6 81
el15mh 0:d7701c5c20e6 82 drawBox();
el15mh 0:d7701c5c20e6 83 lcd.drawCircle(x, y, size, FILL_TRANSPARENT);
el15mh 0:d7701c5c20e6 84 lcd.refresh();
el15mh 0:d7701c5c20e6 85
el15mh 0:d7701c5c20e6 86 Vector2D position = pad.get_mapped_coord();
el15mh 0:d7701c5c20e6 87
el15mh 0:d7701c5c20e6 88 if (MOVE_X == true){
el15mh 0:d7701c5c20e6 89 x += position.x;
el15mh 0:d7701c5c20e6 90 }
el15mh 0:d7701c5c20e6 91 if (MOVE_Y == true){
el15mh 0:d7701c5c20e6 92 y -= position.y;
el15mh 0:d7701c5c20e6 93 }
el15mh 0:d7701c5c20e6 94
el15mh 0:d7701c5c20e6 95 // printf("x = %f, y = %f \n", position.x, position.y);
el15mh 0:d7701c5c20e6 96 // printf("ball X = %f, ball Y = %f \n\n", x, y);
el15mh 0:d7701c5c20e6 97
el15mh 0:d7701c5c20e6 98 wait_ms(20);
el15mh 0:d7701c5c20e6 99
el15mh 0:d7701c5c20e6 100 if (pad.check_event(Gamepad::BACK_PRESSED)){
el15mh 0:d7701c5c20e6 101
el15mh 0:d7701c5c20e6 102 exit = 1;
el15mh 0:d7701c5c20e6 103 }
el15mh 0:d7701c5c20e6 104 }
el15mh 0:d7701c5c20e6 105 }
el15mh 0:d7701c5c20e6 106
el15mh 0:d7701c5c20e6 107 void drawBox()
el15mh 0:d7701c5c20e6 108 {
el15mh 0:d7701c5c20e6 109 for (int i = 0; i < WIDTH; i++){
el15mh 0:d7701c5c20e6 110 lcd.setPixel(i, 0);
el15mh 0:d7701c5c20e6 111 lcd.setPixel(i, HEIGHT - 1);
el15mh 0:d7701c5c20e6 112 }
el15mh 0:d7701c5c20e6 113
el15mh 0:d7701c5c20e6 114 for (int j = 0; j < HEIGHT; j++){
el15mh 0:d7701c5c20e6 115 lcd.setPixel(0, j);
el15mh 0:d7701c5c20e6 116 lcd.setPixel(WIDTH - 1, j);
el15mh 0:d7701c5c20e6 117 }
el15mh 0:d7701c5c20e6 118
el15mh 0:d7701c5c20e6 119 lcd.refresh();
el15mh 0:d7701c5c20e6 120 }
el15mh 0:d7701c5c20e6 121
el15mh 0:d7701c5c20e6 122
el15mh 0:d7701c5c20e6 123 void menu()
el15mh 0:d7701c5c20e6 124 {
el15mh 0:d7701c5c20e6 125 int selected = 0;
el15mh 0:d7701c5c20e6 126
el15mh 0:d7701c5c20e6 127 while(1) {
el15mh 0:d7701c5c20e6 128
el15mh 0:d7701c5c20e6 129 // lcd.printString("Testing", 0, 2);
el15mh 0:d7701c5c20e6 130
el15mh 0:d7701c5c20e6 131 switch (selected) {
el15mh 0:d7701c5c20e6 132
el15mh 0:d7701c5c20e6 133 case 1:
el15mh 0:d7701c5c20e6 134
el15mh 0:d7701c5c20e6 135 lcd.clear();
el15mh 0:d7701c5c20e6 136 lcd.printString(">Play game", 0, 0);
el15mh 0:d7701c5c20e6 137 lcd.printString(" Game options", 0, 1);
el15mh 0:d7701c5c20e6 138 lcd.printString(" LCD settings", 0, 2);
el15mh 0:d7701c5c20e6 139 lcd.printString(" Sound", 0, 3);
el15mh 0:d7701c5c20e6 140
el15mh 0:d7701c5c20e6 141 lcd.refresh();
el15mh 0:d7701c5c20e6 142
el15mh 0:d7701c5c20e6 143 // either clicking joystick or pressing A selects function
el15mh 0:d7701c5c20e6 144 if (pad.check_event(Gamepad::A_PRESSED) ||
el15mh 0:d7701c5c20e6 145 pad.check_event(Gamepad::JOY_PRESSED)){
el15mh 0:d7701c5c20e6 146
el15mh 0:d7701c5c20e6 147 play(); // call the game function
el15mh 0:d7701c5c20e6 148 }
el15mh 0:d7701c5c20e6 149
el15mh 0:d7701c5c20e6 150 wait_ms(250); // 1s propogation delay
el15mh 0:d7701c5c20e6 151
el15mh 0:d7701c5c20e6 152 break;
el15mh 0:d7701c5c20e6 153
el15mh 0:d7701c5c20e6 154 case 2:
el15mh 0:d7701c5c20e6 155
el15mh 0:d7701c5c20e6 156 lcd.clear();
el15mh 0:d7701c5c20e6 157 lcd.printString(" Play game", 0, 0);
el15mh 0:d7701c5c20e6 158 lcd.printString(">Game options", 0, 1);
el15mh 0:d7701c5c20e6 159 lcd.printString(" LCD settings", 0, 2);
el15mh 0:d7701c5c20e6 160 lcd.printString(" Sound", 0, 3);
el15mh 0:d7701c5c20e6 161
el15mh 0:d7701c5c20e6 162 lcd.refresh();
el15mh 0:d7701c5c20e6 163
el15mh 0:d7701c5c20e6 164
el15mh 0:d7701c5c20e6 165 if (pad.check_event(Gamepad::A_PRESSED) ||
el15mh 0:d7701c5c20e6 166 pad.check_event(Gamepad::JOY_PRESSED)){
el15mh 0:d7701c5c20e6 167
el15mh 0:d7701c5c20e6 168 options();
el15mh 0:d7701c5c20e6 169 }
el15mh 0:d7701c5c20e6 170
el15mh 0:d7701c5c20e6 171 wait_ms(250); // 1s propogation delay
el15mh 0:d7701c5c20e6 172
el15mh 0:d7701c5c20e6 173 break;
el15mh 0:d7701c5c20e6 174
el15mh 0:d7701c5c20e6 175 case 3:
el15mh 0:d7701c5c20e6 176
el15mh 0:d7701c5c20e6 177 lcd.clear();
el15mh 0:d7701c5c20e6 178 lcd.printString(" Play game", 0, 0);
el15mh 0:d7701c5c20e6 179 lcd.printString(" Game options", 0, 1);
el15mh 0:d7701c5c20e6 180 lcd.printString(">LCD settings", 0, 2);
el15mh 0:d7701c5c20e6 181 lcd.printString(" Sound", 0, 3);
el15mh 0:d7701c5c20e6 182
el15mh 0:d7701c5c20e6 183 lcd.refresh();
el15mh 0:d7701c5c20e6 184
el15mh 0:d7701c5c20e6 185
el15mh 0:d7701c5c20e6 186 if (pad.check_event(Gamepad::A_PRESSED) ||
el15mh 0:d7701c5c20e6 187 pad.check_event(Gamepad::JOY_PRESSED)){
el15mh 0:d7701c5c20e6 188
el15mh 0:d7701c5c20e6 189 lcdSettings();
el15mh 0:d7701c5c20e6 190 }
el15mh 0:d7701c5c20e6 191
el15mh 0:d7701c5c20e6 192 wait_ms(250); // 1s propogation delay
el15mh 0:d7701c5c20e6 193
el15mh 0:d7701c5c20e6 194 break;
el15mh 0:d7701c5c20e6 195
el15mh 0:d7701c5c20e6 196 case 4:
el15mh 0:d7701c5c20e6 197
el15mh 0:d7701c5c20e6 198 lcd.clear();
el15mh 0:d7701c5c20e6 199 lcd.printString(" Play game", 0, 0);
el15mh 0:d7701c5c20e6 200 lcd.printString(" Game options", 0, 1);
el15mh 0:d7701c5c20e6 201 lcd.printString(" LCD settings", 0, 2);
el15mh 0:d7701c5c20e6 202 lcd.printString(">Sound", 0, 3);
el15mh 0:d7701c5c20e6 203
el15mh 0:d7701c5c20e6 204 lcd.refresh();
el15mh 0:d7701c5c20e6 205
el15mh 0:d7701c5c20e6 206
el15mh 0:d7701c5c20e6 207 if (pad.check_event(Gamepad::A_PRESSED) ||
el15mh 0:d7701c5c20e6 208 pad.check_event(Gamepad::JOY_PRESSED)){
el15mh 0:d7701c5c20e6 209
el15mh 0:d7701c5c20e6 210 soundSettings();
el15mh 0:d7701c5c20e6 211 }
el15mh 0:d7701c5c20e6 212
el15mh 0:d7701c5c20e6 213 wait_ms(250); // 1s propogation delay
el15mh 0:d7701c5c20e6 214
el15mh 0:d7701c5c20e6 215 break;
el15mh 0:d7701c5c20e6 216
el15mh 0:d7701c5c20e6 217 default:
el15mh 0:d7701c5c20e6 218
el15mh 0:d7701c5c20e6 219 selected = 0;
el15mh 0:d7701c5c20e6 220
el15mh 0:d7701c5c20e6 221 break;
el15mh 0:d7701c5c20e6 222 }
el15mh 0:d7701c5c20e6 223
el15mh 0:d7701c5c20e6 224 // menuSelector(selector);
el15mh 0:d7701c5c20e6 225
el15mh 0:d7701c5c20e6 226 char d = pad.get_direction();
el15mh 0:d7701c5c20e6 227
el15mh 0:d7701c5c20e6 228 if ((d == NW) ||
el15mh 0:d7701c5c20e6 229 (d == N) ||
el15mh 0:d7701c5c20e6 230 (d == NE)){
el15mh 0:d7701c5c20e6 231
el15mh 0:d7701c5c20e6 232 selected -= 1;
el15mh 0:d7701c5c20e6 233 }
el15mh 0:d7701c5c20e6 234
el15mh 0:d7701c5c20e6 235 if ((d == SW) ||
el15mh 0:d7701c5c20e6 236 (d == S) ||
el15mh 0:d7701c5c20e6 237 (d == SE)){
el15mh 0:d7701c5c20e6 238
el15mh 0:d7701c5c20e6 239 selected += 1;
el15mh 0:d7701c5c20e6 240 }
el15mh 0:d7701c5c20e6 241
el15mh 0:d7701c5c20e6 242 // printf("Joystick position = %c \n", d);
el15mh 0:d7701c5c20e6 243 // printf("Selected = %i \n", selected);
el15mh 0:d7701c5c20e6 244
el15mh 0:d7701c5c20e6 245 }
el15mh 0:d7701c5c20e6 246 }
el15mh 0:d7701c5c20e6 247
el15mh 0:d7701c5c20e6 248 void options()
el15mh 0:d7701c5c20e6 249 {
el15mh 0:d7701c5c20e6 250 int selected = 0;
el15mh 0:d7701c5c20e6 251 int exit = 0;
el15mh 0:d7701c5c20e6 252
el15mh 0:d7701c5c20e6 253 while(exit == 0){
el15mh 0:d7701c5c20e6 254
el15mh 0:d7701c5c20e6 255 int back = 0;
el15mh 0:d7701c5c20e6 256
el15mh 0:d7701c5c20e6 257 switch (selected) {
el15mh 0:d7701c5c20e6 258
el15mh 0:d7701c5c20e6 259 case 1:
el15mh 0:d7701c5c20e6 260
el15mh 0:d7701c5c20e6 261 lcd.clear();
el15mh 0:d7701c5c20e6 262 // displays options page with indicator on first
el15mh 0:d7701c5c20e6 263 lcd.printString("Game Options:", 0, 0);
el15mh 0:d7701c5c20e6 264 lcd.printString(">Difficulty", 0, 2);
el15mh 0:d7701c5c20e6 265 lcd.printString(" Ball Colour", 0, 3);
el15mh 0:d7701c5c20e6 266 lcd.refresh();
el15mh 0:d7701c5c20e6 267
el15mh 0:d7701c5c20e6 268 while (back == 0){
el15mh 0:d7701c5c20e6 269
el15mh 0:d7701c5c20e6 270 // if first option selected
el15mh 0:d7701c5c20e6 271 if (pad.check_event(Gamepad::A_PRESSED) ||
el15mh 0:d7701c5c20e6 272 pad.check_event(Gamepad::JOY_PRESSED)){
el15mh 0:d7701c5c20e6 273
el15mh 0:d7701c5c20e6 274 switch(selected){
el15mh 0:d7701c5c20e6 275
el15mh 0:d7701c5c20e6 276 case 1:
el15mh 0:d7701c5c20e6 277
el15mh 0:d7701c5c20e6 278 lcd.clear();
el15mh 0:d7701c5c20e6 279 lcd.printString("Difficulty: ", 0, 0);
el15mh 0:d7701c5c20e6 280 lcd.printString(">Easy", 0, 2);
el15mh 0:d7701c5c20e6 281 lcd.printString(" Hard", 0, 3);
el15mh 0:d7701c5c20e6 282 lcd.refresh();
el15mh 0:d7701c5c20e6 283
el15mh 0:d7701c5c20e6 284 if (pad.check_event(Gamepad::A_PRESSED) ||
el15mh 0:d7701c5c20e6 285 pad.check_event(Gamepad::JOY_PRESSED)){
el15mh 0:d7701c5c20e6 286
el15mh 0:d7701c5c20e6 287 // maze.mazeIndex = 0;
el15mh 0:d7701c5c20e6 288 }
el15mh 0:d7701c5c20e6 289
el15mh 0:d7701c5c20e6 290 wait_ms(250);
el15mh 0:d7701c5c20e6 291
el15mh 0:d7701c5c20e6 292 break;
el15mh 0:d7701c5c20e6 293
el15mh 0:d7701c5c20e6 294 case 2:
el15mh 0:d7701c5c20e6 295
el15mh 0:d7701c5c20e6 296 lcd.clear();
el15mh 0:d7701c5c20e6 297 lcd.printString("Difficulty: ", 0, 0);
el15mh 0:d7701c5c20e6 298 lcd.printString(" Easy", 0, 2);
el15mh 0:d7701c5c20e6 299 lcd.printString(">Hard", 0, 3);
el15mh 0:d7701c5c20e6 300 lcd.refresh();
el15mh 0:d7701c5c20e6 301
el15mh 0:d7701c5c20e6 302 if (pad.check_event(Gamepad::A_PRESSED) ||
el15mh 0:d7701c5c20e6 303 pad.check_event(Gamepad::JOY_PRESSED)){
el15mh 0:d7701c5c20e6 304
el15mh 0:d7701c5c20e6 305 // maze.mazeIndex = 1;
el15mh 0:d7701c5c20e6 306 lcd.printString("Hard selected", 0, 1);
el15mh 0:d7701c5c20e6 307 lcd.refresh();
el15mh 0:d7701c5c20e6 308 }
el15mh 0:d7701c5c20e6 309
el15mh 0:d7701c5c20e6 310 wait_ms(250);
el15mh 0:d7701c5c20e6 311
el15mh 0:d7701c5c20e6 312 break;
el15mh 0:d7701c5c20e6 313
el15mh 0:d7701c5c20e6 314 default:
el15mh 0:d7701c5c20e6 315
el15mh 0:d7701c5c20e6 316 selected = 0;
el15mh 0:d7701c5c20e6 317
el15mh 0:d7701c5c20e6 318 break;
el15mh 0:d7701c5c20e6 319
el15mh 0:d7701c5c20e6 320 }
el15mh 0:d7701c5c20e6 321 }
el15mh 0:d7701c5c20e6 322
el15mh 0:d7701c5c20e6 323 if (pad.check_event(Gamepad::BACK_PRESSED)){
el15mh 0:d7701c5c20e6 324
el15mh 0:d7701c5c20e6 325 back = 1;
el15mh 0:d7701c5c20e6 326 }
el15mh 0:d7701c5c20e6 327 }
el15mh 0:d7701c5c20e6 328
el15mh 0:d7701c5c20e6 329 wait(1); // 1s propogation delay
el15mh 0:d7701c5c20e6 330
el15mh 0:d7701c5c20e6 331 case 2:
el15mh 0:d7701c5c20e6 332
el15mh 0:d7701c5c20e6 333 lcd.clear();
el15mh 0:d7701c5c20e6 334 // displays options page with indicator on second
el15mh 0:d7701c5c20e6 335 lcd.printString("Game Options:", 0, 0);
el15mh 0:d7701c5c20e6 336 lcd.printString(" Difficulty", 0, 2);
el15mh 0:d7701c5c20e6 337 lcd.printString(">Ball Colour", 0, 3);
el15mh 0:d7701c5c20e6 338 lcd.refresh();
el15mh 0:d7701c5c20e6 339
el15mh 0:d7701c5c20e6 340 while (back == 0){
el15mh 0:d7701c5c20e6 341
el15mh 0:d7701c5c20e6 342 // if second option selected
el15mh 0:d7701c5c20e6 343 if (pad.check_event(Gamepad::A_PRESSED) ||
el15mh 0:d7701c5c20e6 344 pad.check_event(Gamepad::JOY_PRESSED)){
el15mh 0:d7701c5c20e6 345
el15mh 0:d7701c5c20e6 346 switch (selected){
el15mh 0:d7701c5c20e6 347
el15mh 0:d7701c5c20e6 348 case 1:
el15mh 0:d7701c5c20e6 349
el15mh 0:d7701c5c20e6 350 lcd.clear();
el15mh 0:d7701c5c20e6 351 lcd.printString("Ball colour: ", 0, 0);
el15mh 0:d7701c5c20e6 352 lcd.printString(">Transparent", 0, 2);
el15mh 0:d7701c5c20e6 353 lcd.printString(" Solid", 0, 3);
el15mh 0:d7701c5c20e6 354 lcd.refresh();
el15mh 0:d7701c5c20e6 355
el15mh 0:d7701c5c20e6 356 if (pad.check_event(Gamepad::A_PRESSED) ||
el15mh 0:d7701c5c20e6 357 pad.check_event(Gamepad::JOY_PRESSED)){
el15mh 0:d7701c5c20e6 358
el15mh 0:d7701c5c20e6 359 // ball.ballColour = 0;
el15mh 0:d7701c5c20e6 360 lcd.clear();
el15mh 0:d7701c5c20e6 361 lcd.printString("Transparent", 0, 1);
el15mh 0:d7701c5c20e6 362 lcd.refresh();
el15mh 0:d7701c5c20e6 363
el15mh 0:d7701c5c20e6 364 wait(2);
el15mh 0:d7701c5c20e6 365 }
el15mh 0:d7701c5c20e6 366
el15mh 0:d7701c5c20e6 367 break;
el15mh 0:d7701c5c20e6 368
el15mh 0:d7701c5c20e6 369 case 2:
el15mh 0:d7701c5c20e6 370
el15mh 0:d7701c5c20e6 371 lcd.printString("Ball colour: ", 0, 0);
el15mh 0:d7701c5c20e6 372 lcd.printString(" Transparent", 0, 2);
el15mh 0:d7701c5c20e6 373 lcd.printString(">Solid", 0, 3);
el15mh 0:d7701c5c20e6 374 lcd.refresh();
el15mh 0:d7701c5c20e6 375
el15mh 0:d7701c5c20e6 376 if (pad.check_event(Gamepad::A_PRESSED) ||
el15mh 0:d7701c5c20e6 377 pad.check_event(Gamepad::JOY_PRESSED)){
el15mh 0:d7701c5c20e6 378
el15mh 0:d7701c5c20e6 379 // ball.ballColour = 1;
el15mh 0:d7701c5c20e6 380 lcd.clear();
el15mh 0:d7701c5c20e6 381 lcd.printString("Solid", 0, 1);
el15mh 0:d7701c5c20e6 382 lcd.refresh();
el15mh 0:d7701c5c20e6 383
el15mh 0:d7701c5c20e6 384 wait(2);
el15mh 0:d7701c5c20e6 385 }
el15mh 0:d7701c5c20e6 386
el15mh 0:d7701c5c20e6 387 break;
el15mh 0:d7701c5c20e6 388
el15mh 0:d7701c5c20e6 389 default:
el15mh 0:d7701c5c20e6 390
el15mh 0:d7701c5c20e6 391 selected = 0;
el15mh 0:d7701c5c20e6 392 break;
el15mh 0:d7701c5c20e6 393 }
el15mh 0:d7701c5c20e6 394
el15mh 0:d7701c5c20e6 395 if (pad.check_event(Gamepad::BACK_PRESSED)){
el15mh 0:d7701c5c20e6 396
el15mh 0:d7701c5c20e6 397 back = 1;
el15mh 0:d7701c5c20e6 398 }
el15mh 0:d7701c5c20e6 399 }
el15mh 0:d7701c5c20e6 400
el15mh 0:d7701c5c20e6 401 wait(1); // 1s propogation delay
el15mh 0:d7701c5c20e6 402
el15mh 0:d7701c5c20e6 403 }
el15mh 0:d7701c5c20e6 404
el15mh 0:d7701c5c20e6 405 if (pad.check_event(Gamepad::BACK_PRESSED)){
el15mh 0:d7701c5c20e6 406
el15mh 0:d7701c5c20e6 407 exit = 1;
el15mh 0:d7701c5c20e6 408 }
el15mh 0:d7701c5c20e6 409 }
el15mh 0:d7701c5c20e6 410 }
el15mh 0:d7701c5c20e6 411 }
el15mh 0:d7701c5c20e6 412
el15mh 0:d7701c5c20e6 413
el15mh 0:d7701c5c20e6 414 void soundSettings()
el15mh 0:d7701c5c20e6 415 {
el15mh 0:d7701c5c20e6 416 pad.tone(750.0,0.1);
el15mh 0:d7701c5c20e6 417 lcd.clear();
el15mh 0:d7701c5c20e6 418 lcd.printString("Sound settings", 0, 2);
el15mh 0:d7701c5c20e6 419 lcd.refresh();
el15mh 0:d7701c5c20e6 420
el15mh 0:d7701c5c20e6 421 wait(2);
el15mh 0:d7701c5c20e6 422 }
el15mh 0:d7701c5c20e6 423
el15mh 0:d7701c5c20e6 424 void lcdSettings()
el15mh 0:d7701c5c20e6 425 {
el15mh 0:d7701c5c20e6 426 int exit = 0;
el15mh 0:d7701c5c20e6 427
el15mh 0:d7701c5c20e6 428 while(exit == 0){
el15mh 0:d7701c5c20e6 429
el15mh 0:d7701c5c20e6 430 lcd.clear();
el15mh 0:d7701c5c20e6 431 lcd.printString("LCD Settings", 0, 2);
el15mh 0:d7701c5c20e6 432 lcd.refresh();
el15mh 0:d7701c5c20e6 433
el15mh 0:d7701c5c20e6 434 if(pad.check_event(Gamepad::BACK_PRESSED)){
el15mh 0:d7701c5c20e6 435
el15mh 0:d7701c5c20e6 436 exit = 1;
el15mh 0:d7701c5c20e6 437 }
el15mh 0:d7701c5c20e6 438 }
el15mh 0:d7701c5c20e6 439 }
el15mh 0:d7701c5c20e6 440