Yiu Fai Kwok / Mbed 2 deprecated el17yfk

Dependencies:   mbed FXOS8700CQ mbed-rtos

Committer:
yfkwok
Date:
Wed Apr 17 17:53:56 2019 +0000
Revision:
13:02002658e718
Parent:
11:5a6b9dffd78a
Child:
22:f8f36e88b2ca
17/04/2019 - Update Game_two template

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yfkwok 5:bc0691d02fd5 1 #include "Exam.h"
yfkwok 5:bc0691d02fd5 2
yfkwok 5:bc0691d02fd5 3 Exam::Exam()
yfkwok 5:bc0691d02fd5 4 {
yfkwok 5:bc0691d02fd5 5
yfkwok 5:bc0691d02fd5 6 }
yfkwok 5:bc0691d02fd5 7
yfkwok 5:bc0691d02fd5 8 Exam::~Exam()
yfkwok 5:bc0691d02fd5 9 {
yfkwok 5:bc0691d02fd5 10
yfkwok 5:bc0691d02fd5 11 }
yfkwok 5:bc0691d02fd5 12
yfkwok 5:bc0691d02fd5 13 //Enumerate instruction menu from page 1 - 3
yfkwok 5:bc0691d02fd5 14 enum Page {
yfkwok 5:bc0691d02fd5 15 PAGE_1, PAGE_2, PAGE_3, PAGE_4, PAGE_5, PAGE_6, PAGE_7, PAGE_8, PAGE_9, PAGE_10
yfkwok 5:bc0691d02fd5 16 };
yfkwok 5:bc0691d02fd5 17
yfkwok 5:bc0691d02fd5 18 void Exam::exam_title(Gamepad &pad, N5110 &lcd)
yfkwok 5:bc0691d02fd5 19 {
yfkwok 5:bc0691d02fd5 20 lcd.clear();
yfkwok 11:5a6b9dffd78a 21 int instruct_data[10][78] = {
yfkwok 11:5a6b9dffd78a 22 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
yfkwok 11:5a6b9dffd78a 23 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
yfkwok 11:5a6b9dffd78a 24 {1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 25 {1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 26 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 27 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 28 {1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 29 {1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 30 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 11:5a6b9dffd78a 31 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1},
yfkwok 5:bc0691d02fd5 32 };
yfkwok 11:5a6b9dffd78a 33 lcd.drawSprite(4, 20, 10, 78, (int*)instruct_data);
yfkwok 5:bc0691d02fd5 34 lcd.refresh();
yfkwok 5:bc0691d02fd5 35
yfkwok 5:bc0691d02fd5 36 music.exam_intro(pad);
yfkwok 5:bc0691d02fd5 37 }
yfkwok 5:bc0691d02fd5 38
yfkwok 5:bc0691d02fd5 39 int Exam::exam_q_one(Gamepad &pad, N5110 &lcd, int point)
yfkwok 5:bc0691d02fd5 40 {
yfkwok 5:bc0691d02fd5 41 pad.init();
yfkwok 5:bc0691d02fd5 42 Page currentPage = PAGE_1;
yfkwok 5:bc0691d02fd5 43 int fps = 8.0;
yfkwok 5:bc0691d02fd5 44 int score = 0;
yfkwok 11:5a6b9dffd78a 45 int down[4][7] = {
yfkwok 11:5a6b9dffd78a 46 {1,1,1,1,1,1,1},
yfkwok 11:5a6b9dffd78a 47 {0,1,1,1,1,1,0},
yfkwok 11:5a6b9dffd78a 48 {0,0,1,1,1,0,0},
yfkwok 11:5a6b9dffd78a 49 {0,0,0,1,0,0,0},
yfkwok 5:bc0691d02fd5 50 };
yfkwok 11:5a6b9dffd78a 51 int up[4][7] = {
yfkwok 11:5a6b9dffd78a 52 {0,0,0,1,0,0,0},
yfkwok 11:5a6b9dffd78a 53 {0,0,1,1,1,0,0},
yfkwok 11:5a6b9dffd78a 54 {0,1,1,1,1,1,0},
yfkwok 11:5a6b9dffd78a 55 {1,1,1,1,1,1,1},
yfkwok 5:bc0691d02fd5 56 };
yfkwok 5:bc0691d02fd5 57 bool finished = false;
yfkwok 5:bc0691d02fd5 58
yfkwok 5:bc0691d02fd5 59 while(pad.check_event(Gamepad::START_PRESSED) == false){
yfkwok 5:bc0691d02fd5 60 //music.gym(pad, !finished);
yfkwok 5:bc0691d02fd5 61 switch (currentPage) {
yfkwok 5:bc0691d02fd5 62 case PAGE_1:
yfkwok 13:02002658e718 63 pad.init_input();
yfkwok 5:bc0691d02fd5 64 lcd.clear();
yfkwok 5:bc0691d02fd5 65 lcd.printString("Question 1",0,0);
yfkwok 5:bc0691d02fd5 66 lcd.printString("What is the",0,1);
yfkwok 5:bc0691d02fd5 67 lcd.printString("cut off",0,2);
yfkwok 5:bc0691d02fd5 68 lcd.printString("frequency ",0,3);
yfkwok 5:bc0691d02fd5 69 lcd.printString("of a circuit",0,4);
yfkwok 11:5a6b9dffd78a 70 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 71 lcd.refresh();
yfkwok 5:bc0691d02fd5 72 if(pad.get_direction() == S){currentPage = PAGE_2;}
yfkwok 5:bc0691d02fd5 73 if(pad.get_direction() == N){currentPage = PAGE_1;}
yfkwok 10:adff3c804985 74 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 75 break;
yfkwok 5:bc0691d02fd5 76 case PAGE_2:
yfkwok 13:02002658e718 77 pad.init_input();
yfkwok 5:bc0691d02fd5 78 lcd.clear();
yfkwok 5:bc0691d02fd5 79 lcd.printString("formed by a",0,0);
yfkwok 5:bc0691d02fd5 80 lcd.printString("50k resistor",0,1);
yfkwok 5:bc0691d02fd5 81 lcd.printString("and capacitor",0,2);
yfkwok 5:bc0691d02fd5 82 lcd.printString("of 120pF in",0,3);
yfkwok 5:bc0691d02fd5 83 lcd.printString("series?",0,4);
yfkwok 11:5a6b9dffd78a 84 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 85 lcd.refresh();
yfkwok 5:bc0691d02fd5 86 if(pad.get_direction() == S){currentPage = PAGE_3;}
yfkwok 5:bc0691d02fd5 87 if(pad.get_direction() == N){currentPage = PAGE_1;}
yfkwok 10:adff3c804985 88 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 89 break;
yfkwok 5:bc0691d02fd5 90 case PAGE_3:
yfkwok 13:02002658e718 91 pad.init_input();
yfkwok 5:bc0691d02fd5 92 lcd.clear();
yfkwok 5:bc0691d02fd5 93 if (point > 0){
yfkwok 5:bc0691d02fd5 94 lcd.printString("A. 26.5kHz",0,2);
yfkwok 5:bc0691d02fd5 95 lcd.printString("B. 2.61MHz",0,3);
yfkwok 5:bc0691d02fd5 96 lcd.printString("X. 26.3kHz",0,4);
yfkwok 5:bc0691d02fd5 97 lcd.printString("Y. 26.5MHz",0,5);
yfkwok 5:bc0691d02fd5 98 }
yfkwok 5:bc0691d02fd5 99 else {
yfkwok 5:bc0691d02fd5 100 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 101 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 102 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 103 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 104 }
yfkwok 11:5a6b9dffd78a 105 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 106 lcd.refresh();
yfkwok 5:bc0691d02fd5 107 if(pad.get_direction() == N){currentPage = PAGE_2;}
yfkwok 5:bc0691d02fd5 108 if(pad.check_event(Gamepad::A_PRESSED) == true){
yfkwok 5:bc0691d02fd5 109 score++;
yfkwok 5:bc0691d02fd5 110 currentPage = PAGE_4;
yfkwok 5:bc0691d02fd5 111 }
yfkwok 5:bc0691d02fd5 112 if((pad.check_event(Gamepad::B_PRESSED) == true)
yfkwok 5:bc0691d02fd5 113 || (pad.check_event(Gamepad::X_PRESSED) == true)
yfkwok 5:bc0691d02fd5 114 || (pad.check_event(Gamepad::Y_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 115 currentPage = PAGE_4;
yfkwok 5:bc0691d02fd5 116 }
yfkwok 10:adff3c804985 117 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 118 break;
yfkwok 5:bc0691d02fd5 119 case PAGE_4:
yfkwok 13:02002658e718 120 pad.init_input();
yfkwok 5:bc0691d02fd5 121 lcd.clear();
yfkwok 5:bc0691d02fd5 122 lcd.printString("Question 2",0,0);
yfkwok 5:bc0691d02fd5 123 lcd.printString("What is the",0,1);
yfkwok 5:bc0691d02fd5 124 lcd.printString("integration",0,2);
yfkwok 5:bc0691d02fd5 125 lcd.printString("of function",0,3);
yfkwok 5:bc0691d02fd5 126 lcd.printString("1/(6+5cos(x))",0,4);
yfkwok 11:5a6b9dffd78a 127 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 128 lcd.refresh();
yfkwok 5:bc0691d02fd5 129 if(pad.get_direction() == S){currentPage = PAGE_5;}
yfkwok 5:bc0691d02fd5 130 if(pad.get_direction() == N){currentPage = PAGE_4;}
yfkwok 10:adff3c804985 131 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 132 break;
yfkwok 5:bc0691d02fd5 133 case PAGE_5:
yfkwok 13:02002658e718 134 pad.init_input();
yfkwok 5:bc0691d02fd5 135 lcd.clear();
yfkwok 5:bc0691d02fd5 136 lcd.printString("with respect",0,0);
yfkwok 5:bc0691d02fd5 137 lcd.printString("to x for ",0,1);
yfkwok 5:bc0691d02fd5 138 lcd.printString("[0,pi/2]?",0,2);
yfkwok 11:5a6b9dffd78a 139 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 140 lcd.refresh();
yfkwok 5:bc0691d02fd5 141 if(pad.get_direction() == S){currentPage = PAGE_6;}
yfkwok 5:bc0691d02fd5 142 if(pad.get_direction() == N){currentPage = PAGE_4;}
yfkwok 10:adff3c804985 143 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 144 break;
yfkwok 5:bc0691d02fd5 145 case PAGE_6:
yfkwok 13:02002658e718 146 pad.init_input();
yfkwok 5:bc0691d02fd5 147 lcd.clear();
yfkwok 5:bc0691d02fd5 148 if(point > 1) {
yfkwok 5:bc0691d02fd5 149 lcd.printString("A. 0.1354",0,2);
yfkwok 5:bc0691d02fd5 150 lcd.printString("B. 2.617",0,3);
yfkwok 5:bc0691d02fd5 151 lcd.printString("X. 5.779",0,4);
yfkwok 5:bc0691d02fd5 152 lcd.printString("Y. 0.1766",0,5);
yfkwok 5:bc0691d02fd5 153 }
yfkwok 5:bc0691d02fd5 154 else {
yfkwok 5:bc0691d02fd5 155 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 156 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 157 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 158 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 159 }
yfkwok 11:5a6b9dffd78a 160 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 161 lcd.refresh();
yfkwok 5:bc0691d02fd5 162 if(pad.get_direction() == N){currentPage = PAGE_5;}
yfkwok 5:bc0691d02fd5 163 if(pad.check_event(Gamepad::Y_PRESSED) == true){
yfkwok 5:bc0691d02fd5 164 score++;
yfkwok 5:bc0691d02fd5 165 currentPage = PAGE_7;
yfkwok 5:bc0691d02fd5 166 }
yfkwok 5:bc0691d02fd5 167 if((pad.check_event(Gamepad::A_PRESSED) == true)
yfkwok 5:bc0691d02fd5 168 || (pad.check_event(Gamepad::B_PRESSED) == true)
yfkwok 5:bc0691d02fd5 169 || (pad.check_event(Gamepad::X_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 170 currentPage = PAGE_7;
yfkwok 5:bc0691d02fd5 171 }
yfkwok 10:adff3c804985 172 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 173 break;
yfkwok 5:bc0691d02fd5 174 case PAGE_7:
yfkwok 13:02002658e718 175 pad.init_input();
yfkwok 5:bc0691d02fd5 176 lcd.clear();
yfkwok 5:bc0691d02fd5 177 lcd.printString("Question 3",0,0);
yfkwok 5:bc0691d02fd5 178 lcd.printString("What is the",0,1);
yfkwok 5:bc0691d02fd5 179 lcd.printString("integration",0,2);
yfkwok 5:bc0691d02fd5 180 lcd.printString("of function",0,3);
yfkwok 5:bc0691d02fd5 181 lcd.printString("tan(x)",0,4);
yfkwok 11:5a6b9dffd78a 182 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 183 lcd.refresh();
yfkwok 5:bc0691d02fd5 184 if(pad.get_direction() == S){currentPage = PAGE_8;}
yfkwok 5:bc0691d02fd5 185 if(pad.get_direction() == N){currentPage = PAGE_7;}
yfkwok 10:adff3c804985 186 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 187 break;
yfkwok 5:bc0691d02fd5 188 case PAGE_8:
yfkwok 13:02002658e718 189 pad.init_input();
yfkwok 5:bc0691d02fd5 190 lcd.clear();
yfkwok 5:bc0691d02fd5 191 lcd.printString("with respect",0,0);
yfkwok 5:bc0691d02fd5 192 lcd.printString("to x?",0,1);
yfkwok 11:5a6b9dffd78a 193 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 194 lcd.refresh();
yfkwok 5:bc0691d02fd5 195 if(pad.get_direction() == S){currentPage = PAGE_9;}
yfkwok 5:bc0691d02fd5 196 if(pad.get_direction() == N){currentPage = PAGE_7;}
yfkwok 10:adff3c804985 197 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 198 break;
yfkwok 5:bc0691d02fd5 199 case PAGE_9:
yfkwok 13:02002658e718 200 pad.init_input();
yfkwok 10:adff3c804985 201 lcd.clear();
yfkwok 5:bc0691d02fd5 202 if(point > 2) {
yfkwok 5:bc0691d02fd5 203 lcd.printString("A. -ln|cos(x)|",0,2);
yfkwok 5:bc0691d02fd5 204 lcd.printString("B. -arctan(x)",0,3);
yfkwok 5:bc0691d02fd5 205 lcd.printString("X. -ln|sec(x)|",0,4);
yfkwok 5:bc0691d02fd5 206 lcd.printString("Y. -cot(1/x)",0,5);
yfkwok 5:bc0691d02fd5 207 }
yfkwok 5:bc0691d02fd5 208 else {
yfkwok 5:bc0691d02fd5 209 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 210 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 211 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 212 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 213 }
yfkwok 11:5a6b9dffd78a 214 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 215 lcd.refresh();
yfkwok 5:bc0691d02fd5 216 if(pad.get_direction() == N){currentPage = PAGE_8;}
yfkwok 5:bc0691d02fd5 217 if(pad.check_event(Gamepad::A_PRESSED) == true){
yfkwok 5:bc0691d02fd5 218 score++;
yfkwok 5:bc0691d02fd5 219 currentPage = PAGE_10;
yfkwok 5:bc0691d02fd5 220 }
yfkwok 5:bc0691d02fd5 221 if((pad.check_event(Gamepad::B_PRESSED) == true)
yfkwok 5:bc0691d02fd5 222 || (pad.check_event(Gamepad::Y_PRESSED) == true)
yfkwok 5:bc0691d02fd5 223 || (pad.check_event(Gamepad::X_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 224 currentPage = PAGE_10;
yfkwok 5:bc0691d02fd5 225 }
yfkwok 10:adff3c804985 226 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 227 break;
yfkwok 5:bc0691d02fd5 228 case PAGE_10:
yfkwok 13:02002658e718 229 pad.init_input();
yfkwok 5:bc0691d02fd5 230 lcd.clear();
yfkwok 5:bc0691d02fd5 231 lcd.printString("EXAM",0,0);
yfkwok 5:bc0691d02fd5 232 lcd.printString("COMPLETE",0,1);
yfkwok 5:bc0691d02fd5 233 lcd.printString("PRESS START",0,5);
yfkwok 5:bc0691d02fd5 234 lcd.refresh();
yfkwok 5:bc0691d02fd5 235 if(pad.check_event(Gamepad::START_PRESSED) == true) {finished = true;}
yfkwok 10:adff3c804985 236 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 237 break;
yfkwok 5:bc0691d02fd5 238 }
yfkwok 5:bc0691d02fd5 239 }
yfkwok 5:bc0691d02fd5 240 return score;
yfkwok 5:bc0691d02fd5 241 }
yfkwok 5:bc0691d02fd5 242
yfkwok 5:bc0691d02fd5 243 int Exam::exam_q_two(Gamepad &pad, N5110 &lcd, int point)
yfkwok 5:bc0691d02fd5 244 {
yfkwok 5:bc0691d02fd5 245 pad.init();
yfkwok 5:bc0691d02fd5 246 Page currentPage = PAGE_1;
yfkwok 5:bc0691d02fd5 247 int fps = 8.0;
yfkwok 5:bc0691d02fd5 248 int score = 0;
yfkwok 11:5a6b9dffd78a 249 int down[4][7] = {
yfkwok 11:5a6b9dffd78a 250 {1,1,1,1,1,1,1},
yfkwok 11:5a6b9dffd78a 251 {0,1,1,1,1,1,0},
yfkwok 11:5a6b9dffd78a 252 {0,0,1,1,1,0,0},
yfkwok 11:5a6b9dffd78a 253 {0,0,0,1,0,0,0},
yfkwok 5:bc0691d02fd5 254 };
yfkwok 11:5a6b9dffd78a 255 int up[4][7] = {
yfkwok 11:5a6b9dffd78a 256 {0,0,0,1,0,0,0},
yfkwok 11:5a6b9dffd78a 257 {0,0,1,1,1,0,0},
yfkwok 11:5a6b9dffd78a 258 {0,1,1,1,1,1,0},
yfkwok 11:5a6b9dffd78a 259 {1,1,1,1,1,1,1},
yfkwok 5:bc0691d02fd5 260 };
yfkwok 5:bc0691d02fd5 261 bool finished = false;
yfkwok 5:bc0691d02fd5 262
yfkwok 5:bc0691d02fd5 263 while(pad.check_event(Gamepad::START_PRESSED) == false){
yfkwok 5:bc0691d02fd5 264 //music.gym(pad, !finished);
yfkwok 5:bc0691d02fd5 265 switch (currentPage) {
yfkwok 5:bc0691d02fd5 266 case PAGE_1:
yfkwok 5:bc0691d02fd5 267 lcd.clear();
yfkwok 5:bc0691d02fd5 268 lcd.printString("Question 1",0,0);
yfkwok 5:bc0691d02fd5 269 lcd.printString("A GaAs LED",0,1);
yfkwok 5:bc0691d02fd5 270 lcd.printString("with bandgap",0,2);
yfkwok 5:bc0691d02fd5 271 lcd.printString("of 1.42eV. ",0,3);
yfkwok 5:bc0691d02fd5 272 lcd.printString("Calculate",0,4);
yfkwok 11:5a6b9dffd78a 273 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 274 lcd.refresh();
yfkwok 5:bc0691d02fd5 275 if(pad.get_direction() == S){currentPage = PAGE_2;}
yfkwok 5:bc0691d02fd5 276 if(pad.get_direction() == N){currentPage = PAGE_1;}
yfkwok 10:adff3c804985 277 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 278 break;
yfkwok 5:bc0691d02fd5 279 case PAGE_2:
yfkwok 5:bc0691d02fd5 280 lcd.clear();
yfkwok 5:bc0691d02fd5 281 lcd.printString("the longest",0,0);
yfkwok 5:bc0691d02fd5 282 lcd.printString("wavelength",0,1);
yfkwok 5:bc0691d02fd5 283 lcd.printString("photo that can",0,2);
yfkwok 5:bc0691d02fd5 284 lcd.printString("be emitted",0,3);
yfkwok 5:bc0691d02fd5 285 lcd.printString("by it.",0,4);
yfkwok 11:5a6b9dffd78a 286 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 287 lcd.refresh();
yfkwok 5:bc0691d02fd5 288 if(pad.get_direction() == S){currentPage = PAGE_3;}
yfkwok 5:bc0691d02fd5 289 if(pad.get_direction() == N){currentPage = PAGE_1;}
yfkwok 10:adff3c804985 290 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 291 break;
yfkwok 5:bc0691d02fd5 292 case PAGE_3:
yfkwok 5:bc0691d02fd5 293 lcd.clear();
yfkwok 5:bc0691d02fd5 294 if (point > 0){
yfkwok 5:bc0691d02fd5 295 lcd.printString("A. 913.52nm",0,2);
yfkwok 5:bc0691d02fd5 296 lcd.printString("B. 875.44nm",0,3);
yfkwok 5:bc0691d02fd5 297 lcd.printString("X. 688.91nm",0,4);
yfkwok 5:bc0691d02fd5 298 lcd.printString("Y. 31.29um",0,5);
yfkwok 5:bc0691d02fd5 299 }
yfkwok 5:bc0691d02fd5 300 else {
yfkwok 5:bc0691d02fd5 301 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 302 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 303 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 304 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 305 }
yfkwok 11:5a6b9dffd78a 306 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 307 lcd.refresh();
yfkwok 5:bc0691d02fd5 308 if(pad.get_direction() == N){currentPage = PAGE_2;}
yfkwok 5:bc0691d02fd5 309 if(pad.check_event(Gamepad::B_PRESSED) == true){
yfkwok 5:bc0691d02fd5 310 score++;
yfkwok 5:bc0691d02fd5 311 currentPage = PAGE_4;
yfkwok 5:bc0691d02fd5 312 }
yfkwok 5:bc0691d02fd5 313 if((pad.check_event(Gamepad::A_PRESSED) == true)
yfkwok 5:bc0691d02fd5 314 || (pad.check_event(Gamepad::X_PRESSED) == true)
yfkwok 5:bc0691d02fd5 315 || (pad.check_event(Gamepad::Y_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 316 currentPage = PAGE_4;
yfkwok 5:bc0691d02fd5 317 }
yfkwok 10:adff3c804985 318 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 319 break;
yfkwok 5:bc0691d02fd5 320 case PAGE_4:
yfkwok 5:bc0691d02fd5 321 lcd.clear();
yfkwok 5:bc0691d02fd5 322 lcd.printString("Question 2",0,0);
yfkwok 5:bc0691d02fd5 323 lcd.printString("If the control",0,1);
yfkwok 5:bc0691d02fd5 324 lcd.printString("signal for",0,2);
yfkwok 5:bc0691d02fd5 325 lcd.printString("the switch is",0,3);
yfkwok 5:bc0691d02fd5 326 lcd.printString("closed for",0,4);
yfkwok 11:5a6b9dffd78a 327 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 328 lcd.refresh();
yfkwok 5:bc0691d02fd5 329 if(pad.get_direction() == S){currentPage = PAGE_5;}
yfkwok 5:bc0691d02fd5 330 if(pad.get_direction() == N){currentPage = PAGE_4;}
yfkwok 10:adff3c804985 331 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 332 break;
yfkwok 5:bc0691d02fd5 333 case PAGE_5:
yfkwok 5:bc0691d02fd5 334 lcd.clear();
yfkwok 5:bc0691d02fd5 335 lcd.printString("t(on) = 70us",0,0);
yfkwok 5:bc0691d02fd5 336 lcd.printString("t(off) = 30us",0,1);
yfkwok 5:bc0691d02fd5 337 lcd.printString("what is the",0,2);
yfkwok 5:bc0691d02fd5 338 lcd.printString("switching",0,3);
yfkwok 5:bc0691d02fd5 339 lcd.printString("frequency?",0,4);
yfkwok 11:5a6b9dffd78a 340 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 341 lcd.refresh();
yfkwok 5:bc0691d02fd5 342 if(pad.get_direction() == S){currentPage = PAGE_6;}
yfkwok 5:bc0691d02fd5 343 if(pad.get_direction() == N){currentPage = PAGE_4;}
yfkwok 10:adff3c804985 344 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 345 break;
yfkwok 5:bc0691d02fd5 346 case PAGE_6:
yfkwok 5:bc0691d02fd5 347 lcd.clear();
yfkwok 5:bc0691d02fd5 348 if(point > 1) {
yfkwok 5:bc0691d02fd5 349 lcd.printString("A. 10kHz",0,2);
yfkwok 5:bc0691d02fd5 350 lcd.printString("B. 100kHz",0,3);
yfkwok 5:bc0691d02fd5 351 lcd.printString("X. 1MHz",0,4);
yfkwok 5:bc0691d02fd5 352 lcd.printString("Y. 10MHz",0,5);
yfkwok 5:bc0691d02fd5 353 }
yfkwok 5:bc0691d02fd5 354 else {
yfkwok 5:bc0691d02fd5 355 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 356 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 357 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 358 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 359 }
yfkwok 11:5a6b9dffd78a 360 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 361 lcd.refresh();
yfkwok 5:bc0691d02fd5 362 if(pad.get_direction() == N){currentPage = PAGE_5;}
yfkwok 5:bc0691d02fd5 363 if(pad.check_event(Gamepad::A_PRESSED) == true){
yfkwok 5:bc0691d02fd5 364 score++;
yfkwok 5:bc0691d02fd5 365 currentPage = PAGE_7;
yfkwok 5:bc0691d02fd5 366 }
yfkwok 5:bc0691d02fd5 367 if((pad.check_event(Gamepad::Y_PRESSED) == true)
yfkwok 5:bc0691d02fd5 368 || (pad.check_event(Gamepad::B_PRESSED) == true)
yfkwok 5:bc0691d02fd5 369 || (pad.check_event(Gamepad::X_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 370 currentPage = PAGE_7;
yfkwok 5:bc0691d02fd5 371 }
yfkwok 10:adff3c804985 372 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 373 break;
yfkwok 5:bc0691d02fd5 374 case PAGE_7:
yfkwok 5:bc0691d02fd5 375 lcd.clear();
yfkwok 5:bc0691d02fd5 376 lcd.printString("Question 3",0,0);
yfkwok 5:bc0691d02fd5 377 lcd.printString("Let x(t) be a",0,1);
yfkwok 5:bc0691d02fd5 378 lcd.printString("signal with",0,2);
yfkwok 5:bc0691d02fd5 379 lcd.printString("x(t)=0 for t>2",0,3);
yfkwok 5:bc0691d02fd5 380 lcd.printString("and t<6. What",0,4);
yfkwok 11:5a6b9dffd78a 381 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 382 lcd.refresh();
yfkwok 5:bc0691d02fd5 383 if(pad.get_direction() == S){currentPage = PAGE_8;}
yfkwok 5:bc0691d02fd5 384 if(pad.get_direction() == N){currentPage = PAGE_7;}
yfkwok 10:adff3c804985 385 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 386 break;
yfkwok 5:bc0691d02fd5 387 case PAGE_8:
yfkwok 5:bc0691d02fd5 388 lcd.clear();
yfkwok 5:bc0691d02fd5 389 lcd.printString("is the value",0,0);
yfkwok 5:bc0691d02fd5 390 lcd.printString("of x(-t+5) at",0,1);
yfkwok 5:bc0691d02fd5 391 lcd.printString("t=0?",0,2);
yfkwok 11:5a6b9dffd78a 392 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 393 lcd.refresh();
yfkwok 5:bc0691d02fd5 394 if(pad.get_direction() == S){currentPage = PAGE_9;}
yfkwok 5:bc0691d02fd5 395 if(pad.get_direction() == N){currentPage = PAGE_7;}
yfkwok 10:adff3c804985 396 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 397 break;
yfkwok 5:bc0691d02fd5 398 case PAGE_9:
yfkwok 5:bc0691d02fd5 399 lcd.clear();
yfkwok 5:bc0691d02fd5 400 if(point > 2) {
yfkwok 5:bc0691d02fd5 401 lcd.printString("A. x(0)",0,2);
yfkwok 5:bc0691d02fd5 402 lcd.printString("B. x(1)",0,3);
yfkwok 5:bc0691d02fd5 403 lcd.printString("X. x(2)",0,4);
yfkwok 5:bc0691d02fd5 404 lcd.printString("Y. x(3)",0,5);
yfkwok 5:bc0691d02fd5 405 }
yfkwok 5:bc0691d02fd5 406 else {
yfkwok 5:bc0691d02fd5 407 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 408 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 409 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 410 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 411 }
yfkwok 11:5a6b9dffd78a 412 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 413 lcd.refresh();
yfkwok 5:bc0691d02fd5 414 if(pad.get_direction() == N){currentPage = PAGE_8;}
yfkwok 5:bc0691d02fd5 415 if(pad.check_event(Gamepad::Y_PRESSED) == true){
yfkwok 5:bc0691d02fd5 416 score++;
yfkwok 5:bc0691d02fd5 417 currentPage = PAGE_10;
yfkwok 5:bc0691d02fd5 418 }
yfkwok 5:bc0691d02fd5 419 if((pad.check_event(Gamepad::B_PRESSED) == true)
yfkwok 5:bc0691d02fd5 420 || (pad.check_event(Gamepad::A_PRESSED) == true)
yfkwok 5:bc0691d02fd5 421 || (pad.check_event(Gamepad::X_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 422 currentPage = PAGE_10;
yfkwok 5:bc0691d02fd5 423 }
yfkwok 10:adff3c804985 424 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 425 break;
yfkwok 5:bc0691d02fd5 426 case PAGE_10:
yfkwok 5:bc0691d02fd5 427 lcd.clear();
yfkwok 5:bc0691d02fd5 428 lcd.printString("EXAM",0,0);
yfkwok 5:bc0691d02fd5 429 lcd.printString("COMPLETE",0,1);
yfkwok 5:bc0691d02fd5 430 lcd.printString("PRESS START",0,5);
yfkwok 5:bc0691d02fd5 431 lcd.refresh();
yfkwok 5:bc0691d02fd5 432 if(pad.check_event(Gamepad::START_PRESSED) == true) {finished = true;}
yfkwok 10:adff3c804985 433 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 434 break;
yfkwok 5:bc0691d02fd5 435 }
yfkwok 5:bc0691d02fd5 436 }
yfkwok 5:bc0691d02fd5 437 return score;
yfkwok 5:bc0691d02fd5 438 }
yfkwok 5:bc0691d02fd5 439
yfkwok 5:bc0691d02fd5 440 int Exam::exam_q_three(Gamepad &pad, N5110 &lcd, int point)
yfkwok 5:bc0691d02fd5 441 {
yfkwok 5:bc0691d02fd5 442 pad.init();
yfkwok 5:bc0691d02fd5 443 Page currentPage = PAGE_1;
yfkwok 5:bc0691d02fd5 444 int fps = 8.0;
yfkwok 5:bc0691d02fd5 445 int score = 0;
yfkwok 11:5a6b9dffd78a 446 int down[4][7] = {
yfkwok 11:5a6b9dffd78a 447 {1,1,1,1,1,1,1},
yfkwok 11:5a6b9dffd78a 448 {0,1,1,1,1,1,0},
yfkwok 11:5a6b9dffd78a 449 {0,0,1,1,1,0,0},
yfkwok 11:5a6b9dffd78a 450 {0,0,0,1,0,0,0},
yfkwok 5:bc0691d02fd5 451 };
yfkwok 11:5a6b9dffd78a 452 int up[4][7] = {
yfkwok 11:5a6b9dffd78a 453 {0,0,0,1,0,0,0},
yfkwok 11:5a6b9dffd78a 454 {0,0,1,1,1,0,0},
yfkwok 11:5a6b9dffd78a 455 {0,1,1,1,1,1,0},
yfkwok 11:5a6b9dffd78a 456 {1,1,1,1,1,1,1},
yfkwok 5:bc0691d02fd5 457 };
yfkwok 5:bc0691d02fd5 458 bool finished = false;
yfkwok 5:bc0691d02fd5 459
yfkwok 5:bc0691d02fd5 460 while(pad.check_event(Gamepad::START_PRESSED) == false){
yfkwok 5:bc0691d02fd5 461 //music.gym(pad, !finished);
yfkwok 5:bc0691d02fd5 462 switch (currentPage) {
yfkwok 5:bc0691d02fd5 463 case PAGE_1:
yfkwok 13:02002658e718 464 pad.init_input();
yfkwok 5:bc0691d02fd5 465 lcd.clear();
yfkwok 5:bc0691d02fd5 466 if (point > 0){
yfkwok 5:bc0691d02fd5 467 lcd.printString("Question 1",0,0);
yfkwok 5:bc0691d02fd5 468 lcd.printString("The answer is",0,1);
yfkwok 5:bc0691d02fd5 469 lcd.printString("A",0,2);
yfkwok 5:bc0691d02fd5 470 }
yfkwok 5:bc0691d02fd5 471 else {
yfkwok 5:bc0691d02fd5 472 lcd.printString("$%^&*$%^&*",0,0);
yfkwok 5:bc0691d02fd5 473 lcd.printString("$%^&*$%^&*",0,1);
yfkwok 5:bc0691d02fd5 474 lcd.printString("$%^&*$%^&*",0,2);
yfkwok 5:bc0691d02fd5 475 lcd.printString("$%^&*$%^&*",0,3);
yfkwok 5:bc0691d02fd5 476 }
yfkwok 11:5a6b9dffd78a 477 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 478 lcd.refresh();
yfkwok 5:bc0691d02fd5 479 if(pad.get_direction() == S){currentPage = PAGE_2;}
yfkwok 5:bc0691d02fd5 480 if(pad.get_direction() == N){currentPage = PAGE_1;}
yfkwok 10:adff3c804985 481 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 482 break;
yfkwok 5:bc0691d02fd5 483 case PAGE_2:
yfkwok 13:02002658e718 484 pad.init_input();
yfkwok 5:bc0691d02fd5 485 lcd.clear();
yfkwok 5:bc0691d02fd5 486 if (point > 0){
yfkwok 5:bc0691d02fd5 487 lcd.printString("A. ",0,2);
yfkwok 5:bc0691d02fd5 488 lcd.printString("B. ",0,3);
yfkwok 5:bc0691d02fd5 489 lcd.printString("X. ",0,4);
yfkwok 5:bc0691d02fd5 490 lcd.printString("Y. ",0,5);
yfkwok 5:bc0691d02fd5 491 }
yfkwok 5:bc0691d02fd5 492 else {
yfkwok 5:bc0691d02fd5 493 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 494 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 495 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 496 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 497 }
yfkwok 11:5a6b9dffd78a 498 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 499 lcd.refresh();
yfkwok 5:bc0691d02fd5 500 if(pad.get_direction() == N){currentPage = PAGE_1;}
yfkwok 5:bc0691d02fd5 501 if(pad.check_event(Gamepad::A_PRESSED) == true){
yfkwok 5:bc0691d02fd5 502 score++;
yfkwok 5:bc0691d02fd5 503 currentPage = PAGE_3;
yfkwok 5:bc0691d02fd5 504 }
yfkwok 5:bc0691d02fd5 505 if((pad.check_event(Gamepad::B_PRESSED) == true)
yfkwok 5:bc0691d02fd5 506 || (pad.check_event(Gamepad::X_PRESSED) == true)
yfkwok 5:bc0691d02fd5 507 || (pad.check_event(Gamepad::Y_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 508 currentPage = PAGE_3;
yfkwok 5:bc0691d02fd5 509 }
yfkwok 10:adff3c804985 510 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 511 break;
yfkwok 5:bc0691d02fd5 512 case PAGE_3:
yfkwok 13:02002658e718 513 pad.init_input();
yfkwok 5:bc0691d02fd5 514 lcd.clear();
yfkwok 5:bc0691d02fd5 515 if (point > 1){
yfkwok 5:bc0691d02fd5 516 lcd.printString("Question 2",0,0);
yfkwok 5:bc0691d02fd5 517 lcd.printString("The answer is",0,1);
yfkwok 5:bc0691d02fd5 518 lcd.printString("B",0,2);
yfkwok 5:bc0691d02fd5 519 }
yfkwok 5:bc0691d02fd5 520 else {
yfkwok 5:bc0691d02fd5 521 lcd.printString("$%^&*$%^&*",0,0);
yfkwok 5:bc0691d02fd5 522 lcd.printString("$%^&*$%^&*",0,1);
yfkwok 5:bc0691d02fd5 523 lcd.printString("$%^&*$%^&*",0,2);
yfkwok 5:bc0691d02fd5 524 lcd.printString("$%^&*$%^&*",0,3);
yfkwok 5:bc0691d02fd5 525 }
yfkwok 11:5a6b9dffd78a 526 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 527 lcd.refresh();
yfkwok 5:bc0691d02fd5 528 if(pad.get_direction() == S){currentPage = PAGE_4;}
yfkwok 5:bc0691d02fd5 529 if(pad.get_direction() == N){currentPage = PAGE_3;}
yfkwok 10:adff3c804985 530 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 531 break;
yfkwok 5:bc0691d02fd5 532 case PAGE_4:
yfkwok 13:02002658e718 533 pad.init_input();
yfkwok 5:bc0691d02fd5 534 lcd.clear();
yfkwok 5:bc0691d02fd5 535 if (point > 1){
yfkwok 5:bc0691d02fd5 536 lcd.printString("A. ",0,2);
yfkwok 5:bc0691d02fd5 537 lcd.printString("B. ",0,3);
yfkwok 5:bc0691d02fd5 538 lcd.printString("X. ",0,4);
yfkwok 5:bc0691d02fd5 539 lcd.printString("Y. ",0,5);
yfkwok 5:bc0691d02fd5 540 }
yfkwok 5:bc0691d02fd5 541 else {
yfkwok 5:bc0691d02fd5 542 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 543 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 544 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 545 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 546 }
yfkwok 11:5a6b9dffd78a 547 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 548 lcd.refresh();
yfkwok 5:bc0691d02fd5 549 if(pad.get_direction() == N){currentPage = PAGE_3;}
yfkwok 5:bc0691d02fd5 550 if(pad.check_event(Gamepad::B_PRESSED) == true){
yfkwok 5:bc0691d02fd5 551 score++;
yfkwok 5:bc0691d02fd5 552 currentPage = PAGE_5;
yfkwok 5:bc0691d02fd5 553 }
yfkwok 5:bc0691d02fd5 554 if((pad.check_event(Gamepad::A_PRESSED) == true)
yfkwok 5:bc0691d02fd5 555 || (pad.check_event(Gamepad::X_PRESSED) == true)
yfkwok 5:bc0691d02fd5 556 || (pad.check_event(Gamepad::Y_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 557 currentPage = PAGE_5;
yfkwok 5:bc0691d02fd5 558 }
yfkwok 10:adff3c804985 559 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 560 break;
yfkwok 5:bc0691d02fd5 561 case PAGE_5:
yfkwok 13:02002658e718 562 pad.init_input();
yfkwok 5:bc0691d02fd5 563 lcd.clear();
yfkwok 5:bc0691d02fd5 564 if (point > 2){
yfkwok 5:bc0691d02fd5 565 lcd.printString("Question 3",0,0);
yfkwok 5:bc0691d02fd5 566 lcd.printString("The answer is",0,1);
yfkwok 5:bc0691d02fd5 567 lcd.printString("Y",0,2);
yfkwok 5:bc0691d02fd5 568 }
yfkwok 5:bc0691d02fd5 569 else {
yfkwok 5:bc0691d02fd5 570 lcd.printString("$%^&*$%^&*",0,0);
yfkwok 5:bc0691d02fd5 571 lcd.printString("$%^&*$%^&*",0,1);
yfkwok 5:bc0691d02fd5 572 lcd.printString("$%^&*$%^&*",0,2);
yfkwok 5:bc0691d02fd5 573 lcd.printString("$%^&*$%^&*",0,3);
yfkwok 5:bc0691d02fd5 574 }
yfkwok 11:5a6b9dffd78a 575 lcd.drawSprite(39, 44, 4, 7, (int*)down);
yfkwok 5:bc0691d02fd5 576 lcd.refresh();
yfkwok 5:bc0691d02fd5 577 if(pad.get_direction() == S){currentPage = PAGE_6;}
yfkwok 5:bc0691d02fd5 578 if(pad.get_direction() == N){currentPage = PAGE_5;}
yfkwok 10:adff3c804985 579 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 580 break;
yfkwok 5:bc0691d02fd5 581 case PAGE_6:
yfkwok 13:02002658e718 582 pad.init_input();
yfkwok 5:bc0691d02fd5 583 lcd.clear();
yfkwok 5:bc0691d02fd5 584 if (point > 2){
yfkwok 5:bc0691d02fd5 585 lcd.printString("A. ",0,2);
yfkwok 5:bc0691d02fd5 586 lcd.printString("B. ",0,3);
yfkwok 5:bc0691d02fd5 587 lcd.printString("X. ",0,4);
yfkwok 5:bc0691d02fd5 588 lcd.printString("Y. ",0,5);
yfkwok 5:bc0691d02fd5 589 }
yfkwok 5:bc0691d02fd5 590 else {
yfkwok 5:bc0691d02fd5 591 lcd.printString("A. $%^&*",0,2);
yfkwok 5:bc0691d02fd5 592 lcd.printString("B. $%^&*",0,3);
yfkwok 5:bc0691d02fd5 593 lcd.printString("X. $%^&*",0,4);
yfkwok 5:bc0691d02fd5 594 lcd.printString("Y. $%^&*",0,5);
yfkwok 5:bc0691d02fd5 595 }
yfkwok 11:5a6b9dffd78a 596 lcd.drawSprite(39, 0, 4, 7, (int*)up);
yfkwok 5:bc0691d02fd5 597 lcd.refresh();
yfkwok 5:bc0691d02fd5 598 if(pad.get_direction() == N){currentPage = PAGE_5;}
yfkwok 5:bc0691d02fd5 599 if(pad.check_event(Gamepad::Y_PRESSED) == true){
yfkwok 5:bc0691d02fd5 600 score++;
yfkwok 5:bc0691d02fd5 601 currentPage = PAGE_7;
yfkwok 5:bc0691d02fd5 602 }
yfkwok 5:bc0691d02fd5 603 if((pad.check_event(Gamepad::A_PRESSED) == true)
yfkwok 5:bc0691d02fd5 604 || (pad.check_event(Gamepad::X_PRESSED) == true)
yfkwok 5:bc0691d02fd5 605 || (pad.check_event(Gamepad::B_PRESSED) == true)){
yfkwok 5:bc0691d02fd5 606 currentPage = PAGE_7;
yfkwok 5:bc0691d02fd5 607 }
yfkwok 10:adff3c804985 608 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 609 break;
yfkwok 5:bc0691d02fd5 610 case PAGE_7:
yfkwok 13:02002658e718 611 pad.init_input();
yfkwok 5:bc0691d02fd5 612 lcd.clear();
yfkwok 5:bc0691d02fd5 613 lcd.printString("EXAM",0,0);
yfkwok 5:bc0691d02fd5 614 lcd.printString("COMPLETE",0,1);
yfkwok 5:bc0691d02fd5 615 lcd.printString("PRESS START",0,5);
yfkwok 5:bc0691d02fd5 616 lcd.refresh();
yfkwok 5:bc0691d02fd5 617 if(pad.check_event(Gamepad::START_PRESSED) == true) {finished = true;}
yfkwok 10:adff3c804985 618 wait(1.0f/fps);
yfkwok 5:bc0691d02fd5 619 break;
yfkwok 5:bc0691d02fd5 620 }
yfkwok 5:bc0691d02fd5 621 }
yfkwok 5:bc0691d02fd5 622 return score;
yfkwok 5:bc0691d02fd5 623 }