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