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