Dependencies:   mbed FATFileSystem

Committer:
rottenegg
Date:
Wed May 08 00:30:09 2019 +0000
Revision:
17:7d4d8905b608
Parent:
15:3d29fb195958
Child:
21:f3b0ce18b44f
All Libraries: Huge Bug due to previous changes that causes unexpected crash.; WDplayer: Tuned to meet 20 lines per function criteria;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rottenegg 9:ac396c818874 1 #include "SceneFunctions.h"
rottenegg 10:4fda7b01484a 2 #include "MiscPaths.h"
rottenegg 9:ac396c818874 3
rottenegg 9:ac396c818874 4 //Constructor Functions
rottenegg 9:ac396c818874 5 void SceneFunctions::set_buttonPin(PinName pin) {
rottenegg 9:ac396c818874 6 _BOK = (new DigitalIn(pin));
rottenegg 9:ac396c818874 7 _BOK->mode(PullDown);
rottenegg 10:4fda7b01484a 8 _progress = 0;
rottenegg 10:4fda7b01484a 9 _p[0] = true;
rottenegg 10:4fda7b01484a 10 _p[1] = true;
rottenegg 10:4fda7b01484a 11 _p[2] = true;
rottenegg 9:ac396c818874 12 }
rottenegg 9:ac396c818874 13
rottenegg 9:ac396c818874 14 void SceneFunctions::deletebutton() {
rottenegg 9:ac396c818874 15 delete _BOK;
rottenegg 9:ac396c818874 16 }
rottenegg 9:ac396c818874 17
rottenegg 9:ac396c818874 18 //Ultility Functions
rottenegg 17:7d4d8905b608 19 void SceneFunctions::transition(Bitmap &lcd) {
rottenegg 9:ac396c818874 20 for (int i = 0;i < 84;i++) {
rottenegg 9:ac396c818874 21 lcd.drawRect(0,0,i,48,FILL_BLACK);
rottenegg 9:ac396c818874 22 lcd.refresh();
rottenegg 9:ac396c818874 23 }
rottenegg 9:ac396c818874 24 for (int i = 0;i < 84;i++) {
rottenegg 9:ac396c818874 25 lcd.drawRect(0,0,i,48,FILL_WHITE);
rottenegg 9:ac396c818874 26 lcd.refresh();
rottenegg 9:ac396c818874 27 }
rottenegg 9:ac396c818874 28 }
rottenegg 9:ac396c818874 29
rottenegg 17:7d4d8905b608 30 void SceneFunctions::lockin(Bitmap &lcd) {
rottenegg 9:ac396c818874 31 while (_BOK->read() == 0) {
rottenegg 9:ac396c818874 32 lcd.printString(" ",0,5);
rottenegg 9:ac396c818874 33 lcd.refresh();
rottenegg 9:ac396c818874 34 wait(0.15);
rottenegg 9:ac396c818874 35 lcd.printString("...Press B...",0,5);
rottenegg 9:ac396c818874 36 lcd.refresh();
rottenegg 9:ac396c818874 37 wait(0.15);
rottenegg 9:ac396c818874 38 }
rottenegg 9:ac396c818874 39 }
rottenegg 9:ac396c818874 40
rottenegg 17:7d4d8905b608 41 void SceneFunctions::flash(Bitmap &lcd) {
rottenegg 9:ac396c818874 42 for(int i = 0; i < 4; i++) {
rottenegg 9:ac396c818874 43 lcd.drawRect(0,0,84,48,FILL_BLACK);
rottenegg 9:ac396c818874 44 lcd.refresh();
rottenegg 9:ac396c818874 45 wait(0.15);
rottenegg 9:ac396c818874 46 lcd.drawRect(0,0,84,48,FILL_WHITE);
rottenegg 9:ac396c818874 47 lcd.refresh();
rottenegg 9:ac396c818874 48 wait(0.15);
rottenegg 9:ac396c818874 49 };
rottenegg 9:ac396c818874 50 };
rottenegg 9:ac396c818874 51
rottenegg 9:ac396c818874 52 //Unique to Scene Functions
rottenegg 9:ac396c818874 53 //scene 0 Functions
rottenegg 9:ac396c818874 54 void SceneFunctions::set_scene0(CaMove &CM) {
rottenegg 9:ac396c818874 55 CM.set_region(1, 28, 12, 17); //event 0
rottenegg 9:ac396c818874 56 CM.set_region(66, 15, 21, 24); //event 1
rottenegg 9:ac396c818874 57 };
rottenegg 9:ac396c818874 58 //pre funtions
rottenegg 17:7d4d8905b608 59 void SceneFunctions::obj0_scene0(Bitmap &lcd) {
rottenegg 9:ac396c818874 60 lcd.drawRect(32,1,20,2,FILL_BLACK);
rottenegg 9:ac396c818874 61 };
rottenegg 9:ac396c818874 62 //pos functions
rottenegg 17:7d4d8905b608 63 void SceneFunctions::event0_scene0(Bitmap &lcd) {
rottenegg 9:ac396c818874 64 this->transition(lcd);
rottenegg 9:ac396c818874 65 lcd.clear();
rottenegg 9:ac396c818874 66 lcd.printString("Hello My Name",0,0);
rottenegg 9:ac396c818874 67 lcd.printString("Veigar I Shall",0,1);
rottenegg 9:ac396c818874 68 lcd.printString("Help You Find",0,2);
rottenegg 9:ac396c818874 69 lcd.printString("What You Seek",0,3);
rottenegg 9:ac396c818874 70 lcd.printString("Now go ... ",0,4);
rottenegg 9:ac396c818874 71 lcd.refresh();
rottenegg 9:ac396c818874 72 this->lockin(lcd);
rottenegg 9:ac396c818874 73 this->transition(lcd);
rottenegg 9:ac396c818874 74 }
rottenegg 9:ac396c818874 75
rottenegg 9:ac396c818874 76 //event 1
rottenegg 17:7d4d8905b608 77 void SceneFunctions::event1_scene0(Bitmap &lcd) {
rottenegg 9:ac396c818874 78 this->transition(lcd);
rottenegg 9:ac396c818874 79 lcd.clear();
rottenegg 9:ac396c818874 80 lcd.printString("It's a Weird",0,0);
rottenegg 9:ac396c818874 81 lcd.printString("quite eerie...",0,1);
rottenegg 9:ac396c818874 82 lcd.printString("Statue !!",0,2);
rottenegg 9:ac396c818874 83 lcd.refresh();
rottenegg 9:ac396c818874 84 this->lockin(lcd);
rottenegg 9:ac396c818874 85 this->transition(lcd);
rottenegg 9:ac396c818874 86 }
rottenegg 9:ac396c818874 87
rottenegg 9:ac396c818874 88 //scene1 Funtions
rottenegg 9:ac396c818874 89 void SceneFunctions::set_scene1(CaMove &CM) {
rottenegg 9:ac396c818874 90 CM.set_region(2, 38, 8, 7); //event 0
rottenegg 9:ac396c818874 91 CM.set_region(72, 2, 8, 7); //event 1
rottenegg 9:ac396c818874 92 };
rottenegg 9:ac396c818874 93
rottenegg 9:ac396c818874 94 //pre funtions
rottenegg 17:7d4d8905b608 95 void SceneFunctions::obj0_scene1(Bitmap &lcd) {
rottenegg 9:ac396c818874 96 lcd.drawLine(30,40,31,20,0);
rottenegg 9:ac396c818874 97 lcd.drawLine(55,40,55,20,1);
rottenegg 9:ac396c818874 98 lcd.drawRect(5,1,20,2,FILL_BLACK);
rottenegg 9:ac396c818874 99 }
rottenegg 9:ac396c818874 100
rottenegg 17:7d4d8905b608 101 void SceneFunctions::obj1_scene1(Bitmap &lcd) {
rottenegg 9:ac396c818874 102 lcd.drawRect(32,1,20,2,FILL_BLACK);
rottenegg 9:ac396c818874 103 }
rottenegg 9:ac396c818874 104
rottenegg 9:ac396c818874 105
rottenegg 9:ac396c818874 106 //pos functions
rottenegg 17:7d4d8905b608 107 void SceneFunctions::event0_scene1(Bitmap &lcd) {
rottenegg 9:ac396c818874 108 lcd.drawRect(74,3,6,3,FILL_WHITE);
rottenegg 9:ac396c818874 109 lcd.drawLine(4,39,7,41,1);
rottenegg 9:ac396c818874 110 lcd.refresh();
rottenegg 9:ac396c818874 111 wait(0.2);
rottenegg 9:ac396c818874 112 lcd.drawRect(74,3,6,3,FILL_WHITE);
rottenegg 9:ac396c818874 113 lcd.drawLine(9,39,7,41,1);
rottenegg 9:ac396c818874 114 lcd.refresh();
rottenegg 9:ac396c818874 115 wait(0.2);
rottenegg 9:ac396c818874 116 }
rottenegg 9:ac396c818874 117
rottenegg 17:7d4d8905b608 118 void SceneFunctions::event1_scene1(Bitmap &lcd,CaMove &CM) {
rottenegg 9:ac396c818874 119 lcd.drawRect(74,3,6,3,FILL_WHITE);
rottenegg 9:ac396c818874 120 lcd.drawLine(74,3,77,5,1);
rottenegg 9:ac396c818874 121 lcd.refresh();
rottenegg 9:ac396c818874 122 wait(0.2);
rottenegg 9:ac396c818874 123 lcd.drawRect(74,3,6,3,FILL_WHITE);
rottenegg 9:ac396c818874 124 lcd.drawLine(79,3,77,5,1);
rottenegg 9:ac396c818874 125 lcd.refresh();
rottenegg 9:ac396c818874 126 wait(0.2);
rottenegg 14:165fff6d1854 127 CM.spawn(42,-15);
rottenegg 9:ac396c818874 128 }
rottenegg 10:4fda7b01484a 129
rottenegg 10:4fda7b01484a 130 //Scene 2 Functions
rottenegg 10:4fda7b01484a 131 void SceneFunctions::set_scene2(CaMove &CM) {
rottenegg 10:4fda7b01484a 132 CM.set_region(9, 17, 10, 14); //event 0
rottenegg 10:4fda7b01484a 133
rottenegg 10:4fda7b01484a 134 };
rottenegg 10:4fda7b01484a 135 //pre Functions
rottenegg 17:7d4d8905b608 136 void SceneFunctions::obj0_scene2(Bitmap &lcd) {
rottenegg 17:7d4d8905b608 137 lcd.renderBMP(MISC[0],9,17);
rottenegg 10:4fda7b01484a 138 lcd.drawLine(83,13,83,33,1); //right
rottenegg 10:4fda7b01484a 139 lcd.drawLine(47,0,67,0,1); // top
rottenegg 10:4fda7b01484a 140 lcd.drawLine(47,47,67,47,1); //bot
rottenegg 10:4fda7b01484a 141 }
rottenegg 10:4fda7b01484a 142
rottenegg 17:7d4d8905b608 143 void SceneFunctions::obj1_scene2(Bitmap &lcd,int rng) {
rottenegg 10:4fda7b01484a 144 switch(rng) {
rottenegg 10:4fda7b01484a 145 case 0:
rottenegg 10:4fda7b01484a 146 lcd.drawLine(83,13,83,33,1); //r
rottenegg 10:4fda7b01484a 147 lcd.drawLine(47,0,67,0,1); // t
rottenegg 10:4fda7b01484a 148 break;
rottenegg 10:4fda7b01484a 149 case 1:
rottenegg 10:4fda7b01484a 150 lcd.drawLine(47,47,67,47,1); //b
rottenegg 10:4fda7b01484a 151 lcd.drawLine(83,13,83,33,1); //r
rottenegg 10:4fda7b01484a 152 break;
rottenegg 10:4fda7b01484a 153 case 2:
rottenegg 10:4fda7b01484a 154 lcd.drawLine(47,47,67,47,1); //b
rottenegg 10:4fda7b01484a 155 lcd.drawLine(47,0,67,0,1); // t
rottenegg 10:4fda7b01484a 156 break;
rottenegg 10:4fda7b01484a 157 }
rottenegg 10:4fda7b01484a 158 }
rottenegg 10:4fda7b01484a 159
rottenegg 10:4fda7b01484a 160 //pos Function
rottenegg 17:7d4d8905b608 161 void SceneFunctions::event0_scene2(Bitmap &lcd,CaMove &CM) {
rottenegg 10:4fda7b01484a 162 this->transition(lcd);
rottenegg 10:4fda7b01484a 163 lcd.clear();
rottenegg 17:7d4d8905b608 164 lcd.renderBMP(MISC[1],0,0);
rottenegg 10:4fda7b01484a 165 lcd.refresh();
rottenegg 10:4fda7b01484a 166 wait(1);
rottenegg 10:4fda7b01484a 167 CM.delete_regions();
rottenegg 10:4fda7b01484a 168 lcd.clear();
rottenegg 10:4fda7b01484a 169 lcd.printString("Help Me Please",0,0);
rottenegg 10:4fda7b01484a 170 lcd.refresh();
rottenegg 10:4fda7b01484a 171 wait(0.5);
rottenegg 10:4fda7b01484a 172 lcd.printString("I NEED YOUR",0,1);
rottenegg 10:4fda7b01484a 173 lcd.printString("BLOOOD !!!",0,2);
rottenegg 10:4fda7b01484a 174 lcd.refresh();
rottenegg 10:4fda7b01484a 175 wait(1);
rottenegg 13:95323e0f2fcb 176 CM.init(35,17,Fd);
rottenegg 10:4fda7b01484a 177 CM.spawn(9,17);
rottenegg 10:4fda7b01484a 178 lcd.inverseMode();
rottenegg 10:4fda7b01484a 179 }
rottenegg 10:4fda7b01484a 180
rottenegg 10:4fda7b01484a 181 //Scene 3 Functions
rottenegg 10:4fda7b01484a 182 void SceneFunctions::set_scene3(CaMove &CM) {
rottenegg 10:4fda7b01484a 183 CM.set_region(72, 39, 10, 7); //event 0
rottenegg 10:4fda7b01484a 184 CM.set_region(73, 11, 10, 17); //event 1
rottenegg 10:4fda7b01484a 185 CM.set_region(64, 5, 10, 14); //event 2
rottenegg 10:4fda7b01484a 186 CM.set_region(42, 2, 11, 18); //event 3
rottenegg 10:4fda7b01484a 187 };
rottenegg 10:4fda7b01484a 188
rottenegg 10:4fda7b01484a 189 //pre Functions
rottenegg 17:7d4d8905b608 190 void SceneFunctions::obj0_scene3(Bitmap &lcd) {
rottenegg 10:4fda7b01484a 191 lcd.drawLine(76,42,78,40,1);
rottenegg 10:4fda7b01484a 192 lcd.drawRect(74,40,2,3,FILL_WHITE);
rottenegg 10:4fda7b01484a 193 lcd.drawRect(28,29,11,13,FILL_WHITE);
rottenegg 10:4fda7b01484a 194 lcd.drawRect(14,31,9,11,FILL_BLACK);
rottenegg 10:4fda7b01484a 195 lcd.drawLine(16,33,20,33,0);
rottenegg 10:4fda7b01484a 196 lcd.drawLine(20,33,20,37,0);
rottenegg 10:4fda7b01484a 197 lcd.drawLine(20,37,16,37,0);
rottenegg 10:4fda7b01484a 198 }
rottenegg 10:4fda7b01484a 199
rottenegg 17:7d4d8905b608 200 void SceneFunctions::obj1_scene3(Bitmap &lcd) {
rottenegg 10:4fda7b01484a 201 lcd.setPixel(77,14,false);
rottenegg 10:4fda7b01484a 202 }
rottenegg 10:4fda7b01484a 203 //obj 2 not required
rottenegg 17:7d4d8905b608 204 void SceneFunctions::obj3_scene3(Bitmap &lcd) {
rottenegg 17:7d4d8905b608 205 lcd.renderBMP(MISC[2],21,8);
rottenegg 10:4fda7b01484a 206 }
rottenegg 10:4fda7b01484a 207
rottenegg 17:7d4d8905b608 208 void SceneFunctions::obj4_scene3(Bitmap &lcd) {
rottenegg 10:4fda7b01484a 209 if (_progress < 3) {
rottenegg 10:4fda7b01484a 210 lcd.drawRect(55,46,16,2,FILL_BLACK);
rottenegg 10:4fda7b01484a 211 }
rottenegg 10:4fda7b01484a 212 }
rottenegg 10:4fda7b01484a 213
rottenegg 10:4fda7b01484a 214 //pos functions
rottenegg 17:7d4d8905b608 215 void SceneFunctions::event0_scene3(Bitmap &lcd) {
rottenegg 10:4fda7b01484a 216 if(_p[0]) {
rottenegg 10:4fda7b01484a 217 _p[0] = false;
rottenegg 10:4fda7b01484a 218 _progress++;
rottenegg 10:4fda7b01484a 219 }
rottenegg 10:4fda7b01484a 220 }
rottenegg 10:4fda7b01484a 221
rottenegg 10:4fda7b01484a 222
rottenegg 17:7d4d8905b608 223 void SceneFunctions::event1_scene3(Bitmap &lcd) {
rottenegg 10:4fda7b01484a 224 this->transition(lcd);
rottenegg 10:4fda7b01484a 225 lcd.clear();
rottenegg 10:4fda7b01484a 226 lcd.printString("The Statue",0,0);
rottenegg 10:4fda7b01484a 227 lcd.printString("Looks like a",0,1);
rottenegg 10:4fda7b01484a 228 lcd.printString("Head But Eye",0,2);
rottenegg 10:4fda7b01484a 229 lcd.printString("Missing I Stab",0,3);
rottenegg 10:4fda7b01484a 230 lcd.printString("In a New One.",0,4);
rottenegg 10:4fda7b01484a 231 lcd.refresh();
rottenegg 10:4fda7b01484a 232 if(_p[2]) {
rottenegg 10:4fda7b01484a 233 _p[2] = false;
rottenegg 10:4fda7b01484a 234 _progress++;
rottenegg 10:4fda7b01484a 235 }
rottenegg 10:4fda7b01484a 236 this->lockin(lcd);
rottenegg 10:4fda7b01484a 237 this->transition(lcd);
rottenegg 10:4fda7b01484a 238 }
rottenegg 10:4fda7b01484a 239
rottenegg 10:4fda7b01484a 240
rottenegg 17:7d4d8905b608 241 void SceneFunctions::event2_scene3(Bitmap &lcd) {
rottenegg 10:4fda7b01484a 242 this->transition(lcd);
rottenegg 10:4fda7b01484a 243 lcd.clear();
rottenegg 10:4fda7b01484a 244 lcd.printString("Welcome to",0,0);
rottenegg 10:4fda7b01484a 245 lcd.printString("Mirror Room",0,1);
rottenegg 10:4fda7b01484a 246 lcd.printString("But Beware Not",0,2);
rottenegg 10:4fda7b01484a 247 lcd.printString("Touch Sarced",0,3);
rottenegg 10:4fda7b01484a 248 lcd.printString("!!!ITEM!!!",0,4);
rottenegg 10:4fda7b01484a 249 lcd.refresh();
rottenegg 10:4fda7b01484a 250 if(_p[1]) {
rottenegg 10:4fda7b01484a 251 _p[1] = false;
rottenegg 10:4fda7b01484a 252 _progress++;
rottenegg 10:4fda7b01484a 253 }
rottenegg 10:4fda7b01484a 254 this->lockin(lcd);
rottenegg 10:4fda7b01484a 255 this->transition(lcd);
rottenegg 10:4fda7b01484a 256 }
rottenegg 10:4fda7b01484a 257
rottenegg 17:7d4d8905b608 258 void SceneFunctions::event3_scene3(Bitmap &lcd,CaMove &CM) {
rottenegg 10:4fda7b01484a 259 this->transition(lcd);
rottenegg 10:4fda7b01484a 260 lcd.clear();
rottenegg 10:4fda7b01484a 261 CM.delete_regions();
rottenegg 10:4fda7b01484a 262 lcd.printString("CURSE YOU",0,0);
rottenegg 10:4fda7b01484a 263 lcd.refresh();
rottenegg 10:4fda7b01484a 264 wait(0.5);
rottenegg 10:4fda7b01484a 265 CM.spawn(21,8);
rottenegg 10:4fda7b01484a 266 lcd.inverseMode();
rottenegg 10:4fda7b01484a 267 }
rottenegg 15:3d29fb195958 268
rottenegg 15:3d29fb195958 269 //Scene 4 Functions
rottenegg 15:3d29fb195958 270 void SceneFunctions::set_scene4(CaMove &CM) {
rottenegg 15:3d29fb195958 271 CM.set_region(14, 16, 3, 20); //event 0
rottenegg 15:3d29fb195958 272 }
rottenegg 15:3d29fb195958 273 //pre functions
rottenegg 17:7d4d8905b608 274 void SceneFunctions::obj1_scene4(Bitmap &lcd) {
rottenegg 15:3d29fb195958 275 if (_progress < 5) {
rottenegg 15:3d29fb195958 276 _progress = 7;
rottenegg 15:3d29fb195958 277 }
rottenegg 15:3d29fb195958 278 if (_progress < 15) {
rottenegg 15:3d29fb195958 279 lcd.drawRect((20 -_progress),18,2,18,FILL_BLACK);
rottenegg 15:3d29fb195958 280 }
rottenegg 15:3d29fb195958 281 }
rottenegg 17:7d4d8905b608 282 void SceneFunctions::obj2_scene4(Bitmap &lcd) {
rottenegg 15:3d29fb195958 283
rottenegg 15:3d29fb195958 284 }
rottenegg 17:7d4d8905b608 285 void SceneFunctions::obj3_scene4(Bitmap &lcd) {
rottenegg 15:3d29fb195958 286 if (_progress > 7) {
rottenegg 15:3d29fb195958 287 switch (_progress) {
rottenegg 15:3d29fb195958 288 default:
rottenegg 15:3d29fb195958 289 case 15:
rottenegg 15:3d29fb195958 290 lcd.drawLine(45,4,45,10,1);
rottenegg 15:3d29fb195958 291 case 14:
rottenegg 15:3d29fb195958 292 lcd.drawLine(45,4,49,7,1);
rottenegg 15:3d29fb195958 293 case 13:
rottenegg 15:3d29fb195958 294 lcd.drawLine(49,7,45,10,1);
rottenegg 15:3d29fb195958 295 case 12:
rottenegg 15:3d29fb195958 296 lcd.drawLine(54,5,55,10,1);
rottenegg 15:3d29fb195958 297 case 11:
rottenegg 15:3d29fb195958 298 lcd.drawLine(61,4,59,10,1);
rottenegg 15:3d29fb195958 299 case 10:
rottenegg 15:3d29fb195958 300 lcd.drawLine(61,4,66,3,1);
rottenegg 15:3d29fb195958 301 case 9:
rottenegg 15:3d29fb195958 302 lcd.drawLine(59,10,65,9,1);
rottenegg 15:3d29fb195958 303 case 8:
rottenegg 15:3d29fb195958 304 lcd.drawLine(66,7,60,7,1);
rottenegg 15:3d29fb195958 305 break;
rottenegg 15:3d29fb195958 306 }
rottenegg 15:3d29fb195958 307 }
rottenegg 15:3d29fb195958 308 }
rottenegg 15:3d29fb195958 309 //pos function
rottenegg 17:7d4d8905b608 310 void SceneFunctions::event0_scene4(Bitmap &lcd,CaMove &CM) {
rottenegg 15:3d29fb195958 311 if (_progress == 8) {
rottenegg 15:3d29fb195958 312 CM.spawn(84,19);
rottenegg 15:3d29fb195958 313 }
rottenegg 15:3d29fb195958 314 CM.delete_regions();
rottenegg 15:3d29fb195958 315 CM.set_region((18 - _progress),17,6,18);
rottenegg 15:3d29fb195958 316 _progress++;
rottenegg 15:3d29fb195958 317 }